public SecurityContextCookieSerializer(SecurityStateEncoder securityStateEncoder, IList<Type> knownTypes)
 {
     if (securityStateEncoder == null)
     {
         throw System.ServiceModel.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("securityStateEncoder");
     }
     this.securityStateEncoder = securityStateEncoder;
     this.knownTypes = knownTypes ?? new List<Type>();
 }
 internal SecureConversationServiceCredential(SecureConversationServiceCredential other)
 {
     this.securityStateEncoder = other.securityStateEncoder;
     this.securityContextClaimTypes = new Collection<Type>();
     for (int i = 0; i < other.securityContextClaimTypes.Count; ++i)
     {
         this.securityContextClaimTypes.Add(other.securityContextClaimTypes[i]);
     }
     this.isReadOnly = other.isReadOnly;
 }
 internal SecureConversationServiceCredential(SecureConversationServiceCredential other)
 {
     this.securityStateEncoder      = other.securityStateEncoder;
     this.securityContextClaimTypes = new Collection <Type>();
     for (int i = 0; i < other.securityContextClaimTypes.Count; ++i)
     {
         this.securityContextClaimTypes.Add(other.securityContextClaimTypes[i]);
     }
     this.isReadOnly = other.isReadOnly;
 }
Пример #4
0
		public WSSecurityTokenSerializer (
			SecurityVersion securityVersion,
			bool emitBspRequiredAttributes,
			SamlSerializer samlSerializer,
			SecurityStateEncoder securityStateEncoder,
			IEnumerable<Type> knownTypes)
			: this (securityVersion, emitBspRequiredAttributes, 
				samlSerializer, securityStateEncoder,
				knownTypes, defaultOffset, defaultLabelLength,
				defaultNonceLength)
		{
		}
 public WSSecurityTokenSerializer(
     SecurityVersion securityVersion,
     bool emitBspRequiredAttributes,
     SamlSerializer samlSerializer,
     SecurityStateEncoder securityStateEncoder,
     IEnumerable <Type> knownTypes)
     : this(securityVersion, emitBspRequiredAttributes,
            samlSerializer, securityStateEncoder,
            knownTypes, defaultOffset, defaultLabelLength,
            defaultNonceLength)
 {
 }
Пример #6
0
 void InitializeDefaults()
 {
     this.encryptStateInServiceToken    = !defaultServerMaintainState;
     this.serviceTokenLifetime          = defaultServerIssuedTokenLifetime;
     this.maximumCachedNegotiationState = defaultServerMaxActiveNegotiations;
     this.negotiationTimeout            = defaultServerMaxNegotiationLifetime;
     this.isClientAnonymous             = false;
     this.standardsManager              = defaultStandardsManager;
     this.securityStateEncoder          = defaultSecurityStateEncoder;
     this.maximumConcurrentNegotiations = defaultServerMaxActiveNegotiations;
     // we rely on the transport encoders to enforce the message size except in the
     // mixed mode nego case, where the client is unauthenticated and the maxMessageSize is too
     // large to be a mitigation
     this.maxMessageSize = Int32.MaxValue;
 }
Пример #7
0
        public WSSecureConversationDec2005(WSSecurityTokenSerializer tokenSerializer, SecurityStateEncoder securityStateEncoder, IEnumerable <Type> knownTypes, int maxKeyDerivationOffset, int maxKeyDerivationLabelLength, int maxKeyDerivationNonceLength)
            : base(tokenSerializer, maxKeyDerivationOffset, maxKeyDerivationLabelLength, maxKeyDerivationNonceLength)
        {
#if FEATURE_CORECLR
            throw new NotImplementedException("DataProtectionSecurityStateEncoder not supported in .NET Core");
#else
            this.securityStateEncoder = securityStateEncoder == null ? (SecurityStateEncoder) new DataProtectionSecurityStateEncoder() : securityStateEncoder;
            this.knownClaimTypes      = (IList <Type>) new List <Type>();
            if (knownTypes == null)
            {
                return;
            }
            foreach (Type knownType in knownTypes)
            {
                this.knownClaimTypes.Add(knownType);
            }
#endif
        }
Пример #8
0
        public WSSecureConversationFeb2005(WSSecurityTokenSerializer tokenSerializer, SecurityStateEncoder securityStateEncoder, IEnumerable <Type> knownTypes,
                                           int maxKeyDerivationOffset, int maxKeyDerivationLabelLength, int maxKeyDerivationNonceLength)
            : base(tokenSerializer, maxKeyDerivationOffset, maxKeyDerivationLabelLength, maxKeyDerivationNonceLength)
        {
            if (securityStateEncoder != null)
            {
                _securityStateEncoder = securityStateEncoder;
            }

            _knownClaimTypes = new List <Type>();
            if (knownTypes != null)
            {
                // Clone this collection.
                foreach (Type knownType in knownTypes)
                {
                    _knownClaimTypes.Add(knownType);
                }
            }
        }
 public WSSecureConversationDec2005(WSSecurityTokenSerializer tokenSerializer, SecurityStateEncoder securityStateEncoder, IEnumerable<Type> knownTypes, int maxKeyDerivationOffset, int maxKeyDerivationLabelLength, int maxKeyDerivationNonceLength) : base(tokenSerializer, maxKeyDerivationOffset, maxKeyDerivationLabelLength, maxKeyDerivationNonceLength)
 {
     if (securityStateEncoder != null)
     {
         this.securityStateEncoder = securityStateEncoder;
     }
     else
     {
         this.securityStateEncoder = new DataProtectionSecurityStateEncoder();
     }
     this.knownClaimTypes = new List<Type>();
     if (knownTypes != null)
     {
         foreach (Type type in knownTypes)
         {
             this.knownClaimTypes.Add(type);
         }
     }
 }
Пример #10
0
 public WSSecureConversationDec2005(WSSecurityTokenSerializer tokenSerializer, SecurityStateEncoder securityStateEncoder, IEnumerable <Type> knownTypes, int maxKeyDerivationOffset, int maxKeyDerivationLabelLength, int maxKeyDerivationNonceLength) : base(tokenSerializer, maxKeyDerivationOffset, maxKeyDerivationLabelLength, maxKeyDerivationNonceLength)
 {
     if (securityStateEncoder != null)
     {
         this.securityStateEncoder = securityStateEncoder;
     }
     else
     {
         this.securityStateEncoder = new DataProtectionSecurityStateEncoder();
     }
     this.knownClaimTypes = new List <Type>();
     if (knownTypes != null)
     {
         foreach (Type type in knownTypes)
         {
             this.knownClaimTypes.Add(type);
         }
     }
 }
Пример #11
0
        public WSSecureConversationDec2005(WSSecurityTokenSerializer tokenSerializer, SecurityStateEncoder securityStateEncoder, IEnumerable <Type> knownTypes,
                                           int maxKeyDerivationOffset, int maxKeyDerivationLabelLength, int maxKeyDerivationNonceLength)
            : base(tokenSerializer, maxKeyDerivationOffset, maxKeyDerivationLabelLength, maxKeyDerivationNonceLength)
        {
            if (securityStateEncoder != null)
            {
                _securityStateEncoder = securityStateEncoder;
            }
            else
            {
                //throw new PlatformNotSupportedException();
                //this.securityStateEncoder = new DataProtectionSecurityStateEncoder();
            }

            _knownClaimTypes = new List <Type>();
            if (knownTypes != null)
            {
                // Clone this collection.
                foreach (Type knownType in knownTypes)
                {
                    _knownClaimTypes.Add(knownType);
                }
            }
        }
Пример #12
0
        public WSSecurityTokenSerializer(
            SecurityVersion securityVersion,
            bool emitBspRequiredAttributes,
            SamlSerializer samlSerializer,
            SecurityStateEncoder securityStateEncoder,
            IEnumerable <Type> knownTypes,
            int maximumKeyDerivationOffset,
            int maximumKeyDerivationLabelLength,
            int maximumKeyDerivationNonceLength)
        {
            security_version = securityVersion;
            emit_bsp         = emitBspRequiredAttributes;
            saml_serializer  = samlSerializer;
            encoder          = securityStateEncoder;
            known_types      = new List <Type> (knownTypes ?? Type.EmptyTypes);
            max_offset       = maximumKeyDerivationOffset;
            max_label_length = maximumKeyDerivationLabelLength;
            max_nonce_length = maximumKeyDerivationNonceLength;

            if (encoder == null)
            {
                encoder = new DataProtectionSecurityStateEncoder();
            }
        }
Пример #13
0
 public WSSecureConversationFeb2005(WSSecurityTokenSerializer tokenSerializer, SecurityStateEncoder securityStateEncoder, IEnumerable <Type> knownTypes,
                                    int maxKeyDerivationOffset, int maxKeyDerivationLabelLength, int maxKeyDerivationNonceLength)
     : base(tokenSerializer, maxKeyDerivationOffset, maxKeyDerivationLabelLength, maxKeyDerivationNonceLength)
 {
     if (securityStateEncoder != null)
     {
         throw ExceptionHelper.PlatformNotSupported();
     }
 }
Пример #14
0
 public WSSecurityTokenSerializer(SecurityVersion securityVersion, TrustVersion trustVersion, SecureConversationVersion secureConversationVersion, bool emitBspRequiredAttributes, SamlSerializer samlSerializer, SecurityStateEncoder securityStateEncoder, IEnumerable<Type> knownTypes,
     int maximumKeyDerivationOffset, int maximumKeyDerivationLabelLength, int maximumKeyDerivationNonceLength)
 {
     throw ExceptionHelper.PlatformNotSupported();
 }
Пример #15
0
 public WSSecurityTokenSerializer(SecurityVersion securityVersion, bool emitBspRequiredAttributes, SamlSerializer samlSerializer, SecurityStateEncoder securityStateEncoder, IEnumerable<Type> knownTypes,
     int maximumKeyDerivationOffset, int maximumKeyDerivationLabelLength, int maximumKeyDerivationNonceLength)
     : this(securityVersion, TrustVersion.Default, SecureConversationVersion.Default, emitBspRequiredAttributes, samlSerializer, securityStateEncoder, knownTypes, maximumKeyDerivationOffset, maximumKeyDerivationLabelLength, maximumKeyDerivationNonceLength)
 {
 }
 public WSSecurityTokenSerializer(System.ServiceModel.Security.SecurityVersion securityVersion, TrustVersion trustVersion, SecureConversationVersion secureConversationVersion, bool emitBspRequiredAttributes, SamlSerializer samlSerializer, SecurityStateEncoder securityStateEncoder, IEnumerable<Type> knownTypes) : this(securityVersion, trustVersion, secureConversationVersion, emitBspRequiredAttributes, samlSerializer, securityStateEncoder, knownTypes, 0x40, 0x80, 0x80)
 {
 }
Пример #17
0
 public SecurityContextTokenEntry(WSSecureConversation parent, SecurityStateEncoder securityStateEncoder, IList <Type> knownClaimTypes)
 {
     Parent = parent;
 }
 public WSSecurityTokenSerializer(SecurityVersion securityVersion, bool emitBspRequiredAttributes, System.IdentityModel.Tokens.SamlSerializer samlSerializer, SecurityStateEncoder securityStateEncoder, IEnumerable<Type> knownTypes, int maximumKeyDerivationOffset, int maximumKeyDerivationLabelLength, int maximumKeyDerivationNonceLength)
 {
 }
        /// <summary>
        /// Initializes an instance of <see cref="WsSecurityTokenSerializerAdapter"/>
        /// </summary>
        /// <param name="securityTokenHandlerCollection">
        /// The <see cref="SecurityTokenHandlerCollection" /> containing the set of <see cref="SecurityTokenHandler" />
        /// objects used for serializing and validating tokens found in WS-Trust messages.
        /// </param>
        /// <param name="securityVersion">The SecurityVersion of the base WSSecurityTokenSerializer.</param>
        /// <param name="trustVersion">The TrustVersion of the serializer uses.</param>
        /// <param name="secureConversationVersion">The SecureConversationVersion of the serializer.</param>
        /// <param name="emitBspAttributes">Flag that determines if the serailization shoudl be BSP compliant.</param>
        /// <param name="samlSerializer">Serializer for SAML 1.1 tokens.</param>
        /// <param name="stateEncoder">SecurityStateEncoder used for resolving SCT.</param>
        /// <param name="knownTypes">The collection of known claim types.</param>
        public WsSecurityTokenSerializerAdapter(SecurityTokenHandlerCollection securityTokenHandlerCollection, SecurityVersion securityVersion, TrustVersion trustVersion, SecureConversationVersion secureConversationVersion, bool emitBspAttributes, SamlSerializer samlSerializer, SecurityStateEncoder stateEncoder, IEnumerable <Type> knownTypes)
            : base(securityVersion, trustVersion, secureConversationVersion, emitBspAttributes, samlSerializer, stateEncoder, knownTypes)
        {
            if (securityTokenHandlerCollection == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("securityTokenHandlerCollection");
            }

            _scVersion             = secureConversationVersion;
            _securityTokenHandlers = securityTokenHandlerCollection;
        }
Пример #20
0
 public SecurityContextTokenEntryFeb2005(WSSecureConversationFeb2005 parent, SecurityStateEncoder securityStateEncoder, IList <Type> knownClaimTypes)
     : base(parent, securityStateEncoder, knownClaimTypes)
 {
 }
        public WSSecurityTokenSerializer(SecurityVersion securityVersion, TrustVersion trustVersion, SecureConversationVersion secureConversationVersion, bool emitBspRequiredAttributes, SamlSerializer samlSerializer, SecurityStateEncoder securityStateEncoder, IEnumerable<Type> knownTypes,
            int maximumKeyDerivationOffset, int maximumKeyDerivationLabelLength, int maximumKeyDerivationNonceLength)
        {
            if (securityVersion == null)
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("securityVersion"));

            if (maximumKeyDerivationOffset < 0)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("maximumKeyDerivationOffset", SR.GetString(SR.ValueMustBeNonNegative)));
            }
            if (maximumKeyDerivationLabelLength < 0)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("maximumKeyDerivationLabelLength", SR.GetString(SR.ValueMustBeNonNegative)));
            }
            if (maximumKeyDerivationNonceLength <= 0)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("maximumKeyDerivationNonceLength", SR.GetString(SR.ValueMustBeGreaterThanZero)));
            }

            this.securityVersion = securityVersion;
            this.emitBspRequiredAttributes = emitBspRequiredAttributes;
            this.maximumKeyDerivationOffset = maximumKeyDerivationOffset;
            this.maximumKeyDerivationNonceLength = maximumKeyDerivationNonceLength;
            this.maximumKeyDerivationLabelLength = maximumKeyDerivationLabelLength;

            this.serializerEntries = new List<SerializerEntries>();

            if (secureConversationVersion == SecureConversationVersion.WSSecureConversationFeb2005)
            {
                this.secureConversation = new WSSecureConversationFeb2005(this, securityStateEncoder, knownTypes, maximumKeyDerivationOffset, maximumKeyDerivationLabelLength, maximumKeyDerivationNonceLength);
            }
            else if (secureConversationVersion == SecureConversationVersion.WSSecureConversation13)
            {
                this.secureConversation = new WSSecureConversationDec2005(this, securityStateEncoder, knownTypes, maximumKeyDerivationOffset, maximumKeyDerivationLabelLength, maximumKeyDerivationNonceLength);
            }
            else
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException());
            }

            if (securityVersion == SecurityVersion.WSSecurity10)
            {
                this.serializerEntries.Add(new WSSecurityJan2004(this, samlSerializer));
            }
            else if (securityVersion == SecurityVersion.WSSecurity11)
            {
                this.serializerEntries.Add(new WSSecurityXXX2005(this, samlSerializer));
            }
            else
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("securityVersion", SR.GetString(SR.MessageSecurityVersionOutOfRange)));
            }
            this.serializerEntries.Add(this.secureConversation);
            IdentityModel.TrustDictionary trustDictionary;
            if (trustVersion == TrustVersion.WSTrustFeb2005)
            {
                this.serializerEntries.Add(new WSTrustFeb2005(this));
                trustDictionary = new IdentityModel.TrustFeb2005Dictionary(new CollectionDictionary(DXD.TrustDec2005Dictionary.Feb2005DictionaryStrings));
            }
            else if (trustVersion == TrustVersion.WSTrust13)
            {
                this.serializerEntries.Add(new WSTrustDec2005(this));
                trustDictionary = new IdentityModel.TrustDec2005Dictionary(new CollectionDictionary(DXD.TrustDec2005Dictionary.Dec2005DictionaryString));
            }
            else
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException());
            }

            this.tokenEntries = new List<TokenEntry>();

            for (int i = 0; i < this.serializerEntries.Count; ++i)
            {
                SerializerEntries serializerEntry = this.serializerEntries[i];
                serializerEntry.PopulateTokenEntries(this.tokenEntries);
            }

            IdentityModel.DictionaryManager dictionaryManager = new IdentityModel.DictionaryManager(ServiceModelDictionary.CurrentVersion);
            dictionaryManager.SecureConversationDec2005Dictionary = new IdentityModel.SecureConversationDec2005Dictionary(new CollectionDictionary(DXD.SecureConversationDec2005Dictionary.SecureConversationDictionaryStrings));
            dictionaryManager.SecurityAlgorithmDec2005Dictionary = new IdentityModel.SecurityAlgorithmDec2005Dictionary(new CollectionDictionary(DXD.SecurityAlgorithmDec2005Dictionary.SecurityAlgorithmDictionaryStrings));

            this.keyInfoSerializer = new WSKeyInfoSerializer(this.emitBspRequiredAttributes, dictionaryManager, trustDictionary, this, securityVersion, secureConversationVersion);
        }
        /// <summary>
        /// Initializes an instance of <see cref="WsSecurityTokenSerializerAdapter"/>
        /// </summary>
        /// <param name="securityTokenHandlerCollection">
        /// The <see cref="SecurityTokenHandlerCollection" /> containing the set of <see cref="SecurityTokenHandler" />
        /// objects used for serializing and validating tokens found in WS-Trust messages.
        /// </param>
        /// <param name="securityVersion">The SecurityVersion of the base WSSecurityTokenSerializer.</param>
        /// <param name="trustVersion">The TrustVersion of the serializer uses.</param>
        /// <param name="secureConversationVersion">The SecureConversationVersion of the serializer.</param>
        /// <param name="emitBspAttributes">Flag that determines if the serailization shoudl be BSP compliant.</param>
        /// <param name="samlSerializer">Serializer for SAML 1.1 tokens.</param>
        /// <param name="stateEncoder">SecurityStateEncoder used for resolving SCT.</param>
        /// <param name="knownTypes">The collection of known claim types.</param>
        public WsSecurityTokenSerializerAdapter( SecurityTokenHandlerCollection securityTokenHandlerCollection, SecurityVersion securityVersion, TrustVersion trustVersion, SecureConversationVersion secureConversationVersion, bool emitBspAttributes, SamlSerializer samlSerializer, SecurityStateEncoder stateEncoder, IEnumerable<Type> knownTypes )
            : base( securityVersion, trustVersion, secureConversationVersion, emitBspAttributes, samlSerializer, stateEncoder, knownTypes )
        {
            if ( securityTokenHandlerCollection == null )
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull( "securityTokenHandlerCollection" );
            }

            _scVersion = secureConversationVersion;
            _securityTokenHandlers = securityTokenHandlerCollection;
        }
 /// <summary>
 /// Initializes an instance of <see cref="WsSecurityTokenSerializerAdapter"/>
 /// </summary>
 /// <param name="securityTokenHandlerCollection">
 /// The <see cref="SecurityTokenHandlerCollection" /> containing the set of <see cref="SecurityTokenHandler" />
 /// objects used for serializing and validating tokens found in WS-Trust messages.
 /// </param>
 /// <param name="securityVersion">The SecurityVersion of the base WSSecurityTokenSerializer.</param>
 /// <param name="emitBspAttributes">Flag that determines if the serailization shoudl be BSP compliant.</param>
 /// <param name="samlSerializer">Serializer for SAML 1.1 tokens.</param>
 /// <param name="stateEncoder">SecurityStateEncoder used for resolving SCT.</param>
 /// <param name="knownTypes">The collection of known claim types.</param>
 public WsSecurityTokenSerializerAdapter( SecurityTokenHandlerCollection securityTokenHandlerCollection, SecurityVersion securityVersion, bool emitBspAttributes, SamlSerializer samlSerializer, SecurityStateEncoder stateEncoder, IEnumerable<Type> knownTypes )
     : this( securityTokenHandlerCollection, securityVersion, TrustVersion.WSTrust13, SecureConversationVersion.WSSecureConversation13, emitBspAttributes, samlSerializer, stateEncoder, knownTypes )
 {
 }
Пример #24
0
 public SecurityContextTokenEntry(WSSecureConversation parent, SecurityStateEncoder securityStateEncoder, IList <Type> knownClaimTypes)
 {
     this.parent           = parent;
     this.cookieSerializer = new SecurityContextCookieSerializer(securityStateEncoder, knownClaimTypes);
 }
 public WSSecurityTokenSerializer(System.ServiceModel.Security.SecurityVersion securityVersion, TrustVersion trustVersion, SecureConversationVersion secureConversationVersion, bool emitBspRequiredAttributes, SamlSerializer samlSerializer, SecurityStateEncoder securityStateEncoder, IEnumerable<Type> knownTypes, int maximumKeyDerivationOffset, int maximumKeyDerivationLabelLength, int maximumKeyDerivationNonceLength)
 {
     if (securityVersion == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("securityVersion"));
     }
     if (maximumKeyDerivationOffset < 0)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("maximumKeyDerivationOffset", System.ServiceModel.SR.GetString("ValueMustBeNonNegative")));
     }
     if (maximumKeyDerivationLabelLength < 0)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("maximumKeyDerivationLabelLength", System.ServiceModel.SR.GetString("ValueMustBeNonNegative")));
     }
     if (maximumKeyDerivationNonceLength <= 0)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("maximumKeyDerivationNonceLength", System.ServiceModel.SR.GetString("ValueMustBeGreaterThanZero")));
     }
     this.securityVersion = securityVersion;
     this.emitBspRequiredAttributes = emitBspRequiredAttributes;
     this.maximumKeyDerivationOffset = maximumKeyDerivationOffset;
     this.maximumKeyDerivationNonceLength = maximumKeyDerivationNonceLength;
     this.maximumKeyDerivationLabelLength = maximumKeyDerivationLabelLength;
     this.serializerEntries = new List<SerializerEntries>();
     if (secureConversationVersion == SecureConversationVersion.WSSecureConversationFeb2005)
     {
         this.secureConversation = new WSSecureConversationFeb2005(this, securityStateEncoder, knownTypes, maximumKeyDerivationOffset, maximumKeyDerivationLabelLength, maximumKeyDerivationNonceLength);
     }
     else
     {
         if (secureConversationVersion != SecureConversationVersion.WSSecureConversation13)
         {
             throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException());
         }
         this.secureConversation = new WSSecureConversationDec2005(this, securityStateEncoder, knownTypes, maximumKeyDerivationOffset, maximumKeyDerivationLabelLength, maximumKeyDerivationNonceLength);
     }
     this.serializerEntries.Add(new XmlDsigSep2000(this));
     this.serializerEntries.Add(new XmlEncApr2001(this));
     if (securityVersion == System.ServiceModel.Security.SecurityVersion.WSSecurity10)
     {
         this.serializerEntries.Add(new WSSecurityJan2004(this, samlSerializer));
     }
     else
     {
         if (securityVersion != System.ServiceModel.Security.SecurityVersion.WSSecurity11)
         {
             throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("securityVersion", System.ServiceModel.SR.GetString("MessageSecurityVersionOutOfRange")));
         }
         this.serializerEntries.Add(new WSSecurityXXX2005(this, samlSerializer));
     }
     this.serializerEntries.Add(this.secureConversation);
     if (trustVersion == TrustVersion.WSTrustFeb2005)
     {
         this.serializerEntries.Add(new WSTrustFeb2005(this));
     }
     else
     {
         if (trustVersion != TrustVersion.WSTrust13)
         {
             throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException());
         }
         this.serializerEntries.Add(new WSTrustDec2005(this));
     }
     this.tokenEntries = new List<TokenEntry>();
     this.keyIdentifierEntries = new List<KeyIdentifierEntry>();
     this.keyIdentifierClauseEntries = new List<KeyIdentifierClauseEntry>();
     for (int i = 0; i < this.serializerEntries.Count; i++)
     {
         SerializerEntries entries = this.serializerEntries[i];
         entries.PopulateTokenEntries(this.tokenEntries);
         entries.PopulateKeyIdentifierEntries(this.keyIdentifierEntries);
         entries.PopulateKeyIdentifierClauseEntries(this.keyIdentifierClauseEntries);
     }
 }
 public WSSecurityTokenSerializer(SecurityVersion securityVersion, bool emitBspRequiredAttributes, System.IdentityModel.Tokens.SamlSerializer samlSerializer, SecurityStateEncoder securityStateEncoder, IEnumerable <Type> knownTypes, int maximumKeyDerivationOffset, int maximumKeyDerivationLabelLength, int maximumKeyDerivationNonceLength)
 {
 }
Пример #27
0
		public WSSecurityTokenSerializer (
			SecurityVersion securityVersion,
			bool emitBspRequiredAttributes,
			SamlSerializer samlSerializer,
			SecurityStateEncoder securityStateEncoder,
			IEnumerable<Type> knownTypes,
			int maximumKeyDerivationOffset,
			int maximumKeyDerivationLabelLength,
			int maximumKeyDerivationNonceLength)
		{
			security_version = securityVersion;
			emit_bsp = emitBspRequiredAttributes;
			saml_serializer = samlSerializer;
			encoder = securityStateEncoder;
			known_types = new List<Type> (knownTypes ?? Type.EmptyTypes);
			max_offset = maximumKeyDerivationOffset;
			max_label_length = maximumKeyDerivationLabelLength;
			max_nonce_length = maximumKeyDerivationNonceLength;

			if (encoder == null)
				encoder = new DataProtectionSecurityStateEncoder ();
		}
Пример #28
0
 public WSSecurityTokenSerializer(SecurityVersion securityVersion, bool emitBspRequiredAttributes, SamlSerializer1 samlSerializer, SecurityStateEncoder securityStateEncoder, IEnumerable <Type> knownTypes,
                                  int maximumKeyDerivationOffset, int maximumKeyDerivationLabelLength, int maximumKeyDerivationNonceLength)
     : this(securityVersion, TrustVersion.Default, SecureConversationVersion.Default, emitBspRequiredAttributes, samlSerializer, securityStateEncoder, knownTypes, maximumKeyDerivationOffset, maximumKeyDerivationLabelLength, maximumKeyDerivationNonceLength)
 {
 }
 /// <summary>
 /// Initializes an instance of <see cref="WsSecurityTokenSerializerAdapter"/>
 /// </summary>
 /// <param name="securityTokenHandlerCollection">
 /// The <see cref="SecurityTokenHandlerCollection" /> containing the set of <see cref="SecurityTokenHandler" />
 /// objects used for serializing and validating tokens found in WS-Trust messages.
 /// </param>
 /// <param name="securityVersion">The SecurityVersion of the base WSSecurityTokenSerializer.</param>
 /// <param name="emitBspAttributes">Flag that determines if the serailization shoudl be BSP compliant.</param>
 /// <param name="samlSerializer">Serializer for SAML 1.1 tokens.</param>
 /// <param name="stateEncoder">SecurityStateEncoder used for resolving SCT.</param>
 /// <param name="knownTypes">The collection of known claim types.</param>
 public WsSecurityTokenSerializerAdapter(SecurityTokenHandlerCollection securityTokenHandlerCollection, SecurityVersion securityVersion, bool emitBspAttributes, SamlSerializer samlSerializer, SecurityStateEncoder stateEncoder, IEnumerable <Type> knownTypes)
     : this(securityTokenHandlerCollection, securityVersion, TrustVersion.WSTrust13, SecureConversationVersion.WSSecureConversation13, emitBspAttributes, samlSerializer, stateEncoder, knownTypes)
 {
 }
 public WSSecurityTokenSerializer(System.ServiceModel.Security.SecurityVersion securityVersion, TrustVersion trustVersion, SecureConversationVersion secureConversationVersion, bool emitBspRequiredAttributes, SamlSerializer samlSerializer, SecurityStateEncoder securityStateEncoder, IEnumerable <Type> knownTypes, int maximumKeyDerivationOffset, int maximumKeyDerivationLabelLength, int maximumKeyDerivationNonceLength)
 {
     if (securityVersion == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("securityVersion"));
     }
     if (maximumKeyDerivationOffset < 0)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("maximumKeyDerivationOffset", System.ServiceModel.SR.GetString("ValueMustBeNonNegative")));
     }
     if (maximumKeyDerivationLabelLength < 0)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("maximumKeyDerivationLabelLength", System.ServiceModel.SR.GetString("ValueMustBeNonNegative")));
     }
     if (maximumKeyDerivationNonceLength <= 0)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("maximumKeyDerivationNonceLength", System.ServiceModel.SR.GetString("ValueMustBeGreaterThanZero")));
     }
     this.securityVersion                 = securityVersion;
     this.emitBspRequiredAttributes       = emitBspRequiredAttributes;
     this.maximumKeyDerivationOffset      = maximumKeyDerivationOffset;
     this.maximumKeyDerivationNonceLength = maximumKeyDerivationNonceLength;
     this.maximumKeyDerivationLabelLength = maximumKeyDerivationLabelLength;
     this.serializerEntries               = new List <SerializerEntries>();
     if (secureConversationVersion == SecureConversationVersion.WSSecureConversationFeb2005)
     {
         this.secureConversation = new WSSecureConversationFeb2005(this, securityStateEncoder, knownTypes, maximumKeyDerivationOffset, maximumKeyDerivationLabelLength, maximumKeyDerivationNonceLength);
     }
     else
     {
         if (secureConversationVersion != SecureConversationVersion.WSSecureConversation13)
         {
             throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException());
         }
         this.secureConversation = new WSSecureConversationDec2005(this, securityStateEncoder, knownTypes, maximumKeyDerivationOffset, maximumKeyDerivationLabelLength, maximumKeyDerivationNonceLength);
     }
     this.serializerEntries.Add(new XmlDsigSep2000(this));
     this.serializerEntries.Add(new XmlEncApr2001(this));
     if (securityVersion == System.ServiceModel.Security.SecurityVersion.WSSecurity10)
     {
         this.serializerEntries.Add(new WSSecurityJan2004(this, samlSerializer));
     }
     else
     {
         if (securityVersion != System.ServiceModel.Security.SecurityVersion.WSSecurity11)
         {
             throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("securityVersion", System.ServiceModel.SR.GetString("MessageSecurityVersionOutOfRange")));
         }
         this.serializerEntries.Add(new WSSecurityXXX2005(this, samlSerializer));
     }
     this.serializerEntries.Add(this.secureConversation);
     if (trustVersion == TrustVersion.WSTrustFeb2005)
     {
         this.serializerEntries.Add(new WSTrustFeb2005(this));
     }
     else
     {
         if (trustVersion != TrustVersion.WSTrust13)
         {
             throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException());
         }
         this.serializerEntries.Add(new WSTrustDec2005(this));
     }
     this.tokenEntries               = new List <TokenEntry>();
     this.keyIdentifierEntries       = new List <KeyIdentifierEntry>();
     this.keyIdentifierClauseEntries = new List <KeyIdentifierClauseEntry>();
     for (int i = 0; i < this.serializerEntries.Count; i++)
     {
         SerializerEntries entries = this.serializerEntries[i];
         entries.PopulateTokenEntries(this.tokenEntries);
         entries.PopulateKeyIdentifierEntries(this.keyIdentifierEntries);
         entries.PopulateKeyIdentifierClauseEntries(this.keyIdentifierClauseEntries);
     }
 }
 public SecurityContextTokenEntryDec2005(WSSecureConversationDec2005 parent, SecurityStateEncoder securityStateEncoder, IList<Type> knownClaimTypes) : base(parent, securityStateEncoder, knownClaimTypes)
 {
 }
Пример #32
0
        public WSSecurityTokenSerializer(SecurityVersion securityVersion, TrustVersion trustVersion, SecureConversationVersion secureConversationVersion, bool emitBspRequiredAttributes, SamlSerializer samlSerializer, SecurityStateEncoder securityStateEncoder, IEnumerable <Type> knownTypes,
                                         int maximumKeyDerivationOffset, int maximumKeyDerivationLabelLength, int maximumKeyDerivationNonceLength)
        {
            if (securityVersion == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("securityVersion"));
            }

            if (maximumKeyDerivationOffset < 0)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("maximumKeyDerivationOffset", SRServiceModel.ValueMustBeNonNegative));
            }
            if (maximumKeyDerivationLabelLength < 0)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("maximumKeyDerivationLabelLength", SRServiceModel.ValueMustBeNonNegative));
            }
            if (maximumKeyDerivationNonceLength <= 0)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("maximumKeyDerivationNonceLength", SRServiceModel.ValueMustBeGreaterThanZero));
            }

            _securityVersion                 = securityVersion;
            _emitBspRequiredAttributes       = emitBspRequiredAttributes;
            _maximumKeyDerivationOffset      = maximumKeyDerivationOffset;
            _maximumKeyDerivationNonceLength = maximumKeyDerivationNonceLength;
            _maximumKeyDerivationLabelLength = maximumKeyDerivationLabelLength;

            _serializerEntries = new List <SerializerEntries>();

            if (secureConversationVersion == SecureConversationVersion.WSSecureConversationFeb2005)
            {
                _secureConversation = new WSSecureConversationFeb2005(this, securityStateEncoder, knownTypes, maximumKeyDerivationOffset, maximumKeyDerivationLabelLength, maximumKeyDerivationNonceLength);
            }
            else if (secureConversationVersion == SecureConversationVersion.WSSecureConversation13)
            {
                _secureConversation = new WSSecureConversationDec2005(this, securityStateEncoder, knownTypes, maximumKeyDerivationOffset, maximumKeyDerivationLabelLength, maximumKeyDerivationNonceLength);
            }
            else
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException());
            }

            if (securityVersion == SecurityVersion.WSSecurity10)
            {
                _serializerEntries.Add(new WSSecurityJan2004(this, samlSerializer));
            }
            else if (securityVersion == SecurityVersion.WSSecurity11)
            {
                _serializerEntries.Add(new WSSecurityXXX2005(this, samlSerializer));
            }
            else
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("securityVersion", SRServiceModel.MessageSecurityVersionOutOfRange));
            }
            _serializerEntries.Add(_secureConversation);
            IdentityModel.TrustDictionary trustDictionary;
            if (trustVersion == TrustVersion.WSTrustFeb2005)
            {
                _serializerEntries.Add(new WSTrustFeb2005(this));
                trustDictionary = new IdentityModel.TrustFeb2005Dictionary(new CollectionDictionary(DXD.TrustDec2005Dictionary.Feb2005DictionaryStrings));
            }
            else if (trustVersion == TrustVersion.WSTrust13)
            {
                _serializerEntries.Add(new WSTrustDec2005(this));
                trustDictionary = new IdentityModel.TrustDec2005Dictionary(new CollectionDictionary(DXD.TrustDec2005Dictionary.Dec2005DictionaryString));
            }
            else
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException());
            }

            _tokenEntries = new List <TokenEntry>();

            for (int i = 0; i < _serializerEntries.Count; ++i)
            {
                SerializerEntries serializerEntry = _serializerEntries[i];
                serializerEntry.PopulateTokenEntries(_tokenEntries);
            }

            IdentityModel.DictionaryManager dictionaryManager = new IdentityModel.DictionaryManager(ServiceModelDictionary.CurrentVersion);
            dictionaryManager.SecureConversationDec2005Dictionary = new IdentityModel.SecureConversationDec2005Dictionary(new CollectionDictionary(DXD.SecureConversationDec2005Dictionary.SecureConversationDictionaryStrings));
            dictionaryManager.SecurityAlgorithmDec2005Dictionary  = new IdentityModel.SecurityAlgorithmDec2005Dictionary(new CollectionDictionary(DXD.SecurityAlgorithmDec2005Dictionary.SecurityAlgorithmDictionaryStrings));

            _keyInfoSerializer = new WSKeyInfoSerializer(_emitBspRequiredAttributes, dictionaryManager, trustDictionary, this, securityVersion, secureConversationVersion);
        }
 public WSSecurityTokenSerializer(SecurityVersion securityVersion, bool emitBspRequiredAttributes, System.IdentityModel.Tokens.SamlSerializer samlSerializer, SecurityStateEncoder securityStateEncoder, IEnumerable <Type> knownTypes)
 {
 }
 public WSSecurityTokenSerializer(SecurityVersion securityVersion, bool emitBspRequiredAttributes, System.IdentityModel.Tokens.SamlSerializer samlSerializer, SecurityStateEncoder securityStateEncoder, IEnumerable<Type> knownTypes)
 {
 }
 internal SecureConversationServiceCredential()
 {
     this.securityStateEncoder = defaultSecurityStateEncoder;
     securityContextClaimTypes = new Collection <Type>();
     SamlAssertion.AddSamlClaimTypes(securityContextClaimTypes);
 }
 public SecurityContextTokenEntry(WSSecureConversation parent, SecurityStateEncoder securityStateEncoder, IList<Type> knownClaimTypes)
 {
     this.parent = parent;
     this.cookieSerializer = new SecurityContextCookieSerializer(securityStateEncoder, knownClaimTypes);
 }
Пример #37
0
 public WSSecurityTokenSerializer(SecurityVersion securityVersion, bool emitBspRequiredAttributes, SamlSerializer1 samlSerializer, SecurityStateEncoder securityStateEncoder, IEnumerable <Type> knownTypes)
     : this(securityVersion, emitBspRequiredAttributes, samlSerializer, securityStateEncoder, knownTypes, DefaultMaximumKeyDerivationOffset, DefaultMaximumKeyDerivationLabelLength, DefaultMaximumKeyDerivationNonceLength)
 {
 }
 internal SecureConversationServiceCredential()
 {
     this.securityStateEncoder = defaultSecurityStateEncoder;
     securityContextClaimTypes = new Collection<Type>();
     SamlAssertion.AddSamlClaimTypes(securityContextClaimTypes);
 }
Пример #39
0
        public WSSecurityTokenSerializer(SecurityVersion securityVersion, TrustVersion trustVersion, SecureConversationVersion secureConversationVersion, bool emitBspRequiredAttributes, SamlSerializer1 samlSerializer, SecurityStateEncoder securityStateEncoder, IEnumerable <Type> knownTypes,
                                         int maximumKeyDerivationOffset, int maximumKeyDerivationLabelLength, int maximumKeyDerivationNonceLength)
        {
#if !FEATURE_CORECLR
            throw ExceptionHelper.PlatformNotSupported();
#endif
        }
 public WSSecurityTokenSerializer(System.ServiceModel.Security.SecurityVersion securityVersion, TrustVersion trustVersion, SecureConversationVersion secureConversationVersion, bool emitBspRequiredAttributes, SamlSerializer samlSerializer, SecurityStateEncoder securityStateEncoder, IEnumerable <Type> knownTypes) : this(securityVersion, trustVersion, secureConversationVersion, emitBspRequiredAttributes, samlSerializer, securityStateEncoder, knownTypes, 0x40, 0x80, 0x80)
 {
 }