2 // SamlAuthorityBinding.cs
5 // Atsushi Enomoto <atsushi@ximian.com>
7 // Copyright (C) 2006 Novell, Inc. http://www.novell.com
9 // Permission is hereby granted, free of charge, to any person obtaining
10 // a copy of this software and associated documentation files (the
11 // "Software"), to deal in the Software without restriction, including
12 // without limitation the rights to use, copy, modify, merge, publish,
13 // distribute, sublicense, and/or sell copies of the Software, and to
14 // permit persons to whom the Software is furnished to do so, subject to
15 // the following conditions:
17 // The above copyright notice and this permission notice shall be
18 // included in all copies or substantial portions of the Software.
20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 using System.Collections.Generic;
31 using System.Runtime.Serialization;
32 using System.IdentityModel.Claims;
33 using System.IdentityModel.Policy;
34 using System.IdentityModel.Selectors;
36 namespace System.IdentityModel.Tokens
39 public class SamlAuthorityBinding
41 XmlQualifiedName kind;
42 string binding, location;
45 public SamlAuthorityBinding ()
49 public SamlAuthorityBinding (XmlQualifiedName authorityKind, string binding, string location)
51 if (authorityKind == null)
52 throw new ArgumentNullException ("authorityKind");
53 AuthorityKind = authorityKind;
59 public XmlQualifiedName AuthorityKind {
64 throw new ArgumentNullException ("value");
65 if (value.Equals (XmlQualifiedName.Empty))
66 throw new ArgumentException ("non-empty XmlQualifiedName must be set to AuthorityKind of SamlAuthorityBinding.");
72 public string Binding {
73 get { return binding; }
76 if (value == null || value.Length == 0)
77 throw new ArgumentException ("non-zero length string must be set to Binding of SamlAuthorityBinding.");
83 public string Location {
84 get { return location; }
87 if (value == null || value.Length == 0)
88 throw new ArgumentException ("non-zero length string must be set to Location of SamlAuthorityBinding.");
93 public bool IsReadOnly {
94 get { return is_readonly; }
100 throw new InvalidOperationException ("This object is read-only.");
103 public void MakeReadOnly ()
109 public virtual void ReadXml (XmlDictionaryReader reader,
110 SamlSerializer samlSerializer,
111 SecurityTokenSerializer keyInfoSerializer,
112 SecurityTokenResolver outOfBandTokenResolver)
114 throw new NotImplementedException ();
117 public virtual void WriteXml (
118 XmlDictionaryWriter writer,
119 SamlSerializer samlSerializer,
120 SecurityTokenSerializer keyInfoSerializer)
123 throw new ArgumentNullException ("writer");
124 if (samlSerializer == null)
125 throw new ArgumentNullException ("samlSerializer");
127 if (AuthorityKind == null)
128 throw new SecurityTokenException ("AuthorityKind must be set to SAML AuthorityBinding before being written.");
130 throw new SecurityTokenException ("non-zero length Binding must be set to SAML AuthorityBinding before being written.");
131 if (Location == null)
132 throw new SecurityTokenException ("non-zero length Location must be set to SAML AuthorityBinding before being written.");
134 writer.WriteStartElement ("saml", "AuthorityBinding", SamlConstants.Namespace);
135 writer.WriteXmlnsAttribute (String.Empty, AuthorityKind.Namespace);
136 writer.WriteAttributeString ("AuthorityKind", AuthorityKind.Name);
137 writer.WriteAttributeString ("Location", Location);
138 writer.WriteAttributeString ("Binding", Binding);
139 writer.WriteEndElement ();