コード例 #1
0
 public static bool IsInfoCardParameters(IssuedSecurityTokenParameters parameters, SecurityStandardsManager standardsManager)
 {
     if (parameters == null || parameters.TokenType != "http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV1.1" || parameters.KeyType != SecurityKeyType.AsymmetricKey)
     {
         return(false);
     }
     if (parameters.ClaimTypeRequirements.Count == 1)
     {
         ClaimTypeRequirement claimTypeRequirement = parameters.ClaimTypeRequirements[0];
         if (claimTypeRequirement == null || claimTypeRequirement.ClaimType != IssuedSecurityTokenParameters.wsidPPIClaim)
         {
             return(false);
         }
     }
     else
     {
         if (parameters.AdditionalRequestParameters == null || parameters.AdditionalRequestParameters.Count <= 0)
         {
             return(false);
         }
         bool       flag = false;
         XmlElement claimTypeRequirement = IssuedSecurityTokenParameters.GetClaimTypeRequirement(parameters.AdditionalRequestParameters, standardsManager);
         if (claimTypeRequirement != null && claimTypeRequirement.ChildNodes.Count == 1)
         {
             XmlElement childNode = claimTypeRequirement.ChildNodes[0] as XmlElement;
             if (childNode != null)
             {
                 XmlNode namedItem = childNode.Attributes.GetNamedItem("Uri");
                 if (namedItem != null && namedItem.Value == IssuedSecurityTokenParameters.wsidPPIClaim)
                 {
                     flag = true;
                 }
             }
         }
         if (!flag)
         {
             return(false);
         }
     }
     return(!(parameters.IssuerAddress != (EndpointAddress)null) && (parameters.AlternativeIssuerEndpoints == null || parameters.AlternativeIssuerEndpoints.Count <= 0));
 }
コード例 #2
0
        internal static bool IsInfoCardParameters(IssuedSecurityTokenParameters parameters, SecurityStandardsManager standardsManager)
        {
            if (parameters == null)
            {
                return(false);
            }
            if (parameters.TokenType != SecurityXXX2005Strings.SamlTokenType)
            {
                return(false);
            }
            if (parameters.KeyType != SecurityKeyType.AsymmetricKey)
            {
                return(false);
            }

            if (parameters.ClaimTypeRequirements.Count == 1)
            {
                ClaimTypeRequirement claimTypeRequirement = parameters.ClaimTypeRequirements[0] as ClaimTypeRequirement;
                if (claimTypeRequirement == null)
                {
                    return(false);
                }
                if (claimTypeRequirement.ClaimType != s_wsidPPIClaim)
                {
                    return(false);
                }
            }
            else if ((parameters.AdditionalRequestParameters != null) && (parameters.AdditionalRequestParameters.Count > 0))
            {
                // Check the AdditionalRequest Parameters to see if ClaimTypeRequirements got imported there.
                bool       claimTypeRequirementMatched = false;
                XmlElement claimTypeRequirement        = GetClaimTypeRequirement(parameters.AdditionalRequestParameters, standardsManager);
                if (claimTypeRequirement != null && claimTypeRequirement.ChildNodes.Count == 1)
                {
                    XmlElement claimTypeElement = claimTypeRequirement.ChildNodes[0] as XmlElement;
                    if (claimTypeElement != null)
                    {
                        XmlNode claimType = claimTypeElement.Attributes.GetNamedItem("Uri");
                        if (claimType != null && claimType.Value == s_wsidPPIClaim)
                        {
                            claimTypeRequirementMatched = true;
                        }
                    }
                }

                if (!claimTypeRequirementMatched)
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }
            if (parameters.IssuerAddress != null)
            {
                return(false);
            }
            if (parameters.AlternativeIssuerEndpoints != null && parameters.AlternativeIssuerEndpoints.Count > 0)
            {
                return(false);
            }
            return(true);
        }
コード例 #3
0
        internal void SetRequestParameters(Collection <XmlElement> requestParameters, TrustDriver trustDriver)
        {
            if (requestParameters == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("requestParameters");
            }

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

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

            foreach (XmlElement element in requestParameters)
            {
                int                     keySize;
                string                  tokenType;
                SecurityKeyType         keyType;
                Collection <XmlElement> requiredClaims;
                if (trustDriver.TryParseKeySizeElement(element, out keySize))
                {
                    _keySize = keySize;
                }
                else if (trustDriver.TryParseKeyTypeElement(element, out keyType))
                {
                    this.KeyType = keyType;
                }
                else if (trustDriver.TryParseTokenTypeElement(element, out tokenType))
                {
                    this.TokenType = tokenType;
                }
                // Only copy RP policy to client policy for TrustFeb2005
                else if (trustDriver.StandardsManager.TrustVersion == TrustVersion.WSTrustFeb2005)
                {
                    if (trustDriver.TryParseRequiredClaimsElement(element, out 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)
                {
                    this.AdditionalRequestParameters.Add(unknownRequestParameters[i]);
                }
            }
        }
 internal void SetRequestParameters(Collection<XmlElement> requestParameters, TrustDriver trustDriver)
 {
     if (requestParameters == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("requestParameters");
     }
     if (trustDriver == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("trustDriver");
     }
     Collection<XmlElement> unknownRequestParameters = new Collection<XmlElement>();
     foreach (XmlElement element in requestParameters)
     {
         int num;
         if (trustDriver.TryParseKeySizeElement(element, out num))
         {
             this.keySize = num;
         }
         else
         {
             SecurityKeyType type;
             if (trustDriver.TryParseKeyTypeElement(element, out type))
             {
                 this.KeyType = type;
             }
             else
             {
                 string str;
                 if (trustDriver.TryParseTokenTypeElement(element, out str))
                 {
                     this.TokenType = str;
                 }
                 else if (trustDriver.StandardsManager.TrustVersion == TrustVersion.WSTrustFeb2005)
                 {
                     Collection<XmlElement> collection2;
                     if (trustDriver.TryParseRequiredClaimsElement(element, out collection2))
                     {
                         Collection<XmlElement> claimsList = new Collection<XmlElement>();
                         foreach (XmlElement element2 in collection2)
                         {
                             if ((element2.LocalName == "ClaimType") && (element2.NamespaceURI == "http://schemas.xmlsoap.org/ws/2005/05/identity"))
                             {
                                 string attribute = element2.GetAttribute("Uri", string.Empty);
                                 if (!string.IsNullOrEmpty(attribute))
                                 {
                                     ClaimTypeRequirement requirement;
                                     string str3 = element2.GetAttribute("Optional", string.Empty);
                                     if (string.IsNullOrEmpty(str3))
                                     {
                                         requirement = new ClaimTypeRequirement(attribute);
                                     }
                                     else
                                     {
                                         requirement = new ClaimTypeRequirement(attribute, XmlConvert.ToBoolean(str3));
                                     }
                                     this.claimTypeRequirements.Add(requirement);
                                 }
                             }
                             else
                             {
                                 claimsList.Add(element2);
                             }
                         }
                         if (claimsList.Count > 0)
                         {
                             unknownRequestParameters.Add(trustDriver.CreateRequiredClaimsElement(claimsList));
                         }
                     }
                     else
                     {
                         unknownRequestParameters.Add(element);
                     }
                 }
             }
         }
     }
     unknownRequestParameters = trustDriver.ProcessUnknownRequestParameters(unknownRequestParameters, requestParameters);
     if (unknownRequestParameters.Count > 0)
     {
         for (int i = 0; i < unknownRequestParameters.Count; i++)
         {
             this.AdditionalRequestParameters.Add(unknownRequestParameters[i]);
         }
     }
 }
        internal void SetRequestParameters(Collection <XmlElement> requestParameters, TrustDriver trustDriver)
        {
            if (requestParameters == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("requestParameters");
            }
            if (trustDriver == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("trustDriver");
            }
            Collection <XmlElement> unknownRequestParameters = new Collection <XmlElement>();

            foreach (XmlElement element in requestParameters)
            {
                int num;
                if (trustDriver.TryParseKeySizeElement(element, out num))
                {
                    this.keySize = num;
                }
                else
                {
                    SecurityKeyType type;
                    if (trustDriver.TryParseKeyTypeElement(element, out type))
                    {
                        this.KeyType = type;
                    }
                    else
                    {
                        string str;
                        if (trustDriver.TryParseTokenTypeElement(element, out str))
                        {
                            this.TokenType = str;
                        }
                        else if (trustDriver.StandardsManager.TrustVersion == TrustVersion.WSTrustFeb2005)
                        {
                            Collection <XmlElement> collection2;
                            if (trustDriver.TryParseRequiredClaimsElement(element, out collection2))
                            {
                                Collection <XmlElement> claimsList = new Collection <XmlElement>();
                                foreach (XmlElement element2 in collection2)
                                {
                                    if ((element2.LocalName == "ClaimType") && (element2.NamespaceURI == "http://schemas.xmlsoap.org/ws/2005/05/identity"))
                                    {
                                        string attribute = element2.GetAttribute("Uri", string.Empty);
                                        if (!string.IsNullOrEmpty(attribute))
                                        {
                                            ClaimTypeRequirement requirement;
                                            string str3 = element2.GetAttribute("Optional", string.Empty);
                                            if (string.IsNullOrEmpty(str3))
                                            {
                                                requirement = new ClaimTypeRequirement(attribute);
                                            }
                                            else
                                            {
                                                requirement = new ClaimTypeRequirement(attribute, XmlConvert.ToBoolean(str3));
                                            }
                                            this.claimTypeRequirements.Add(requirement);
                                        }
                                    }
                                    else
                                    {
                                        claimsList.Add(element2);
                                    }
                                }
                                if (claimsList.Count > 0)
                                {
                                    unknownRequestParameters.Add(trustDriver.CreateRequiredClaimsElement(claimsList));
                                }
                            }
                            else
                            {
                                unknownRequestParameters.Add(element);
                            }
                        }
                    }
                }
            }
            unknownRequestParameters = trustDriver.ProcessUnknownRequestParameters(unknownRequestParameters, requestParameters);
            if (unknownRequestParameters.Count > 0)
            {
                for (int i = 0; i < unknownRequestParameters.Count; i++)
                {
                    this.AdditionalRequestParameters.Add(unknownRequestParameters[i]);
                }
            }
        }
 internal static bool IsInfoCardParameters(IssuedSecurityTokenParameters parameters, SecurityStandardsManager standardsManager)
 {
     if (parameters == null)
     {
         return(false);
     }
     if (parameters.TokenType != "http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV1.1")
     {
         return(false);
     }
     if (parameters.KeyType != SecurityKeyType.AsymmetricKey)
     {
         return(false);
     }
     if (parameters.ClaimTypeRequirements.Count == 1)
     {
         ClaimTypeRequirement requirement = parameters.ClaimTypeRequirements[0];
         if (requirement == null)
         {
             return(false);
         }
         if (requirement.ClaimType != wsidPPIClaim)
         {
             return(false);
         }
     }
     else
     {
         if ((parameters.AdditionalRequestParameters == null) || (parameters.AdditionalRequestParameters.Count <= 0))
         {
             return(false);
         }
         bool       flag = false;
         XmlElement claimTypeRequirement = GetClaimTypeRequirement(parameters.AdditionalRequestParameters, standardsManager);
         if ((claimTypeRequirement != null) && (claimTypeRequirement.ChildNodes.Count == 1))
         {
             XmlElement element2 = claimTypeRequirement.ChildNodes[0] as XmlElement;
             if (element2 != null)
             {
                 System.Xml.XmlNode namedItem = element2.Attributes.GetNamedItem("Uri");
                 if ((namedItem != null) && (namedItem.Value == wsidPPIClaim))
                 {
                     flag = true;
                 }
             }
         }
         if (!flag)
         {
             return(false);
         }
     }
     if (parameters.IssuerAddress != null)
     {
         return(false);
     }
     if ((parameters.AlternativeIssuerEndpoints != null) && (parameters.AlternativeIssuerEndpoints.Count > 0))
     {
         return(false);
     }
     return(true);
 }
コード例 #7
0
        internal void SetRequestParameters(Collection<XmlElement> requestParameters, TrustDriver trustDriver)
        {
            if (requestParameters == null)
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("requestParameters");

            if (trustDriver == null)
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("trustDriver");

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

            foreach (XmlElement element in requestParameters)
            {
                int keySize;
                string tokenType;
                SecurityKeyType keyType;
                Collection<XmlElement> requiredClaims;
                if (trustDriver.TryParseKeySizeElement(element, out keySize))
                    this.keySize = keySize;
                else if (trustDriver.TryParseKeyTypeElement(element, out keyType))
                    this.KeyType = keyType;
                else if (trustDriver.TryParseTokenTypeElement(element, out tokenType))
                    this.TokenType = tokenType;
                // Only copy RP policy to client policy for TrustFeb2005
                else if (trustDriver.StandardsManager.TrustVersion == TrustVersion.WSTrustFeb2005)
                {
                    if (trustDriver.TryParseRequiredClaimsElement(element, out 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));
                                    }

                                    this.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)
                    this.AdditionalRequestParameters.Add(unknownRequestParameters[i]);
            }
        }