| | | 1 | | // Licensed to the .NET Foundation under one or more agreements. |
| | | 2 | | // The .NET Foundation licenses this file to you under the MIT license. |
| | | 3 | | |
| | | 4 | | using System; |
| | | 5 | | using System.Collections.ObjectModel; |
| | | 6 | | using System.Xml; |
| | | 7 | | using CoreWCF.IdentityModel; |
| | | 8 | | using CoreWCF.Security.Tokens; |
| | | 9 | | |
| | | 10 | | namespace CoreWCF.Security |
| | | 11 | | { |
| | | 12 | | internal class WSTrustFeb2005 : WSTrust |
| | | 13 | | { |
| | | 14 | | public WSTrustFeb2005(WSSecurityTokenSerializer tokenSerializer) |
| | 132 | 15 | | : base(tokenSerializer) |
| | | 16 | | { |
| | 132 | 17 | | } |
| | | 18 | | |
| | | 19 | | public override TrustDictionary SerializerDictionary |
| | | 20 | | { |
| | 172 | 21 | | get { return XD.TrustFeb2005Dictionary; } |
| | | 22 | | } |
| | | 23 | | |
| | | 24 | | public class DriverFeb2005 : Driver |
| | | 25 | | { |
| | | 26 | | public DriverFeb2005(SecurityStandardsManager standardsManager) |
| | 131 | 27 | | : base(standardsManager) |
| | | 28 | | { |
| | 131 | 29 | | } |
| | | 30 | | |
| | | 31 | | public override TrustDictionary DriverDictionary |
| | | 32 | | { |
| | | 33 | | get |
| | | 34 | | { |
| | 498 | 35 | | return XD.TrustFeb2005Dictionary; |
| | | 36 | | } |
| | | 37 | | } |
| | | 38 | | |
| | | 39 | | public override XmlDictionaryString RequestSecurityTokenResponseFinalAction |
| | | 40 | | { |
| | | 41 | | get |
| | | 42 | | { |
| | 0 | 43 | | return XD.TrustFeb2005Dictionary.RequestSecurityTokenIssuanceResponse; |
| | | 44 | | } |
| | | 45 | | } |
| | | 46 | | |
| | | 47 | | public override bool IsSessionSupported |
| | | 48 | | { |
| | | 49 | | get |
| | | 50 | | { |
| | 22 | 51 | | return true; |
| | | 52 | | } |
| | | 53 | | } |
| | | 54 | | |
| | | 55 | | public override bool IsIssuedTokensSupported |
| | | 56 | | { |
| | | 57 | | get |
| | | 58 | | { |
| | 0 | 59 | | return true; |
| | | 60 | | } |
| | | 61 | | } |
| | | 62 | | |
| | | 63 | | public override string IssuedTokensHeaderName |
| | | 64 | | { |
| | | 65 | | get |
| | | 66 | | { |
| | 0 | 67 | | return DriverDictionary.IssuedTokensHeader.Value; |
| | | 68 | | } |
| | | 69 | | } |
| | | 70 | | |
| | | 71 | | public override string IssuedTokensHeaderNamespace |
| | | 72 | | { |
| | | 73 | | get |
| | | 74 | | { |
| | 0 | 75 | | return DriverDictionary.Namespace.Value; |
| | | 76 | | } |
| | | 77 | | } |
| | | 78 | | |
| | | 79 | | public override string RequestTypeRenew |
| | | 80 | | { |
| | | 81 | | get |
| | | 82 | | { |
| | 0 | 83 | | return DriverDictionary.RequestTypeRenew.Value; |
| | | 84 | | } |
| | | 85 | | } |
| | | 86 | | |
| | | 87 | | public override string RequestTypeClose |
| | | 88 | | { |
| | | 89 | | get |
| | | 90 | | { |
| | 10 | 91 | | return DriverDictionary.RequestTypeClose.Value; |
| | | 92 | | } |
| | | 93 | | } |
| | | 94 | | |
| | | 95 | | public override Collection<XmlElement> ProcessUnknownRequestParameters(Collection<XmlElement> unknownRequest |
| | | 96 | | { |
| | 0 | 97 | | throw new NotImplementedException(); |
| | | 98 | | } |
| | | 99 | | |
| | | 100 | | protected override void ReadReferences(XmlElement rstrXml, out SecurityKeyIdentifierClause requestedAttached |
| | | 101 | | out SecurityKeyIdentifierClause requestedUnattachedReference) |
| | | 102 | | { |
| | 0 | 103 | | XmlElement issuedTokenXml = null; |
| | 0 | 104 | | requestedAttachedReference = null; |
| | 0 | 105 | | requestedUnattachedReference = null; |
| | 0 | 106 | | for (int i = 0; i < rstrXml.ChildNodes.Count; ++i) |
| | | 107 | | { |
| | 0 | 108 | | if (rstrXml.ChildNodes[i] is XmlElement child) |
| | | 109 | | { |
| | 0 | 110 | | if (child.LocalName == DriverDictionary.RequestedSecurityToken.Value && child.NamespaceURI == Dr |
| | | 111 | | { |
| | 0 | 112 | | issuedTokenXml = XmlHelper.GetChildElement(child); |
| | | 113 | | } |
| | 0 | 114 | | else if (child.LocalName == DriverDictionary.RequestedAttachedReference.Value && child.Namespace |
| | | 115 | | { |
| | 0 | 116 | | requestedAttachedReference = GetKeyIdentifierXmlReferenceClause(XmlHelper.GetChildElement(ch |
| | | 117 | | } |
| | 0 | 118 | | else if (child.LocalName == DriverDictionary.RequestedUnattachedReference.Value && child.Namespa |
| | | 119 | | { |
| | 0 | 120 | | requestedUnattachedReference = GetKeyIdentifierXmlReferenceClause(XmlHelper.GetChildElement( |
| | | 121 | | } |
| | | 122 | | } |
| | | 123 | | } |
| | | 124 | | |
| | | 125 | | try |
| | | 126 | | { |
| | 0 | 127 | | if (issuedTokenXml != null) |
| | | 128 | | { |
| | 0 | 129 | | if (requestedAttachedReference == null) |
| | | 130 | | { |
| | 0 | 131 | | StandardsManager.TryCreateKeyIdentifierClauseFromTokenXml(issuedTokenXml, SecurityTokenRefer |
| | | 132 | | } |
| | 0 | 133 | | if (requestedUnattachedReference == null) |
| | | 134 | | { |
| | 0 | 135 | | StandardsManager.TryCreateKeyIdentifierClauseFromTokenXml(issuedTokenXml, SecurityTokenRefer |
| | | 136 | | } |
| | | 137 | | } |
| | 0 | 138 | | } |
| | 0 | 139 | | catch (XmlException) |
| | | 140 | | { |
| | 0 | 141 | | throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(SR.Format(SR.TrustDriverI |
| | | 142 | | } |
| | 0 | 143 | | } |
| | | 144 | | |
| | | 145 | | protected override bool ReadRequestedTokenClosed(XmlElement rstrXml) |
| | | 146 | | { |
| | 0 | 147 | | for (int i = 0; i < rstrXml.ChildNodes.Count; ++i) |
| | | 148 | | { |
| | 0 | 149 | | XmlElement child = (rstrXml.ChildNodes[i] as XmlElement); |
| | 0 | 150 | | if (child != null) |
| | | 151 | | { |
| | 0 | 152 | | if (child.LocalName == DriverDictionary.RequestedTokenClosed.Value && child.NamespaceURI == Driv |
| | | 153 | | { |
| | 0 | 154 | | return true; |
| | | 155 | | } |
| | | 156 | | } |
| | | 157 | | } |
| | 0 | 158 | | return false; |
| | | 159 | | } |
| | | 160 | | |
| | | 161 | | protected override void ReadTargets(XmlElement rstXml, out SecurityKeyIdentifierClause renewTarget, out Secu |
| | | 162 | | { |
| | 20 | 163 | | renewTarget = null; |
| | 20 | 164 | | closeTarget = null; |
| | | 165 | | |
| | 160 | 166 | | for (int i = 0; i < rstXml.ChildNodes.Count; ++i) |
| | | 167 | | { |
| | 60 | 168 | | XmlElement child = (rstXml.ChildNodes[i] as XmlElement); |
| | 60 | 169 | | if (child != null) |
| | | 170 | | { |
| | 60 | 171 | | if (child.LocalName == DriverDictionary.RenewTarget.Value && child.NamespaceURI == DriverDiction |
| | | 172 | | { |
| | 0 | 173 | | renewTarget = StandardsManager.SecurityTokenSerializer.ReadKeyIdentifierClause(new XmlNodeRe |
| | | 174 | | } |
| | 60 | 175 | | else if (child.LocalName == DriverDictionary.CloseTarget.Value && child.NamespaceURI == DriverDi |
| | | 176 | | { |
| | 10 | 177 | | closeTarget = StandardsManager.SecurityTokenSerializer.ReadKeyIdentifierClause(new XmlNodeRe |
| | | 178 | | } |
| | | 179 | | } |
| | | 180 | | } |
| | 20 | 181 | | } |
| | | 182 | | |
| | | 183 | | protected override void WriteReferences(RequestSecurityTokenResponse rstr, XmlDictionaryWriter writer) |
| | | 184 | | { |
| | 20 | 185 | | if (rstr.RequestedAttachedReference != null) |
| | | 186 | | { |
| | 10 | 187 | | writer.WriteStartElement(DriverDictionary.Prefix.Value, DriverDictionary.RequestedAttachedReference, |
| | 10 | 188 | | StandardsManager.SecurityTokenSerializer.WriteKeyIdentifierClause(writer, rstr.RequestedAttachedRefe |
| | 10 | 189 | | writer.WriteEndElement(); |
| | | 190 | | } |
| | | 191 | | |
| | 20 | 192 | | if (rstr.RequestedUnattachedReference != null) |
| | | 193 | | { |
| | 10 | 194 | | writer.WriteStartElement(DriverDictionary.Prefix.Value, DriverDictionary.RequestedUnattachedReferenc |
| | 10 | 195 | | StandardsManager.SecurityTokenSerializer.WriteKeyIdentifierClause(writer, rstr.RequestedUnattachedRe |
| | 10 | 196 | | writer.WriteEndElement(); |
| | | 197 | | } |
| | 20 | 198 | | } |
| | | 199 | | |
| | | 200 | | protected override void WriteRequestedTokenClosed(RequestSecurityTokenResponse rstr, XmlDictionaryWriter wri |
| | | 201 | | { |
| | 20 | 202 | | if (rstr.IsRequestedTokenClosed) |
| | | 203 | | { |
| | 10 | 204 | | writer.WriteElementString(DriverDictionary.RequestedTokenClosed, DriverDictionary.Namespace, string. |
| | | 205 | | } |
| | 20 | 206 | | } |
| | | 207 | | |
| | | 208 | | protected override void WriteTargets(RequestSecurityToken rst, XmlDictionaryWriter writer) |
| | | 209 | | { |
| | 0 | 210 | | if (rst.RenewTarget != null) |
| | | 211 | | { |
| | 0 | 212 | | writer.WriteStartElement(DriverDictionary.Prefix.Value, DriverDictionary.RenewTarget, DriverDictiona |
| | 0 | 213 | | StandardsManager.SecurityTokenSerializer.WriteKeyIdentifierClause(writer, rst.RenewTarget); |
| | 0 | 214 | | writer.WriteEndElement(); |
| | | 215 | | } |
| | | 216 | | |
| | 0 | 217 | | if (rst.CloseTarget != null) |
| | | 218 | | { |
| | 0 | 219 | | writer.WriteStartElement(DriverDictionary.Prefix.Value, DriverDictionary.CloseTarget, DriverDictiona |
| | 0 | 220 | | StandardsManager.SecurityTokenSerializer.WriteKeyIdentifierClause(writer, rst.CloseTarget); |
| | 0 | 221 | | writer.WriteEndElement(); |
| | | 222 | | } |
| | 0 | 223 | | } |
| | | 224 | | } |
| | | 225 | | } |
| | | 226 | | } |