|
Java AFS Admin API v1.3 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.openafs.jafsadm.User
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
Group
s that it owns and Group
s 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.jafsadm.Cell; import org.openafs.jafsadm.AFSAdminException; import org.openafs.jafsadm.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]; cell = new Cell(cellName, username, password); 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()); } } ... }
Field Summary | |
static int |
ADMIN
User has administrative kas privileges |
static int |
CHANGE_PASSWORD
User can change their password |
static int |
ENCRYPT
TGS can use user's key for an encryption key |
static int |
GRANT_TICKETS
TGS will grant tickets for user |
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 |
static int |
REUSE_PASSWORD
User can reuse their password |
static int |
USER_ANYUSER_ACCESS
Any user has access |
static int |
USER_OWNER_ACCESS
Only the owner of the user has access |
Fields inherited from interface org.openafs.jafsadm.PTSEntry |
PTS_GROUP, PTS_USER |
Constructor Summary | |
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. |
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. |
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. |
int |
getGroupsOwnedCount()
PTS: Returns the total count of groups this user owns. |
String[] |
getGroupsOwnedNames()
PTS: Returns a String array of the group names
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. |
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. |
void |
refresh()
Refreshes the properties of this User object instance with values from the AFS user it represents. |
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). |
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. |
String |
toString()
Returns the name of this User |
void |
unlock()
Unlocks the given user if they were locked out of the cell. |
boolean |
willGrantTickets()
KAS: Returns whether or not TGS will issue tickets for this user |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final int USER_OWNER_ACCESS
public static final int USER_ANYUSER_ACCESS
public static final int ADMIN
public static final int NO_ADMIN
public static final int GRANT_TICKETS
public static final int NO_GRANT_TICKETS
public static final int ENCRYPT
public static final int NO_ENCRYPT
public static final int CHANGE_PASSWORD
public static final int NO_CHANGE_PASSWORD
public static final int REUSE_PASSWORD
public static final int NO_REUSE_PASSWORD
Constructor Detail |
public User(String name, Cell cell) throws AFSAdminException
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.name
- the name of the user to representcell
- the cell to which the user belongs.AFSAdminException
- If an error occurs in the native codepublic User(String name, Cell cell, boolean preloadAllMembers) throws AFSAdminException
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.
name
- the name of the user to representcell
- 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.AFSAdminException
- If an error occurs in the native coderefresh()
Method Detail |
public void create(String password) throws AFSAdminException
password
- the password for the new userAFSAdminException
- If an error occurs in the native codepublic void create(String password, int uid) throws AFSAdminException
password
- the password for the new useruid
- the user id to assign to the new userAFSAdminException
- If an error occurs in the native codepublic void delete() throws AFSAdminException
AFSAdminException
- If an error occurs in the native codepublic void unlock() throws AFSAdminException
userName
- the name of the user to unlockAFSAdminException
- If an error occurs in the native codepublic void flushInfo() throws AFSAdminException
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.AFSAdminException
- If an error occurs in the native codepublic void rename(String newName) throws AFSAdminException
newName
- the new name for this userAFSAdminException
- If an error occurs in the native codepublic void refresh() throws AFSAdminException
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.
AFSAdminException
- If an error occurs in the native codepublic String getName()
getName
in interface PTSEntry
public Cell getCell()
getCell
in interface PTSEntry
public boolean isKAS() throws AFSAdminException
AFSAdminException
- If an error occurs in the native coderefresh()
public boolean isPTS() throws AFSAdminException
AFSAdminException
- If an error occurs in the native coderefresh()
public Group[] getGroups() throws AFSAdminException
Group
objects
to which this user belongs.AFSAdminException
- If an error occurs in the native coderefresh()
public int getGroupsOwnedCount() throws AFSAdminException
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.
AFSAdminException
- If an error occurs in the native codegetGroupsOwned()
,
getGroupsOwnedNames()
public Group[] getGroupsOwned() throws AFSAdminException
Group
objects
this user owns.Groups
this user ownsAFSAdminException
- If an error occurs in the native coderefresh()
public String[] getGroupNames() throws AFSAdminException
String
array of the group names
to which this user belongs.String
array of the groups to which this
user belongsAFSAdminException
- If an error occurs in the native coderefresh()
public String[] getGroupsOwnedNames() throws AFSAdminException
String
array of the group names
this user owns.String
array of the groups this user ownsAFSAdminException
- If an error occurs in the native coderefresh()
public int getUID() throws AFSAdminException
getUID
in interface PTSEntry
AFSAdminException
- If an error occurs in the native coderefresh()
public int getGroupCreationQuota() throws AFSAdminException
AFSAdminException
- If an error occurs in the native coderefresh()
public int getGroupMembershipCount() throws AFSAdminException
AFSAdminException
- If an error occurs in the native coderefresh()
public PTSEntry getOwner() throws AFSAdminException
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.
getOwner
in interface PTSEntry
AFSAdminException
- If an error occurs in the native codePTSEntry
,
PTSEntry.getType()
,
refresh()
public PTSEntry getCreator() throws AFSAdminException
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.
getCreator
in interface PTSEntry
AFSAdminException
- If an error occurs in the native codePTSEntry
,
PTSEntry.getType()
,
refresh()
public short getType()
PTSEntry
this object represents.
This method will always return PTSEntry.PTS_USER
.
getType
in interface PTSEntry
PTSEntry.PTS_USER
)PTSEntry
,
PTSEntry.getType()
public int getListStatus() throws AFSAdminException
USER_OWNER_ACCESS
-- only the owner has permissionUSER_ANYUSER_ACCESS
-- any user has permissionAFSAdminException
- If an error occurs in the native coderefresh()
public int getListGroupsOwned() throws AFSAdminException
USER_OWNER_ACCESS
-- only the owner has permissionUSER_ANYUSER_ACCESS
-- any user has permissionAFSAdminException
- If an error occurs in the native coderefresh()
public int getListMembership() throws AFSAdminException
USER_OWNER_ACCESS
-- only the owner has permissionUSER_ANYUSER_ACCESS
-- any user has permissionAFSAdminException
- If an error occurs in the native coderefresh()
public boolean isAdmin() throws AFSAdminException
AFSAdminException
- If an error occurs in the native coderefresh()
public boolean willGrantTickets() throws AFSAdminException
AFSAdminException
- If an error occurs in the native coderefresh()
public boolean canEncrypt() throws AFSAdminException
AFSAdminException
- If an error occurs in the native coderefresh()
public boolean canChangePassword() throws AFSAdminException
AFSAdminException
- If an error occurs in the native coderefresh()
public boolean canReusePassword() throws AFSAdminException
AFSAdminException
- If an error occurs in the native coderefresh()
public int getUserExpiration() throws AFSAdminException
null
value indicates the user never exipres (or that
there is no kas entry for this user).AFSAdminException
- If an error occurs in the native coderefresh()
public GregorianCalendar getUserExpirationDate() throws AFSAdminException
null
value indicates the user never expires (or that
there is no kas entry for this user).AFSAdminException
- If an error occurs in the native coderefresh()
public int getLastModTime() throws AFSAdminException
AFSAdminException
- If an error occurs in the native coderefresh()
public GregorianCalendar getLastModTimeDate() throws AFSAdminException
AFSAdminException
- If an error occurs in the native coderefresh()
public String getLastModName() throws AFSAdminException
AFSAdminException
- If an error occurs in the native coderefresh()
public GregorianCalendar getLastChangePasswordTimeDate() throws AFSAdminException
AFSAdminException
- If an error occurs in the native coderefresh()
public int getLastChangePasswordTime() throws AFSAdminException
AFSAdminException
- If an error occurs in the native coderefresh()
public int getMaxTicketLifetime() throws AFSAdminException
AFSAdminException
- If an error occurs in the native coderefresh()
public int getDaysToPasswordExpire() throws AFSAdminException
AFSAdminException
- If an error occurs in the native coderefresh()
public int getFailLoginCount() throws AFSAdminException
AFSAdminException
- If an error occurs in the native coderefresh()
public int getLockTime() throws AFSAdminException
AFSAdminException
- If an error occurs in the native coderefresh()
public String getEncryptionKey() throws AFSAdminException
AFSAdminException
- If an error occurs in the native coderefresh()
public long getKeyCheckSum() throws AFSAdminException
AFSAdminException
- If an error occurs in the native coderefresh()
public int getKeyVersion() throws AFSAdminException
AFSAdminException
- If an error occurs in the native coderefresh()
public int getLockedUntil() throws AFSAdminException
AFSAdminException
- If an error occurs in the native coderefresh()
public GregorianCalendar getLockedUntilDate() throws AFSAdminException
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.AFSAdminException
- If an error occurs in the native coderefresh()
public void setGroupCreationQuota(int quota)
quota
- the new group creation quotapublic void setListStatus(int value) throws AFSAdminException
USER_OWNER_ACCESS
-- only the owner has permissionUSER_ANYUSER_ACCESS
-- any user has permissionvalue
- the value of the new list status permissionAFSAdminException
- if an error occurs in the native codeIllegalArgumentException
- if an invalud argument is providedpublic void setListGroupsOwned(int value) throws AFSAdminException
USER_OWNER_ACCESS
-- only the owner has permissionUSER_ANYUSER_ACCESS
-- any user has permissionvalue
- the value of the new list groups owned permissionAFSAdminException
- if an error occurs in the native codeIllegalArgumentException
- if an invalud argument is providedpublic void setListMembership(int value) throws AFSAdminException
USER_OWNER_ACCESS
-- only the owner has permissionUSER_ANYUSER_ACCESS
-- any user has permissionvalue
- the value of the new list membership permissionAFSAdminException
- if an error occurs in the native codeIllegalArgumentException
- if an invalud argument is providedpublic void setAdmin(boolean setting)
setting
- whether or not this user has kas
administrative privilegespublic void setGrantTickets(boolean setting)
setting
- whether or not TGS will issue tickets for this userpublic void setEncrypt(boolean setting)
setting
- whether or not TGS can use this users ticket for an
encryption keypublic void setChangePassword(boolean setting)
setting
- whether or not the user can change their passwordpublic void setReusePassword(boolean setting)
setting
- whether or not the user can reuse their passwordpublic void setUserExpiration(GregorianCalendar expirationDate)
null
value indicates the user never exipres.expirationDate
- the date and time the user expirespublic void setMaxTicketLifetime(int seconds)
seconds
- the maximum lifetime of a ticket issued to this user (in seconds).public void setDaysToPasswordExpire(int days)
days
- the number of days for which a password is validpublic void setFailLoginCount(int logins)
logins
- the number of failed login attempts a user is allowedpublic void setLockTime(int seconds)
seconds
- the number of failed login attempts a user is allowedpublic void setPassword(String newPassword) throws AFSAdminException
newPassword
- the new password for this userAFSAdminException
- If an error occurs in the native codepublic int compareTo(User user)
user
- The User object to be compared to this User instancepublic int compareTo(Object obj)
compareTo
in interface Comparable
compareTo(User)
public boolean equals(User otherUser)
User
objects are equal, based on their
names.otherUser
- the user to testpublic String toString()
User
toString
in class Object
User
|
Java AFS Admin (jafsadm) API for OpenAFS | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |