eu.xtreemos.xosd.security.rca.server
Class ResourceRegistration

java.lang.Object
  extended by eu.xtreemos.xosd.security.rca.server.ResourceRegistration
All Implemented Interfaces:
java.io.Serializable

public class ResourceRegistration
extends java.lang.Object
implements java.io.Serializable

The class representing the interface to the database of the registered resources for the Resource Certification Authority (RCA). The RCA database keeps a list of resources that are pending registration, and the ones having been registered. Anyone can apply for their resource to be registered, but only the authorised users should be able to grant the application, thus completing the registration of the resource. The resources that have been registered can have their resource certificates signed by the RCA.

Version:
0.01 The database has a form of a collection in RAM.
Author:
matej.artac@xlab.si
See Also:
Serialized Form

Field Summary
protected  java.util.Hashtable<java.lang.String,ResourceDescriptorRecord> appliedResources
          The collection of resources applied for the registration.
protected  java.lang.String dbAppliedStorageFile
          The filename where the applied resource database should (de)serialise.
protected  java.lang.String dbRegisteredStorageFile
          The filename where the registered resource database should (de)serialise.
(package private) static org.apache.log4j.Logger logger
           
protected  java.util.Hashtable<java.lang.String,ResourceDescriptorRecord> registeredResources
          The collection of resources that have been successfully registered.
protected  java.lang.String resourceRegistrationFile
          The filename for serialising the data into and the object from.
static java.lang.Integer ResourceStatusNone
          The status of the resource is none (neither applied nor registered).
static java.lang.Integer ResourceStatusPending
          The status of the resource is pending (applied for registration).
static java.lang.Integer ResourceStatusRegistered
          The status of the resource is registered.
 
Constructor Summary
ResourceRegistration()
           
ResourceRegistration(java.lang.String rcaDBFile)
          Provide the name if the file that is to be used for storing and loading the database.
 
Method Summary
 void applyForResourceRegistration(ResourceID id, ResourceDescriptorRecord resource)
          Adds the resource to the list of resources that are waiting to be confirmed for registration.
 void clear()
          Clears the collections containing pending and registered resources.
 ResourceDescriptorRecord confirmRegistration(ResourceID id)
          Confirms the resouce registration by moving the resource's entry from the pending resources collection to the registered resources collection.
protected  void finalize()
           
protected  java.util.Hashtable<java.lang.String,ResourceDescriptorRecord> getAppliedResources()
           
 java.util.ArrayList<ResourceDescriptorRecord> getPendingResources()
          Return a list of resources currently pending for registration.
 java.util.ArrayList<ResourceDescriptorRecord> getRegisteredResources()
          Return a list of currently registered resources.
protected  java.util.Hashtable<java.lang.String,ResourceDescriptorRecord> getRegisterefResourcesHT()
           
 ResourceDescriptorRecord getResource(ResourceID id)
          Checks whether the resource with the given id has been registered or is pending registration, and returns its description.
 java.lang.Integer getResourceStatus(ResourceID id)
          Check the status of the resource.
protected  void loadData()
           
 void registerResource(ResourceID id, ResourceDescriptorRecord resource)
          Adds a resource to the list of registered entries.
protected  void saveData()
           
 void setVOMembership(ResourceID id, java.lang.String vo, boolean setMember)
          Lets manipulate with the resource's membership of a VO.
 ResourceDescriptorRecord unregisterResource(ResourceID id)
          Remove the resource previously registered with the given id.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

static org.apache.log4j.Logger logger

ResourceStatusNone

public static final java.lang.Integer ResourceStatusNone
The status of the resource is none (neither applied nor registered).


ResourceStatusPending

public static final java.lang.Integer ResourceStatusPending
The status of the resource is pending (applied for registration).


ResourceStatusRegistered

public static final java.lang.Integer ResourceStatusRegistered
The status of the resource is registered.


appliedResources

protected java.util.Hashtable<java.lang.String,ResourceDescriptorRecord> appliedResources
The collection of resources applied for the registration. These are the resources that an admin has applied for the registration for, but the registration has not yet been confirmed by the authorised user.


registeredResources

protected java.util.Hashtable<java.lang.String,ResourceDescriptorRecord> registeredResources
The collection of resources that have been successfully registered.


dbAppliedStorageFile

protected java.lang.String dbAppliedStorageFile
The filename where the applied resource database should (de)serialise.


dbRegisteredStorageFile

protected java.lang.String dbRegisteredStorageFile
The filename where the registered resource database should (de)serialise.


resourceRegistrationFile

protected java.lang.String resourceRegistrationFile
The filename for serialising the data into and the object from.

Constructor Detail

ResourceRegistration

public ResourceRegistration()

ResourceRegistration

public ResourceRegistration(java.lang.String rcaDBFile)
Provide the name if the file that is to be used for storing and loading the database. The input parameter represents a basis for the file names of the files holding the collections.

Parameters:
rcaDBFile - The basis of the filenames of the serialised collections.
Method Detail

loadData

protected void loadData()
                 throws java.lang.Exception
Throws:
java.lang.Exception

saveData

protected void saveData()
                 throws java.lang.Exception
Throws:
java.lang.Exception

registerResource

public void registerResource(ResourceID id,
                             ResourceDescriptorRecord resource)
Adds a resource to the list of registered entries. This method bypasses the resource application, but if the resource with the given ID has been applied for registration, it removes the resource from the applicant resource collection.

Parameters:
id - The id of the resource, serving as the key to the resource.
resource - The description of the resource to be registered.

applyForResourceRegistration

public void applyForResourceRegistration(ResourceID id,
                                         ResourceDescriptorRecord resource)
Adds the resource to the list of resources that are waiting to be confirmed for registration. If the resource already exists on either the registered or the applied resource list, then the method updates the record with the new resource details.

Parameters:
id - The id of the resource, serving as the key to the resource.
resource - The description of the resource to be registered.

getResource

public ResourceDescriptorRecord getResource(ResourceID id)
Checks whether the resource with the given id has been registered or is pending registration, and returns its description.

Parameters:
id - The id of the resource to retrieve.
Returns:
The description of the resource that has been registered. Returns null if the resource with the provided id is not on the list of the registered resources.

confirmRegistration

public ResourceDescriptorRecord confirmRegistration(ResourceID id)
Confirms the resouce registration by moving the resource's entry from the pending resources collection to the registered resources collection. Returns null if the resouce is not on the pending resources list, effectively not registering anything.

Parameters:
id - The ID of the resource previously placed on the pending resource list.
Returns:
The description of the resource being confirmed. It will return the resource description if we are confirming an already confirmed resource. Returns null if the resource is not on the list of pending resources.

getResourceStatus

public java.lang.Integer getResourceStatus(ResourceID id)
Check the status of the resource. The method tells whether the resource with the given id is either registered, pending registration (applied) or none of the above.

Parameters:
id -
Returns:

unregisterResource

public ResourceDescriptorRecord unregisterResource(ResourceID id)
Remove the resource previously registered with the given id. The method removes the resource from the registered resources collection as well as from the collection of resources applied for registration.

Parameters:
id - The id of the resource to unregister.
Returns:
The resource description of the resource being unregistered. Returns null if the resource is not on the list of the registered nor pending resources.

getRegisteredResources

public java.util.ArrayList<ResourceDescriptorRecord> getRegisteredResources()
Return a list of currently registered resources.

Returns:
The collection of descriptions of the registered resources.

getPendingResources

public java.util.ArrayList<ResourceDescriptorRecord> getPendingResources()
Return a list of resources currently pending for registration.

Returns:
The collection of descriptions of the resources pending for registration.

getAppliedResources

protected java.util.Hashtable<java.lang.String,ResourceDescriptorRecord> getAppliedResources()

getRegisterefResourcesHT

protected java.util.Hashtable<java.lang.String,ResourceDescriptorRecord> getRegisterefResourcesHT()

setVOMembership

public void setVOMembership(ResourceID id,
                            java.lang.String vo,
                            boolean setMember)
                     throws ResourceNotRegisteredException
Lets manipulate with the resource's membership of a VO. The method can set and unset the VO which the resource belongs to. The resource has to be on a registered resources list. The membership of a resource in a VO is expressed by a list of VOs the resource is the member of, the list being a part of the resource description record. If we are setting the membership of a VO the resource is already a member of, then the list does not change.

Parameters:
id - The identification of the resource we are setting the membership in a VO of.
vo - The VO to set the membership in.
setMember - If true, the membership will be set, and if false, the VO will be removed from the list of VOs the resource is a member of.
Throws:
ResourceNotRegisteredException - If the resource is not on the list of the registered resources.

clear

public void clear()
Clears the collections containing pending and registered resources.


finalize

protected void finalize()
                 throws java.lang.Throwable
Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable