ccc.security
Class JdbcDatabase

java.lang.Object
  extended by ccc.security.JdbcDatabase
All Implemented Interfaces:
Database

public class JdbcDatabase
extends java.lang.Object
implements Database

JDBC implementation of the Database api.

Author:
Civic Computing Ltd.

Constructor Summary
JdbcDatabase()
          Constructor.
JdbcDatabase(Registry r)
          Constructor.
 
Method Summary
 java.util.Set<java.lang.String> lookupPerms(java.lang.String userId)
          Look up a user's permissions from the DB.
 java.lang.Object[] lookupUser(Username username)
          Lookup details of a user from the DB.
 void setOptions(java.util.Map<java.lang.String,?> options)
          Specify the options for the database.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JdbcDatabase

public JdbcDatabase(Registry r)
Constructor.

Parameters:
r - The registry to use for resource lookup.

JdbcDatabase

public JdbcDatabase()
Constructor.

Method Detail

lookupUser

public java.lang.Object[] lookupUser(Username username)
                              throws java.sql.SQLException
Lookup details of a user from the DB. Details are returned in object array with the following structure:
[0] user id, as a string
[1] hashed password, as a byte array
[2] password salt, as a string

Specified by:
lookupUser in interface Database
Parameters:
username - The username representing the user to look up.
Returns:
The user data as an object array; NULL if no valid user is found.
Throws:
java.sql.SQLException - If an error occurs while communicating with the DB.

lookupPerms

public java.util.Set<java.lang.String> lookupPerms(java.lang.String userId)
                                            throws java.sql.SQLException
Look up a user's permissions from the DB.

Specified by:
lookupPerms in interface Database
Parameters:
userId - The user id whose permissions we will retrieve.
Returns:
A set of permissions, represented as strings.
Throws:
java.sql.SQLException - If an error occurs while communicating with the DB.

setOptions

public void setOptions(java.util.Map<java.lang.String,?> options)
Specify the options for the database.

Specified by:
setOptions in interface Database
Parameters:
options - A map of key:value pairs.


Copyright © 2010. All Rights Reserved.