| | | 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.Xml; |
| | | 5 | | using CoreWCF.IdentityModel.Selectors; |
| | | 6 | | using CoreWCF.IdentityModel.Tokens; |
| | | 7 | | |
| | | 8 | | namespace CoreWCF.IdentityModel |
| | | 9 | | { |
| | | 10 | | internal class KeyInfo |
| | | 11 | | { |
| | | 12 | | private readonly SecurityTokenSerializer _keyInfoSerializer; |
| | | 13 | | private SecurityKeyIdentifier _ski; |
| | | 14 | | |
| | 0 | 15 | | public KeyInfo( SecurityTokenSerializer keyInfoSerializer ) |
| | | 16 | | { |
| | 0 | 17 | | _keyInfoSerializer = keyInfoSerializer; |
| | 0 | 18 | | _ski = new SecurityKeyIdentifier(); |
| | 0 | 19 | | } |
| | | 20 | | |
| | 0 | 21 | | public string RetrievalMethod { get; private set; } |
| | | 22 | | |
| | | 23 | | public SecurityKeyIdentifier KeyIdentifier |
| | | 24 | | { |
| | 0 | 25 | | get { return _ski; } |
| | | 26 | | set |
| | | 27 | | { |
| | 0 | 28 | | if ( value == null ) |
| | | 29 | | { |
| | 0 | 30 | | throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(value)); |
| | | 31 | | } |
| | | 32 | | |
| | 0 | 33 | | _ski = value; |
| | 0 | 34 | | } |
| | | 35 | | } |
| | | 36 | | |
| | | 37 | | public virtual void ReadXml(XmlDictionaryReader reader) |
| | | 38 | | { |
| | 0 | 39 | | if ( reader == null ) |
| | | 40 | | { |
| | 0 | 41 | | throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(reader)); |
| | | 42 | | } |
| | | 43 | | |
| | 0 | 44 | | reader.MoveToContent(); |
| | 0 | 45 | | if ( reader.IsStartElement(CoreWCF.XD.XmlSignatureDictionary.KeyInfo.Value, CoreWCF.XD.XmlSignatureDictionar |
| | | 46 | | { |
| | | 47 | | // <KeyInfo> |
| | 0 | 48 | | reader.ReadStartElement(); |
| | | 49 | | |
| | 0 | 50 | | while ( reader.IsStartElement() ) |
| | | 51 | | { |
| | | 52 | | // <RetrievalMethod> |
| | 0 | 53 | | if ( reader.IsStartElement( XmlSignatureConstants.Elements.RetrievalMethod, CoreWCF.XD.XmlSignatureD |
| | | 54 | | { |
| | 0 | 55 | | string method = reader.GetAttribute(CoreWCF.XD.XmlSignatureDictionary.URI.Value ); |
| | 0 | 56 | | if ( !string.IsNullOrEmpty( method ) ) |
| | | 57 | | { |
| | 0 | 58 | | RetrievalMethod = method; |
| | | 59 | | } |
| | 0 | 60 | | reader.Skip(); |
| | | 61 | | } |
| | | 62 | | // check if internal serializer can handle clause |
| | 0 | 63 | | else if ( _keyInfoSerializer.CanReadKeyIdentifierClause( reader ) ) |
| | | 64 | | { |
| | 0 | 65 | | _ski.Add( _keyInfoSerializer.ReadKeyIdentifierClause( reader ) ); |
| | | 66 | | } |
| | | 67 | | // trace we skipped over an element |
| | 0 | 68 | | else if ( reader.IsStartElement() ) |
| | | 69 | | { |
| | 0 | 70 | | string xml = reader.ReadOuterXml(); |
| | | 71 | | |
| | | 72 | | //if ( DiagnosticUtility.ShouldTraceWarning ) |
| | | 73 | | //{ |
| | | 74 | | // TraceUtility.TraceString( System.Diagnostics.TraceEventType.Warning, SR.GetString( SR.ID80 |
| | | 75 | | //} |
| | | 76 | | } |
| | 0 | 77 | | reader.MoveToContent(); |
| | | 78 | | } |
| | | 79 | | |
| | 0 | 80 | | reader.MoveToContent(); |
| | 0 | 81 | | reader.ReadEndElement(); |
| | | 82 | | } |
| | 0 | 83 | | } |
| | | 84 | | } |
| | | 85 | | } |