Пример #1
0
        CreateMutualCertificateBindingElement(
            MessageSecurityVersion version,
            bool allowSerializedSigningTokenOnReply)
        {
            if (version == null)
            {
                throw new ArgumentNullException("version");
            }

            if (allowSerializedSigningTokenOnReply)
            {
                throw new NotSupportedException("allowSerializedSigningTokenOnReply is not supported");
            }

            if (version.SecurityVersion == SecurityVersion.WSSecurity10)
            {
                var recipient = new X509SecurityTokenParameters(
                    X509KeyIdentifierClauseType.Any,
                    SecurityTokenInclusionMode.Never);
                recipient.RequireDerivedKeys = false;

                var initiator = new X509SecurityTokenParameters(
                    X509KeyIdentifierClauseType.Any,
                    SecurityTokenInclusionMode.AlwaysToRecipient);
                initiator.RequireDerivedKeys = false;

                return(new AsymmetricSecurityBindingElement(recipient, initiator)
                {
                    MessageSecurityVersion = version
                });
            }
            else
            {
                X509SecurityTokenParameters p =
                    new X509SecurityTokenParameters(X509KeyIdentifierClauseType.Thumbprint);
                p.RequireDerivedKeys = false;

                var sym = new SymmetricSecurityBindingElement()
                {
                    MessageSecurityVersion       = version,
                    RequireSignatureConfirmation = true
                };

                sym.EndpointSupportingTokenParameters.Endorsing.Add(p);
                return(sym);
            }
        }
        private bool TryImportSymmetricSecurityBindingElement(MetadataImporter importer, PolicyConversionContext policyContext, out SecurityBindingElement sbe)
        {
            SymmetricSecurityBindingElement binding = null;
            WSSecurityPolicy policy;

            if (WSSecurityPolicy.TryGetSecurityPolicyDriver(policyContext.GetBindingAssertions(), out policy))
            {
                XmlElement element2;
                if (policy.TryImportWsspSymmetricBindingAssertion(importer, policyContext, policyContext.GetBindingAssertions(), out binding, out element2))
                {
                    this.ImportEndpointScopeMessageBindingAssertions(importer, policyContext, binding);
                    this.ImportOperationScopeSupportingTokensPolicy(importer, policyContext, binding);
                    this.ImportMessageScopeProtectionPolicy(importer, policyContext);
                    policyContext.BindingElements.Add(binding);
                }
                else if (element2 != null)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("UnsupportedSecurityPolicyAssertion", new object[] { element2.OuterXml })));
                }
            }
            sbe = binding;
            return(binding != null);
        }
Пример #3
0
        private bool TryImportSymmetricSecurityBindingElement(MetadataImporter importer, PolicyConversionContext policyContext, out SecurityBindingElement sbe)
        {
            SymmetricSecurityBindingElement binding = null;
            XmlElement       assertion;
            WSSecurityPolicy securityPolicy;

            if (WSSecurityPolicy.TryGetSecurityPolicyDriver(policyContext.GetBindingAssertions(), out securityPolicy))
            {
                if (securityPolicy.TryImportWsspSymmetricBindingAssertion(importer, policyContext, policyContext.GetBindingAssertions(), out binding, out assertion))
                {
                    this.ImportEndpointScopeMessageBindingAssertions(importer, policyContext, binding);
                    this.ImportOperationScopeSupportingTokensPolicy(importer, policyContext, binding);
                    this.ImportMessageScopeProtectionPolicy(importer, policyContext);
                    policyContext.BindingElements.Add(binding);
                }
                else if (assertion != null)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(string.Format(SRServiceModel.UnsupportedSecurityPolicyAssertion, assertion.OuterXml)));
                }
            }

            sbe = binding;
            return(binding != null);
        }
 public SymmetricSecurityCapabilities(
     SymmetricSecurityBindingElement element)
 {
     this.element = element;
 }