org.jasig.portal.security.provider
Class RDBMPermissionImpl

java.lang.Object
  extended by org.jasig.portal.security.provider.RDBMPermissionImpl
All Implemented Interfaces:
IPermissionStore

public class RDBMPermissionImpl
extends java.lang.Object
implements IPermissionStore

Reference implementation of IPermissionStore. Performs CRUD operations on the UP_Permission table.

Version:
$Revision: 1.21 $
Author:
Dan Ellentuck (de3@columbia.edu)

Field Summary
private static java.lang.String ACTIVITY_COLUMN
           
private static java.lang.String allPermissionColumnsSql
           
private static java.lang.String deletePermissionSql
           
private static java.lang.String EFFECTIVE_COLUMN
           
private static java.lang.String EXPIRES_COLUMN
           
private static java.lang.String findPermissionSql
           
private static java.lang.String insertPermissionSql
           
private static org.apache.commons.logging.Log log
           
private static java.lang.String OWNER_COLUMN
           
private static java.lang.String PERMISSION_TABLE
           
private static java.lang.String PRINCIPAL_KEY_COLUMN
           
private static java.lang.String PRINCIPAL_SEPARATOR
           
private static java.lang.String PRINCIPAL_TYPE_COLUMN
           
private static java.lang.String selectPermissionSql
           
private static RDBMPermissionImpl singleton
           
private static java.lang.String TARGET_COLUMN
           
private static boolean timestampHasMillis
           
private static java.lang.String TYPE_COLUMN
           
private static java.lang.String updatePermissionSql
           
 
Constructor Summary
RDBMPermissionImpl()
          RDBMReferencePermission constructor comment.
 
Method Summary
 void add(IPermission perm)
          Add the IPermission to the store.
 void add(IPermission[] perms)
          Add the IPermissions to the store.
 void delete(IPermission perm)
          Delete a single IPermission from the store.
 void delete(IPermission[] perms)
          Delete the IPermissions from the store.
 boolean existsInDatabase(IPermission perm)
          Answer if this entity exists in the database.
private static java.lang.String getAllPermissionColumnsSql()
           
private static java.lang.String getDeletePermissionSql()
           
private static java.lang.String getFindPermissionSql()
          Insert the method's description here.
private static java.lang.String getInsertPermissionSql()
           
private  java.lang.String getPrincipalKey(IPermission perm)
          Returns the principal key portion of the IPermission principal.
private  java.lang.String getPrincipalKey(java.lang.String principalString)
          Returns the principal key portion of the IPermission principal.
private  int getPrincipalType(IPermission perm)
          Returns the principal type portion of the IPermission principal.
private  int getPrincipalType(java.lang.String principalString)
          Returns the principal type portion of the principal.
private static java.lang.String getSelectPermissionSql()
           
private static long getTimestampMillis(java.sql.Timestamp ts)
           
private static java.lang.String getUpdatePermissionSql()
           
private  IPermission instanceFromResultSet(java.sql.ResultSet rs)
           
 IPermission newInstance(java.lang.String owner)
          Factory method for IPermissions
private  void primAdd(IPermission[] perms)
          Add the IPermissions to the store.
private  void primAdd(IPermission perm, java.sql.PreparedStatement ps)
          Set the params on the PreparedStatement and execute the insert.
private  void primDelete(IPermission[] perms)
          Delete the IPermissions from the store.
private  int primDelete(IPermission perm, java.sql.PreparedStatement ps)
          Set the params on the PreparedStatement and execute the delete.
private  void primUpdate(IPermission[] perms)
          Update the IPermissions in the store.
private  int primUpdate(IPermission perm, java.sql.PreparedStatement ps)
          Set the params on the PreparedStatement and execute the update.
 IPermission[] select(java.lang.String owner, java.lang.String principal, java.lang.String activity, java.lang.String target, java.lang.String type)
          Select the Permissions from the store.
static RDBMPermissionImpl singleton()
           
 void update(IPermission perm)
          Update a single IPermission in the store.
 void update(IPermission[] perms)
          Update the IPermissions in the store.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

private static final org.apache.commons.logging.Log log

singleton

private static RDBMPermissionImpl singleton

timestampHasMillis

private static boolean timestampHasMillis

PERMISSION_TABLE

private static java.lang.String PERMISSION_TABLE

OWNER_COLUMN

private static java.lang.String OWNER_COLUMN

PRINCIPAL_TYPE_COLUMN

private static java.lang.String PRINCIPAL_TYPE_COLUMN

PRINCIPAL_KEY_COLUMN

private static java.lang.String PRINCIPAL_KEY_COLUMN

ACTIVITY_COLUMN

private static java.lang.String ACTIVITY_COLUMN

TARGET_COLUMN

private static java.lang.String TARGET_COLUMN

TYPE_COLUMN

private static java.lang.String TYPE_COLUMN

EFFECTIVE_COLUMN

private static java.lang.String EFFECTIVE_COLUMN

EXPIRES_COLUMN

private static java.lang.String EXPIRES_COLUMN

allPermissionColumnsSql

private static java.lang.String allPermissionColumnsSql

deletePermissionSql

private static java.lang.String deletePermissionSql

findPermissionSql

private static java.lang.String findPermissionSql

insertPermissionSql

private static java.lang.String insertPermissionSql

selectPermissionSql

private static java.lang.String selectPermissionSql

updatePermissionSql

private static java.lang.String updatePermissionSql

PRINCIPAL_SEPARATOR

private static java.lang.String PRINCIPAL_SEPARATOR
Constructor Detail

RDBMPermissionImpl

public RDBMPermissionImpl()
RDBMReferencePermission constructor comment.

Method Detail

add

public void add(IPermission[] perms)
         throws AuthorizationException
Add the IPermissions to the store.

Specified by:
add in interface IPermissionStore
Parameters:
perms - org.jasig.portal.security.IPermission[]
Throws:
AuthorizationException - - wraps an Exception specific to the store.

add

public void add(IPermission perm)
         throws AuthorizationException
Add the IPermission to the store.

Specified by:
add in interface IPermissionStore
Parameters:
perm - org.jasig.portal.security.IPermission
Throws:
AuthorizationException - - wraps an Exception specific to the store.

delete

public void delete(IPermission[] perms)
            throws AuthorizationException
Delete the IPermissions from the store.

Specified by:
delete in interface IPermissionStore
Parameters:
perms - org.jasig.portal.security.IPermission[]
Throws:
AuthorizationException - - wraps an Exception specific to the store.

delete

public void delete(IPermission perm)
            throws AuthorizationException
Delete a single IPermission from the store.

Specified by:
delete in interface IPermissionStore
Parameters:
perm - org.jasig.portal.security.IPermission
Throws:
AuthorizationException - - wraps an Exception specific to the store.

existsInDatabase

public boolean existsInDatabase(IPermission perm)
                         throws AuthorizationException,
                                java.sql.SQLException
Answer if this entity exists in the database.

Parameters:
perm - org.jasig.portal.security.IPermission
Returns:
boolean
Throws:
java.sql.SQLException
AuthorizationException

getAllPermissionColumnsSql

private static java.lang.String getAllPermissionColumnsSql()
Returns:
java.lang.String

getDeletePermissionSql

private static java.lang.String getDeletePermissionSql()
Returns:
java.lang.String

getFindPermissionSql

private static java.lang.String getFindPermissionSql()
Insert the method's description here. Creation date: (11/6/01 5:19:57 PM)

Returns:
java.lang.String

getInsertPermissionSql

private static java.lang.String getInsertPermissionSql()
Returns:
java.lang.String

getPrincipalKey

private java.lang.String getPrincipalKey(java.lang.String principalString)
Returns the principal key portion of the IPermission principal.

Parameters:
principalString -
Returns:
String

getPrincipalKey

private java.lang.String getPrincipalKey(IPermission perm)
                                  throws AuthorizationException
Returns the principal key portion of the IPermission principal.

Parameters:
perm - org.jasig.portal.security.IPermission
Returns:
String
Throws:
AuthorizationException

getPrincipalType

private int getPrincipalType(java.lang.String principalString)
Returns the principal type portion of the principal.

Parameters:
principalString -
Returns:
int

getPrincipalType

private int getPrincipalType(IPermission perm)
                      throws AuthorizationException
Returns the principal type portion of the IPermission principal.

Parameters:
perm - org.jasig.portal.security.IPermission
Returns:
int
Throws:
AuthorizationException

getSelectPermissionSql

private static java.lang.String getSelectPermissionSql()
Returns:
java.lang.String

getUpdatePermissionSql

private static java.lang.String getUpdatePermissionSql()
Returns:
java.lang.String

instanceFromResultSet

private IPermission instanceFromResultSet(java.sql.ResultSet rs)
                                   throws java.sql.SQLException
Parameters:
rs - java.sql.ResultSet
Returns:
org.jasig.portal.security.IPermission
Throws:
java.sql.SQLException

newInstance

public IPermission newInstance(java.lang.String owner)
Factory method for IPermissions

Specified by:
newInstance in interface IPermissionStore

primAdd

private void primAdd(IPermission[] perms)
              throws java.lang.Exception
Add the IPermissions to the store.

Parameters:
perms - org.jasig.portal.security.IPermission[]
Throws:
java.lang.Exception

primAdd

private void primAdd(IPermission perm,
                     java.sql.PreparedStatement ps)
              throws java.lang.Exception
Set the params on the PreparedStatement and execute the insert.

Parameters:
perm - org.jasig.portal.security.IPermission
ps - java.sql.PreparedStatement - the PreparedStatement for inserting a Permission row.
Throws:
java.lang.Exception

primDelete

private void primDelete(IPermission[] perms)
                 throws java.lang.Exception
Delete the IPermissions from the store.

Parameters:
perms - org.jasig.portal.security.IPermission[]
Throws:
java.lang.Exception

primDelete

private int primDelete(IPermission perm,
                       java.sql.PreparedStatement ps)
                throws java.lang.Exception
Set the params on the PreparedStatement and execute the delete.

Parameters:
perm - org.jasig.portal.security.IPermission
ps - java.sql.PreparedStatement - the PreparedStatement for deleting a Permission row.
Returns:
int - the return code from the PreparedStatement
Throws:
java.lang.Exception

primUpdate

private void primUpdate(IPermission[] perms)
                 throws java.lang.Exception
Update the IPermissions in the store.

Parameters:
perms - org.jasig.portal.security.IPermission[]
Throws:
java.lang.Exception

primUpdate

private int primUpdate(IPermission perm,
                       java.sql.PreparedStatement ps)
                throws java.lang.Exception
Set the params on the PreparedStatement and execute the update.

Parameters:
perm - org.jasig.portal.security.IPermission
ps - java.sql.PreparedStatement - the PreparedStatement for updating a Permission row.
Returns:
int - the return code from the PreparedStatement
Throws:
java.lang.Exception

select

public IPermission[] select(java.lang.String owner,
                            java.lang.String principal,
                            java.lang.String activity,
                            java.lang.String target,
                            java.lang.String type)
                     throws AuthorizationException
Select the Permissions from the store.

Specified by:
select in interface IPermissionStore
Parameters:
owner - String - the Permission owner
principal - String - the Permission principal
activity - String - the Permission activity
target - String - the Permission target
type - String - the Permission type
Throws:
AuthorizationException - - wraps an Exception specific to the store.

singleton

public static RDBMPermissionImpl singleton()
Returns:
org.jasig.portal.security.provider.RDBMPermissionImpl

update

public void update(IPermission[] perms)
            throws AuthorizationException
Update the IPermissions in the store.

Specified by:
update in interface IPermissionStore
Parameters:
perms - org.jasig.portal.security.IPermission[]
Throws:
AuthorizationException - - wraps an Exception specific to the store.

update

public void update(IPermission perm)
            throws AuthorizationException
Update a single IPermission in the store.

Specified by:
update in interface IPermissionStore
Parameters:
perm - org.jasig.portal.security.IPermission
Throws:
AuthorizationException - - wraps an Exception specific to the store.

getTimestampMillis

private static long getTimestampMillis(java.sql.Timestamp ts)
Returns:
long