public void TestSetExtendedACL() { var host = "localhost:8080"; var key = "KxDgvEKzgSBPPfuVfw67oPQBSjidEiqTHURKSDL1R7yGaGYAeYnr".LoadWif(); var cid = ContainerID.FromBase58String("Bun3sfMBpnjKc3Tx7SdwrMxyNi8ha8JT3dhuFGvYBRTz"); var client = new Client.Client(key, host); var eacl = new EACLTable { Version = Refs.Version.SDKVersion(), ContainerId = cid, }; var filter = new EACLRecord.Types.Filter { HeaderType = HeaderType.HeaderUnspecified, MatchType = MatchType.StringEqual, Key = "test", Value = "test" }; var target = new EACLRecord.Types.Target { Role = Role.Others, }; var record = new EACLRecord { Operation = Acl.Operation.Get, Action = Acl.Action.Deny, }; record.Filters.Add(filter); record.Targets.Add(target); var source = new CancellationTokenSource(); source.CancelAfter(10000); client.SetEACL(source.Token, eacl); }
public void TestSetExtendedACL() { using var client = new Client.Client(key, host); var target = new EACLRecord.Types.Target { Role = Role.Others, }; var record = new EACLRecord { Operation = API.Acl.Operation.Delete, Action = API.Acl.Action.Allow, }; record.Targets.Add(target); var eacl = new EACLTable { Version = Refs.Version.SDKVersion(), ContainerId = cid, }; eacl.Records.Add(record); using var source = new CancellationTokenSource(); source.CancelAfter(10000); client.SetEACL(eacl, context: source.Token).Wait(); }
public void SetEACL(CancellationToken context, EACLTable eacl, CallOptions options = null) { var container_client = new ContainerService.ContainerServiceClient(channel); var opts = DefaultCallOptions.ApplyCustomOptions(options); var req = new SetExtendedACLRequest { Body = new SetExtendedACLRequest.Types.Body { Eacl = eacl, Signature = eacl.SignMessagePart(key), } }; req.MetaHeader = opts.GetRequestMetaHeader(); req.SignRequest(key); var resp = container_client.SetExtendedACL(req, cancellationToken: context); if (!resp.VerifyResponse()) { throw new InvalidOperationException("invalid container put response"); } }
public async Task SetEACL(EACLTable eacl, CallOptions options = null, CancellationToken context = default) { if (eacl is null) { throw new ArgumentNullException(nameof(eacl)); } var opts = DefaultCallOptions.ApplyCustomOptions(options); CheckOptions(opts); eacl.Version = Refs.Version.SDKVersion(); var req = new SetExtendedACLRequest { Body = new SetExtendedACLRequest.Types.Body { Eacl = eacl, Signature = opts.Key.SignRFC6979(eacl), } }; req.MetaHeader = opts.GetRequestMetaHeader(); opts.Key.Sign(req); await SetEACL(req, opts.Deadline, context); }