Exemplo n.º 1
0
        /// <summary>
        /// Creates the default set of SecurityTokenHandlers.
        /// </summary>
        /// <returns>A SecurityTokenHandlerCollectionManager with a default collection of token handlers.</returns>
        public static SecurityTokenHandlerCollectionManager CreateDefaultSecurityTokenHandlerCollectionManager()
        {
            SecurityTokenHandlerCollection        defaultHandlers = SecurityTokenHandlerCollection.CreateDefaultSecurityTokenHandlerCollection();
            SecurityTokenHandlerCollectionManager defaultManager  = new SecurityTokenHandlerCollectionManager(ConfigurationStrings.DefaultServiceName);

            defaultManager.collections.Clear();
            defaultManager.collections.Add(SecurityTokenHandlerCollectionManager.Usage.Default, defaultHandlers);

            return(defaultManager);
        }
        /// <summary>
        /// Initializes an instance of <see cref="WSTrustSerializationContext"/>
        /// </summary>
        /// <param name="securityTokenHandlerCollectionManager">
        /// The <see cref="SecurityTokenHandlerCollectionManager" /> containing the set of <see cref="SecurityTokenHandler" />
        /// objects used for serializing and validating tokens found in WS-Trust messages.
        /// </param>
        /// <param name="securityTokenResolver">
        /// The <see cref="SecurityTokenResolver"/> used to resolve security token references found in most
        /// elements of WS-Trust messages.
        /// </param>
        /// <param name="useKeyTokenResolver">
        /// The <see cref="SecurityTokenResolver"/> used to resolve security token references found in the
        /// UseKey element of RST messages as well as the RenewTarget element found in RST messages.
        /// </param>
        public WSTrustSerializationContext(SecurityTokenHandlerCollectionManager securityTokenHandlerCollectionManager, SecurityTokenResolver securityTokenResolver, SecurityTokenResolver useKeyTokenResolver)
        {
            if (securityTokenHandlerCollectionManager == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("securityTokenHandlerCollectionManager");
            }

            if (securityTokenResolver == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("securityTokenResolver");
            }

            if (useKeyTokenResolver == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("useKeyTokenResolver");
            }

            this.securityTokenHandlerCollectionManager = securityTokenHandlerCollectionManager;
            this.securityTokenResolver = securityTokenResolver;
            this.useKeyTokenResolver = useKeyTokenResolver;
        }
        /// <summary>
        /// Creates the default set of SecurityTokenHandlers.
        /// </summary>
        /// <returns>A SecurityTokenHandlerCollectionManager with a default collection of token handlers.</returns>
        public static SecurityTokenHandlerCollectionManager CreateDefaultSecurityTokenHandlerCollectionManager()
        {
            SecurityTokenHandlerCollection defaultHandlers = SecurityTokenHandlerCollection.CreateDefaultSecurityTokenHandlerCollection();
            SecurityTokenHandlerCollectionManager defaultManager = new SecurityTokenHandlerCollectionManager(ConfigurationStrings.DefaultServiceName);

            defaultManager.collections.Clear();
            defaultManager.collections.Add(SecurityTokenHandlerCollectionManager.Usage.Default, defaultHandlers);

            return defaultManager;
        }
        /// <summary>
        /// Loads the settings for the IdentityConfiguration from the application or web configuration file.
        /// </summary>
        /// <remarks>
        /// If there is no configuration file, or the named section does not exist, then no exception is thrown,
        /// instead the class is loaded with a set of default values.
        /// </remarks>
        protected void LoadConfiguration(IdentityConfigurationElement element)
        {

            if (element != null)
            {
                //
                // Load the claims authentication manager
                //
                if (element.ClaimsAuthenticationManager.IsConfigured)
                {
                    _claimsAuthenticationManager = GetClaimsAuthenticationManager(element);
                }

                //
                // Load the claims authorization manager.
                //
                if (element.ClaimsAuthorizationManager.IsConfigured)
                {
                    _claimsAuthorizationManager = CustomTypeElement.Resolve<ClaimsAuthorizationManager>(element.ClaimsAuthorizationManager);
                }

                //
                // Load the service level Security Token Handler configuration
                //
                _serviceHandlerConfiguration = LoadHandlerConfiguration(element);
            }

            //
            // Reads handler configuration via LoadConfiguredHandlers. Do this last.
            //
            _securityTokenHandlerCollectionManager = LoadHandlers(element);
        }
 /// <summary>
 /// Initializes an instance of <see cref="WSTrustSerializationContext"/>
 /// </summary>
 /// <param name="securityTokenHandlerCollectionManager">The security token handler collection manager.</param>
 public WSTrustSerializationContext(SecurityTokenHandlerCollectionManager securityTokenHandlerCollectionManager)
     : this(securityTokenHandlerCollectionManager, EmptySecurityTokenResolver.Instance, EmptySecurityTokenResolver.Instance)
 {
 }
        protected ClientCredentials(ClientCredentials other)
        {
            if (other == null)
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("other");
            if (other.userName != null)
                this.userName = new UserNamePasswordClientCredential(other.userName);
            if (other.clientCertificate != null)
                this.clientCertificate = new X509CertificateInitiatorClientCredential(other.clientCertificate);
            if (other.serviceCertificate != null)
                this.serviceCertificate = new X509CertificateRecipientClientCredential(other.serviceCertificate);
            if (other.windows != null)
                this.windows = new WindowsClientCredential(other.windows);
            if (other.httpDigest != null)
                this.httpDigest = new HttpDigestClientCredential(other.httpDigest);
            if (other.issuedToken != null)
                this.issuedToken = new IssuedTokenClientCredential(other.issuedToken);
            if (other.peer != null)
                this.peer = new PeerCredential(other.peer);

            this.getInfoCardTokenCallback = other.getInfoCardTokenCallback;
            this.supportInteractive = other.supportInteractive;
            this.securityTokenHandlerCollectionManager = other.securityTokenHandlerCollectionManager;
            this.useIdentityConfiguration = other.useIdentityConfiguration;
            this.isReadOnly = other.isReadOnly;
        }