All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class jnfs.security.FileBasedPermissionGranter

java.lang.Object
   |
   +----jnfs.security.UnixStylePermissionGranter
           |
           +----jnfs.security.FileBasedPermissionGranter

public class FileBasedPermissionGranter
extends UnixStylePermissionGranter
implements Serializable
Implements a unix-style permission granter based on the information provided by the equivalents of ls -laR, /etc/passwd, and /etc/group.

The ls -laR stream should be formatted as the below example, where the first column lists the permission bits, the third lists the owner, the fourth lists the group, and the ninth the filename. All other fields are required but ignored.

The filename separator used to indicate which directory the files belong to must conform to the system-dependent file separator string (for example, "/" on unix and "\" on WinNT). A fragment from a directory listing is given below:

 /:
 total 129
 drwxr-xr-x  32 root     root        1024 Feb 25 13:05 .
 drwxr-xr-x  32 root     root        1024 Feb 25 13:05 ..
 dr-xr-xr-x   2 root     root           3 May 21 15:40 bin
 lrwxrwxrwx   1 root     root           9 Jan  6 19:47 lib -> ./usr/lib
 drwx------   2 root     root        8192 Jan  6 19:47 lost+found
 drwxrwxr-x  25 root     sys         1024 Jan  7 09:16 usr
/bin: total 18944 drwxrwxr-x 2 root bin 7168 Mar 18 05:13 . drwxrwxr-x 25 root sys 1024 Jan 7 09:16 .. -r-sr-xr-x 1 root bin 32868 Jan 29 05:13 login -r-xr-xr-x 1 bin bin 17500 Oct 25 1995 ls -r-x--s--x 1 bin mail 66208 Jan 6 20:16 mail
The group stream should consist of a one-line entry for each group recognized by the system, of the form:
groupname:password:gid:user-list
where The passwd stream should consist of a one-line entry for each user of the form:
username:password:uid:gid:gcos-field:home-dir:login-shell
where

Version:
$Id: FileBasedPermissionGranter.java,v 1.13 1997/05/21 20:19:07 mjr Exp $
Author:
Michael John Radwin
See Also:
separator

Constructor Index

 o FileBasedPermissionGranter(UserTable, InputStream, InputStream, InputStream)
Build a new permission granter based on the information provided by the equivalents of ls -laR, /etc/group, and /etc/passwd.

Method Index

 o chmod(String, int)
Changes the mode of pathname to mode.
 o chown(String, String, String)
Changes the ownership of pathname to owner and group membership to group.
 o group(String)
Returns the name of the group associated with pathname.
 o members(String)
Returns the group members of group groupname.
 o mode(String)
Returns the Unix mode bits associated with pathname.
 o owner(String)
Returns the name of the owner of pathname.
 o readDirListing(InputStream)
Read the information from a stream formatted like ls -laR into this permission granter.
 o readGroup(InputStream)
Read the information from a stream formatted like /etc/group into this permission granter.
 o readPasswd(InputStream)
Read the information from a stream formatted like /etc/passwd into this permission granter.

Constructors

 o FileBasedPermissionGranter
 public FileBasedPermissionGranter(UserTable users,
                                   InputStream ls_laR,
                                   InputStream group,
                                   InputStream passwd)
Build a new permission granter based on the information provided by the equivalents of ls -laR, /etc/group, and /etc/passwd. This constructor is very slow.

Methods

 o readGroup
 public void readGroup(InputStream is)
Read the information from a stream formatted like /etc/group into this permission granter.

 o readPasswd
 public void readPasswd(InputStream is)
Read the information from a stream formatted like /etc/passwd into this permission granter.

 o readDirListing
 public void readDirListing(InputStream is)
Read the information from a stream formatted like ls -laR into this permission granter.

 o mode
 protected int mode(String pathname) throws IOException
Returns the Unix mode bits associated with pathname.

Throws: IOException
if an I/O error occurs.
Throws: FileNotFoundException
if pathname does not exist.
Overrides:
mode in class UnixStylePermissionGranter
 o owner
 protected String owner(String pathname) throws IOException
Returns the name of the owner of pathname.

Throws: IOException
if an I/O error occurs.
Throws: FileNotFoundException
if pathname does not exist.
Overrides:
owner in class UnixStylePermissionGranter
 o group
 protected String group(String pathname) throws IOException
Returns the name of the group associated with pathname.

Throws: IOException
if an I/O error occurs.
Throws: FileNotFoundException
if pathname does not exist.
Overrides:
group in class UnixStylePermissionGranter
 o members
 protected String[] members(String group_name) throws IOException
Returns the group members of group groupname.

Throws: IOException
if the group does not exist.
Overrides:
members in class UnixStylePermissionGranter
 o chmod
 protected void chmod(String pathname,
                      int mode) throws IOException
Changes the mode of pathname to mode.

Throws: IOException
if an I/O error occurs.
Throws: FileNotFoundException
if pathname does not exist.
Overrides:
chmod in class UnixStylePermissionGranter
 o chown
 protected void chown(String pathname,
                      String owner,
                      String group) throws IOException
Changes the ownership of pathname to owner and group membership to group. If either owner or group are null, that permission is not changed. If both are null, nothing happens.

Throws: IOException
if an I/O error occurs.
Throws: FileNotFoundException
if pathname does not exist.
Overrides:
chown in class UnixStylePermissionGranter

All Packages  Class Hierarchy  This Package  Previous  Next  Index