com.sun.management.snmp.uacl
Class JdmkUserAcl

java.lang.Object
  extended by com.sun.management.snmp.uacl.JdmkUserAcl
All Implemented Interfaces:
UserAcl, Serializable

public class JdmkUserAcl
extends Object
implements UserAcl, Serializable

Defines an implementation of the UserAcl interface.

In this implementation the ACL information is stored on a flat file and its default location is specified in the following order:

  1. The value of the jdmk.uacl.file property.
  2. The return value of getEtcDir("conf" + File.separator + "jdmk.uacl") in class DefaultPaths.

Since:
Java DMK 5.1
See Also:
Serialized Form

Constructor Summary
JdmkUserAcl(String name)
          Constructs the Java Dynamic Management(TM) Access Control List based on user names.
JdmkUserAcl(String name, String fileName)
          Constructs the Java Dynamic Management(TM) Access Control List based on user names.
 
Method Summary
 boolean checkContextName(String context)
          Checks whether or not a context name is defined.
 boolean checkReadPermission(String user)
          Checks whether or not the specified user has READ access.
 boolean checkReadPermission(String user, String context, int securityLevel)
          Checks whether or not the specified user and context name have READ access.
 boolean checkWritePermission(String user)
          Checks whether or not the specified user has WRITE access.
 boolean checkWritePermission(String user, String context, int securityLevel)
          Checks whether or not the specified user and context name have WRITE access.
 Enumeration entries()
          Returns an enumeration of the entries in this ACL.
 String getAuthorizedListFile()
          Returns the full path of the file used to get ACL information.
 String getName()
          Returns the name of the ACL.
static com.sun.management.snmp.uacl.PermissionImpl getREAD()
          Returns the read permission instance used.
static com.sun.management.snmp.uacl.PermissionImpl getWRITE()
          Returns the write permission instance used.
 void rereadTheFile()
          Resets this ACL to the values contained in the configuration file.
 void setAuthorizedListFile(String filename)
          Sets the full path of the file containing the ACL information.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JdmkUserAcl

public JdmkUserAcl(String name,
                   String fileName)
            throws IllegalArgumentException
Constructs the Java Dynamic Management(TM) Access Control List based on user names. The ACL will take the given owner name. The ACL will take the given acl file. The current IP address will be the owner of the ACL.

Parameters:
name - The name of the ACL.
fileName - The name of the ACL file.
Throws:
IllegalArgumentException - If the ACL file doesn't exist.

JdmkUserAcl

public JdmkUserAcl(String name)
            throws IllegalArgumentException
Constructs the Java Dynamic Management(TM) Access Control List based on user names. The ACL will take the given owner name. The current IP address will be the owner of the ACL.

Parameters:
name - The name of the ACL.
Throws:
IllegalArgumentException - If the ACL file doesn't exist.
Method Detail

entries

public Enumeration entries()
Returns an enumeration of the entries in this ACL. Each element in the enumeration is of type java.security.acl.AclEntry.

Returns:
An enumeration of the entries in this ACL.

getName

public String getName()
Returns the name of the ACL.

Specified by:
getName in interface UserAcl
Returns:
The name of the ACL.

getREAD

public static com.sun.management.snmp.uacl.PermissionImpl getREAD()
Returns the read permission instance used.

Returns:
The read permission instance.

getWRITE

public static com.sun.management.snmp.uacl.PermissionImpl getWRITE()
Returns the write permission instance used.

Returns:
The write permission instance.

setAuthorizedListFile

public void setAuthorizedListFile(String filename)
                           throws IllegalArgumentException,
                                  NotOwnerException
Sets the full path of the file containing the ACL information. Setting a file makes the previous loaded ACL configuration to be cleared. Access control is based on this new file. If IllegalArgumentException is thrown, the previous existing ACL configuration is not cleared.

Parameters:
filename - The full path of the file containing the ACL information.
Throws:
IllegalArgumentException - If the passed ACL file is null or doesn't exist.
NotOwnerException - This exception is never thrown.

rereadTheFile

public void rereadTheFile()
                   throws NotOwnerException
Resets this ACL to the values contained in the configuration file.

Throws:
NotOwnerException - If the principal attempting the reset is not an owner of this ACL.

getAuthorizedListFile

public String getAuthorizedListFile()
Returns the full path of the file used to get ACL information.

Returns:
The full path of the file used to get ACL information.

checkReadPermission

public boolean checkReadPermission(String user)
Checks whether or not the specified user has READ access.

Specified by:
checkReadPermission in interface UserAcl
Parameters:
user - The user name to check.
Returns:
true if the host has read permission, false otherwise.

checkReadPermission

public boolean checkReadPermission(String user,
                                   String context,
                                   int securityLevel)
Checks whether or not the specified user and context name have READ access.

Specified by:
checkReadPermission in interface UserAcl
Parameters:
user - The user name to check.
context - The context name associated with the user.
securityLevel - The request security level.
Returns:
true if the pair (user, context) has read permission, false otherwise.

checkContextName

public boolean checkContextName(String context)
Checks whether or not a context name is defined.

Specified by:
checkContextName in interface UserAcl
Parameters:
context - The context to check.
Returns:
true if the context is known, false otherwise.

checkWritePermission

public boolean checkWritePermission(String user)
Checks whether or not the specified user has WRITE access.

Specified by:
checkWritePermission in interface UserAcl
Parameters:
user - The user to check.
Returns:
true if the user has write permission, false otherwise.

checkWritePermission

public boolean checkWritePermission(String user,
                                    String context,
                                    int securityLevel)
Checks whether or not the specified user and context name have WRITE access.

Specified by:
checkWritePermission in interface UserAcl
Parameters:
user - The user name to check.
context - The context name associated with the user.
securityLevel - The request security level.
Returns:
true if the pair (user, context) has write permission, false otherwise.

Open Source build 02
opendmk-1.0-b02 2007.10.01_19:17:46_MEST

Copyright 1998-2007 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.