gov.nih.nci.caarray.services.security
Class SecurityAdminService

java.lang.Object
  extended by gov.nih.nci.caarray.services.util.db.ManagerDB
      extended by gov.nih.nci.caarray.services.security.SecurityAdminService

public class SecurityAdminService
extends ManagerDB

This class provides the security admin services such as the creation/update/deletion of a protection element and assigning/de-assigning a protection element to a role.

Version:
1.0
Author:
Q. Pan

Field Summary
 
Fields inherited from class gov.nih.nci.caarray.services.util.db.ManagerDB
CASCADE_LINK, CASCADE_NONE, CASCADE_OBJECT, ID_UNSET
 
Constructor Summary
SecurityAdminService()
          Constructor for a new SecurityAdminService object.
 
Method Summary
 void assignElementToRole(long protectElemId, java.lang.String roleName)
          Assign a protection element to a role.
 boolean checkAdminRole(java.lang.String userName)
           
 int createProtectionElem_Refactored(java.lang.String applicationName, java.lang.String objectId, java.lang.String attrName, java.lang.String elemName, java.lang.String elemDesc, java.lang.String ownerLoginName, ProtectionGroupData[] protectionGroups)
          Create a protection element.
 int createProtectionElem(java.lang.String applicationName, java.lang.String objectId, java.lang.String attrName, java.lang.String elemName, java.lang.String elemDesc, java.lang.String ownerLoginName, ProtectionGroupData[] protectionGroups)
          Create a protection element.
 int deassignElementToRole(long protectElementId, java.lang.String roleName)
          Deprecated. Not used, marked for removal
 int deassignProtectionElementOwner(java.lang.String objectId)
          Unset a Protected Element Owner as the data is public
 void deleteProtectionElem(long protectElemId)
          Delete a protection element.
 java.lang.String getCaseSensitivityUserName(java.lang.String userName)
           
 ProtectionGroupData[] getElementGroups(java.lang.String objectId)
          Returns an array of ProtectionGroups with which the protectionElement is associated
 boolean getIsActiveUser(java.lang.String userName)
           
 long getProtectionElementID(java.lang.String objectId, java.lang.String applicationName)
          Returns protection elementID based on object ID and the application name
 ProtectionGroupData[] getProtectionGroups()
          Returns an array of ProtectionGroups which are present in the application.
 long[] getSequencesById(int numberOfSequences, java.lang.Class classDesc)
           
 UserDesc[] getUsers()
          Returns an array of ProtectionGroups which are present in the application.
static void main(java.lang.String[] args)
          Used for test only.
 void removeSecuredElemProtectionGroups(java.lang.String objectId, ProtectionGroupData[] protectionGroups)
          remove Protection/Group association from AS_PROTECTION_GROUP_ELEMENT table.
 int setProtectionElementOwner(java.lang.String objectId, java.lang.String ownerLoginName)
          Update a protection element owner.
 void setSecuredElemProtectionGroups(java.lang.String objectId, ProtectionGroupData[] protectionGroups)
          Insert a protection element to AS_PROTECTION_GROUP_ELEMENT table.
 void updateProtectionElem(long protectElemId, java.lang.String objectId, java.lang.String attrName, java.lang.String elemName, java.lang.String elemDesc, java.lang.String ownerLoginName)
          Update a protection element.
 void updateSecuredElemProtectionGroups(java.lang.String objectId, ProtectionGroupData[] protectionGroups)
          Update ProtectionGroups associated with a protection element to AS_PROTECTION_GROUP_ELEMENT table.
 
Methods inherited from class gov.nih.nci.caarray.services.util.db.ManagerDB
clearCache, close, countObjects, countObjects, deleteByQuery, deleteMtoNRelation, deleteObject, deleteObject, deleteObject, deleteObjectByQuery, exists, getIdentifiable, getObject, getObject, getObject, getObject, getObject, getObject, getObjectIterator, getObjectIterator, getObjects, getObjects, getObjects, getPersistenceBroker, getSqlInLimit, insertMtoNRelation, insertMtoNRelation, insertObject, insertObject, link, link, removeFromCache, retrieveReference, retrieveReferences, setCascadeDelete, setCascadeRetrieve, setCascadeStore, storeObject, storeObject, unlink, unlink, updateObject, updateObject
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SecurityAdminService

public SecurityAdminService()
Constructor for a new SecurityAdminService object.

Method Detail

getUsers

public UserDesc[] getUsers()
                    throws DBException
Returns an array of ProtectionGroups which are present in the application.

Returns:
an array of ProtectionGroups
Throws:
DBException

checkAdminRole

public boolean checkAdminRole(java.lang.String userName)
                       throws DBException
Throws:
DBException

getIsActiveUser

public boolean getIsActiveUser(java.lang.String userName)
                        throws DBException
Throws:
DBException

getSequencesById

public long[] getSequencesById(int numberOfSequences,
                               java.lang.Class classDesc)

createProtectionElem

public int createProtectionElem(java.lang.String applicationName,
                                java.lang.String objectId,
                                java.lang.String attrName,
                                java.lang.String elemName,
                                java.lang.String elemDesc,
                                java.lang.String ownerLoginName,
                                ProtectionGroupData[] protectionGroups)
                         throws DBException
Create a protection element.

Parameters:
applicationName - application name
objectId - object ID
attrName - attribute name
elemName - element name
elemDesc - element description
ownerLoginName - element owner's login name
Returns:
1 if the protection element created successful
0 if fail to create the protection element
Throws:
DBException

createProtectionElem_Refactored

public int createProtectionElem_Refactored(java.lang.String applicationName,
                                           java.lang.String objectId,
                                           java.lang.String attrName,
                                           java.lang.String elemName,
                                           java.lang.String elemDesc,
                                           java.lang.String ownerLoginName,
                                           ProtectionGroupData[] protectionGroups)
                                    throws DBException
Create a protection element.

Parameters:
applicationName - application name
objectId - object ID
attrName - attribute name
elemName - element name
elemDesc - element description
ownerLoginName - element owner's login name
Returns:
1 if the protection element created successful
0 if fail to create the protection element
Throws:
DBException

setSecuredElemProtectionGroups

public void setSecuredElemProtectionGroups(java.lang.String objectId,
                                           ProtectionGroupData[] protectionGroups)
                                    throws DBException
Insert a protection element to AS_PROTECTION_GROUP_ELEMENT table. It assocaiates a protection element to protection group.

Parameters:
objectId - object id
protectionGroups - protection groups to which the object is associated
Throws:
DBException

updateSecuredElemProtectionGroups

public void updateSecuredElemProtectionGroups(java.lang.String objectId,
                                              ProtectionGroupData[] protectionGroups)
                                       throws DBException
Update ProtectionGroups associated with a protection element to AS_PROTECTION_GROUP_ELEMENT table. It updated the association from a protection element to protection group. It first deletes existing associations ant then adds new ones.

Parameters:
objectId - object id
protectionGroups - protection groups to which the object is to be associated
Throws:
DBException

removeSecuredElemProtectionGroups

public void removeSecuredElemProtectionGroups(java.lang.String objectId,
                                              ProtectionGroupData[] protectionGroups)
                                       throws DBException
remove Protection/Group association from AS_PROTECTION_GROUP_ELEMENT table. It assocaiates a protection element to protection group.

Parameters:
objectId - object id
protectionGroups - protection groups from which the object is dissociated
Throws:
DBException

updateProtectionElem

public void updateProtectionElem(long protectElemId,
                                 java.lang.String objectId,
                                 java.lang.String attrName,
                                 java.lang.String elemName,
                                 java.lang.String elemDesc,
                                 java.lang.String ownerLoginName)
                          throws DBException
Update a protection element.

Parameters:
protectElemId - protection element Id, a required field.
objectId - object ID, set to null if there is no change
attrName - attribute name, set to null if there is no change
elemName - element name, set to null if there is no change
elemDesc - element description, set to null if there is no change
ownerLoginName - element owner's login name, set to null if there is no change
Throws:
DBException

deleteProtectionElem

public void deleteProtectionElem(long protectElemId)
                          throws DBException
Delete a protection element.

Parameters:
protectElemId - protection element Id, a required field.
Throws:
DBException

assignElementToRole

public void assignElementToRole(long protectElemId,
                                java.lang.String roleName)
                         throws DBException
Assign a protection element to a role.

Parameters:
protectElemId - protection element Id
roleName - role name
Throws:
DBException

deassignElementToRole

public int deassignElementToRole(long protectElementId,
                                 java.lang.String roleName)
                          throws DBException
Deprecated. Not used, marked for removal

Deassign a protection Element from a role.

Parameters:
protectElemId - protection element Id
roleName - role name
Returns:
1 if the protection element created successful
0 if fail to create the protection element
Throws:
DBException

getProtectionGroups

public ProtectionGroupData[] getProtectionGroups()
                                          throws DBException
Returns an array of ProtectionGroups which are present in the application.

Returns:
an array of ProtectionGroups
Throws:
DBException

getElementGroups

public ProtectionGroupData[] getElementGroups(java.lang.String objectId)
                                       throws DBException
Returns an array of ProtectionGroups with which the protectionElement is associated

Parameters:
objectId - Id of the secured element
Returns:
an array of ProtectionGroups assocated with obejctId
Throws:
DBException

setProtectionElementOwner

public int setProtectionElementOwner(java.lang.String objectId,
                                     java.lang.String ownerLoginName)
                              throws DBException
Update a protection element owner.

Parameters:
objectId - application Object ID
ownerLoginName - element owner's login name,
Returns:
1 if the protection element created successful
0 if fail to create the protection element
Throws:
DBException

deassignProtectionElementOwner

public int deassignProtectionElementOwner(java.lang.String objectId)
                                   throws DBException
Unset a Protected Element Owner as the data is public

Parameters:
objectId - application Object ID
Returns:
1 if the protection element updated successful
0 if fail to update the protection element
Throws:
DBException

getProtectionElementID

public long getProtectionElementID(java.lang.String objectId,
                                   java.lang.String applicationName)
                            throws DBException
Returns protection elementID based on object ID and the application name

Parameters:
objectId - application Object ID
applicationName - element owner's login name,
Returns:
protection element ID.
null if protection element not found
Throws:
DBException

main

public static void main(java.lang.String[] args)
Used for test only.


getCaseSensitivityUserName

public java.lang.String getCaseSensitivityUserName(java.lang.String userName)
                                            throws DBException
Throws:
DBException