issrg.utils.repository
Class VirtualRepository

java.lang.Object
  extended by issrg.utils.repository.VirtualRepository
All Implemented Interfaces:
AttributeRepository
Direct Known Subclasses:
PMIXMLRepository, VirtualLDAP

public class VirtualRepository
extends java.lang.Object
implements AttributeRepository

This is the class for representing the virtual repository of ACs and ACRLs for the push model. It can be used to store other attributes, too.

Version:
1.0
Author:
A Otenko

Field Summary
protected  RepositoryException diagnosis
          This is the diagnostic message reference; it is null, if everything was OK
protected  java.util.Map repository
          This is the actual repository.
 
Fields inherited from interface issrg.utils.repository.AttributeRepository
FAILURE_STATUS, INHERENT_FAILURE_STATUS, PARTIAL_SUCCESS_STATUS, SUCCESS_STATUS
 
Constructor Summary
VirtualRepository()
           
 
Method Summary
 javax.naming.directory.Attributes get(java.lang.String DN)
          This method allows the caller to access the Attributes of the given entry, which can be useful for updating the entry's contents (remove or replace attributes or their values).
 javax.naming.directory.Attributes getAllAttributes(java.security.Principal DN)
          This method returns all available attributes from the entry.
 javax.naming.directory.Attribute getAttribute(java.security.Principal DN, java.lang.String attributeID)
          This method returns the values of the requested attribute from a given entry.
 javax.naming.directory.Attributes getAttributes(java.security.Principal DN, java.lang.String[] attributeIDs)
          This method returns the attributes from the given entry.
 java.lang.Throwable getDiagnosis()
          This method returns the last Exception thrown or an exception the Repository wanted to throw very much, but did not, only because the error was not fatal.
 int getStatus()
          This method returns the status of the Repository.
 byte[] loadPKC(java.lang.String pkcattribute, java.io.File f)
          This method loads a PKC from the given file, populates this repository with the DN taken from the PKC, and returns the byte array that has been placed in the repository.
 void populate(java.lang.String DN, java.lang.String attributeName, java.lang.Object value)
          This method allows the caller to place the given value of the named attribute in the specified entry.
 javax.naming.directory.Attributes remove(java.lang.String DN)
          This method destroys the whole entry: all the data is lost; the former contents of the entry is returned.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

repository

protected java.util.Map repository
This is the actual repository. It contains the javax.naming.directory.Attributes objects indexed by the String entry DN.


diagnosis

protected final RepositoryException diagnosis
This is the diagnostic message reference; it is null, if everything was OK

Constructor Detail

VirtualRepository

public VirtualRepository()
Method Detail

populate

public void populate(java.lang.String DN,
                     java.lang.String attributeName,
                     java.lang.Object value)
This method allows the caller to place the given value of the named attribute in the specified entry. If the entry does not exist, it is created. If the attribute does not exist, it is created. No checks for duplicate values are done.

Parameters:
DN - is the canonical LDAP DN of the entry
attributeName - is the name of the attribute
value - is the value to add to the attribute

loadPKC

public byte[] loadPKC(java.lang.String pkcattribute,
                      java.io.File f)
               throws java.io.IOException
This method loads a PKC from the given file, populates this repository with the DN taken from the PKC, and returns the byte array that has been placed in the repository.

Throws:
java.io.IOException

get

public javax.naming.directory.Attributes get(java.lang.String DN)
This method allows the caller to access the Attributes of the given entry, which can be useful for updating the entry's contents (remove or replace attributes or their values). It is equal to the getAllAttributes with a few unapparent differences: it does not affect the repository status; it gives access to the repository, whilst getAllAttributes returns a copy of the data, so tampering with it is safe after getAllAttributes, and is not after get().

Parameters:
DN - is the canonical LDAP DN of the entry to retrieve
Returns:
the Attributes of that entry; is null if no such entry exists

remove

public javax.naming.directory.Attributes remove(java.lang.String DN)
This method destroys the whole entry: all the data is lost; the former contents of the entry is returned.

Parameters:
DN - is the canonical LDAP DN of the entry to remove
Returns:
the Attributes of that entry, the repository no longer contains any of the attributes in that entry; can be null, if no such entry existed

getAttribute

public javax.naming.directory.Attribute getAttribute(java.security.Principal DN,
                                                     java.lang.String attributeID)
This method returns the values of the requested attribute from a given entry.

Specified by:
getAttribute in interface AttributeRepository
Parameters:
DN - is the name of the entry
attributeID - is the name of the attribute to return
Returns:
the Attribute with values or null, if no such attribute was there

getAttributes

public javax.naming.directory.Attributes getAttributes(java.security.Principal DN,
                                                       java.lang.String[] attributeIDs)
This method returns the attributes from the given entry.

Specified by:
getAttributes in interface AttributeRepository
Parameters:
DN - - the entry name; its getName() should return the canonical name
attributeIDs - - the array of attribute names; if null, all available attributes are returned
Returns:
the requested Attributes, or null, if no such entry exists

getAllAttributes

public javax.naming.directory.Attributes getAllAttributes(java.security.Principal DN)
This method returns all available attributes from the entry. It does the same as getAttributes(DN, null)

Specified by:
getAllAttributes in interface AttributeRepository
Parameters:
DN - - the entry name; its getName method should return the canonical name
Returns:
all available Attributes, or null, if no such entry exists

getStatus

public int getStatus()
Description copied from interface: AttributeRepository
This method returns the status of the Repository.

Specified by:
getStatus in interface AttributeRepository
Returns:
one of the *_STATUS values
See Also:
AttributeRepository.SUCCESS_STATUS, AttributeRepository.FAILURE_STATUS, AttributeRepository.PARTIAL_SUCCESS_STATUS, AttributeRepository.INHERENT_FAILURE_STATUS

getDiagnosis

public java.lang.Throwable getDiagnosis()
Description copied from interface: AttributeRepository
This method returns the last Exception thrown or an exception the Repository wanted to throw very much, but did not, only because the error was not fatal.

TODO: I am very keen to remove getStatus() method, and return DiagnosisException only; which will contain the status code in it and a reference to an embedded exception. Thus it will be possible to throw such an exception in cases of need, and still it will be possible to keep it for further information. I envisage that the PbaException is one of this sort: a DiagnosisException.

Specified by:
getDiagnosis in interface AttributeRepository
Returns:
the last Throwable the Repository was eager to throw or has thrown
See Also:
AttributeRepository.getStatus()