X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mcs%2Fclass%2Fcorlib%2FSystem.IO.IsolatedStorage%2FIsolatedStorage.cs;h=7f64bbd0746452a348dffedc79dc9bbb37423b20;hb=5d9434fcb3acc1ed7d3d30603faae797d672fe65;hp=73c311fed5a7da77ec446badaeebd14f7a7b9204;hpb=13d1764537ce5bbe5a06bf133fb2db1a4b5d2131;p=mono.git diff --git a/mcs/class/corlib/System.IO.IsolatedStorage/IsolatedStorage.cs b/mcs/class/corlib/System.IO.IsolatedStorage/IsolatedStorage.cs index 73c311fed5a..7f64bbd0746 100644 --- a/mcs/class/corlib/System.IO.IsolatedStorage/IsolatedStorage.cs +++ b/mcs/class/corlib/System.IO.IsolatedStorage/IsolatedStorage.cs @@ -1,12 +1,12 @@ // // System.IO.IsolatedStorage.cs // -// Author: Duncan Mak (duncan@ximian.com) +// Authors: +// Duncan Mak (duncan@ximian.com) +// Sebastien Pouliot // // (C) 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 @@ -28,28 +28,61 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // -using System.Security; using System.Globalization; +using System.Reflection; +using System.Runtime.InteropServices; +using System.Security; using System.Security.Permissions; +using System.Security.Policy; + +namespace System.IO.IsolatedStorage { + +#if NET_2_0 + [ComVisible (true)] +#endif + public abstract class IsolatedStorage : MarshalByRefObject { -namespace System.IO.IsolatedStorage -{ - public abstract class IsolatedStorage : MarshalByRefObject - { // Constructor protected IsolatedStorage () : base () { } - protected static IsolatedStorageScope storage_scope; + internal IsolatedStorageScope storage_scope; + internal object _assemblyIdentity; + internal object _domainIdentity; + internal object _applicationIdentity; // Properties - [MonoTODO ("Code Identity is CAS related")] + +#if NET_2_0 + [MonoTODO ("requires manifest support")] + [ComVisible (false)] + public object ApplicationIdentity { + [SecurityPermission (SecurityAction.Demand, ControlPolicy=true)] + get { + if ((storage_scope & IsolatedStorageScope.Application) == 0) { + throw new InvalidOperationException (Locale.GetText ("Invalid Isolation Scope.")); + } + if (_applicationIdentity == null) + throw new InvalidOperationException (Locale.GetText ("Identity unavailable.")); + + throw new NotImplementedException (Locale.GetText ("CAS related")); + } + } +#endif + public object AssemblyIdentity { + [SecurityPermission (SecurityAction.Demand, ControlPolicy=true)] get { - throw new NotImplementedException ( - Locale.GetText ("CAS related")); +#if NET_2_0 + if ((storage_scope & IsolatedStorageScope.Assembly) == 0) { + throw new InvalidOperationException (Locale.GetText ("Invalid Isolation Scope.")); + } + if (_assemblyIdentity == null) + throw new InvalidOperationException (Locale.GetText ("Identity unavailable.")); +#endif + return _assemblyIdentity; } } @@ -61,11 +94,15 @@ namespace System.IO.IsolatedStorage } } - [MonoTODO ("Code Identity is CAS related")] public object DomainIdentity { + [SecurityPermission (SecurityAction.Demand, ControlPolicy=true)] get { - throw new NotImplementedException ( - Locale.GetText ("CAS related")); + if ((storage_scope & IsolatedStorageScope.Domain) == 0) { + throw new InvalidOperationException (Locale.GetText ("Invalid Isolation Scope.")); + } + if (_domainIdentity == null) + throw new InvalidOperationException (Locale.GetText ("Identity unavailable.")); + return _domainIdentity; } } @@ -92,16 +129,33 @@ namespace System.IO.IsolatedStorage // Methods protected abstract IsolatedStoragePermission GetPermission (PermissionSet ps); - [MonoTODO ("Evidences are CAS related")] - protected void InitStore ( - IsolatedStorageScope scope, Type domainEvidenceType, - Type assemblyEvidenceType) + protected void InitStore (IsolatedStorageScope scope, Type domainEvidenceType, Type assemblyEvidenceType) + { + // I know it's useless - but it's tested as such... + switch (scope) { + case (IsolatedStorageScope.Assembly | IsolatedStorageScope.User): + case (IsolatedStorageScope.Assembly | IsolatedStorageScope.User | IsolatedStorageScope.Domain): + throw new NotImplementedException (scope.ToString ()); + default: + // invalid (incomplete) scope + throw new ArgumentException (scope.ToString ()); + } + } +#if NET_2_0 + [MonoTODO ("requires manifest support")] + protected void InitStore (IsolatedStorageScope scope, Type appEvidenceType) { + if (AppDomain.CurrentDomain.ApplicationIdentity == null) + throw new IsolatedStorageException (Locale.GetText ("No ApplicationIdentity available for AppDomain.")); + + if (appEvidenceType == null) { + // TODO - Choose evidence + } + // no exception here because this can work without CAS storage_scope = scope; - } - +#endif public abstract void Remove (); } }