2 // CardSpaceSelector.cs
5 // Atsushi Enomoto <atsushi@ximian.com>
7 // Copyright (C) 2005-2007 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
;
30 using System
.Collections
.Generic
;
31 using System
.Collections
.ObjectModel
;
32 using System
.IdentityModel
.Tokens
;
33 using System
.Reflection
;
36 namespace System
.IdentityModel
.Selectors
38 public static class CardSpaceSelector
40 static readonly Type impl_type
;
41 static readonly object impl
;
42 static readonly MethodInfo get_token
, import
, manage
;
44 static CardSpaceSelector ()
47 switch (Environment
.GetEnvironmentVariable ("MONO_IDENTITY_SELECTOR_TYPE")) {
49 implName
= "Mono.ServiceModel.IdentitySelectors.Win32.CardSelectorClientWin32, Mono.ServiceModel.IdentitySelectors, Version=3.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756";
52 impl_type
= Type
.GetType (implName
);
53 impl
= Activator
.CreateInstance (impl_type
, new object [0]);
54 get_token
= impl_type
.GetMethod ("GetToken", new Type
[] {
55 typeof (CardSpacePolicyElement
[]),
56 typeof (SecurityTokenSerializer
)});
57 import
= impl_type
.GetMethod ("Import", new Type
[] {
59 manage
= impl_type
.GetMethod ("Manage", new Type
[0]);
63 public static GenericXmlSecurityToken
GetToken (
64 CardSpacePolicyElement
[] policyChain
,
65 SecurityTokenSerializer serializer
)
67 return (GenericXmlSecurityToken
) get_token
.Invoke (impl
, new object [] {policyChain, serializer}
);
70 public static GenericXmlSecurityToken
GetToken (
72 IEnumerable
<XmlElement
> policy
,
73 XmlElement requiredRemoteTokenIssuer
,
74 SecurityTokenSerializer serializer
)
76 CardSpacePolicyElement pe
= new CardSpacePolicyElement (endpoint
, requiredRemoteTokenIssuer
, new Collection
<XmlElement
> (new List
<XmlElement
> (policy
)), null, 0, requiredRemoteTokenIssuer
!= null);
77 return GetToken (new CardSpacePolicyElement
[] {pe}
, serializer
);
81 public static void Import (string fileName
)
83 import
.Invoke (impl
, new object [] {fileName}
);
87 public static void Manage ()
89 manage
.Invoke (impl
, new object [0]);