umich.cac.util
Class Passwd

java.lang.Object
  extended byumich.cac.util.Passwd

public class Passwd
extends java.lang.Object

A class that reads a UNIX style password file so we can obtain the UNIX uid for a given user for PBS accounting

Version:
$Header: /cvsroot/pbsaccounting/pbsaccounting/doc/javadoc/umich/cac/util/Passwd.html,v 1.6 2003/10/21 20:33:47 rodmach Exp $
Author:
rmach@umich.edu

Field Summary
 long NOT_FOUND
          If UID not found, the default value is NOT_FOUND
 
Constructor Summary
Passwd()
          Constructor.
Passwd(java.lang.String passwdFile)
          Constructor for unit testing
 
Method Summary
 boolean isExist(java.lang.String filename)
          Checks if passwd file exists
 long lookupUid(java.lang.String loginId)
          Lookup the UID for a user given the loginId
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NOT_FOUND

public long NOT_FOUND
If UID not found, the default value is NOT_FOUND

Constructor Detail

Passwd

public Passwd(java.lang.String passwdFile)
       throws java.io.FileNotFoundException,
              java.io.IOException
Constructor for unit testing

Parameters:
passwdFile - an optional password file to use for lookups
Throws:
java.io.IOException - if problem reading password file
java.io.FileNotFoundException - if doesn't exist

Passwd

public Passwd()
       throws java.io.FileNotFoundException,
              java.io.IOException
Constructor. By default reads "/etc/passwd" file

Throws:
java.io.IOException - if problem reading password file
java.io.FileNotFoundException - if doesn't exist
Method Detail

isExist

public boolean isExist(java.lang.String filename)
Checks if passwd file exists

Parameters:
filename - passwd file to check for
Returns:
true if exists, false if not

lookupUid

public long lookupUid(java.lang.String loginId)
Lookup the UID for a user given the loginId

Parameters:
loginId - The login ID (entry 0 in the passwd file)
Returns:
The UID for the corresponding loginId, or NOT_FOUND if not found