JAFS API v2

org.openafs.jafs
Class User

java.lang.Object
  |
  +--org.openafs.jafs.User
All Implemented Interfaces:
Comparable, PTSEntry, Serializable

public class User
extends Object
implements PTSEntry, Serializable, Comparable

An abstract representation of an AFS user. It holds information about the user, such as what groups it belongs to.

Constructing an instance of a User does not mean an actual AFS user is created in a cell -- usually a User object is a representation of an already existing AFS user. If, however, the User is constructed with the name of a user that does not exist in the cell represented by the provided Cell, a new user with that name can be created in that server by calling the create(String, int) or create(String) method. If such a user does already exist when one of these methods is called, an exception will be thrown.

Each User object has its own individual set of Groups that it owns and Groups for which it is a member. These represents the properties and attributes of an actual AFS user.

Since this User object is a union of both the PTS and KAS properties of AFS users, some methods meant for users with a PTS entry will throw exceptions if used on a user with only a KAS entry, and vice versa.

Associated with an AFS user are many attributes, such as whether or not it can change its own password, or who is allowed to find out the groups to which this user belongs. The User class has many "set" methods to indicate values for these attributes (i.e. setChangePassword(boolean) and setListMembership(int)). However, in order for these values to be written to the actual AFS user, the flushInfo() method needs to be called. This writes all user attributes set through this API to AFS. This is done to minimize calls through JNI.

The following is a simple example of how to construct and use a User object. It iterates through the list of users (a union of pts and kas users) for a cell, and prints out the name and id of each.

 import org.openafs.jafs.Cell;
 import org.openafs.jafs.AFSException;
 import org.openafs.jafs.User;
 ...
 public class ...
 {
   ...
   private Cell cell;
   ...
   public static void main(String[] args) throws Exception
   {
     String username   = arg[0];
     String password   = arg[1];
     String cellName   = arg[2];
 
     token  = new Token(username, password, cellName);
     cell   = new Cell(token);
     server = cell.getServer(serverName);
 
     System.out.println("Users in Cell " + cell.getName() + ":");
     User[] users = cell.getUsers();
     for (int i = 0; i < users.length; i++) {
       System.out.println(" -> " + users[i] + ": " users[i].getID());
     }
   }
   ...
 }
 

See Also:
Serialized Form

Field Summary
static int ADMIN
          User has administrative kas privileges
protected  int adminSetting
          whether or not this user has kas administrative privileges.
protected  boolean cachedInfo
          Whether or not the information fields of this user have been filled.
protected  Cell cell
           
protected  int cellHandle
           
static int CHANGE_PASSWORD
          User can change their password
protected  int cpwSetting
          whether this user is allowed to change its password.
protected  String creator
           
protected  int creatorUID
           
protected  int daysToPasswordExpire
           
static int ENCRYPT
          TGS can use user's key for an encryption key
protected  String encryptionKey
           
protected  int encSetting
          whether the TGS can use this user's key as an encryption key.
protected  int failLoginCount
           
static int GRANT_TICKETS
          TGS will grant tickets for user
protected  int groupCreationQuota
           
protected  int groupMembershipCount
           
protected  ArrayList groupNames
           
protected  ArrayList groups
           
protected  ArrayList groupsOwned
           
protected  ArrayList groupsOwnedNames
           
protected  boolean kas
          Does this user have a kas entry?
protected  long keyCheckSum
           
protected  int keyVersion
           
protected  int lastChangePasswordTime
           
protected  GregorianCalendar lastChangePasswordTimeDate
           
protected  String lastModName
           
protected  int lastModTime
           
protected  GregorianCalendar lastModTimeDate
           
protected  int listGroupsOwned
          who is allowed to execute pts listowned for this user.
protected  int listMembership
          who is allowed to execute pts membership for this user.
protected  int listStatus
          who is allowed to execute pts examine for this user.
protected  int lockedUntil
           
protected  GregorianCalendar lockedUntilDate
           
protected  int lockTime
           
protected  int maxTicketLifetime
           
protected  String name
           
protected  int nameUID
           
static int NO_ADMIN
          User has no administrative kas privileges
static int NO_CHANGE_PASSWORD
          User cannot change their password
static int NO_ENCRYPT
          TGS cannot use user's key for an encryption key
static int NO_GRANT_TICKETS
          TGS will not grant tickets for user
static int NO_REUSE_PASSWORD
          User cannot reuse their password
protected  String owner
           
protected  int ownerUID
           
protected  boolean pts
          Does this user have a pts entry?
static int REUSE_PASSWORD
          User can reuse their password
protected  int rpwSetting
          whether this user is allowed to reuse its password.
protected  int tgsSetting
          whether the TGS will grant tickets for this user.
static int USER_ANYUSER_ACCESS
          Any user has access
static int USER_OWNER_ACCESS
          Only the owner of the user has access
protected  int userExpiration
           
protected  GregorianCalendar userExpirationDate
           
 
Fields inherited from interface org.openafs.jafs.PTSEntry
PTS_GROUP, PTS_USER
 
Constructor Summary
(package private) User(Cell cell)
          Constructs a blank User object given the cell to which the user belongs.
  User(String name, Cell cell)
          Constructs a new User object instance given the name of the AFS user and the AFS cell, represented by cell, to which it belongs.
  User(String name, Cell cell, boolean preloadAllMembers)
          Constructs a new User object instance given the name of the AFS user and the AFS cell, represented by cell, to which it belongs.
 
Method Summary
 boolean canChangePassword()
          KAS: Returns whether or not the user can change their password
 boolean canEncrypt()
          KAS: Returns whether or not TGS can use this users ticket for an encryption key
 boolean canReusePassword()
          KAS: Returns whether or not the user can reuse their password
 int compareTo(Object obj)
          Comparable interface method.
 int compareTo(User user)
          Compares two User objects respective to their names and does not factor any other attribute.
protected static void create(int cellHandle, String userName, String password, int uid)
          Creates the kas and pts entries for a new user.
 void create(String password)
          Creates the kas and pts entries for a new user in this cell.
 void create(String password, int uid)
          Creates the kas and pts entries for a new user in this cell.
 void delete()
          Deletes the pts and kas entries for a user in this cell.
protected static void delete(int cellHandle, String userName)
          Deletes the pts and kas entry for a user.
 boolean equals(User otherUser)
          Tests whether two User objects are equal, based on their names.
 void flushInfo()
          Flushes the current information of this User object to disk.
 Cell getCell()
          Returns the Cell this user belongs to.
 PTSEntry getCreator()
          PTS: Returns the creator of this user in the form of a PTSEntry.
 int getDaysToPasswordExpire()
          KAS: Returns the number of days a password is valid before it expires.
 String getEncryptionKey()
          KAS: Returns the encryption key, in octal form, of this user.
 int getFailLoginCount()
          KAS: Returns the number of failed login attempts this user is allowed before being locked out.
 int getGroupCreationQuota()
          PTS: Returns how many more groups this user is allowed to create
 int getGroupMembershipCount()
          PTS: Returns the number of groups to which this user belongs.
 String[] getGroupNames()
          PTS: Returns a String array of the group names to which this user belongs.
 Group[] getGroups()
          PTS: Returns an array of the Group objects to which this user belongs.
 Group[] getGroupsOwned()
          PTS: Returns an array of the Group objects this user owns.
protected static int getGroupsOwnedBegin(int cellHandle, String name)
          Begin the process of getting the groups that a user or group owns.
 int getGroupsOwnedCount()
          PTS: Returns the total count of groups this user owns.
protected static int getGroupsOwnedCount(int cellHandle, String name)
          Returns the total number of groups owned by the user.
protected static void getGroupsOwnedDone(int iterationId)
          Signals that the iteration is complete and will not be accessed anymore.
 String[] getGroupsOwnedNames()
          PTS: Returns a String array of the group names this user owns.
protected static int getGroupsOwnedNext(int cellHandle, int iterationId, Group theGroup)
          Fills the next group object that the user or group owns.
protected static String getGroupsOwnedNextString(int iterationId)
          Returns the next group the user or group owns.
protected  String getInfo()
          Returns a String representation of this User.
protected  String getInfoGroups()
          Returns a String containing the String representations of all the groups to which this user belongs.
protected  String getInfoGroupsOwned()
          Returns a String containing the String representations of all the groups that this user owns.
 long getKeyCheckSum()
          KAS: Returns the check sum of this user's key.
 int getKeyVersion()
          KAS: Returns the version number of the user's key.
 int getLastChangePasswordTime()
          KAS: Returns the last date and time (in UTC) the user changed its password.
 GregorianCalendar getLastChangePasswordTimeDate()
          KAS: Returns the last date and time the user changed its password.
 String getLastModName()
          KAS: Returns the name of the user that last modified this user.
 int getLastModTime()
          KAS: Returns the date and time (in UTC) the user's KAS entry was last modified.
 GregorianCalendar getLastModTimeDate()
          KAS: Returns the date and time the user was last modified.
 int getListGroupsOwned()
          PTS: Returns who can list the groups owned (pts listowned) by this user.
 int getListMembership()
          PTS: Returns who can list the groups (pts membership) to which this user belongs.
 int getListStatus()
          PTS: Returns who can list the status (pts examine) of this user.
 int getLockedUntil()
          KAS: Returns the date and time (in UTC) at which the user stops being locked out.
 GregorianCalendar getLockedUntilDate()
          KAS: Returns the date and time at which the user stops being locked out.
 int getLockTime()
          KAS: Returns the amount of time (in seconds) a user is locked out when it exceeds the maximum number of allowable failed login attempts.
 int getMaxTicketLifetime()
          KAS: Returns the maximum lifetime of a ticket issued to this user (in seconds).
 String getName()
          Returns the name of this user.
 PTSEntry getOwner()
          PTS: Returns the owner of this user in the form of a PTSEntry.
 short getType()
          Returns the type of PTSEntry this object represents.
 int getUID()
          PTS: Returns the numeric AFS id of this user.
 int getUserExpiration()
          KAS: Returns the date and time the user expires.
 GregorianCalendar getUserExpirationDate()
          KAS: Returns the date and time the user expires.
protected static int getUserGroupsBegin(int cellHandle, String name)
          Begin the process of getting the groups to which the user belongs.
protected static void getUserGroupsDone(int iterationId)
          Signals that the iteration is complete and will not be accessed anymore.
protected static int getUserGroupsNext(int cellHandle, int iterationId, Group theGroup)
          Fills the next group object of which the user belongs.
protected static String getUserGroupsNextString(int iterationId)
          Returns the next group to which the user belongs.
protected static void getUserInfo(int cellHandle, String name, User user)
          Fills in the information fields of the provided User.
 boolean isAdmin()
          KAS: Returns whether or not this user has kas administrative privileges
 boolean isKAS()
          Returns whether or not this user has a kas entry.
 boolean isPTS()
          Returns whether or not this user has a pts entry.
protected static void reclaimUserMemory()
          Reclaims all memory being saved by the user portion of the native library.
 void refresh()
          Refreshes the properties of this User object instance with values from the AFS user it represents.
protected  void refresh(boolean all)
          Refreshes the properties of this User object instance with values from the AFS user it represents.
protected  void refreshGroupNames()
          Refreshes the current information about the group names to which the user belongs.
protected  void refreshGroups()
          Refreshes the current information about the group objects to which the user belongs.
protected  void refreshGroupsOwned()
          Refreshes the current information about the group objects that the user \ owns.
protected  void refreshGroupsOwnedNames()
          Refreshes the current information about the group names that the user owns.
protected  void refreshInfo()
          Refreshes the information fields of this User to reflect the current state of the AFS user.
protected static void rename(int cellHandle, String oldName, String newName)
          Renames the given user.
 void rename(String newName)
          Change the name of this user.
 void setAdmin(boolean setting)
          KAS: Sets whether or not this user has kas administrative privileges
 void setChangePassword(boolean setting)
          KAS: Sets whether or not the user can change their password
 void setDaysToPasswordExpire(int days)
          KAS: Sets the number of days a password is valid before it expires.
 void setEncrypt(boolean setting)
          KAS: Sets whether or not TGS can use this users ticket for an encryption key
 void setFailLoginCount(int logins)
          KAS: Sets the number of failed login attempts this user is allowed before being locked out.
 void setGrantTickets(boolean setting)
          KAS: Sets whether or not TGS will issue tickets for this user
 void setGroupCreationQuota(int quota)
          PTS: Sets how many more groups this user is allowed to create
 void setListGroupsOwned(int value)
          PTS: Sets who can list the groups owned (pts listowned) by this user.
 void setListMembership(int value)
          PTS: Sets who can list the groups (pts membership) to which this user belongs.
 void setListStatus(int value)
          PTS: Sets who can list the status (pts examine) of this user.
 void setLockTime(int seconds)
          KAS: Sets the amount of time (in seconds) a user is locked out when it exceeds the maximum number of allowable failed login attempts.
 void setMaxTicketLifetime(int seconds)
          KAS: Sets the maximum lifetime of a ticket issued to this user (in seconds).
protected static void setPassword(int cellHandle, String userName, String newPassword)
          Sets the password of the given user.
 void setPassword(String newPassword)
          Sets the password of this user to something new.
 void setReusePassword(boolean setting)
          KAS: Sets whether or not the user can reuse their password
 void setUserExpiration(GregorianCalendar expirationDate)
          KAS: Sets the date and time the user expires.
protected static void setUserInfo(int cellHandle, String name, User theUser)
          Sets the information values of this AFS user to be the parameter values.
 String toString()
          Returns the name of this User
 void unlock()
          Unlocks the given user if they were locked out of the cell.
protected static void unlock(int cellHandle, String userName)
          Unlocks a user.
 boolean willGrantTickets()
          KAS: Returns whether or not TGS will issue tickets for this user
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

USER_OWNER_ACCESS

public static final int USER_OWNER_ACCESS
Only the owner of the user has access

See Also:
Constant Field Values

USER_ANYUSER_ACCESS

public static final int USER_ANYUSER_ACCESS
Any user has access

See Also:
Constant Field Values

ADMIN

public static final int ADMIN
User has administrative kas privileges

See Also:
Constant Field Values

NO_ADMIN

public static final int NO_ADMIN
User has no administrative kas privileges

See Also:
Constant Field Values

GRANT_TICKETS

public static final int GRANT_TICKETS
TGS will grant tickets for user

See Also:
Constant Field Values

NO_GRANT_TICKETS

public static final int NO_GRANT_TICKETS
TGS will not grant tickets for user

See Also:
Constant Field Values

ENCRYPT

public static final int ENCRYPT
TGS can use user's key for an encryption key

See Also:
Constant Field Values

NO_ENCRYPT

public static final int NO_ENCRYPT
TGS cannot use user's key for an encryption key

See Also:
Constant Field Values

CHANGE_PASSWORD

public static final int CHANGE_PASSWORD
User can change their password

See Also:
Constant Field Values

NO_CHANGE_PASSWORD

public static final int NO_CHANGE_PASSWORD
User cannot change their password

See Also:
Constant Field Values

REUSE_PASSWORD

public static final int REUSE_PASSWORD
User can reuse their password

See Also:
Constant Field Values

NO_REUSE_PASSWORD

public static final int NO_REUSE_PASSWORD
User cannot reuse their password

See Also:
Constant Field Values

cell

protected Cell cell

cellHandle

protected int cellHandle

name

protected String name

kas

protected boolean kas
Does this user have a kas entry?


pts

protected boolean pts
Does this user have a pts entry?


groupCreationQuota

protected int groupCreationQuota

groupMembershipCount

protected int groupMembershipCount

nameUID

protected int nameUID

ownerUID

protected int ownerUID

creatorUID

protected int creatorUID

listStatus

protected int listStatus
who is allowed to execute pts examine for this user. Valid values are:


listGroupsOwned

protected int listGroupsOwned
who is allowed to execute pts listowned for this user. Valid values are:


listMembership

protected int listMembership
who is allowed to execute pts membership for this user. Valid values are:


owner

protected String owner

creator

protected String creator

groups

protected ArrayList groups

groupNames

protected ArrayList groupNames

groupsOwned

protected ArrayList groupsOwned

groupsOwnedNames

protected ArrayList groupsOwnedNames

adminSetting

protected int adminSetting
whether or not this user has kas administrative privileges. Valid values are:


tgsSetting

protected int tgsSetting
whether the TGS will grant tickets for this user. Valid values are:


encSetting

protected int encSetting
whether the TGS can use this user's key as an encryption key. Valid values are:


cpwSetting

protected int cpwSetting
whether this user is allowed to change its password. Valid values are:


rpwSetting

protected int rpwSetting
whether this user is allowed to reuse its password. Valid values are:


userExpiration

protected int userExpiration

lastModTime

protected int lastModTime

lastModName

protected String lastModName

lastChangePasswordTime

protected int lastChangePasswordTime

maxTicketLifetime

protected int maxTicketLifetime

keyVersion

protected int keyVersion

encryptionKey

protected String encryptionKey

keyCheckSum

protected long keyCheckSum

daysToPasswordExpire

protected int daysToPasswordExpire

failLoginCount

protected int failLoginCount

lockTime

protected int lockTime

lockedUntil

protected int lockedUntil

lockedUntilDate

protected GregorianCalendar lockedUntilDate

userExpirationDate

protected GregorianCalendar userExpirationDate

lastModTimeDate

protected GregorianCalendar lastModTimeDate

lastChangePasswordTimeDate

protected GregorianCalendar lastChangePasswordTimeDate

cachedInfo

protected boolean cachedInfo
Whether or not the information fields of this user have been filled.

Constructor Detail

User

public User(String name,
            Cell cell)
     throws AFSException
Constructs a new User object instance given the name of the AFS user and the AFS cell, represented by cell, to which it belongs. This does not actually create a new AFS user, it just represents one. If name is not an actual AFS user, exceptions will be thrown during subsequent method invocations on this object, unless the create(String, int) or create(String) method is explicitly called to create it.

Parameters:
name - the name of the user to represent
cell - the cell to which the user belongs.
Throws:
AFSException - If an error occurs in the native code

User

public User(String name,
            Cell cell,
            boolean preloadAllMembers)
     throws AFSException
Constructs a new User object instance given the name of the AFS user and the AFS cell, represented by cell, to which it belongs. This does not actually create a new AFS user, it just represents one. If name is not an actual AFS user, exceptions will be thrown during subsequent method invocations on this object, unless the create(String, int) or create(String) method is explicitly called to create it. Note that if the process doesn't exist and preloadAllMembers is true, an exception will be thrown.

This constructor is ideal for point-in-time representation and transient applications. It ensures all data member values are set and available without calling back to the filesystem at the first request for them. Use the refresh() method to address any coherency concerns.

Parameters:
name - the name of the user to represent
cell - the cell to which the user belongs.
preloadAllMembers - true will ensure all object members are set upon construction; otherwise members will be set upon access, which is the default behavior.
Throws:
AFSException - If an error occurs in the native code
See Also:
refresh()

User

User(Cell cell)
throws AFSException
Constructs a blank User object given the cell to which the user belongs. This blank object can then be passed into other methods to fill out its properties.

Parameters:
cell - the cell to which the user belongs.
Throws:
AFSException - If an error occurs in the native code
Method Detail

create

public void create(String password)
            throws AFSException
Creates the kas and pts entries for a new user in this cell. Automatically assigns a user id. *

Parameters:
password - the password for the new user
Throws:
AFSException - If an error occurs in the native code

create

public void create(String password,
                   int uid)
            throws AFSException
Creates the kas and pts entries for a new user in this cell.

Parameters:
password - the password for the new user
uid - the user id to assign to the new user
Throws:
AFSException - If an error occurs in the native code

delete

public void delete()
            throws AFSException
Deletes the pts and kas entries for a user in this cell. Deletes this user from the membership list of the groups to which it belonged, but does not delete the groups owned by this user. Also nullifies this corresponding Java object.

Throws:
AFSException - If an error occurs in the native code

unlock

public void unlock()
            throws AFSException
Unlocks the given user if they were locked out of the cell.

Throws:
AFSException - If an error occurs in the native code

flushInfo

public void flushInfo()
               throws AFSException
Flushes the current information of this User object to disk. This will update the information of the actual AFS user to match the settings that have been modified within this User object. This function must be called before any changes made to the information fields of this user will be seen by AFS.

Throws:
AFSException - If an error occurs in the native code

rename

public void rename(String newName)
            throws AFSException
Change the name of this user. Automatically flushes the info of this user in order to update kas entry of the new name. NOTE: renaming a locked user will unlock that user.

Parameters:
newName - the new name for this user
Throws:
AFSException - If an error occurs in the native code

refresh

public void refresh()
             throws AFSException
Refreshes the properties of this User object instance with values from the AFS user it represents. All properties that have been initialized and/or accessed will be renewed according to the values of the AFS user this User object instance represents.

Since in most environments administrative changes can be administered from an AFS command-line program or an alternate GUI application, this method provides a means to refresh the Java object representation and thereby ascertain any possible modifications that may have been made from such alternate administrative programs. Using this method before an associated instance accessor will ensure the highest level of representative accuracy, accommodating changes made external to the Java application space. If administrative changes to the underlying AFS system are only allowed via this API, then the use of this method is unnecessary.

Throws:
AFSException - If an error occurs in the native code

refresh

protected void refresh(boolean all)
                throws AFSException
Refreshes the properties of this User object instance with values from the AFS user it represents. If all is true then all of the properties of this User object instance will be set, or renewed, according to the values of the AFS user it represents, disregarding any previously set properties.

Thus, if all is false then properties that are currently set will be refreshed and properties that are not set will remain uninitialized. See refresh() for more information.

Parameters:
all - if true set or renew all object properties; otherwise renew all set properties
Throws:
AFSException - If an error occurs in the native code
See Also:
refresh()

refreshInfo

protected void refreshInfo()
                    throws AFSException
Refreshes the information fields of this User to reflect the current state of the AFS user. Does not refresh the groups to which the user belongs or groups owned by the user.

Throws:
AFSException - If an error occurs in the native code

refreshGroupNames

protected void refreshGroupNames()
                          throws AFSException
Refreshes the current information about the group names to which the user belongs. Does not refresh the information fields of the user or the groups owned.

Throws:
AFSException - If an error occurs in the native code

refreshGroups

protected void refreshGroups()
                      throws AFSException
Refreshes the current information about the group objects to which the user belongs. Does not refresh the information fields of the user or the groups owned.

Throws:
AFSException - If an error occurs in the native code

refreshGroupsOwnedNames

protected void refreshGroupsOwnedNames()
                                throws AFSException
Refreshes the current information about the group names that the user owns. Does not refresh the information fields of the user or the groups belonged to.

Throws:
AFSException - If an error occurs in the native code

refreshGroupsOwned

protected void refreshGroupsOwned()
                           throws AFSException
Refreshes the current information about the group objects that the user \ owns. Does not refresh the information fields of the user or the groups belonged to.

Throws:
AFSException - If an error occurs in the native code

getName

public String getName()
Returns the name of this user.

Specified by:
getName in interface PTSEntry
Returns:
the name of this user

getCell

public Cell getCell()
Returns the Cell this user belongs to.

Specified by:
getCell in interface PTSEntry
Returns:
the Cell this user belongs to

isKAS

public boolean isKAS()
              throws AFSException
Returns whether or not this user has a kas entry.

Returns:
whether or not this user has a kas entry
Throws:
AFSException - If an error occurs in the native code
See Also:
refresh()

isPTS

public boolean isPTS()
              throws AFSException
Returns whether or not this user has a pts entry.

Returns:
whether or not this user has a pts entry
Throws:
AFSException - If an error occurs in the native code
See Also:
refresh()

getGroups

public Group[] getGroups()
                  throws AFSException
PTS: Returns an array of the Group objects to which this user belongs.

Returns:
an array of the groups to which this user belongs
Throws:
AFSException - If an error occurs in the native code
See Also:
refresh()

getGroupsOwnedCount

public int getGroupsOwnedCount()
                        throws AFSException
PTS: Returns the total count of groups this user owns.

If the total list of groups or group names have already been collected (see getGroupsOwned()), then the returning value will be calculated based upon the current list. Otherwise, PTS will be explicitly queried for the information.

Returns:
total count of groups this user owns
Throws:
AFSException - If an error occurs in the native code
See Also:
getGroupsOwned(), getGroupsOwnedNames()

getGroupsOwned

public Group[] getGroupsOwned()
                       throws AFSException
PTS: Returns an array of the Group objects this user owns.

Returns:
an array of the Groups this user owns
Throws:
AFSException - If an error occurs in the native code
See Also:
refresh()

getGroupNames

public String[] getGroupNames()
                       throws AFSException
PTS: Returns a String array of the group names to which this user belongs.

Returns:
a String array of the groups to which this user belongs
Throws:
AFSException - If an error occurs in the native code
See Also:
refresh()

getGroupsOwnedNames

public String[] getGroupsOwnedNames()
                             throws AFSException
PTS: Returns a String array of the group names this user owns.

Returns:
a String array of the groups this user owns
Throws:
AFSException - If an error occurs in the native code
See Also:
refresh()

getUID

public int getUID()
           throws AFSException
PTS: Returns the numeric AFS id of this user.

Specified by:
getUID in interface PTSEntry
Returns:
the AFS id of this user
Throws:
AFSException - If an error occurs in the native code
See Also:
refresh()

getGroupCreationQuota

public int getGroupCreationQuota()
                          throws AFSException
PTS: Returns how many more groups this user is allowed to create. -1 indicates unlimited.

Returns:
the group creation quota
Throws:
AFSException - If an error occurs in the native code
See Also:
refresh()

getGroupMembershipCount

public int getGroupMembershipCount()
                            throws AFSException
PTS: Returns the number of groups to which this user belongs.

Returns:
the group membership count
Throws:
AFSException - If an error occurs in the native code
See Also:
refresh()

getOwner

public PTSEntry getOwner()
                  throws AFSException
PTS: Returns the owner of this user in the form of a PTSEntry.

The returning object could be either a User or Group; to determine what type of object the PTSEntry represents, call the PTSEntry.getType() method.

Specified by:
getOwner in interface PTSEntry
Returns:
the owner of this user
Throws:
AFSException - If an error occurs in the native code
See Also:
PTSEntry, PTSEntry.getType(), refresh()

getCreator

public PTSEntry getCreator()
                    throws AFSException
PTS: Returns the creator of this user in the form of a PTSEntry.

The returning object could be either a User or Group; to determine what type of object the PTSEntry represents, call the PTSEntry.getType() method.

Specified by:
getCreator in interface PTSEntry
Returns:
the creator of this user
Throws:
AFSException - If an error occurs in the native code
See Also:
PTSEntry, PTSEntry.getType(), refresh()

getType

public short getType()
Returns the type of PTSEntry this object represents.

This method will always return PTSEntry.PTS_USER.

Specified by:
getType in interface PTSEntry
Returns:
the type of PTSEntry this object represents (will always return PTSEntry.PTS_USER)
See Also:
PTSEntry, PTSEntry.getType()

getListStatus

public int getListStatus()
                  throws AFSException
PTS: Returns who can list the status (pts examine) of this user. Valid values are:

Returns:
the status listing permission
Throws:
AFSException - If an error occurs in the native code
See Also:
refresh()

getListGroupsOwned

public int getListGroupsOwned()
                       throws AFSException
PTS: Returns who can list the groups owned (pts listowned) by this user. Valid values are:

Returns:
the groups owned listing permission
Throws:
AFSException - If an error occurs in the native code
See Also:
refresh()

getListMembership

public int getListMembership()
                      throws AFSException
PTS: Returns who can list the groups (pts membership) to which this user belongs. Valid values are:

Returns:
the membership listing permission
Throws:
AFSException - If an error occurs in the native code
See Also:
refresh()

isAdmin

public boolean isAdmin()
                throws AFSException
KAS: Returns whether or not this user has kas administrative privileges

Returns:
whether or not this user has kas administrative priveleges
Throws:
AFSException - If an error occurs in the native code
See Also:
refresh()

willGrantTickets

public boolean willGrantTickets()
                         throws AFSException
KAS: Returns whether or not TGS will issue tickets for this user

Returns:
whether or not TGS will issue tickets for this user
Throws:
AFSException - If an error occurs in the native code
See Also:
refresh()

canEncrypt

public boolean canEncrypt()
                   throws AFSException
KAS: Returns whether or not TGS can use this users ticket for an encryption key

Returns:
whether or not TGS can use this users ticket for an encryption key
Throws:
AFSException - If an error occurs in the native code
See Also:
refresh()

canChangePassword

public boolean canChangePassword()
                          throws AFSException
KAS: Returns whether or not the user can change their password

Returns:
whether or not the user can change their password
Throws:
AFSException - If an error occurs in the native code
See Also:
refresh()

canReusePassword

public boolean canReusePassword()
                         throws AFSException
KAS: Returns whether or not the user can reuse their password

Returns:
whether or not the user can reuse their password
Throws:
AFSException - If an error occurs in the native code
See Also:
refresh()

getUserExpiration

public int getUserExpiration()
                      throws AFSException
KAS: Returns the date and time the user expires. A null value indicates the user never exipres (or that there is no kas entry for this user).

Returns:
the date and time the user expires
Throws:
AFSException - If an error occurs in the native code
See Also:
refresh()

getUserExpirationDate

public GregorianCalendar getUserExpirationDate()
                                        throws AFSException
KAS: Returns the date and time the user expires. A null value indicates the user never expires (or that there is no kas entry for this user).

Returns:
the date and time the user expires
Throws:
AFSException - If an error occurs in the native code
See Also:
refresh()

getLastModTime

public int getLastModTime()
                   throws AFSException
KAS: Returns the date and time (in UTC) the user's KAS entry was last modified.

Returns:
the date and time (in UTC) the user was last modified
Throws:
AFSException - If an error occurs in the native code
See Also:
refresh()

getLastModTimeDate

public GregorianCalendar getLastModTimeDate()
                                     throws AFSException
KAS: Returns the date and time the user was last modified.

Returns:
the date and time the user was last modified
Throws:
AFSException - If an error occurs in the native code
See Also:
refresh()

getLastModName

public String getLastModName()
                      throws AFSException
KAS: Returns the name of the user that last modified this user.

Returns:
the name of this user that last modified this user.
Throws:
AFSException - If an error occurs in the native code
See Also:
refresh()

getLastChangePasswordTimeDate

public GregorianCalendar getLastChangePasswordTimeDate()
                                                throws AFSException
KAS: Returns the last date and time the user changed its password.

Returns:
the last date and time the user changed its password.
Throws:
AFSException - If an error occurs in the native code
See Also:
refresh()

getLastChangePasswordTime

public int getLastChangePasswordTime()
                              throws AFSException
KAS: Returns the last date and time (in UTC) the user changed its password.

Returns:
the last date and time (in UTC) the user changed its password.
Throws:
AFSException - If an error occurs in the native code
See Also:
refresh()

getMaxTicketLifetime

public int getMaxTicketLifetime()
                         throws AFSException
KAS: Returns the maximum lifetime of a ticket issued to this user (in seconds).

Returns:
the maximum lifetime of a ticket issued to this user (in seconds).
Throws:
AFSException - If an error occurs in the native code
See Also:
refresh()

getDaysToPasswordExpire

public int getDaysToPasswordExpire()
                            throws AFSException
KAS: Returns the number of days a password is valid before it expires. A value of 0 indicates passwords never expire.

Returns:
the number of days for which a password is valid
Throws:
AFSException - If an error occurs in the native code
See Also:
refresh()

getFailLoginCount

public int getFailLoginCount()
                      throws AFSException
KAS: Returns the number of failed login attempts this user is allowed before being locked out. A value of 0 indicates there is no limit.

Returns:
the number of failed login attempts a user is allowed
Throws:
AFSException - If an error occurs in the native code
See Also:
refresh()

getLockTime

public int getLockTime()
                throws AFSException
KAS: Returns the amount of time (in seconds) a user is locked out when it exceeds the maximum number of allowable failed login attempts. A value of 0 indicates an infinite lockout time.

Returns:
the number of failed login attempts a user is allowed
Throws:
AFSException - If an error occurs in the native code
See Also:
refresh()

getEncryptionKey

public String getEncryptionKey()
                        throws AFSException
KAS: Returns the encryption key, in octal form, of this user. An example of a key in octal form is: '\040\205\211\241\345\002\023\211'.

Returns:
the encryption key
Throws:
AFSException - If an error occurs in the native code
See Also:
refresh()

getKeyCheckSum

public long getKeyCheckSum()
                    throws AFSException
KAS: Returns the check sum of this user's key.

Returns:
the check sum
Throws:
AFSException - If an error occurs in the native code
See Also:
refresh()

getKeyVersion

public int getKeyVersion()
                  throws AFSException
KAS: Returns the version number of the user's key.

Returns:
the key version
Throws:
AFSException - If an error occurs in the native code
See Also:
refresh()

getLockedUntil

public int getLockedUntil()
                   throws AFSException
KAS: Returns the date and time (in UTC) at which the user stops being locked out. A value of 0 indicates the user is not currently locked out. If the user is locked out forever, the value will be equal to -1.

Returns:
the date and time (in UTC) at which the user stops being locked out
Throws:
AFSException - If an error occurs in the native code
See Also:
refresh()

getLockedUntilDate

public GregorianCalendar getLockedUntilDate()
                                     throws AFSException
KAS: Returns the date and time at which the user stops being locked out. A value of null indicates the user is not currently locked out. If the user is locked out forever, the value getLockedUntil().getTime().getTime() will be equal to -1.

Returns:
the date and time at which the user stops being locked out
Throws:
AFSException - If an error occurs in the native code
See Also:
refresh()

setGroupCreationQuota

public void setGroupCreationQuota(int quota)
PTS: Sets how many more groups this user is allowed to create. -1 indicates unlimited.

Parameters:
quota - the new group creation quota

setListStatus

public void setListStatus(int value)
                   throws AFSException
PTS: Sets who can list the status (pts examine) of this user. Valid values are:

Parameters:
value - the value of the new list status permission
Throws:
AFSException - if an error occurs in the native code
IllegalArgumentException - if an invalud argument is provided

setListGroupsOwned

public void setListGroupsOwned(int value)
                        throws AFSException
PTS: Sets who can list the groups owned (pts listowned) by this user. Valid values are:

Parameters:
value - the value of the new list groups owned permission
Throws:
AFSException - if an error occurs in the native code
IllegalArgumentException - if an invalud argument is provided

setListMembership

public void setListMembership(int value)
                       throws AFSException
PTS: Sets who can list the groups (pts membership) to which this user belongs. Valid values are:

Parameters:
value - the value of the new list membership permission
Throws:
AFSException - if an error occurs in the native code
IllegalArgumentException - if an invalud argument is provided

setAdmin

public void setAdmin(boolean setting)
KAS: Sets whether or not this user has kas administrative privileges

Parameters:
setting - whether or not this user has kas administrative privileges

setGrantTickets

public void setGrantTickets(boolean setting)
KAS: Sets whether or not TGS will issue tickets for this user

Parameters:
setting - whether or not TGS will issue tickets for this user

setEncrypt

public void setEncrypt(boolean setting)
KAS: Sets whether or not TGS can use this users ticket for an encryption key

Parameters:
setting - whether or not TGS can use this users ticket for an encryption key

setChangePassword

public void setChangePassword(boolean setting)
KAS: Sets whether or not the user can change their password

Parameters:
setting - whether or not the user can change their password

setReusePassword

public void setReusePassword(boolean setting)
KAS: Sets whether or not the user can reuse their password

Parameters:
setting - whether or not the user can reuse their password

setUserExpiration

public void setUserExpiration(GregorianCalendar expirationDate)
KAS: Sets the date and time the user expires. A null value indicates the user never exipres.

Parameters:
expirationDate - the date and time the user expires

setMaxTicketLifetime

public void setMaxTicketLifetime(int seconds)
KAS: Sets the maximum lifetime of a ticket issued to this user (in seconds).

Parameters:
seconds - the maximum lifetime of a ticket issued to this user (in seconds).

setDaysToPasswordExpire

public void setDaysToPasswordExpire(int days)
KAS: Sets the number of days a password is valid before it expires. A value of 0 indicates passwords never expire.

Parameters:
days - the number of days for which a password is valid

setFailLoginCount

public void setFailLoginCount(int logins)
KAS: Sets the number of failed login attempts this user is allowed before being locked out. A value of 0 indicates there is no limit.

Parameters:
logins - the number of failed login attempts a user is allowed

setLockTime

public void setLockTime(int seconds)
KAS: Sets the amount of time (in seconds) a user is locked out when it exceeds the maximum number of allowable failed login attempts. A value of 0 indicates an infinite lockout time. Any nonzero value gets rounded up to the next highest multiple of 8.5 minutes, and any value over 36 hours gets rounded down to 36 hours.

Parameters:
seconds - the number of failed login attempts a user is allowed

setPassword

public void setPassword(String newPassword)
                 throws AFSException
Sets the password of this user to something new. Sets the key version to 0 automatically.

Parameters:
newPassword - the new password for this user
Throws:
AFSException - If an error occurs in the native code

getInfo

protected String getInfo()
Returns a String representation of this User. Contains the information fields and groups.

Returns:
a String representation of the User

getInfoGroups

protected String getInfoGroups()
                        throws AFSException
Returns a String containing the String representations of all the groups to which this user belongs.

Returns:
a String representation of the groups belonged to
AFSException
See Also:
Group.toString()

getInfoGroupsOwned

protected String getInfoGroupsOwned()
                             throws AFSException
Returns a String containing the String representations of all the groups that this user owns.

Returns:
a String representation of the groups owned
AFSException
See Also:
Group.toString()

compareTo

public int compareTo(User user)
Compares two User objects respective to their names and does not factor any other attribute. Alphabetic case is significant in comparing names.

Parameters:
user - The User object to be compared to this User instance
Returns:
Zero if the argument is equal to this User's name, a value less than zero if this User's name is lexicographically less than the argument, or a value greater than zero if this User's name is lexicographically greater than the argument

compareTo

public int compareTo(Object obj)
Comparable interface method.

Specified by:
compareTo in interface Comparable
See Also:
compareTo(User)

equals

public boolean equals(User otherUser)
Tests whether two User objects are equal, based on their names.

Parameters:
otherUser - the user to test
Returns:
whether the specifed user is the same as this user

toString

public String toString()
Returns the name of this User

Overrides:
toString in class Object
Returns:
the name of this User

create

protected static void create(int cellHandle,
                             String userName,
                             String password,
                             int uid)
                      throws AFSException
Creates the kas and pts entries for a new user. Pass in 0 for the uid if pts is to automatically assign the user id.

Parameters:
cellHandle - the handle of the cell to which the user belongs
userName - the name of the user to create
password - the password for the new user
uid - the user id to assign to the user (0 to have one automatically assigned)
Throws:
AFSException - If an error occurs in the native code
See Also:
Cell.getCellHandle()

delete

protected static void delete(int cellHandle,
                             String userName)
                      throws AFSException
Deletes the pts and kas entry for a user. Deletes this user from the membership list of the groups to which it belonged, but does not delete the groups owned by this user.

Parameters:
cellHandle - the handle of the cell to which the user belongs
Throws:
AFSException - If an error occurs in the native code
See Also:
Cell.getCellHandle()

unlock

protected static void unlock(int cellHandle,
                             String userName)
                      throws AFSException
Unlocks a user.

Parameters:
cellHandle - the handle of the cell to which the user belongs
Throws:
AFSException - If an error occurs in the native code
See Also:
Cell.getCellHandle()

getUserInfo

protected static void getUserInfo(int cellHandle,
                                  String name,
                                  User user)
                           throws AFSException
Fills in the information fields of the provided User. Fills in values based on the current pts and kas information of the user.

Parameters:
cellHandle - the handle of the cell to which the user belongs
name - the name of the user for which to get the information
user - the User object in which to fill in the information
Throws:
AFSException - If an error occurs in the native code
See Also:
Cell.getCellHandle(), User

setUserInfo

protected static void setUserInfo(int cellHandle,
                                  String name,
                                  User theUser)
                           throws AFSException
Sets the information values of this AFS user to be the parameter values. Sets both kas and pts fields.

Parameters:
cellHandle - the handle of the cell to which the user belongs
name - the name of the user for which to set the information
theUser - the User object containing the desired information
Throws:
AFSException - If an error occurs in the native code
See Also:
Cell.getCellHandle()

rename

protected static void rename(int cellHandle,
                             String oldName,
                             String newName)
                      throws AFSException
Renames the given user. Does not update the info fields of the kas entry -- the calling code is responsible for that.

Parameters:
cellHandle - the handle of the cell to which the user belongs
oldName - the name of the user to rename
newName - the new name for the user
Throws:
AFSException - If an error occurs in the native code
See Also:
Cell.getCellHandle()

setPassword

protected static void setPassword(int cellHandle,
                                  String userName,
                                  String newPassword)
                           throws AFSException
Sets the password of the given user. Sets the key version to 0.

Parameters:
cellHandle - the handle of the cell to which the user belongs
userName - the name of the user for which to set the password
newPassword - the new password for the user
Throws:
AFSException - If an error occurs in the native code
See Also:
Cell.getCellHandle()

getUserGroupsBegin

protected static int getUserGroupsBegin(int cellHandle,
                                        String name)
                                 throws AFSException
Begin the process of getting the groups to which the user belongs. Returns an iteration ID to be used by subsequent calls to getUserGroupsNext and getUserGroupsDone.

Parameters:
cellHandle - the handle of the cell to which the user belongs
name - the name of the user for which to get the groups
Returns:
an iteration ID
Throws:
AFSException - If an error occurs in the native code
See Also:
Cell.getCellHandle()

getUserGroupsNextString

protected static String getUserGroupsNextString(int iterationId)
                                         throws AFSException
Returns the next group to which the user belongs. Returns null if there are no more groups.

Parameters:
iterationId - the iteration ID of this iteration
Returns:
the name of the next group
Throws:
AFSException - If an error occurs in the native code
See Also:
getUserGroupsBegin(int, java.lang.String)

getUserGroupsNext

protected static int getUserGroupsNext(int cellHandle,
                                       int iterationId,
                                       Group theGroup)
                                throws AFSException
Fills the next group object of which the user belongs. Returns 0 if there are no more groups, != 0 otherwise.

Parameters:
cellHandle - the handle of the cell to which the users belong
iterationId - the iteration ID of this iteration
theGroup - a Group object to be populated with the values of the next group
Returns:
0 if there are no more users, != 0 otherwise
Throws:
AFSException - If an error occurs in the native code
See Also:
Cell.getCellHandle(), getUserGroupsBegin(int, java.lang.String)

getUserGroupsDone

protected static void getUserGroupsDone(int iterationId)
                                 throws AFSException
Signals that the iteration is complete and will not be accessed anymore.

Parameters:
iterationId - the iteration ID of this iteration
Throws:
AFSException - If an error occurs in the native code
See Also:
getUserGroupsBegin(int, java.lang.String)

getGroupsOwnedCount

protected static int getGroupsOwnedCount(int cellHandle,
                                         String name)
                                  throws AFSException
Returns the total number of groups owned by the user.

Parameters:
cellHandle - the handle of the cell to which the user belongs
name - the name of the user for which to get the groups
Returns:
total number of groups owned by the user
Throws:
AFSException - If an error occurs in the native code
See Also:
Cell.getCellHandle()

getGroupsOwnedBegin

protected static int getGroupsOwnedBegin(int cellHandle,
                                         String name)
                                  throws AFSException
Begin the process of getting the groups that a user or group owns. Returns an iteration ID to be used by subsequent calls to getGroupsOwnedNext and getGroupsOwnedDone.

Parameters:
cellHandle - the handle of the cell to which the user belongs
name - the name of the user or group for which to get the groups
Returns:
an iteration ID
Throws:
AFSException - If an error occurs in the native code
See Also:
Cell.getCellHandle()

getGroupsOwnedNextString

protected static String getGroupsOwnedNextString(int iterationId)
                                          throws AFSException
Returns the next group the user or group owns. Returns null if there are no more groups.

Parameters:
iterationId - the iteration ID of this iteration
Returns:
the name of the next group
Throws:
AFSException - If an error occurs in the native code
See Also:
getGroupsOwnedBegin(int, java.lang.String)

getGroupsOwnedNext

protected static int getGroupsOwnedNext(int cellHandle,
                                        int iterationId,
                                        Group theGroup)
                                 throws AFSException
Fills the next group object that the user or group owns. Returns 0 if there are no more groups, != 0 otherwise.

Parameters:
cellHandle - the handle of the cell to which the users belong
iterationId - the iteration ID of this iteration
theGroup - a Group object to be populated with the values of the next group
Returns:
0 if there are no more users, != 0 otherwise
Throws:
AFSException - If an error occurs in the native code
See Also:
Cell.getCellHandle(), getGroupsOwnedBegin(int, java.lang.String)

getGroupsOwnedDone

protected static void getGroupsOwnedDone(int iterationId)
                                  throws AFSException
Signals that the iteration is complete and will not be accessed anymore.

Parameters:
iterationId - the iteration ID of this iteration
Throws:
AFSException - If an error occurs in the native code
See Also:
getGroupsOwnedBegin(int, java.lang.String)

reclaimUserMemory

protected static void reclaimUserMemory()
Reclaims all memory being saved by the user portion of the native library. This method should be called when no more Users are expected to be used.


JAFS API v2