The permission classes allow you to get and set object authority information. Object authority information is also known as permission. The Permission class represents a collection of many users' authority to a specific object. The UserPermission class represents a single user's authority to a specific object.
The Permission class allows you to retrieve and change object authority information. It includes a collection of many users who are authorized to the object. The Permission object allows the Java™ program to cache authority changes until the commit() method is called. Once the commit() method is called, all changes made up to that point are sent to the server. Some of the functions provided by the Permission class include:
The following example shows you how to create a permission and add an authorized user to an object.
// Create AS400 object AS400 as400 = new AS400(); // Create Permission passing in the AS400 and object Permission myPermission = new Permission(as400, "QSYS.LIB/myLib.LIB"); // Add a user to be authorized to the object myPermission.addAuthorizedUser("User1");
The UserPermission class represents the authority of a single, specific user. UserPermission has three subclasses that handle the authority based on the object type:
UserPermission class | Description |
---|---|
DLOPermission | Represents a user's authority to Document Library Objects (DLOs), which are stored in QDLS. |
QSYSPermission | Represents a user's authority to objects stored in QSYS.LIB and contained in the server. |
RootPermission | Represents a user's authority to objects contained in the root directory structure. RootPermissions objects are those objects not contained in QSYS.LIB or QDLS. |
The UserPermission class allows you to do the following:
The following example shows you how to retrieve the users and groups that have permission on an object and print them out one at a time.
// Create a system object. AS400 sys = new AS400("MYAS400", "USERID", "PASSWORD"); // Represent the permissions to an object on the system, such as a library. Permission objectInQSYS = new Permission(sys, "/QSYS.LIB/FRED.LIB"); // Retrieve the various users/groups that have permissions set on that object. Enumeration enum = objectInQSYS.getUserPermissions(); while (enum.hasMoreElements()) { // Print out the user/group profile names one at a time. UserPermission userPerm = (UserPermission)enum.nextElement(); System.out.println(userPerm.getUserID()); }