internal bool MatchesGenericXmlTokenKeyIdentifierClause(SecurityToken token, SecurityKeyIdentifierClause keyIdentifierClause, SecurityTokenReferenceStyle referenceStyle) { if (token == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("token"); } bool result; GenericXmlSecurityToken xmlToken = token as GenericXmlSecurityToken; if (xmlToken == null) { result = false; } else if (referenceStyle == SecurityTokenReferenceStyle.External && xmlToken.ExternalTokenReference != null) { result = xmlToken.ExternalTokenReference.Matches(keyIdentifierClause); } else if (referenceStyle == SecurityTokenReferenceStyle.Internal) { result = xmlToken.MatchesKeyIdentifierClause(keyIdentifierClause); } else { result = false; } return(result); }
internal bool MatchesGenericXmlTokenKeyIdentifierClause(SecurityToken token, SecurityKeyIdentifierClause keyIdentifierClause, SecurityTokenReferenceStyle referenceStyle) { if (token == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("token"); } GenericXmlSecurityToken token2 = token as GenericXmlSecurityToken; if (token2 == null) { return(false); } if ((referenceStyle == SecurityTokenReferenceStyle.External) && (token2.ExternalTokenReference != null)) { return(token2.ExternalTokenReference.Matches(keyIdentifierClause)); } return((referenceStyle == SecurityTokenReferenceStyle.Internal) && token2.MatchesKeyIdentifierClause(keyIdentifierClause)); }
public static void KeyIdentifierClauseMethods() { XmlDocument doc = new XmlDocument(); XmlElement tokenXml = doc.CreateElement("ElementName"); XmlAttribute attr = doc.CreateAttribute("Id", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"); string attrValue = "Value for Attribute Name Id"; attr.Value = attrValue; tokenXml.Attributes.Append(attr); UserNameSecurityToken proofToken = new UserNameSecurityToken("user", "password"); var keyIdentifierGuid = Guid.NewGuid(); var internalTokenReference = CreateGenericKeyIdentifierClause(keyIdentifierGuid); GenericXmlSecurityToken gxst = new GenericXmlSecurityToken(tokenXml, proofToken, DateTime.UtcNow, DateTime.MaxValue, internalTokenReference, null, null); Assert.True(gxst.CanCreateKeyIdentifierClause <GenericXmlSecurityKeyIdentifierClause>()); Assert.Equal(internalTokenReference, gxst.CreateKeyIdentifierClause <GenericXmlSecurityKeyIdentifierClause>()); Assert.True(gxst.MatchesKeyIdentifierClause(CreateGenericKeyIdentifierClause(keyIdentifierGuid))); }