private void GetIssuedAndProofXml(RequestSecurityTokenResponse rstr, out XmlElement issuedTokenXml, out XmlElement proofTokenXml) { issuedTokenXml = null; proofTokenXml = null; if ((rstr.RequestSecurityTokenResponseXml != null) && (rstr.RequestSecurityTokenResponseXml.ChildNodes != null)) { for (int i = 0; i < rstr.RequestSecurityTokenResponseXml.ChildNodes.Count; ++i) { XmlElement elem = rstr.RequestSecurityTokenResponseXml.ChildNodes[i] as XmlElement; if (elem != null) { if (elem.LocalName == DriverDictionary.RequestedSecurityToken.Value && elem.NamespaceURI == DriverDictionary.Namespace.Value) { if (issuedTokenXml != null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SRServiceModel.RstrHasMultipleIssuedTokens)); } issuedTokenXml = XmlHelper.GetChildElement(elem); } else if (elem.LocalName == DriverDictionary.RequestedProofToken.Value && elem.NamespaceURI == DriverDictionary.Namespace.Value) { if (proofTokenXml != null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SRServiceModel.RstrHasMultipleProofTokens)); } proofTokenXml = XmlHelper.GetChildElement(elem); } } } } }
private SecurityToken GetEntropy(XmlElement rootElement, SecurityTokenResolver resolver) { if (rootElement == null || rootElement.ChildNodes == null) { return(null); } for (int i = 0; i < rootElement.ChildNodes.Count; ++i) { XmlElement element = rootElement.ChildNodes[i] as XmlElement; if (element != null) { if (element.LocalName == DriverDictionary.Entropy.Value && element.NamespaceURI == DriverDictionary.Namespace.Value) { XmlElement tokenXml = XmlHelper.GetChildElement(element); string valueTypeUri = element.GetAttribute(SecurityJan2004Strings.ValueType); if (valueTypeUri.Length == 0) { valueTypeUri = null; } return(_standardsManager.SecurityTokenSerializer.ReadToken(new XmlNodeReader(tokenXml), resolver)); } } } return(null); }
protected override void ReadReferences(XmlElement rstrXml, out SecurityKeyIdentifierClause requestedAttachedReference, out SecurityKeyIdentifierClause requestedUnattachedReference) { XmlElement element = (XmlElement)null; requestedAttachedReference = (SecurityKeyIdentifierClause)null; requestedUnattachedReference = (SecurityKeyIdentifierClause)null; for (int index = 0; index < rstrXml.ChildNodes.Count; ++index) { XmlElement childNode = rstrXml.ChildNodes[index] as XmlElement; if (childNode != null) { if (childNode.LocalName == this.DriverDictionary.RequestedSecurityToken.Value && childNode.NamespaceURI == this.DriverDictionary.Namespace.Value) { element = XmlHelper.GetChildElement(childNode); } else if (childNode.LocalName == this.DriverDictionary.RequestedAttachedReference.Value && childNode.NamespaceURI == this.DriverDictionary.Namespace.Value) { requestedAttachedReference = this.GetKeyIdentifierXmlReferenceClause(XmlHelper.GetChildElement(childNode)); } else if (childNode.LocalName == this.DriverDictionary.RequestedUnattachedReference.Value && childNode.NamespaceURI == this.DriverDictionary.Namespace.Value) { requestedUnattachedReference = this.GetKeyIdentifierXmlReferenceClause(XmlHelper.GetChildElement(childNode)); } } } try { if (element == null) { return; } if (requestedAttachedReference == null) { this.StandardsManager.TryCreateKeyIdentifierClauseFromTokenXml(element, SecurityTokenReferenceStyle.Internal, out requestedAttachedReference); } if (requestedUnattachedReference != null) { return; } this.StandardsManager.TryCreateKeyIdentifierClauseFromTokenXml(element, SecurityTokenReferenceStyle.External, out requestedUnattachedReference); } catch (XmlException) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError((Exception) new XmlException(SR.GetString("TrustDriverIsUnableToCreatedNecessaryAttachedOrUnattachedReferences", new object[1] { (object)element.ToString() }))); } }
protected override void ReadReferences(XmlElement rstrXml, out SecurityKeyIdentifierClause requestedAttachedReference, out SecurityKeyIdentifierClause requestedUnattachedReference) { XmlElement issuedTokenXml = null; requestedAttachedReference = null; requestedUnattachedReference = null; for (int i = 0; i < rstrXml.ChildNodes.Count; ++i) { XmlElement child = rstrXml.ChildNodes[i] as XmlElement; if (child != null) { if (child.LocalName == DriverDictionary.RequestedSecurityToken.Value && child.NamespaceURI == DriverDictionary.Namespace.Value) { issuedTokenXml = XmlHelper.GetChildElement(child); } else if (child.LocalName == DriverDictionary.RequestedAttachedReference.Value && child.NamespaceURI == DriverDictionary.Namespace.Value) { requestedAttachedReference = GetKeyIdentifierXmlReferenceClause(XmlHelper.GetChildElement(child)); } else if (child.LocalName == DriverDictionary.RequestedUnattachedReference.Value && child.NamespaceURI == DriverDictionary.Namespace.Value) { requestedUnattachedReference = GetKeyIdentifierXmlReferenceClause(XmlHelper.GetChildElement(child)); } } } try { if (issuedTokenXml != null) { if (requestedAttachedReference == null) { StandardsManager.TryCreateKeyIdentifierClauseFromTokenXml(issuedTokenXml, SecurityTokenReferenceStyle.Internal, out requestedAttachedReference); } if (requestedUnattachedReference == null) { StandardsManager.TryCreateKeyIdentifierClauseFromTokenXml(issuedTokenXml, SecurityTokenReferenceStyle.External, out requestedUnattachedReference); } } } catch (XmlException) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(SR.Format(SR.TrustDriverIsUnableToCreatedNecessaryAttachedOrUnattachedReferences, issuedTokenXml.ToString()))); } }
protected override void ReadReferences(XmlElement rstrXml, out SecurityKeyIdentifierClause requestedAttachedReference, out SecurityKeyIdentifierClause requestedUnattachedReference) { XmlElement childElement = null; requestedAttachedReference = null; requestedUnattachedReference = null; for (int i = 0; i < rstrXml.ChildNodes.Count; i++) { XmlElement parent = rstrXml.ChildNodes[i] as XmlElement; if (parent != null) { if ((parent.LocalName == this.DriverDictionary.RequestedSecurityToken.Value) && (parent.NamespaceURI == this.DriverDictionary.Namespace.Value)) { childElement = XmlHelper.GetChildElement(parent); } else if ((parent.LocalName == this.DriverDictionary.RequestedAttachedReference.Value) && (parent.NamespaceURI == this.DriverDictionary.Namespace.Value)) { requestedAttachedReference = this.StandardsManager.SecurityTokenSerializer.ReadKeyIdentifierClause(new XmlNodeReader(XmlHelper.GetChildElement(parent))); } else if ((parent.LocalName == this.DriverDictionary.RequestedUnattachedReference.Value) && (parent.NamespaceURI == this.DriverDictionary.Namespace.Value)) { requestedUnattachedReference = this.StandardsManager.SecurityTokenSerializer.ReadKeyIdentifierClause(new XmlNodeReader(XmlHelper.GetChildElement(parent))); } } } try { if (childElement != null) { if (requestedAttachedReference == null) { this.StandardsManager.TryCreateKeyIdentifierClauseFromTokenXml(childElement, SecurityTokenReferenceStyle.Internal, out requestedAttachedReference); } if (requestedUnattachedReference == null) { this.StandardsManager.TryCreateKeyIdentifierClauseFromTokenXml(childElement, SecurityTokenReferenceStyle.External, out requestedUnattachedReference); } } } catch (XmlException) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(System.ServiceModel.SR.GetString("TrustDriverIsUnableToCreatedNecessaryAttachedOrUnattachedReferences", new object[] { childElement.ToString() }))); } }
public override byte[] GetAuthenticator(RequestSecurityTokenResponse rstr) { if (rstr != null && rstr.RequestSecurityTokenResponseXml != null && rstr.RequestSecurityTokenResponseXml.ChildNodes != null) { for (int i = 0; i < rstr.RequestSecurityTokenResponseXml.ChildNodes.Count; ++i) { XmlElement element = rstr.RequestSecurityTokenResponseXml.ChildNodes[i] as XmlElement; if (element != null) { if (element.LocalName == DriverDictionary.Authenticator.Value && element.NamespaceURI == DriverDictionary.Namespace.Value) { XmlElement combinedHashElement = XmlHelper.GetChildElement(element); if (combinedHashElement.LocalName == DriverDictionary.CombinedHash.Value && combinedHashElement.NamespaceURI == DriverDictionary.Namespace.Value) { string authenticatorString = XmlHelper.ReadTextElementAsTrimmedString(combinedHashElement); return(Convert.FromBase64String(authenticatorString)); } } } } } return(null); }