org.mentawai.authorization
Class DBAuthorizationGroup

java.lang.Object
  extended by org.mentawai.authorization.DBAuthorizationGroup

public class DBAuthorizationGroup
extends Object

The DBAuthorizationGroup that will load groups and/or permissions with exists from a database. All you have to do is provide: - the names of the key columns - the names of the value columns - the names of the tables - the column to sort

Since:
1.12
Author:
Leiber Wallace Bento de Sousa

Constructor Summary
DBAuthorizationGroup(String sql)
          Set the SQL command to load groups and permissions from data base.
DBAuthorizationGroup(String tableGroup, String keyGroup, String valueGroup)
          Get a groups only.
DBAuthorizationGroup(String tableGroup, String keyGroup, String valueGroup, String sqlWhere)
          Get a groups using a command SQL WHERE
DBAuthorizationGroup(String tableGroup, String keyGroup, String valueGroup, String tablePermission, String valuePermission)
          Get a groups and permissions (OneToMany)
DBAuthorizationGroup(String tableGroup, String keyGroup, String valueGroup, String tablePermission, String valuePermission, String sqlWhere)
          Get a groups and permissions (OneToMany) using a command SQL WHERE
DBAuthorizationGroup(String tableGroup, String keyGroup, String valueGroup, String tableReference, String keyPermissionReference, String keyGroupReference, String tablePermission, String keyPermission, String valuePermission)
          Get a groups and permissions (ManyToMany)
DBAuthorizationGroup(String tableGroup, String keyGroup, String valueGroup, String tableReference, String keyPermissionReference, String keyGroupReference, String tablePermission, String keyPermission, String valuePermission, String sqlWhere)
          Get a groups and permissions (ManyToMany)
 
Method Summary
protected  String buildSQL()
          Build the SQL command using the parameters from the DBAuthorizationGroup to get the groups and permissions (if exists) from database!
 void load(Connection conn)
          Call this method passing a db connection to load the groups/permissions from database and adding in AuthorizationManager using the add(Group); The SQL statement that will be constructed:
 List<Group> loadGroupList(Connection conn)
          Call this method if you need to get a list of groups and permissions (if exists) The SQL statement that will be constructed:
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DBAuthorizationGroup

public DBAuthorizationGroup(String sql)
Set the SQL command to load groups and permissions from data base.

Parameters:
sql -

DBAuthorizationGroup

public DBAuthorizationGroup(String tableGroup,
                            String keyGroup,
                            String valueGroup)
Get a groups only.

Parameters:
tableGroup - name of table.
keyGroup - name of field contain a ID (key)
valueGroup - name of field contain a Name.

DBAuthorizationGroup

public DBAuthorizationGroup(String tableGroup,
                            String keyGroup,
                            String valueGroup,
                            String sqlWhere)
Get a groups using a command SQL WHERE

Parameters:
tableGroup - name of table.
keyGroup - name of field contain a ID (key)
valueGroup - name of field contain a Name.
sqlWhere - contain a command SQL WHERE, Ex. WHERE group.id < 5.

DBAuthorizationGroup

public DBAuthorizationGroup(String tableGroup,
                            String keyGroup,
                            String valueGroup,
                            String tablePermission,
                            String valuePermission)
Get a groups and permissions (OneToMany)

Parameters:
tableGroup - name of table.
keyGroup - name of field contain a ID (key)
valueGroup - name of field contain a Name.
tablePermission - name of table contain the permissions.
valuePermission - name of field contain the permissions.

DBAuthorizationGroup

public DBAuthorizationGroup(String tableGroup,
                            String keyGroup,
                            String valueGroup,
                            String tablePermission,
                            String valuePermission,
                            String sqlWhere)
Get a groups and permissions (OneToMany) using a command SQL WHERE

Parameters:
tableGroup - name of table.
keyGroup - name of field contain a ID (key)
valueGroup - name of field contain a Name.
tablePermission - name of table contain the permissions.
valuePermission - name of field contain the name of permission.
sqlWhere - contain a command SQL WHERE, Ex. WHERE group.id < 5 and permission < 2.

DBAuthorizationGroup

public DBAuthorizationGroup(String tableGroup,
                            String keyGroup,
                            String valueGroup,
                            String tableReference,
                            String keyPermissionReference,
                            String keyGroupReference,
                            String tablePermission,
                            String keyPermission,
                            String valuePermission)
Get a groups and permissions (ManyToMany)

Parameters:
tableGroup - name of table.
keyGroup - name of field contain a ID (key)
valueGroup - name of field contain a Name.
tableReference - name of table contain the IDs groups and permissions.
keyPermissionReference - name of field contain the permissions Id.
keyGroupReference - name of field contain the groups Id.
tablePermission - name of table contain permissions.
keyPermission - name of field contain the id of permission.
valuePermission - name of field contain the name of permission.

DBAuthorizationGroup

public DBAuthorizationGroup(String tableGroup,
                            String keyGroup,
                            String valueGroup,
                            String tableReference,
                            String keyPermissionReference,
                            String keyGroupReference,
                            String tablePermission,
                            String keyPermission,
                            String valuePermission,
                            String sqlWhere)
Get a groups and permissions (ManyToMany)

Parameters:
tableGroup - name of table.
keyGroup - name of field contain a ID (key)
valueGroup - name of field contain a Name.
tableReference - name of table contain the IDs groups and permissions.
keyPermissionReference - name of field contain the permissions Id.
keyGroupReference - name of field contain the groups Id.
tablePermission - name of table contain permissions.
keyPermission - name of field contain the id of permission.
valuePermission - name of field contain the name of permission.
sqlWhere - contain a command SQL WHERE, Ex. WHERE group_permission.group_id = 2.
Method Detail

buildSQL

protected String buildSQL()
Build the SQL command using the parameters from the DBAuthorizationGroup to get the groups and permissions (if exists) from database!


load

public void load(Connection conn)
          throws SQLException
Call this method passing a db connection to load the groups/permissions from database and adding in AuthorizationManager using the add(Group); The SQL statement that will be constructed:

Parameters:
conn -
Throws:
SQLException

loadGroupList

public List<Group> loadGroupList(Connection conn)
                          throws SQLException
Call this method if you need to get a list of groups and permissions (if exists) The SQL statement that will be constructed:

Parameters:
conn -
Returns:
List List of groups with permissions (if exists)
Throws:
SQLException


Copyright © 2013. All Rights Reserved.