com.cinecolombia.component.Security.ejb
Class SecurityDAO

java.lang.Object
  |
  +--com.cinecolombia.component.Security.ejb.SecurityDAO

public class SecurityDAO
extends java.lang.Object

This class has JDBC calls required by Security EJB for implementing its services

Author:
CincoSOFT
Created:
Junio 2003

Field Summary
private  java.lang.String companyId
          current company
private  javax.sql.DataSource datasource
          datasource corresponding to the database
private  java.sql.Connection dbConnection
          connection with the database
private  Debug debug
          The ubiquitous debugging object.
private  java.lang.Long userId
          current user
 
Constructor Summary
SecurityDAO(java.lang.String companyId, java.lang.Long userId)
           
 
Method Summary
private  int auxGetNullInt(java.sql.ResultSet rs, int index)
          metodo auxiliar que obtiene un valor int de un Resultset, posiblemente null,
private  long auxGetNullLong(java.sql.ResultSet rs, int index)
          metodo auxiliar que obtiene un valor long de un Resultset, posiblemente null,
private  java.util.ArrayList auxLoadUserModulosConPermisos(java.sql.ResultSet rs)
          Auxiliary method of LoadUserModulosConPermisos
private  void auxSetNullDate(java.sql.PreparedStatement ps, java.sql.Date value, int index)
          metodo auxiliar que asigna un valor, posiblemente null, a un parametro Date de un PreparedStatement
private  void auxSetNullInt(java.sql.PreparedStatement ps, int value, int index)
          metodo auxiliar que asigna un valor, posiblemente null, a un parametro int de un PreparedStatement
private  void auxSetNullLong(java.sql.PreparedStatement ps, long value, int index)
          metodo auxiliar que asigna un valor, posiblemente null, a un parametro long de un PreparedStatement
private  void auxSetNullString(java.sql.PreparedStatement ps, java.lang.String value, int index)
          metodo auxiliar que asigna un valor, posiblemente null, a un parametro String de un PreparedStatement
 java.util.ArrayList getUserProfile(java.lang.String userName, java.lang.String companyNumber)
          Loads user profile: global data and security user actions from DatabaseNames.COMPANIA, USUARIO, COMPANIA, USUARIO_CASOUSO_ACCION
 java.util.Hashtable getUsersRoles()
          Loads users and associated roles of the system from DatabaseNames.USUARIO_ROL view
 void inactivateUser(long idUsuario)
          set user to inactive state in DatabaseNames.USUARIO
 ParametrosGlobalesModel loadCompany()
          Get global parameters of current company from DatabaseNames.COMPANIA table
 Profile loadProfile(long idProfile)
          Get complete data of a profile from DatabaseNames.PERFIL,DatabaseNames.MODULO, DatabaseNames.CASO_USO, DatabaseNames.ACCION, DatabaseNames.ACCION_PERFIL
 java.util.ArrayList loadSystemProfiles()
          Get list of system profiles ordered by nombre_perfil from DatabaseNames.PERFIL
 User loadUser(long idUsuario)
          Get data of selected user from DatabaseNames.USUARIO
 java.util.ArrayList loadUserModulosConPermisos(long idUsuario)
          Get list of system modules and the permissions of user from DatabaseNames.PERMISO_PERFIL and DatabaseNames.PERMISO_ESPECIAL views, DatabaseNames.MODULO, DatabaseNames.CASO_USO and DatabaseNames.ACCION tables
 java.util.ArrayList loadUserProfiles(long idUsuario)
          Get list of user profiles (for a specific user) ordered by nombre_perfil from DatabaseNames.PERFIL, REL_PERFIL_USUARIO
 java.util.ArrayList loadUsers()
          Get list of active users (except the SUPERUSER) ordered by codigoUsuario from DatabaseNames.USUARIO
 void removeProfile(long idProfile)
          Remove complete data of a profile
 void revokePermisosUsuario(long idUsuario, long[] codigosRevocados)
          Revoke every especial permissions of user in DatabaseNames.ACCION_USUARIO table
 void setState(java.lang.String companyId, java.lang.Long userId)
          Set value of attributes
 void storePermisosUsuario(long idUsuario, AccionPermisoEspecial accionesPermisoEspecial)
          Save new especial permissions of user in DatabaseNames.ACCION_USUARIO table
 void storeProfile(long idProfile, java.lang.String profileName, long[] allowedActions)
          Set complete data of a profile into DatabaseNames.PERFIL and DatabaseNames.ACCION_PERFIL
 void storeUser(User user, long[] userProfilesCodes)
          Store user in DatabaseNames.USUARIO, REL_PERFIL_USUARIO
 void updateCompany(ParametrosGlobalesValue value)
          Set global parameters of current company into from DatabaseNames.COMPANIA table
 void updatePassword(java.lang.String newPassword)
          Update the password of the user from DatabaseNames.USUARIO table
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

companyId

private java.lang.String companyId
current company


userId

private java.lang.Long userId
current user


dbConnection

private java.sql.Connection dbConnection
connection with the database


datasource

private javax.sql.DataSource datasource
datasource corresponding to the database


debug

private Debug debug
The ubiquitous debugging object.

Constructor Detail

SecurityDAO

public SecurityDAO(java.lang.String companyId,
                   java.lang.Long userId)
            throws DAOException
Parameters:
companyId - current company
userId - current user
Throws:
DAOException - Description of the Exception
Method Detail

getUserProfile

public java.util.ArrayList getUserProfile(java.lang.String userName,
                                          java.lang.String companyNumber)
                                   throws DAOException
Loads user profile: global data and security user actions from DatabaseNames.COMPANIA, USUARIO, COMPANIA, USUARIO_CASOUSO_ACCION

Parameters:
userName - Description of the Parameter
companyNumber - Description of the Parameter
Returns:
ArrayList with 2 elements: userGlobals: String[] composed of: companyName, userId, companySessionTime, companyId, password userActions: Hashtable of: (usecase, useCaseActions) where useCaseActions is an ArrayList of actions and each action is a String
Throws:
DAOException

getUsersRoles

public java.util.Hashtable getUsersRoles()
                                  throws DAOException
Loads users and associated roles of the system from DatabaseNames.USUARIO_ROL view

Returns:
Hashtable of: (user, userRoles) where user is a String (codigo_usuario), userRoles is an ArrayList of roles and each role is a String
Throws:
DAOException

setState

public void setState(java.lang.String companyId,
                     java.lang.Long userId)
Set value of attributes

Parameters:
companyId -
userId -

loadUsers

public java.util.ArrayList loadUsers()
                              throws DAOException
Get list of active users (except the SUPERUSER) ordered by codigoUsuario from DatabaseNames.USUARIO

Returns:
ArrayList where each element is a User
Throws:
DAOException

loadSystemProfiles

public java.util.ArrayList loadSystemProfiles()
                                       throws DAOException
Get list of system profiles ordered by nombre_perfil from DatabaseNames.PERFIL

Returns:
ArrayList where each element is a CodeDescription composed by: (codigo_perfil, nombre_perfil)
Throws:
DAOException

loadUser

public User loadUser(long idUsuario)
              throws DAOException
Get data of selected user from DatabaseNames.USUARIO

Parameters:
idUsuario - Description of the Parameter
Returns:
User with data of user
Throws:
DAOException

loadUserProfiles

public java.util.ArrayList loadUserProfiles(long idUsuario)
                                     throws DAOException
Get list of user profiles (for a specific user) ordered by nombre_perfil from DatabaseNames.PERFIL, REL_PERFIL_USUARIO

Parameters:
idUsuario - Description of the Parameter
Returns:
ArrayList where each element is a CodeDescription composed by: (codigo_perfil, nombre_perfil)
Throws:
DAOException

storeUser

public void storeUser(User user,
                      long[] userProfilesCodes)
               throws DAOException
Store user in DatabaseNames.USUARIO, REL_PERFIL_USUARIO

Parameters:
user - data of the user
userProfilesCodes - profiles of the user
Throws:
DAOException

inactivateUser

public void inactivateUser(long idUsuario)
                    throws DAOException
set user to inactive state in DatabaseNames.USUARIO

Parameters:
idUsuario - identifier of the user
Throws:
DAOException

updatePassword

public void updatePassword(java.lang.String newPassword)
                    throws DAOException
Update the password of the user from DatabaseNames.USUARIO table

Parameters:
newPassword - new password of the user
Throws:
DAOException

loadProfile

public Profile loadProfile(long idProfile)
                    throws DAOException
Get complete data of a profile from DatabaseNames.PERFIL,DatabaseNames.MODULO, DatabaseNames.CASO_USO, DatabaseNames.ACCION, DatabaseNames.ACCION_PERFIL

Parameters:
idProfile - code of Profile
Returns:
profile Object composed by profiles' information(Profile Module, UseCase and Action).
Throws:
DAOException

storeProfile

public void storeProfile(long idProfile,
                         java.lang.String profileName,
                         long[] allowedActions)
                  throws DAOException
Set complete data of a profile into DatabaseNames.PERFIL and DatabaseNames.ACCION_PERFIL

Parameters:
idProfile - Code of Profile
profileName - Name of Perfil
allowedActions - List of actions allowed
Throws:
DAOException

removeProfile

public void removeProfile(long idProfile)
                   throws DAOException
Remove complete data of a profile

Parameters:
idProfile - Code of Profile
Throws:
DAOException

loadCompany

public ParametrosGlobalesModel loadCompany()
                                    throws DAOException
Get global parameters of current company from DatabaseNames.COMPANIA table

Returns:
answer ParametrosGlobalesModel Object.
Throws:
DAOException

updateCompany

public void updateCompany(ParametrosGlobalesValue value)
                   throws DAOException
Set global parameters of current company into from DatabaseNames.COMPANIA table

Parameters:
value - ParametrosGlobalesValue Object.
Throws:
DAOException

loadUserModulosConPermisos

public java.util.ArrayList loadUserModulosConPermisos(long idUsuario)
                                               throws DAOException
Get list of system modules and the permissions of user from DatabaseNames.PERMISO_PERFIL and DatabaseNames.PERMISO_ESPECIAL views, DatabaseNames.MODULO, DatabaseNames.CASO_USO and DatabaseNames.ACCION tables

Parameters:
idUsuario - Code of user
Returns:
answer ArrayList where each element is a ModuloConPermisos
Throws:
DAOException

revokePermisosUsuario

public void revokePermisosUsuario(long idUsuario,
                                  long[] codigosRevocados)
                           throws DAOException
Revoke every especial permissions of user in DatabaseNames.ACCION_USUARIO table

Parameters:
idUsuario - User code
codigosRevocados - List of revoked especial permissions
Throws:
DAOException

storePermisosUsuario

public void storePermisosUsuario(long idUsuario,
                                 AccionPermisoEspecial accionesPermisoEspecial)
                          throws DAOException
Save new especial permissions of user in DatabaseNames.ACCION_USUARIO table

Parameters:
idUsuario - User code
accionesPermisoEspecial - Set of new especial permissions
Throws:
DAOException

auxLoadUserModulosConPermisos

private java.util.ArrayList auxLoadUserModulosConPermisos(java.sql.ResultSet rs)
                                                   throws java.lang.Exception
Auxiliary method of LoadUserModulosConPermisos

Parameters:
rs - ResultSet
Returns:
answer ArrayList where each element is a ModuloConPermisos
Throws:
java.lang.Exception

auxSetNullString

private void auxSetNullString(java.sql.PreparedStatement ps,
                              java.lang.String value,
                              int index)
                       throws java.lang.Exception
metodo auxiliar que asigna un valor, posiblemente null, a un parametro String de un PreparedStatement

Parameters:
ps - el PreparedStatement
value - el String posiblemente null
index - indice del parametro a asignar.
Throws:
java.lang.Exception

auxSetNullDate

private void auxSetNullDate(java.sql.PreparedStatement ps,
                            java.sql.Date value,
                            int index)
                     throws java.lang.Exception
metodo auxiliar que asigna un valor, posiblemente null, a un parametro Date de un PreparedStatement

Parameters:
ps - el PreparedStatement
value - el Date posiblemente null
index - indice del parametro a asignar.
Throws:
java.lang.Exception

auxSetNullLong

private void auxSetNullLong(java.sql.PreparedStatement ps,
                            long value,
                            int index)
                     throws java.lang.Exception
metodo auxiliar que asigna un valor, posiblemente null, a un parametro long de un PreparedStatement

Parameters:
ps - el PreparedStatement
value - si es UNDEF, se asignara null a ps, si no el value
index - indice del parametro a asignar.
Throws:
java.lang.Exception

auxSetNullInt

private void auxSetNullInt(java.sql.PreparedStatement ps,
                           int value,
                           int index)
                    throws java.lang.Exception
metodo auxiliar que asigna un valor, posiblemente null, a un parametro int de un PreparedStatement

Parameters:
ps - el PreparedStatement
value - si es UNDEF, se asignara null a ps, si no el value
index - indice del parametro a asignar.
Throws:
java.lang.Exception

auxGetNullLong

private long auxGetNullLong(java.sql.ResultSet rs,
                            int index)
                     throws java.lang.Exception
metodo auxiliar que obtiene un valor long de un Resultset, posiblemente null,

Parameters:
rs - el Resultset
index - indice del parametro a obtener.
Returns:
valor long obtenido: si viene e null de la BD se transforma en UNDEF
Throws:
java.lang.Exception

auxGetNullInt

private int auxGetNullInt(java.sql.ResultSet rs,
                          int index)
                   throws java.lang.Exception
metodo auxiliar que obtiene un valor int de un Resultset, posiblemente null,

Parameters:
rs - el Resultset
index - indice del parametro a obtener.
Returns:
valor int obtenido: si viene e null de la BD se transforma en UNDEF
Throws:
java.lang.Exception