vj#:
hello, For the follwoing code public class Demo { /** @method IsolatedStorageFilePermissionAttribute(SecurityAction.Deny, UsageAllowed = IsolatedStorageContainment.DomainIsolationByRoamingUser, UserQuota = 100) * */ private void UserQuota_UsageDemo() { Console.WriteLine("\nUserQuota_Usage demo."); boolean returnValue = false; IsolatedStorageFilePermission isfp0 = new IsolatedStorageFilePermission(PermissionState.None); Console.WriteLine("Checking UsageAllowed for IsolatedStorageContainment.None"); returnValue = UsageAllowed(isfp0, IsolatedStorageContainment.None, false); if (!(returnValue) ) { Console.WriteLine("IsolatedStorageContainment.None demo failed"); } Console.WriteLine("Checking UsageAllowed for IsolatedStorageContainment.DomainIsolationByRoamingUser."); returnValue = UsageAllowed(isfp0, IsolatedStorageContainment.DomainIsolationByRoamingUser, true); if (!(returnValue) ) { Console.WriteLine("IsolatedStorageContainment.DomainIsolationByRoamingUser failed"); } Console.WriteLine("Checking UsageAllowed for IsolatedStorageContainment.AssemblyIsolationByUser."); returnValue = UsageAllowed(isfp0, IsolatedStorageContainment.AssemblyIsolationByUser, true); if (!(returnValue) ) { Console.WriteLine("IsolatedStorageContainment.AssemblyIsolationByUse failed"); } Console.WriteLine("Requesting UserQuota of 0."); returnValue = UserQuota(isfp0, 0, true); if (!(returnValue) ) { Console.WriteLine("UserQuota 0 failed"); } Console.WriteLine("Requesting UserQuota of 100."); returnValue = UserQuota(isfp0, 100, true); if (!(returnValue) ) { Console.WriteLine("UserQuota 100 failed"); } Console.WriteLine("Requesting UserQuota of -2147483648."); returnValue = UserQuota(isfp0,-2147483648, true); if (!(returnValue) ) { Console.WriteLine("UserQuota -214748364 failed"); } } //UserQuota_UsageDemo // UserQuota // Sets UserQuota to the value that was passed in. // private boolean UserQuota(IsolatedStorageFilePermission isfp, int user_quota, boolean exception_expected) { boolean ExceptionCaught = false; isfp.set_UserQuota(user_quota); try { isfp.Demand(); } catch (System.Exception e) { ExceptionCaught = true; if (!(exception_expected)) { Console.WriteLine("An unexpected exception was thrown when setting UserQuota value [{0}]", System.Convert.ToString(user_quota)); Console.WriteLine(("Exception: \r\n" + e.ToString())); } } if ((!(ExceptionCaught)) && exception_expected) { Console.WriteLine("An expected exception not thrown when setting UserQuota value [{0}]", System.Convert.ToString(user_quota)); } return true; } //UserQuota // UsageAllowed // This method sets UsageAllowed to the value that was passed in. // private boolean UsageAllowed(IsolatedStorageFilePermission isfp, IsolatedStorageContainment isc, boolean exception_expected) { boolean ExceptionCaught = false; isfp.set_UsageAllowed(isc); try { isfp.Demand(); } catch (System.Exception e) { ExceptionCaught = true; if (!(exception_expected)) { Console.WriteLine("An unexpected exception was thrown when setting IsolatedStorageContainment value [{0}]", isc.ToString()); Console.WriteLine(("Exception: \r\n" + e.ToString())); } } if (!(ExceptionCaught) && exception_expected) { Console.WriteLine("An expected exception was not thrown when setting IsolatedStorageContainment value [{0}]", isc.ToString()); } return true; } //UsageAllowed public static void main(String [] args) { main(); } public static int main() { Demo MyDemo = new Demo(); MyDemo.UserQuota_UsageDemo(); return 0 ; } //Main } //Demo System.Security.SecurityException is not thrown when UsageAllowed function is called more than once from the UserQuota_UsageDemo function.It is thrown only once. But ideally it should be thrown everytime we call Demand function in UsageAllowed function. The code works fine in C#. Can any one help me? Thanks,
Thanks for sending in the repro code. I have reproduced the problem and submitted a bug to the J# development team. Thanks, Michael Green Microsoft Developer Support -------------------- | Thread-Topic: Security exception not thrown | thread-index: AcPyuwvU0CDBW5X6RxWVwInu14HFMA== | X-Tomcat-NG: microsoft.public.dotnet.vjsharp | From: =?Utf-8?B?WHl6?= <anonymous@discussions.microsoft.com> | Subject: Security exception not thrown | Date: Fri, 13 Feb 2004 21:26:06 -0800 | Lines: 125 | Message-ID: <521A18E5-4212-4C02-8A64-4AC11FC60AA9@microsoft.com> | MIME-Version: 1.0 | Content-Type: text/plain; | charset="Utf-8" | Content-Transfer-Encoding: 7bit | X-Newsreader: Microsoft CDO for Windows 2000 | Content-Class: urn:content-classes:message | Importance: normal | Priority: normal | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0 | Newsgroups: microsoft.public.dotnet.vjsharp | Path: cpmsftngxa07.phx.gbl | Xref: cpmsftngxa07.phx.gbl microsoft.public.dotnet.vjsharp:5397 | NNTP-Posting-Host: tk2msftcmty1.phx.gbl 10.40.1.180 | X-Tomcat-NG: microsoft.public.dotnet.vjsharp | | hello, For the follwoing code public class Demo { /** @method IsolatedStorageFilePermissionAttribute(SecurityAction.Deny, UsageAllowed = IsolatedStorageContainment.DomainIsolationByRoamingUser, UserQuota = 100) * */ private void UserQuota_UsageDemo() { Console.WriteLine("\nUserQuota_Usage demo."); boolean returnValue = false; IsolatedStorageFilePermission isfp0 = new IsolatedStorageFilePermission(PermissionState.None); Console.WriteLine("Checking UsageAllowed for IsolatedStorageContainment.None"); returnValue = UsageAllowed(isfp0, IsolatedStorageContainment.None, false); if (!(returnValue) ) { Console.WriteLine("IsolatedStorageContainment.None demo failed"); } Console.WriteLine("Checking UsageAllowed for IsolatedStorageContainment.DomainIsolationByRoamingUser."); returnValue = UsageAllowed(isfp0, IsolatedStorageContainment.DomainIsolationByRoamingUser, true); if (!(returnValue) ) { Console.WriteLine("IsolatedStorageContainment.DomainIsolationByRoamingUser failed"); } Console.WriteLine("Checking UsageAllowed for IsolatedStorageContainment.AssemblyIsolationByUser."); returnValue = UsageAllowed(isfp0, IsolatedStorageContainment.AssemblyIsolationByUser, true); if (!(returnValue) ) { Console.WriteLine("IsolatedStorageContainment.AssemblyIsolationByUse failed"); } Console.WriteLine("Requesting UserQuota of 0."); returnValue = UserQuota(isfp0, 0, true); if (!(returnValue) ) { Console.WriteLine("UserQuota 0 failed"); } Console.WriteLine("Requesting UserQuota of 100."); returnValue = UserQuota(isfp0, 100, true); if (!(returnValue) ) { Console.WriteLine("UserQuota 100 failed"); } Console.WriteLine("Requesting UserQuota of -2147483648."); returnValue = UserQuota(isfp0,-2147483648, true); if (!(returnValue) ) { Console.WriteLine("UserQuota -214748364 failed"); } } //UserQuota_UsageDemo // UserQuota // Sets UserQuota to the value that was passed in. // private boolean UserQuota(IsolatedStorageFilePermission isfp, int user_quota, boolean exception_expected) { boolean ExceptionCaught = false; isfp.set_UserQuota(user_quota); try { isfp.Demand(); } catch (System.Exception e) { ExceptionCaught = true; if (!(exception_expected)) { Console.WriteLine("An unexpected exception was thrown when setting UserQuota value [{0}]", System.Convert.ToString(user_quota)); Console.WriteLine(("Exception: \r\n" + e.ToString())); } } if ((!(ExceptionCaught)) && exception_expected) { Console.WriteLine("An expected exception not thrown when setting UserQuota value [{0}]", System.Convert.ToString(user_quota)); } return true; } //UserQuota // UsageAllowed // This method sets UsageAllowed to the value that was passed in. // private boolean UsageAllowed(IsolatedStorageFilePermission isfp, IsolatedStorageContainment isc, boolean exception_expected) { boolean ExceptionCaught = false; isfp.set_UsageAllowed(isc); try { isfp.Demand(); } catch (System.Exception e) { ExceptionCaught = true; if (!(exception_expected)) { Console.WriteLine("An unexpected exception was thrown when setting IsolatedStorageContainment value [{0}]", isc.ToString()); Console.WriteLine(("Exception: \r\n" + e.ToString())); } } if (!(ExceptionCaught) && exception_expected) { Console.WriteLine("An expected exception was not thrown when setting IsolatedStorageContainment value [{0}]", isc.ToString()); } return true; } //UsageAllowed public static void main(String [] args) { main(); } public static int main() { Demo MyDemo = new Demo(); MyDemo.UserQuota_UsageDemo(); return 0 ; } //Main } //Demo System.Security.SecurityException is not thrown when UsageAllowed function is called more than once from the UserQuota_UsageDemo function.It is thrown only once. But ideally it should be thrown everytime we call Demand function in UsageAllowed function. The code works fine in C#. Can any one help me? Thanks, |
Don't see what you're looking for? Try a search.
|