Beispiel #1
0
        protected IssuedSecurityTokenParameters(IssuedSecurityTokenParameters other)
            : base(other)
        {
            DefaultMessageSecurityVersion = other.DefaultMessageSecurityVersion;
            IssuerAddress   = other.IssuerAddress;
            _keyType        = other._keyType;
            TokenType       = other.TokenType;
            _keySize        = other._keySize;
            UseStrTransform = other.UseStrTransform;

            foreach (XmlElement parameter in other.AdditionalRequestParameters)
            {
                AdditionalRequestParameters.Add((XmlElement)parameter.Clone());
            }
            foreach (ClaimTypeRequirement c in other.ClaimTypeRequirements)
            {
                ClaimTypeRequirements.Add(c);
            }
            if (other.IssuerBinding != null)
            {
                IssuerBinding = new CustomBinding(other.IssuerBinding);
            }
            IssuerMetadataAddress = other.IssuerMetadataAddress;
        }
Beispiel #2
0
        internal void SetRequestParameters(Collection <XmlElement> requestParameters, TrustDriver trustDriver)
        {
            if (requestParameters == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(requestParameters));
            }

            if (trustDriver == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(trustDriver));
            }

            Collection <XmlElement> unknownRequestParameters = new Collection <XmlElement>();

            foreach (XmlElement element in requestParameters)
            {
                if (trustDriver.TryParseKeySizeElement(element, out int keySize))
                {
                    _keySize = keySize;
                }
                else if (trustDriver.TryParseKeyTypeElement(element, out SecurityKeyType keyType))
                {
                    KeyType = keyType;
                }
                else if (trustDriver.TryParseTokenTypeElement(element, out string tokenType))
                {
                    TokenType = tokenType;
                }
                // Only copy RP policy to client policy for TrustFeb2005
                else if (trustDriver.StandardsManager.TrustVersion == TrustVersion.WSTrustFeb2005)
                {
                    if (trustDriver.TryParseRequiredClaimsElement(element, out Collection <XmlElement> requiredClaims))
                    {
                        Collection <XmlElement> unrecognizedRequiredClaims = new Collection <XmlElement>();
                        foreach (XmlElement claimRequirement in requiredClaims)
                        {
                            if (claimRequirement.LocalName == "ClaimType" && claimRequirement.NamespaceURI == wsidNamespace)
                            {
                                string claimValue = claimRequirement.GetAttribute("Uri", string.Empty);
                                if (!string.IsNullOrEmpty(claimValue))
                                {
                                    ClaimTypeRequirement claimTypeRequirement;
                                    string optional = claimRequirement.GetAttribute("Optional", string.Empty);
                                    if (string.IsNullOrEmpty(optional))
                                    {
                                        claimTypeRequirement = new ClaimTypeRequirement(claimValue);
                                    }
                                    else
                                    {
                                        claimTypeRequirement = new ClaimTypeRequirement(claimValue, XmlConvert.ToBoolean(optional));
                                    }

                                    ClaimTypeRequirements.Add(claimTypeRequirement);
                                }
                            }
                            else
                            {
                                unrecognizedRequiredClaims.Add(claimRequirement);
                            }
                        }
                        if (unrecognizedRequiredClaims.Count > 0)
                        {
                            unknownRequestParameters.Add(trustDriver.CreateRequiredClaimsElement(unrecognizedRequiredClaims));
                        }
                    }
                    else
                    {
                        unknownRequestParameters.Add(element);
                    }
                }
            }

            unknownRequestParameters = trustDriver.ProcessUnknownRequestParameters(unknownRequestParameters, requestParameters);
            if (unknownRequestParameters.Count > 0)
            {
                for (int i = 0; i < unknownRequestParameters.Count; ++i)
                {
                    AdditionalRequestParameters.Add(unknownRequestParameters[i]);
                }
            }
        }