2010-04-06 Jb Evain <jbevain@novell.com>
[mcs.git] / class / System.IdentityModel.Selectors / System.IdentityModel.Selectors / CardSpaceSelector.cs
blob16b6de3a66a8d7893bf1cc6b000dc867936a70c9
1 //
2 // CardSpaceSelector.cs
3 //
4 // Author:
5 // Atsushi Enomoto <atsushi@ximian.com>
6 //
7 // Copyright (C) 2005-2007 Novell, Inc. http://www.novell.com
8 //
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:
16 //
17 // The above copyright notice and this permission notice shall be
18 // included in all copies or substantial portions of the Software.
19 //
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.
28 using System;
29 using System.Collections;
30 using System.Collections.Generic;
31 using System.Collections.ObjectModel;
32 using System.IdentityModel.Tokens;
33 using System.Reflection;
34 using System.Xml;
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 ()
46 string implName;
47 switch (Environment.GetEnvironmentVariable ("MONO_IDENTITY_SELECTOR_TYPE")) {
48 default:
49 implName = "Mono.ServiceModel.IdentitySelectors.Win32.CardSelectorClientWin32, Mono.ServiceModel.IdentitySelectors, Version=3.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756";
50 break;
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 [] {
58 typeof (string)});
59 manage = impl_type.GetMethod ("Manage", new Type [0]);
62 [MonoTODO]
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 (
71 XmlElement endpoint,
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);
80 [MonoTODO]
81 public static void Import (string fileName)
83 import.Invoke (impl, new object [] {fileName});
86 [MonoTODO]
87 public static void Manage ()
89 manage.Invoke (impl, new object [0]);