コード例 #1
0
        /// <summary>
        /// Overriden from the base class. Creates the requested Token Serializer.
        /// Returns a Security Token Serializer that is wraps the list of token
        /// hanlders registerd and also the serializers from the inner token manager.
        /// </summary>
        /// <param name="version">SecurityTokenVersion of the serializer to be created.</param>
        /// <returns>Instance of SecurityTokenSerializer.</returns>
        /// <exception cref="ArgumentNullException">Input parameter is null.</exception>
        public override SecurityTokenSerializer CreateSecurityTokenSerializer(SecurityTokenVersion version)
        {
            if (version == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("version");
            }

            TrustVersion trustVersion           = null;
            SecureConversationVersion scVersion = null;

            foreach (string securitySpecification in version.GetSecuritySpecifications())
            {
                if (StringComparer.Ordinal.Equals(securitySpecification, WSTrustFeb2005Constants.NamespaceURI))
                {
                    trustVersion = TrustVersion.WSTrustFeb2005;
                }
                else if (StringComparer.Ordinal.Equals(securitySpecification, WSTrust13Constants.NamespaceURI))
                {
                    trustVersion = TrustVersion.WSTrust13;
                }
                else if (StringComparer.Ordinal.Equals(securitySpecification, WSSecureConversationFeb2005Constants.Namespace))
                {
                    scVersion = SecureConversationVersion.WSSecureConversationFeb2005;
                }
                else if (StringComparer.Ordinal.Equals(securitySpecification, WSSecureConversation13Constants.Namespace))
                {
                    scVersion = SecureConversationVersion.WSSecureConversation13;
                }

                if (trustVersion != null && scVersion != null)
                {
                    break;
                }
            }

            if (trustVersion == null)
            {
                trustVersion = TrustVersion.WSTrust13;
            }

            if (scVersion == null)
            {
                scVersion = SecureConversationVersion.WSSecureConversation13;
            }

            WsSecurityTokenSerializerAdapter adapter = new WsSecurityTokenSerializerAdapter(_securityTokenHandlerCollection,
                                                                                            GetSecurityVersion(version), trustVersion, scVersion, false, this.ServiceCredentials.IssuedTokenAuthentication.SamlSerializer,
                                                                                            this.ServiceCredentials.SecureConversationAuthentication.SecurityStateEncoder,
                                                                                            this.ServiceCredentials.SecureConversationAuthentication.SecurityContextClaimTypes);

            adapter.MapExceptionsToSoapFaults = true;
            adapter.ExceptionMapper           = _exceptionMapper;

            return(adapter);
        }
コード例 #2
0
        /// <summary>
        /// Overriden from the base class. Creates the requested Token Serializer.
        /// Returns a Security Token Serializer that is wraps the list of token
        /// hanlders registerd and also the serializers from the inner token manager.
        /// </summary>
        /// <param name="version">SecurityTokenVersion of the serializer to be created.</param>
        /// <returns>Instance of SecurityTokenSerializer.</returns>
        /// <exception cref="ArgumentNullException">Input parameter is null.</exception>
        public override SecurityTokenSerializer CreateSecurityTokenSerializer( SecurityTokenVersion version )
        {
            if ( version == null )
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull( "version" );
            }

            TrustVersion trustVersion = null;
            SecureConversationVersion scVersion = null;

            foreach ( string securitySpecification in version.GetSecuritySpecifications() )
            {
                if ( StringComparer.Ordinal.Equals( securitySpecification, WSTrustFeb2005Constants.NamespaceURI ) )
                {
                    trustVersion = TrustVersion.WSTrustFeb2005;
                }
                else if ( StringComparer.Ordinal.Equals( securitySpecification, WSTrust13Constants.NamespaceURI ) )
                {
                    trustVersion = TrustVersion.WSTrust13;
                }
                else if ( StringComparer.Ordinal.Equals( securitySpecification, WSSecureConversationFeb2005Constants.Namespace ) )
                {
                    scVersion = SecureConversationVersion.WSSecureConversationFeb2005;
                }
                else if ( StringComparer.Ordinal.Equals( securitySpecification, WSSecureConversation13Constants.Namespace ) )
                {
                    scVersion = SecureConversationVersion.WSSecureConversation13;
                }

                if ( trustVersion != null && scVersion != null )
                {
                    break;
                }
            }

            if ( trustVersion == null )
            {
                trustVersion = TrustVersion.WSTrust13;
            }

            if ( scVersion == null )
            {
                scVersion = SecureConversationVersion.WSSecureConversation13;
            }

            WsSecurityTokenSerializerAdapter adapter = new WsSecurityTokenSerializerAdapter( _securityTokenHandlerCollection,
                GetSecurityVersion( version ), trustVersion, scVersion, false, this.ServiceCredentials.IssuedTokenAuthentication.SamlSerializer,
                this.ServiceCredentials.SecureConversationAuthentication.SecurityStateEncoder,
                this.ServiceCredentials.SecureConversationAuthentication.SecurityContextClaimTypes );

            adapter.MapExceptionsToSoapFaults = true;
            adapter.ExceptionMapper = _exceptionMapper;

            return adapter;
        }
        private SecurityTokenSerializer WrapTokenHandlersAsSecurityTokenSerializer(SecurityTokenVersion version)
        {
            TrustVersion trustVersion = TrustVersion.WSTrust13;
            SecureConversationVersion scVersion = SecureConversationVersion.WSSecureConversation13;
            SecurityVersion securityVersion = SecurityVersion.WSSecurity11;
            foreach (string securitySpecification in version.GetSecuritySpecifications())
            {
                if (StringComparer.Ordinal.Equals(securitySpecification, WSTrustFeb2005Constants.NamespaceURI))
                {
                    trustVersion = TrustVersion.WSTrustFeb2005;
                }
                else if (StringComparer.Ordinal.Equals(securitySpecification, WSTrust13Constants.NamespaceURI))
                {
                    trustVersion = TrustVersion.WSTrust13;
                }
                else if (StringComparer.Ordinal.Equals(securitySpecification, System.IdentityModel.WSSecureConversationFeb2005Constants.Namespace))
                {
                    scVersion = SecureConversationVersion.WSSecureConversationFeb2005;
                }
                else if (StringComparer.Ordinal.Equals(securitySpecification, System.IdentityModel.WSSecureConversation13Constants.Namespace))
                {
                    scVersion = SecureConversationVersion.WSSecureConversation13;
                }
            }

            securityVersion = FederatedSecurityTokenManager.GetSecurityVersion(version);

            //
            // 


            SecurityTokenHandlerCollectionManager sthcm = this.parent.SecurityTokenHandlerCollectionManager;
            WsSecurityTokenSerializerAdapter adapter = new WsSecurityTokenSerializerAdapter(sthcm[SecurityTokenHandlerCollectionManager.Usage.Default], securityVersion, trustVersion, scVersion, false, null, null, null);
            return adapter;
        }