com.ibm.as400.access
Class Permission

java.lang.Object
  extended bycom.ibm.as400.access.Permission
All Implemented Interfaces:
Cloneable, Serializable

public class Permission
extends Object
implements Cloneable, Serializable

The Permission class is provided to retrieve user's authority to an object.
To improve performance, the Permission object caches authority changes until the commit() method is called. When commit()is called, all changes up to that point are sent to the system.
The permission of an object is a collection of many users' authority to that object, and the UserPermission class is used to represent a user's authority to a object. Because there are three kinds of objects on the system, three subclasses of UserPermission are defined:

Here is a simple example:

 AS400 as400 = new AS400();
 Permission permission = new Permission(as400,"/QSYS.LIB/QJAVA.LIB");
 permission.addAuthorizedUser("user1");
 QSYSPermission userPermission = (QSYSPermission)permission.getUserPermission("user1");
 userPermission.setObjectAuthority("*CHANGE");
 permission.commit();
 

See Also:
UserPermission, DLOPermission, QSYSPermission, RootPermission, Serialized Form

Field Summary
static int TYPE_DLO
          Constant indicating the object is a Document Library Objects (DLO) stored in QDLS.
static int TYPE_QSYS
          Constant indicating the object is contained in the system library structure and stored in QSYS.LIB.
static int TYPE_ROOT
          Constant indicating that the object is contained in the root directory structure.
 
Constructor Summary
Permission(AS400 as400, String fileName)
          Constructs a Permission object.
Permission(AS400 as400, String fileName, boolean pathMayStartWithIASP)
          Constructs a Permission object.
Permission(IFSFile file)
          Constructs a Permission object.
Permission(IFSFile file, boolean pathMayStartWithIASP)
          Constructs a Permission object.
 
Method Summary
 void addAuthorizedUser(String userProfileName)
          Adds an authorized user.
 void addPropertyChangeListener(PropertyChangeListener listener)
          Adds a property change listener.
 void addUserPermission(UserPermission userPermission)
          Adds a user permission.
 void commit()
          Commits the permission changes to the system.
 String getAuthorizationList()
          Returns the authorizations list of the object.
 Enumeration getAuthorizedUsers()
          Returns an enumeration of authorized users.
 String getName()
          Returns the name of the object whose permission is represented by this object.
 String getObjectPath()
          Returns the path of the integrated file system object whose permission is represented by this object.
 String getOwner()
          Returns the object owner.
 String getPrimaryGroup()
          Returns the primary group of the object.
 int getSensitivityLevel()
          Returns the sensitivity level of the object.
 AS400 getSystem()
          Returns the system
 int getType()
          Returns the object type.
 UserPermission getUserPermission(String userProfileName)
          Returns a UserPermission object for the specified user.
 Enumeration getUserPermissions()
          Returns an enumeration of UserPermission objects.
 boolean isCommitted()
          Returns a flag indicating whether the change has been committed.
 void removeAuthorizedUser(String userProfileName)
          Removes an authorized user.
 void removePropertyChangeListener(PropertyChangeListener listener)
          Removes a property change listener.
 void removeUserPermission(UserPermission permission)
          Removes a user permission.
 void setAuthorizationList(String autList)
          Sets the authorizations list of the object.
 void setOwner(String owner, boolean revokeOldAuthority)
          Sets the owner of the object.
 void setPrimaryGroup(String primaryGroup, boolean revokeOldAuthority)
          Sets the primary group of the object.
 void setSensitivityLevel(int sensitivityLevel)
          Sets the sensitivity level of the object.
 void setSystem(AS400 system)
          Sets the system where system value is retrieved.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TYPE_DLO

public static final int TYPE_DLO
Constant indicating the object is a Document Library Objects (DLO) stored in QDLS.

See Also:
Constant Field Values

TYPE_QSYS

public static final int TYPE_QSYS
Constant indicating the object is contained in the system library structure and stored in QSYS.LIB.

See Also:
Constant Field Values

TYPE_ROOT

public static final int TYPE_ROOT
Constant indicating that the object is contained in the root directory structure. This includes everything that is not in QSYS.LIB or QDLS.

See Also:
Constant Field Values
Constructor Detail

Permission

public Permission(IFSFile file)
           throws AS400Exception,
                  AS400SecurityException,
                  ConnectionDroppedException,
                  ErrorCompletingRequestException,
                  InterruptedException,
                  IOException,
                  ObjectDoesNotExistException,
                  UnsupportedEncodingException
Constructs a Permission object.

Parameters:
file - The IFSFile object. For example, The IFSFile object which represents the object "QSYS.LIB/FRED.LIB".
Throws:
AS400Exception - If the system returns an error message.
AS400SecurityException - If a security or authority error occurs.
ConnectionDroppedException - If the connection is dropped unexpectedly.
ErrorCompletingRequestException - If an error occurs before the request is completed.
InterruptedException - If this thread is interrupted.
IOException - If an error occurs while communicating with the system.
ObjectDoesNotExistException - If the system object does not exist.
UnsupportedEncodingException

Permission

public Permission(IFSFile file,
                  boolean pathMayStartWithIASP)
           throws AS400Exception,
                  AS400SecurityException,
                  ConnectionDroppedException,
                  ErrorCompletingRequestException,
                  InterruptedException,
                  IOException,
                  ObjectDoesNotExistException,
                  UnsupportedEncodingException
Constructs a Permission object.

Use the independent auxiliary storage pool (IASP) parameter to indicate if the path name can contain an IASP name. If true, the name will be parsed as if the name starts with an IASP name. If false, the name is treated as an ordinary path. For example, suppose the path is "/myIASP/QSYS.LIB/MYLIB.LIB". If the IASP parameter is true the object is treated as library "MYLIB" on IASP "myIASP". If the IASP parameter is false the object is treated as object "MYLIB.LIB" in directory "/myIASP/QSYS.LIB" in the root file system. Note the IASP parameter is used only if the second component of the path is QSYS.LIB. If the second component of the path is not QSYS.LIB, the parameter is ignored.

Parameters:
file - The IFSFile object. For example, The IFSFile object which represents the object "QSYS.LIB/FRED.LIB".
pathMayStartWithIASP - True if the path may start with an independent auxiliary storage pool (IASP) name; false otherwise.
Throws:
AS400Exception - If the system returns an error message.
AS400SecurityException - If a security or authority error occurs.
ConnectionDroppedException - If the connection is dropped unexpectedly.
ErrorCompletingRequestException - If an error occurs before the request is completed.
InterruptedException - If this thread is interrupted.
IOException - If an error occurs while communicating with the system.
ObjectDoesNotExistException - If the system object does not exist.
UnsupportedEncodingException

Permission

public Permission(AS400 as400,
                  String fileName)
           throws AS400Exception,
                  AS400SecurityException,
                  ConnectionDroppedException,
                  ErrorCompletingRequestException,
                  InterruptedException,
                  IOException,
                  ObjectDoesNotExistException,
                  UnsupportedEncodingException
Constructs a Permission object.

Parameters:
as400 - The system.
fileName - The full path of the object. For example, "/QSYS.LIB/FRED.LIB".
Throws:
AS400Exception - If the system returns an error message.
AS400SecurityException - If a security or authority error occurs.
ConnectionDroppedException - If the connection is dropped unexpectedly.
ErrorCompletingRequestException - If an error occurs before the request is completed.
InterruptedException - If this thread is interrupted.
IOException - If an error occurs while communicating with the system.
ObjectDoesNotExistException - If the system object does not exist.
UnsupportedEncodingException

Permission

public Permission(AS400 as400,
                  String fileName,
                  boolean pathMayStartWithIASP)
           throws AS400Exception,
                  AS400SecurityException,
                  ConnectionDroppedException,
                  ErrorCompletingRequestException,
                  InterruptedException,
                  IOException,
                  ObjectDoesNotExistException,
                  UnsupportedEncodingException
Constructs a Permission object.

Use the independent auxiliary storage pool (IASP) parameter to indicate if the path name can contain an IASP name. If true, the name will be parsed as if the name starts with an IASP name. If false, the name is treated as an ordinary path. For example, suppose the path is "/myIASP/QSYS.LIB/MYLIB.LIB". If the IASP parameter is true the object is treated as library "MYLIB" on IASP "myIASP". If the IASP parameter is false the object is treated as object "MYLIB.LIB" in directory "/myIASP/QSYS.LIB" in the root file system. Note the IASP parameter is used only if the second component of the path is QSYS.LIB. If the second component of the path is not QSYS.LIB, the parameter is ignored.

Parameters:
as400 - The system.
fileName - The full path of the object. For example, "/QSYS.LIB/FRED.LIB".
pathMayStartWithIASP - True if the path may start with an independent auxiliary storage pool (IASP) name; false otherwise.
Throws:
AS400Exception - If the system returns an error message.
AS400SecurityException - If a security or authority error occurs.
ConnectionDroppedException - If the connection is dropped unexpectedly.
ErrorCompletingRequestException - If an error occurs before the request is completed.
InterruptedException - If this thread is interrupted.
IOException - If an error occurs while communicating with the system.
ObjectDoesNotExistException - If the system object does not exist.
UnsupportedEncodingException
Method Detail

addAuthorizedUser

public void addAuthorizedUser(String userProfileName)
Adds an authorized user. The user added will have "*EXCLUDE" authorities on the object.

Parameters:
userProfileName - The authorized user profile name.

addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener listener)
Adds a property change listener.

Parameters:
listener - The property change listener to add.

addUserPermission

public void addUserPermission(UserPermission userPermission)
Adds a user permission.

Parameters:
userPermission - The UserPermission object.

commit

public void commit()
            throws AS400Exception,
                   AS400SecurityException,
                   ConnectionDroppedException,
                   ErrorCompletingRequestException,
                   InterruptedException,
                   IOException,
                   ObjectDoesNotExistException,
                   ServerStartupException
Commits the permission changes to the system.

Throws:
AS400Exception - If the system returns an error message.
AS400SecurityException - If a security or authority error occurs.
ConnectionDroppedException - If the connection is dropped unexpectedly.
ErrorCompletingRequestException - If an error occurs before the request is completed.
InterruptedException - If this thread is interrupted.
IOException - If an error occurs while communicating with the system.
ObjectDoesNotExistException - If the system object does not exist.
ServerStartupException - If the host server cannot be started.

getAuthorizationList

public String getAuthorizationList()
Returns the authorizations list of the object.

Returns:
The authorizations list of the object.
See Also:
setAuthorizationList(String)

getAuthorizedUsers

public Enumeration getAuthorizedUsers()
Returns an enumeration of authorized users.

Returns:
An enumeration of authorized users.

getObjectPath

public String getObjectPath()
Returns the path of the integrated file system object whose permission is represented by this object.

Returns:
The integrated file system path name.

getName

public String getName()
Returns the name of the object whose permission is represented by this object.

Returns:
The name of the object.

getOwner

public String getOwner()
Returns the object owner.

Returns:
The object owner.

getPrimaryGroup

public String getPrimaryGroup()
Returns the primary group of the object.

Returns:
The primary group of the object.

getSensitivityLevel

public int getSensitivityLevel()
Returns the sensitivity level of the object.

Returns:
The sensitivity level of the object.
  • 0 : This value does not apply to this object.
  • 1 : (*NONE) The document has no sensitivity restrictions.
  • 2 : (*PERSONAL) The document is intended for the user as an individual.
  • 3 : (*PRIVATE) The document contains information that should be accessed only by the owner. This value cannot be specified if the access code zero (0) is assigned to the object.
  • 4 : (*CONFIDENTIAL) The document contains information that should be handled according to company procedures.
See Also:
setSensitivityLevel(int)

getSystem

public AS400 getSystem()
Returns the system

Returns:
The system instance.

getType

public int getType()
Returns the object type.

Returns:
The object type. The possible values are:
  • TYPE_DLO - Indicating the object is a Document Library Objects (DLO) stored in QDLS.
  • TYPE_QSYS - Indicating the object is contained in the system library structure and stored in QSYS.LIB.
  • TYPE_ROOT - Indicating the object is contained in the root directory structure. This includes everything that is not in QSYS.LIB or QDLS.

getUserPermission

public UserPermission getUserPermission(String userProfileName)
Returns a UserPermission object for the specified user. If the specified user profile has no explicit authority to the object, returns null.

Parameters:
userProfileName - The name of the user profile.
Returns:
The specific Permission object.

getUserPermissions

public Enumeration getUserPermissions()
Returns an enumeration of UserPermission objects.

Returns:
An enumeration of UserPermission objects.

isCommitted

public boolean isCommitted()
Returns a flag indicating whether the change has been committed.

Returns:
The flag indicating whether the change has been committed.

removeAuthorizedUser

public void removeAuthorizedUser(String userProfileName)
Removes an authorized user.

Parameters:
userProfileName - The authorized user profile name.

removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener listener)
Removes a property change listener.

Parameters:
listener - The property change listener to remove.

removeUserPermission

public void removeUserPermission(UserPermission permission)
Removes a user permission.

Parameters:
permission - The UserPermission object.

setAuthorizationList

public void setAuthorizationList(String autList)
Sets the authorizations list of the object. For example:

 Permission permisson = new Permisson(new AS400(),"/QSYS.LIB/FRED.LIB";
 permission.setAuthorizationList("testautl");
 System.out.println("The authorization list of fred.lib is " + permissin.geAuthorizationList();
 permission.setAuthorizationList("*NONE");
 System.out.println("The authorization list of fred.lib is " + permissin.geAuthorizationList();
 

Parameters:
autList - The authorizations list of the object.

setOwner

public void setOwner(String owner,
                     boolean revokeOldAuthority)
Sets the owner of the object.

Parameters:
owner - The owner of the object.
revokeOldAuthority - Specifies whether the authorities for the current owner are revoked when ownership is transferred to the new owner.
See Also:
getOwner()

setPrimaryGroup

public void setPrimaryGroup(String primaryGroup,
                            boolean revokeOldAuthority)
Sets the primary group of the object.

Parameters:
primaryGroup - The primary group of the object.
revokeOldAuthority - Specifies whether the authorities for the current primary group are revoked when the primary group is changed to the new value.

setSensitivityLevel

public void setSensitivityLevel(int sensitivityLevel)
Sets the sensitivity level of the object.

Parameters:
sensitivityLevel - The sensitivity level of the object. The possible values :
  • 0 : This value does not apply to this object.
  • 1 : (*NONE) The document has no sensitivity restrictions.
  • 2 : (*PERSONAL) The document is intended for the user as an individual.
  • 3 : (*PRIVATE) The document contains information that should be accessed only by the owner. This value cannot be specified if the access code zero (0) is assigned to the object.
  • 4 : (*CONFIDENTIAL) The document contains information that should be handled according to company procedures.
See Also:
getSensitivityLevel()

setSystem

public void setSystem(AS400 system)
Sets the system where system value is retrieved.

Parameters:
system - The system object.
See Also:
getSystem()