private XmlNode GetChainedToken(XmlElement removedPvpToken) { // neither http headers nor soap headers avaiable if (removedPvpToken == null && _headers == null) { return(null); } if (_headers != null && PvpToken.DeterminePvpVersion(_headers).HasValue) { PvpToken chainedToken = new PvpToken(_headers); // Use http header if possible if (chainedToken.ParticipantId != null) { return(chainedToken.GetChainedSoapFragment()); } } // http headers available, but not sufficent if (removedPvpToken == null) { return(null); } XmlDocument tempDoc = new XmlDocument(); XmlNode chainedNode = tempDoc.CreateElement(_pvpChainedTokenTag, _pvpTokenNS); XmlNode importedToken = tempDoc.ImportNode(removedPvpToken, true); foreach (XmlNode child in importedToken.ChildNodes) { chainedNode.AppendChild(child); } foreach (XmlAttribute a in importedToken.Attributes) { chainedNode.Attributes.Append((XmlAttribute)a.Clone()); } return(chainedNode); }
public void ChainedTokenTest() { var headers = GetNameValueCollection19(); PvpToken token = new PvpToken(headers); string result = token.GetChainedSoapFragment().OuterXml; Assert.IsTrue( result.Contains( @"<pvpChainedToken version=""1.9"" xmlns=""http://egov.gv.at/pvp1.xsd"">")) ; Assert.IsTrue(result.Contains("<participantId>AT:L6:1234789</participantId>")); Assert.IsTrue(result.Contains("<userId>[email protected]</userId>")); Assert.IsTrue(result.Contains("<cn>Max Mustermann</cn>")); Assert.IsTrue(result.Contains("<ou>Meldeamt</ou>")); Assert.IsTrue(result.Contains("<gvOuOKZ>AT:GGA-60420-Abt13</gvOuOKZ>")); Assert.IsTrue(result.Contains("<gvSecClass>2</gvSecClass>")); Assert.IsTrue(result.Contains("<gvGid>AT:B:0:LxXnvpcYZesiqVXsZG0bB==</gvGid>")); Assert.IsTrue(result.Contains("<gvOuId>AT:GGA-60420:0815</gvOuId>")); Assert.IsTrue(result.Contains("<mail>[email protected]</mail>")); Assert.IsTrue(result.Contains("<tel>+43 3155 5153</tel>")); Assert.IsTrue(result.Contains("</userPrincipal></authenticate>")); Assert.IsTrue( result.Contains(@"<role value=""Beispielrolle""><param><key>GKZ</key><value>60420</value></param></role>")); }