public class HecSecurityManager
extends java.lang.Object
implements hec.security.PermissionConstants
The HecSecurityManager class contains 1 method with
names that begin with the word check. These methods
are called by various methods in the Java libraries before those
methods perform certain potentially sensitive operations. The
invocation of such a check method typically looks like this:
HecSecurityManager security = HecSecurityManager.getSecurityManager();
if (security != null) {
security.checkXXX(argument, . . . );
}
The security manager is thereby given an opportunity to prevent completion of the operation by throwing an exception. A security manager routine simply returns true if the operation is permitted, and returns false if the operation is not permitted.
The current security manager is obtained
by the getSecurityManager method.
The special method
HecSecurityManager#checkPermission(java.security.Permission)
determines whether an access request indicated by a specified
permission should be granted or denied. The
default implementation calls
AccessController.checkPermission(perm);
If a requested access is allowed,
checkPermission returns true. If denied returns false.
The checkPermission method
that takes a context object in addition to a permission
makes access decisions based on that context,
rather than on that of the current execution thread.
Code within a different context can thus call that method,
passing the permission and the
previously-saved context object. A sample call, using the
HecSecurityManager sm obtained as in the previous example,
is the following:
HecSecurityManager hsm = HecSecurityManager.getSecurityManager(); if (hsm != null) hsm.checkPermission(permission, context);
Permissions fall into these categories: Application & Mode.
The classes managing these various
permission categories are hec.security.ApplicationPermission,
hec.security.ModePermission,
All are
subclasses of java.security.BasicPermission, which itself
is an abstract subclass of the
top-level class for permissions, which is
java.security.Permission. BasicPermission defines the
functionality needed for all permissions that contain a name
that follows the hierarchical property naming convention
(for example, "exitVM", "setFactory", "queuePrintJob", etc).
An asterisk
may appear at the end of the name, following a ".", or by itself, to
signify a wildcard match. For example: "a.*" or "*" is valid,
"*a" or "a*b" is not valid.
All of the permission classes have an "actions" list that tells
the actions that are permitted for the object. For example,
for a hec.security.ApplicationPermission object, the actions list
(such as "read, write") specifies which actions are granted for the
specified permission.
Other permission classes are for "named" permissions - ones that contain a name but no actions list; you either have the named permission or you don't.
Note: There is also a hec.security.AllPermission
permission that implies all permissions. It exists to simplify the work
of system administrators who might need to perform multiple
tasks that require all (or numerous) permissions.
ClassLoader,
SecurityException,
checkTopLevelWindow,
getSecurityManager,
setSecurityManager,
AccessController,
AccessControlContext,
AccessControlException,
Permission,
BasicPermission,
FilePermission,
SocketPermission,
PropertyPermission,
RuntimePermission,
AWTPermission,
Policy,
SecurityPermission,
ProtectionDomain| Constructor and Description |
|---|
HecSecurityManager(hec.security.ApplicationPermissionCollection[] permissions)
Constructs a new
SecurityManager. |
| Modifier and Type | Method and Description |
|---|---|
int |
checkPermission(hec.security.ApplicationPermission perm)
Throws a
SecurityException if the requested
access, specified by the given permission, is not permitted based
on the security policy currently in effect. |
static int |
checkPermission(hec.security.ApplicationPermission perm,
hec.security.ApplicationPermissionCollection[] permissions) |
boolean |
checkPermission(java.lang.String permission) |
int |
checkPermission(java.lang.String permission,
java.lang.String action) |
int |
getActionForPermission(hec.security.ApplicationPermission perm) |
int |
getActionForPermission(java.lang.String permName) |
static HecSecurityManager |
getSecurityManager() |
void |
setPermissions(hec.security.ApplicationPermissionCollection[] permissions) |
void |
setReadOnly()
make the SecurityManager's permissions readonly.
|
public HecSecurityManager(hec.security.ApplicationPermissionCollection[] permissions)
SecurityManager.
If there is a security manager already installed, this method first
calls the security manager's checkPermission method
with the RuntimePermission("createSecurityManager")
permission to ensure the calling thread has permission to create a new
security manager.
This may result in throwing a SecurityException.
java.lang.SecurityException - if a security manager already
exists and its checkPermission method
doesn't allow creation of a new security manager.System.getSecurityManager(),
checkPermission,
RuntimePermissionpublic void setPermissions(hec.security.ApplicationPermissionCollection[] permissions)
public void setReadOnly()
public static HecSecurityManager getSecurityManager()
public boolean checkPermission(java.lang.String permission)
public int checkPermission(java.lang.String permission,
java.lang.String action)
public int getActionForPermission(hec.security.ApplicationPermission perm)
public int getActionForPermission(java.lang.String permName)
public int checkPermission(hec.security.ApplicationPermission perm)
SecurityException if the requested
access, specified by the given permission, is not permitted based
on the security policy currently in effect.
This method calls AccessController.checkPermission
with the given permission.
perm - the requested permission.java.lang.NullPointerException - if the permission argument is
null.public static int checkPermission(hec.security.ApplicationPermission perm,
hec.security.ApplicationPermissionCollection[] permissions)