org.locomotive.loco.perm
Class UserPerm

java.lang.Object
  |
  +--org.locomotive.loco.perm.UserPerm

public class UserPerm
extends java.lang.Object

Maintains users' permissions in the database.


Constructor Summary
UserPerm()
           
 
Method Summary
static void deletePermissions(int[] userids, java.sql.Connection conn)
          Deletes many users' permissions from the database.
static void deletePermissions(int userid, java.sql.Connection conn)
          Deletes a user's permissions in the database.
static PermissionSet[] getPermissions(java.sql.Connection conn, int[] userids)
          Gets a bunch of users' permissions from the database.
static PermissionSet getPermissions(int userid, java.sql.Connection conn)
          Gets a user's permissions from the database.
static void setPermissions(int userid, PermissionSet perms, java.sql.Connection conn)
          Deprecated. - the userid should be in the perms, so we don't need it here
static void setPermissions(PermissionSet[] perms, java.sql.Connection conn)
          Lets you insert multiple permissions for of the users associated with each of the perms' userid.
static void setPermissions(PermissionSet perms, java.sql.Connection conn)
          Sets the users's permissions in the database
static java.util.Vector usersWhoHave(java.sql.Connection conn, java.lang.String permName)
          Returns a Vector of userids, which represent the users who have the permission with the specified name.
static java.util.Vector usersWhoHaveAll(java.sql.Connection conn, PermissionSet pset)
          Returns a Vector of userids, which represent the users who have ALL of the permisssions in the specified permission set.
static java.util.Vector usersWhoHaveAny(java.sql.Connection conn, PermissionSet pset)
          Returns a Vector of userids, which represent the users who have any of the permissions in the specified permission set.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UserPerm

public UserPerm()
Method Detail

setPermissions

public static void setPermissions(PermissionSet perms,
                                  java.sql.Connection conn)
                           throws java.sql.SQLException
Sets the users's permissions in the database
Parameters:
perms - the user's permission set
conn - the database connection to use
Throws:
java.sql.SQLException - if some database error occurs

setPermissions

public static void setPermissions(int userid,
                                  PermissionSet perms,
                                  java.sql.Connection conn)
                           throws java.sql.SQLException
Deprecated. - the userid should be in the perms, so we don't need it here

Sets the a user's permissions in the database.
Parameters:
userid - userid of user
perms - PermissionSet containing the user's permissions
conn - database connection object
Throws:
java.sql.SQLException - if some database error occurs

getPermissions

public static PermissionSet getPermissions(int userid,
                                           java.sql.Connection conn)
                                    throws java.sql.SQLException
Gets a user's permissions from the database.
Parameters:
userid - userid of user
conn - database connection object
Returns:
PermissionSet containing the user's permissions
Throws:
java.sql.SQLException - if some database error occurs

deletePermissions

public static void deletePermissions(int userid,
                                     java.sql.Connection conn)
                              throws java.sql.SQLException
Deletes a user's permissions in the database.
Parameters:
userid - userid of user
conn - database connection object
Throws:
java.sql.SQLException - if some database error occurs

deletePermissions

public static void deletePermissions(int[] userids,
                                     java.sql.Connection conn)
                              throws java.sql.SQLException
Deletes many users' permissions from the database.
Parameters:
userids - userid of users to delete the permissions from
conn - database connection object
Throws:
java.sql.SQLException - if some database error occurs

setPermissions

public static void setPermissions(PermissionSet[] perms,
                                  java.sql.Connection conn)
                           throws java.sql.SQLException
Lets you insert multiple permissions for of the users associated with each of the perms' userid. Besides that its about the same as the one above.
Parameters:
perms - the permissions that correspond to the userids
conn - the db connection to use
Throws:
java.sql.SQLException - if we didn't get along well with our database

getPermissions

public static PermissionSet[] getPermissions(java.sql.Connection conn,
                                             int[] userids)
                                      throws java.sql.SQLException
Gets a bunch of users' permissions from the database.
Parameters:
userids - the userids for the users whose permissions we'll get
conn - the database connection we'll use
Returns:
an array of PermissionSet objects corresponding to each user. This array will be ordered by the userid. If any users in the userids parameter didn't have any permissions, then the array will just skip over them.
Throws:
java.sql.SQLException - if our db doesn't like what we're doing to it

usersWhoHave

public static java.util.Vector usersWhoHave(java.sql.Connection conn,
                                            java.lang.String permName)
                                     throws java.sql.SQLException
Returns a Vector of userids, which represent the users who have the permission with the specified name. If the permission doesn't exist, then an empty vector is returned
Throws:
java.sql.SQLException - is there was a problem with the database

usersWhoHaveAny

public static java.util.Vector usersWhoHaveAny(java.sql.Connection conn,
                                               PermissionSet pset)
                                        throws java.sql.SQLException
Returns a Vector of userids, which represent the users who have any of the permissions in the specified permission set. Note that using a blank permission set will return all the users who have any permissions at all.
Throws:
java.sql.SQLException - is there was a problem with the database

usersWhoHaveAll

public static java.util.Vector usersWhoHaveAll(java.sql.Connection conn,
                                               PermissionSet pset)
                                        throws java.sql.SQLException
Returns a Vector of userids, which represent the users who have ALL of the permisssions in the specified permission set. Basically does an INTERSECT of the set of users that have each of the permissions in the permissions set. Using a blank permission set will return no users.
Throws:
java.sql.SQLException - is there was a problem with the database