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. 27 // 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; 35 36 namespace System.IdentityModel.Selectors 37 { 38 public static class CardSpaceSelector 39 { 40 static readonly Type impl_type; 41 static readonly object impl; 42 static readonly MethodInfo get_token, import, manage; 43 CardSpaceSelector()44 static CardSpaceSelector () 45 { 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; 51 } 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]); 60 } 61 62 [MonoTODO] GetToken( CardSpacePolicyElement [] policyChain, SecurityTokenSerializer tokenSerializer)63 public static GenericXmlSecurityToken GetToken ( 64 CardSpacePolicyElement [] policyChain, 65 SecurityTokenSerializer tokenSerializer) 66 { 67 return (GenericXmlSecurityToken) get_token.Invoke (impl, new object [] {policyChain, tokenSerializer}); 68 } 69 GetToken( XmlElement endpoint, IEnumerable<XmlElement> policy, XmlElement requiredRemoteTokenIssuer, SecurityTokenSerializer tokenSerializer)70 public static GenericXmlSecurityToken GetToken ( 71 XmlElement endpoint, 72 IEnumerable<XmlElement> policy, 73 XmlElement requiredRemoteTokenIssuer, 74 SecurityTokenSerializer tokenSerializer) 75 { 76 CardSpacePolicyElement pe = new CardSpacePolicyElement (endpoint, requiredRemoteTokenIssuer, new Collection<XmlElement> (new List<XmlElement> (policy)), null, 0, requiredRemoteTokenIssuer != null); 77 return GetToken (new CardSpacePolicyElement [] {pe}, tokenSerializer); 78 } 79 80 [MonoTODO] Import(string fileName)81 public static void Import (string fileName) 82 { 83 import.Invoke (impl, new object [] {fileName}); 84 } 85 86 [MonoTODO] Manage()87 public static void Manage () 88 { 89 manage.Invoke (impl, new object [0]); 90 } 91 } 92 } 93