コード例 #1
0
        private void configureRoot(IConfigSectionNode node)
        {
            var pnode = node[CONFIG_POLICY_SECTION];

            if (pnode.Exists)
            {
                m_Policy = FactoryUtils.MakeAndConfigure <OperationPolicy>(pnode, typeof(OperationPolicy));
            }

            if (node.AttrByName(CONFIG_TCP_KEEPALIVE_ENABLED_ATTR).ValueAsBool())
            {
                ServicePointManager.SetTcpKeepAlive(
                    true,
                    node.AttrByName(CONFIG_TCP_KEEPALIVE_TIME_MS_ATTR).ValueAsInt(),
                    node.AttrByName(CONFIG_TCP_KEEPALIVE_INTERVAL_MS_ATTR).ValueAsInt());
            }

            var lst = new List <ServicePointConfigurator>();

            foreach (var nsp in node.Children.Where(c => c.IsSameName(CONFIG_SERVICE_POINT_SECTION)))
            {
                var addr = nsp.AttrByName(CONFIG_URI_ATTR).Value;
                if (addr.IsNullOrWhiteSpace())
                {
                    continue;
                }

                var sp = ServicePointManager.FindServicePoint(new Uri(addr));

                lst.Add(new ServicePointConfigurator(sp, nsp));
            }
            m_ServicePoints = lst; // atomic
        }
コード例 #2
0
 /// <summary>Create session</summary>
 public OperationSession(OperationPolicy policy = OperationPolicy.Default, IBlockPool blockPool = default, CancellationTokenSource cancelSrc = default, IOption option = default)
 {
     this.Policy    = policy;
     this.BlockPool = blockPool ?? new BlockPool();
     this.CancelSrc = cancelSrc ?? new CancellationTokenSource();
     this.Option    = option;
 }
コード例 #3
0
ファイル: Batch.cs プロジェクト: windischb/Lexical.FileSystem
 /// <summary>Create batch op.</summary>
 public Batch(IOperationSession session, OperationPolicy policy, params IOperation[] ops) : base(session, policy)
 {
     if (ops != null)
     {
         this.Ops.AddRange(ops);
     }
     this.CanRollback = true;
 }
コード例 #4
0
ファイル: Batch.cs プロジェクト: windischb/Lexical.FileSystem
 /// <summary>Create batch op.</summary>
 public Batch(IOperationSession session, OperationPolicy policy, IEnumerable <IOperation> ops) : base(session, policy)
 {
     if (ops != null)
     {
         this.Ops.AddRange(ops);
     }
     this.CanRollback = true;
 }
コード例 #5
0
        public void WrapRequest(XmlDocument request, OperationPolicy policy)
        {
            if (policy.BusinessSignatureRequired)
            {
                var signer = new Signer(request);
                signer.BusinessSign();
            }

            if (policy.RequestEncryptionRequired)
            {
                var encryptor = new Encryptor(request, CertificateStore.Instance.ServiceCertificate);
                encryptor.EncryptBody();
            }

            if (policy.WsSignatureRequired)
            {
                var signer = new Signer(request);
                signer.WsSecuritySign();
            }
        }
コード例 #6
0
        public void UnwrapResponse(XmlDocument response, OperationPolicy policy)
        {
            if (policy.WsSignatureRequired)
            {
                ValidateWsSignature(response);
            }

            if (policy.ResponseEncryptionRequired)
            {
                var decryptor = new Decryptor(response)
                {
                    ValidateEncryptionCertificate = true
                };
                decryptor.Decrypt();
            }

            //We don't check the policy here because all responses require business signatures
            ValidateBusinessSignature(response);

            RemoveSecurityHeaderIfPresent(response);
        }
コード例 #7
0
        public void AfterReceiveReply(ref Message reply, object correlationState)
        {
            var action           = currentAction.Value;
            var policy           = OperationPolicy.GetPolicyForAction(action);
            var transformer      = new MessageTransformer(reply);
            var responseDocument = transformer.GetXmlDocument();

            if (!IsFault(responseDocument))
            {
                if (debug)
                {
                    Console.WriteLine("### Response wrapped: " + XmlUtil.AsText(responseDocument));
                }
                securityService.UnwrapResponse(responseDocument, policy);
            }
            if (debug)
            {
                Console.WriteLine("### Response unwrapped: " + XmlUtil.PrettyXml(responseDocument));
            }

            currentAction.Value = null;
            reply = transformer.ToMessage(responseDocument);
        }
コード例 #8
0
        public object BeforeSendRequest(ref Message request, IClientChannel channel)
        {
            var action = request.Headers.Action;

            currentAction.Value = action;

            var policy          = OperationPolicy.GetPolicyForAction(action);
            var transformer     = new MessageTransformer(request);
            var requestDocument = transformer.GetXmlDocument();

            if (debug)
            {
                Console.WriteLine("### Request not wrapped: " + XmlUtil.PrettyXml(requestDocument));
            }
            securityService.WrapRequest(requestDocument, policy);

            if (debug)
            {
                Console.WriteLine("### Request wrapped: " + XmlUtil.AsText(requestDocument));
            }

            request = transformer.ToMessage(requestDocument);
            return(null);
        }
コード例 #9
0
 /// <summary>Create move op.</summary>
 public CopyTree(IOperationSession session, IFileSystem srcFilesystem, string srcPath, IFileSystem dstFilesystem, string dstPath, IOption srcOption = null, IOption dstOption = null, OperationPolicy policy = OperationPolicy.Unset) : base(session, policy)
 {
     this.srcFileSystem = srcFilesystem ?? throw new ArgumentNullException(nameof(srcFilesystem));
     this.dstFileSystem = dstFilesystem ?? throw new ArgumentNullException(nameof(dstFilesystem));
     this.srcPath       = srcPath ?? throw new ArgumentNullException(nameof(srcPath));
     this.dstPath       = dstPath ?? throw new ArgumentNullException(nameof(dstPath));
     this.srcOption     = srcOption;
     this.Option        = dstOption;
 }
コード例 #10
0
 /// <summary>
 /// Create delete directory op.
 /// </summary>
 /// <param name="session"></param>
 /// <param name="filesystem"></param>
 /// <param name="path"></param>
 /// <param name="recurse"></param>
 /// <param name="option">(optional) </param>
 /// <param name="policy">(optional) Responds to <see cref="OperationPolicy.DstThrow"/> and <see cref="OperationPolicy.DstSkip"/> policies.</param>
 /// <param name="rollback">(optional) Rollback operation</param>
 public Delete(IOperationSession session, IFileSystem filesystem, string path, bool recurse, IOption option = null, OperationPolicy policy = OperationPolicy.Unset, OperationBase rollback = null) : base(session, policy)
 {
     this.fileSystem  = filesystem ?? throw new ArgumentNullException(nameof(filesystem));
     this.path        = path ?? throw new ArgumentNullException(nameof(path));
     this.Recurse     = recurse;
     this.rollback    = rollback;
     this.CanRollback = rollback != null;
     this.Option      = option;
 }
コード例 #11
0
        private void configureRoot(IConfigSectionNode node)
        {
            var pnode = node[CONFIG_POLICY_SECTION];
            if (pnode.Exists)
              m_Policy = FactoryUtils.MakeAndConfigure<OperationPolicy>(pnode, typeof(OperationPolicy));

            if (node.AttrByName(CONFIG_TCP_KEEPALIVE_ENABLED_ATTR).ValueAsBool())
            {
              ServicePointManager.SetTcpKeepAlive(
            true,
            node.AttrByName(CONFIG_TCP_KEEPALIVE_TIME_MS_ATTR).ValueAsInt(),
            node.AttrByName(CONFIG_TCP_KEEPALIVE_INTERVAL_MS_ATTR).ValueAsInt());
            }

            var lst = new List<ServicePointConfigurator>();
            foreach (var nsp in node.Children.Where(c => c.IsSameName(CONFIG_SERVICE_POINT_SECTION)))
            {

              var addr = nsp.AttrByName(CONFIG_URI_ATTR).Value;
              if (addr.IsNullOrWhiteSpace()) continue;

              var sp = ServicePointManager.FindServicePoint(new Uri(addr));

              lst.Add( new ServicePointConfigurator(sp, nsp));
            }
            m_ServicePoints = lst; // atomic
        }
コード例 #12
0
 /// <summary>Create move op.</summary>
 public DeleteTree(IOperationSession session, IFileSystem filesystem, string path, IOption srcOption = null, IOption dstOption = null, OperationPolicy policy = OperationPolicy.Unset) : base(session, policy)
 {
     this.fileSystem = filesystem ?? throw new ArgumentNullException(nameof(filesystem));
     this.path       = path ?? throw new ArgumentNullException(nameof(path));
     this.srcOption  = srcOption;
     this.Option     = dstOption;
 }
コード例 #13
0
 /// <summary>Set new policy</summary>
 public static IOperationSession SetPolicy(this IOperationSession session, OperationPolicy newPolicy)
 {
     session.Policy = newPolicy;
     return(session);
 }
コード例 #14
0
 /// <summary>Set new policy</summary>
 public OperationSession SetPolicy(OperationPolicy newPolicy)
 {
     this.Policy = newPolicy;
     return(this);
 }
コード例 #15
0
 /// <summary>
 /// Create create directory op.
 /// </summary>
 /// <param name="session"></param>
 /// <param name="filesystem"></param>
 /// <param name="path"></param>
 /// <param name="option"></param>
 /// <param name="policy">(optional) Responds to <see cref="OperationPolicy.DstThrow"/>, <see cref="OperationPolicy.DstSkip"/> and <see cref="OperationPolicy.DstOverwrite"/> policies</param>
 public CreateDirectory(IOperationSession session, IFileSystem filesystem, string path, IOption option = null, OperationPolicy policy = OperationPolicy.Unset) : base(session, policy)
 {
     this.fileSystem = filesystem ?? throw new ArgumentNullException(nameof(filesystem));
     this.path       = path ?? throw new ArgumentNullException(nameof(path));
     // Can rollback if can delete
     this.CanRollback = filesystem.CanDelete();
     this.Option      = option;
 }
コード例 #16
0
ファイル: Move.cs プロジェクト: windischb/Lexical.FileSystem
 /// <summary>Create move op.</summary>
 public Move(IOperationSession session, IFileSystem srcFilesystem, string srcPath, IFileSystem dstFilesystem, string dstPath, IOption srcOption = null, IOption dstOption = null, OperationPolicy policy = OperationPolicy.Unset) : base(session, policy)
 {
     this.srcFileSystem = srcFilesystem ?? throw new ArgumentNullException(nameof(srcFilesystem));
     this.dstFileSystem = dstFilesystem ?? throw new ArgumentNullException(nameof(dstFilesystem));
     this.srcPath       = srcPath ?? throw new ArgumentNullException(nameof(srcPath));
     this.dstPath       = dstPath ?? throw new ArgumentNullException(nameof(dstPath));
     if (srcFileSystem != dstFileSystem)
     {
         throw new ArgumentException($"Move implementation requires that {nameof(srcFilesystem)} and {nameof(dstFilesystem)} are same. Use MoveTree instead.");
     }
     this.srcOption = srcOption;
     this.Option    = dstOption;
 }
コード例 #17
0
 /// <summary>
 /// Create filesystem operation
 /// </summary>
 /// <param name="session">operation session</param>
 /// <param name="policy">operation specific policy</param>
 public OperationBase(IOperationSession session, OperationPolicy policy)
 {
     this.session  = session ?? throw new ArgumentNullException(nameof(session));
     this.OpPolicy = policy;
 }