
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
1008
|
Chapter 17: Security
Discussion
These new properties on the SecurityException class provide much more insight into
what caused the exception to be thrown. For example, if you think a
Demand has
failed, you can examine the
Action property to determine that it was in fact the
Demand. Next you can use the Demanded property to find out exactly what permis-
sion(s) the
Demand attempted to demand. You can compare this to the GrantedSet
property, which contains the permission(s) that were granted to the assembly. Now
that you know what caused the
Demand to fail, you can use the Method,
FailedAssemblyInfo, and URL properties to determine where the failure occurred.
Demanded Returns the permission(s) that caused the Demand to fail. The returned object needs to be cast
to a
Permission, PermissionSet, or PermissionSetCollection type in order to
access its information. You can use the
is keyword to determine which one of these types this
property returned.
DenySetInstance Returns the denied permission(s) that caused the Demand to fail. This property contains a value
whenever a
Deny higher up in the stack causes a Demand to fail. The returned object needs to
be cast to a
Permission, PermissionSet, or PermissionSetCollection type in
order to access its information. You can use the
is keyword to determine ...