org.edg.security.voms.database
Class DBUser

java.lang.Object
  |
  +--org.edg.security.voms.database.DBUser

public final class DBUser
extends java.lang.Object

A class representing the users in a VO. Essentially, a database wrapper class for the users table.

Version:
$Name: v0_7_0 $
Author:
Karoly Lorentey, Akos Frohner

Field Summary
private  int ca
          The id of this users' CA.
private  java.lang.String certUri
          Pointer to the user's certificate (optional).
private  java.lang.String cn
          The common name of this user.
private  long createdBy
          The id of the client who created this user.
private  long createdSerial
          The number of the transaction that created this user.
private  java.lang.String dn
          The distinguished name of this user.
private static int DN
           
private  long id
          The internal id of this user.
private static int ID
           
private static org.apache.log4j.Logger log
          Logger.
private  java.lang.String mail
          The email address of this user (optional).
(package private) static Sequence seq
          Sequence.
 
Constructor Summary
private DBUser(long id)
          Initialize a new DBUser from the given id.
private DBUser(java.lang.String dn, DBCA ca)
          Initialize a new DBUser from the given DN.
 
Method Summary
 int countCapabilities()
          Return the number of capabilities that this user has.
 int countGroups()
          Return the number of groups that this user is a member of, including the VO group.
 int countRoles()
          Return the number of role-group pairs that this user has.
static DBUser createUser(java.lang.String dn, java.lang.String cn, DBCA ca, java.lang.String certUri, java.lang.String mail)
          Creates a new user in the database.
 void deleteUser()
          Deletes a user from the database.
static java.util.List getAllUsernames()
           
 User getAsUser()
          Return this as a User.
 DBCA getCA()
          Return the CA of this user.
(package private)  int getCAId()
          Return the id of the CA of this user.
 java.lang.String[] getCapabilityNames()
          Return the names of all capabilities that this user has.
 java.lang.String getCertUri()
          Return the URI to the user's certificate.
 java.lang.String getCN()
          Return the common name of this user.
 DBAdmin getCreatedBy()
          Return the user who created this user.
(package private)  long getCreatedById()
          Return the id of the user who last modified this user.
 long getCreatedSerial()
          Return the serial number of the transaction that committed this user.
 java.lang.String getDN()
          Return the distinguished name of this user.
 java.lang.String[] getGroupnames()
          Return the names of all groups that this user is a member of, including the VO group, in an unspecified order.
(package private)  long getId()
          Return the id of this user.
(package private) static DBUser getInstance(long id)
           
static DBUser getInstance(java.lang.String name, DBCA ca)
           
static DBUser getInstance(User user)
           
static DBUser getInstanceFromSecurityContext()
          Returns the user object associated with the current client.
 java.lang.String getMail()
          Return the email address of this user.
 QualifiedRole[] getRolenames()
          Return the names of all role-group pairs that this user has.
private  void initialize(int from)
          Query the database for the full user row.
 void setAttributes(java.lang.String cn, java.lang.String mail, java.lang.String certUri)
          Set auxiliary attributes.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

log

private static final org.apache.log4j.Logger log
Logger.


dn

private java.lang.String dn
The distinguished name of this user.


id

private long id
The internal id of this user.


ca

private int ca
The id of this users' CA.


certUri

private java.lang.String certUri
Pointer to the user's certificate (optional).


cn

private java.lang.String cn
The common name of this user.


mail

private java.lang.String mail
The email address of this user (optional).


createdBy

private long createdBy
The id of the client who created this user.


createdSerial

private long createdSerial
The number of the transaction that created this user.


seq

static final Sequence seq
Sequence.


DN

private static final int DN
See Also:
Constant Field Values

ID

private static final int ID
See Also:
Constant Field Values
Constructor Detail

DBUser

private DBUser(java.lang.String dn,
               DBCA ca)
        throws GeneralDatabaseException,
               NotInDatabase,
               ArgumentException
Initialize a new DBUser from the given DN.


DBUser

private DBUser(long id)
        throws GeneralDatabaseException,
               NotInDatabase
Initialize a new DBUser from the given id.

Method Detail

initialize

private void initialize(int from)
                 throws GeneralDatabaseException,
                        NotInDatabase
Query the database for the full user row. Use either the uid or the dn field to find the correct user in the database.

GeneralDatabaseException
NotInDatabase

getInstance

public static DBUser getInstance(java.lang.String name,
                                 DBCA ca)
                          throws GeneralDatabaseException,
                                 NotInDatabase,
                                 ArgumentException
GeneralDatabaseException
NotInDatabase
ArgumentException

getInstance

static DBUser getInstance(long id)
                   throws GeneralDatabaseException,
                          NotInDatabase
GeneralDatabaseException
NotInDatabase

getInstance

public static DBUser getInstance(User user)
                          throws GeneralDatabaseException,
                                 NotInDatabase,
                                 ArgumentException
GeneralDatabaseException
NotInDatabase
ArgumentException

getInstanceFromSecurityContext

public static DBUser getInstanceFromSecurityContext()
                                             throws GeneralDatabaseException,
                                                    NotInDatabase,
                                                    VOMSSecurityException
Returns the user object associated with the current client.

Throws:
VOMSSecurityException - if the client's credentials could not be determined or if the client is not a user in the database.
GeneralDatabaseException
NotInDatabase

getId

long getId()
Return the id of this user.


getCAId

int getCAId()
Return the id of the CA of this user. Please consider using getCA instead of this method.


getDN

public java.lang.String getDN()
Return the distinguished name of this user.


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getCN

public java.lang.String getCN()
Return the common name of this user.


getMail

public java.lang.String getMail()
Return the email address of this user.


getCertUri

public java.lang.String getCertUri()
Return the URI to the user's certificate.


getCreatedById

long getCreatedById()
Return the id of the user who last modified this user. Please consider using getCreatedBy instead of this method.


getCreatedSerial

public long getCreatedSerial()
Return the serial number of the transaction that committed this user.


getCA

public DBCA getCA()
           throws GeneralDatabaseException,
                  NotInDatabase
Return the CA of this user.

GeneralDatabaseException
NotInDatabase

getCreatedBy

public DBAdmin getCreatedBy()
                     throws GeneralDatabaseException,
                            NotInDatabase
Return the user who created this user.

Returns:
the creator of this user if she is still in the database.
Throws:
NotInDatabase - if the creator has been deleted from the database.
GeneralDatabaseException

getAsUser

public User getAsUser()
               throws GeneralDatabaseException,
                      NotInDatabase
Return this as a User.

GeneralDatabaseException
NotInDatabase

setAttributes

public void setAttributes(java.lang.String cn,
                          java.lang.String mail,
                          java.lang.String certUri)
                   throws GeneralDatabaseException
Set auxiliary attributes.

GeneralDatabaseException

createUser

public static DBUser createUser(java.lang.String dn,
                                java.lang.String cn,
                                DBCA ca,
                                java.lang.String certUri,
                                java.lang.String mail)
                         throws GeneralDatabaseException,
                                ArgumentException
Creates a new user in the database.

GeneralDatabaseException
ArgumentException

deleteUser

public void deleteUser()
                throws GeneralDatabaseException,
                       NotInDatabase
Deletes a user from the database.

GeneralDatabaseException
NotInDatabase

getAllUsernames

public static java.util.List getAllUsernames()
                                      throws GeneralDatabaseException
GeneralDatabaseException

countGroups

public int countGroups()
                throws GeneralDatabaseException
Return the number of groups that this user is a member of, including the VO group.

GeneralDatabaseException

getGroupnames

public java.lang.String[] getGroupnames()
                                 throws GeneralDatabaseException
Return the names of all groups that this user is a member of, including the VO group, in an unspecified order.

GeneralDatabaseException

countRoles

public int countRoles()
               throws GeneralDatabaseException
Return the number of role-group pairs that this user has.

GeneralDatabaseException

getRolenames

public QualifiedRole[] getRolenames()
                             throws GeneralDatabaseException
Return the names of all role-group pairs that this user has.

GeneralDatabaseException

countCapabilities

public int countCapabilities()
                      throws GeneralDatabaseException
Return the number of capabilities that this user has.

GeneralDatabaseException

getCapabilityNames

public java.lang.String[] getCapabilityNames()
                                      throws GeneralDatabaseException
Return the names of all capabilities that this user has.

GeneralDatabaseException