//
// System.Security.Permissions.StrongNameIdentityPermissionAttribute.cs
//
-// Duncan Mak <duncan@ximian.com>
+// Authors:
+// Duncan Mak <duncan@ximian.com>
+// Sebastien Pouliot <sebastien@ximian.com>
//
// (C) 2002 Ximian, Inc. http://www.ximian.com
-//
-
-//
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+// Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-using System;
+using System.Globalization;
+using System.Runtime.InteropServices;
namespace System.Security.Permissions {
+ [ComVisible (true)]
[AttributeUsage (AttributeTargets.Assembly | AttributeTargets.Class |
AttributeTargets.Struct | AttributeTargets.Constructor |
AttributeTargets.Method, AllowMultiple=true, Inherited=false)]
private string version;
// Constructor
- public StrongNameIdentityPermissionAttribute (SecurityAction action) : base (action) {}
+ public StrongNameIdentityPermissionAttribute (SecurityAction action)
+ : base (action)
+ {
+ }
// Properties
- public string Name
- {
+ public string Name {
get { return name; }
set { name = value; }
}
- public string PublicKey
- {
+ public string PublicKey {
get { return key; }
set { key = value; }
}
- public string Version
- {
+ public string Version {
get { return version; }
set { version = value; }
}
// Methods
public override IPermission CreatePermission ()
{
+#if MOBILE
+ return null;
+#else
if (this.Unrestricted)
- throw new ArgumentException ("Unsupported PermissionState.Unrestricted");
+ return new StrongNameIdentityPermission (PermissionState.Unrestricted);
- StrongNameIdentityPermission perm = null;
if ((name == null) && (key == null) && (version == null))
- perm = new StrongNameIdentityPermission (PermissionState.None);
- else {
- if (key == null)
- throw new ArgumentException ("PublicKey is required");
+ return new StrongNameIdentityPermission (PermissionState.None);
- byte[] keyblob = Convert.FromBase64String (key);
- StrongNamePublicKeyBlob blob = new StrongNamePublicKeyBlob (keyblob);
+ if (key == null) {
+ throw new ArgumentException (Locale.GetText (
+ "PublicKey is required"));
+ }
+ StrongNamePublicKeyBlob blob = StrongNamePublicKeyBlob.FromString (key);
- Version v = null;
- if (version != null)
- v = new Version (version);
- else
- v = new Version ();
+ Version v = null;
+ if (version != null)
+ v = new Version (version);
- if (name == null)
- name = String.Empty;
-
- perm = new StrongNameIdentityPermission (blob, name, v);
- }
- return perm;
+ return new StrongNameIdentityPermission (blob, name, v);
+#endif
}
}
}