All Packages This Package Class Hierarchy Class Search Index
java.lang.Object | +----posix.Passwd
| Summary |
public class Passwd
extends java.lang.Object
{
// Fields 7
public String pw_dir;
public String pw_gecos;
public int pw_gid;
public String pw_name;
public String pw_passwd;
public String pw_shell;
public int pw_uid;
// Constructors 2
public Passwd();
public Passwd(String);
// Methods 6
public void endpwent();
public boolean getpwent() throws IOException;
public boolean getpwnam(String) throws IOException;
public boolean getpwuid(int) throws IOException;
public boolean putpwent() throws IOException;
public void setpwent() throws IOException;
}
POSIX style access to the unix passwd file. There is no caching. This gets you the most up to date data, but if you are looking up lots of user ids, you probably want to load them into a Hashtable.
This class is implemented in Java for the standard text passwd files used by unix systems. Some unix systems replace the text format with an indexed database of some description. This improves performance when there are thousands of users, but we won't be able to take advantage of that. Such systems should still keep a text version in the usual place.
This code is distributed under the GNU Library General Public License
This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details.
You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
| Fields |
· pw_name | Summary | Top |
public String pw_name
· pw_passwd | Summary | Top |
public String pw_passwd
· pw_uid | Summary | Top |
public int pw_uid
· pw_gid | Summary | Top |
public int pw_gid
· pw_gecos | Summary | Top |
public String pw_gecos
· pw_dir | Summary | Top |
public String pw_dir
· pw_shell | Summary | Top |
public String pw_shell
| Constructors |
· Passwd | Summary | Top |
public Passwd(String path)
Access an arbitrary passwd format file.
· Passwd | Summary | Top |
public Passwd()
Access the standard passwd file. For unix, this is
/etc/passwd.
| Methods |
· getpwent | Summary | Top |
public boolean getpwent() throws IOException
Read the next record in the passwd file.
- Returns:
- true if we found another record
· setpwent | Summary | Top |
public void setpwent() throws IOException
Open and position the passwd file just before the first record.
· getpwuid | Summary | Top |
public boolean getpwuid(int uid) throws IOException
Read the passwd record that matches a user id.
Parameter Description uid The user id
- Returns:
- true if the record is found
· getpwnam | Summary | Top |
public boolean getpwnam(String nam) throws IOException
Read the first passwd record that matches a user name.
Parameter Description nam The user name
- Returns:
- true if the record is found
· putpwent | Summary | Top |
public boolean putpwent() throws IOException
Update the passwd file with the current values. This is not yet implemented. A proper implementation requires the traditional unix text file locking mechanism (which uses a temporary output file with a well known name as the lock). Traditional locking will soon be another feature of the posix package.
· endpwent | Summary | Top |
public void endpwent()
Close the passwd file.
All Packages This Package Class Hierarchy Class Search IndexFreshly brewed Java API Documentation automatically generated with polardoc Version 1.0.7