it.dtt.ca
Class CAObject

java.lang.Object
  extended by it.dtt.ca.CAObject
Direct Known Subclasses:
CAManager, Pin, Slot, SmartCard

public abstract class CAObject
extends java.lang.Object

All CA related classes shall extend this class in order to be able to ensure that the actual CA session is opened. The CASession and CAObject mechanism works as follows:

  1. when a new CAManager object is created, it calls the empty constructor of its parent class CAObject, which creates a new CASession object;
  2. instead, when creating other objects derived from CAObject (Pin, Slot, SmartCard), these objects share the same CASession instance (meaning: the same session) of the parent object (typically: CAManager);
  3. if the session - for any reason - is closed, all objects derived from CAObject are "closed" and will reply with a SessionClosedException exception to any method which includes a call to CAObject.checksession()


Constructor Summary
protected CAObject()
          Constructs the object using a new CA session.
protected CAObject(CAObject parent)
          Constructs the object using the same CA session of the parent object.
 
Method Summary
protected  void checkSession()
          Checks if the actual session is opened.
protected  void closeSession()
          Closes the session related with this CA object only if the current session was created by this object, i.e.
 CAObject getParent()
          Return the parent object of this CAObject.
 it.dtt.ca.CASession getSession()
          Get the session associated with this CAObject.
protected abstract  void sessionClosed()
          This method is invoked after the session has been closed.
protected abstract  void sessionClosing()
          This method is invoked before session closing.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CAObject

protected CAObject()
Constructs the object using a new CA session.


CAObject

protected CAObject(CAObject parent)
Constructs the object using the same CA session of the parent object.

Parameters:
parent - the parent of this CA object.
Method Detail

closeSession

protected final void closeSession()
Closes the session related with this CA object only if the current session was created by this object, i.e. CAObject() was used to create this object.


sessionClosing

protected abstract void sessionClosing()
This method is invoked before session closing.


sessionClosed

protected abstract void sessionClosed()
This method is invoked after the session has been closed.


checkSession

protected final void checkSession()
                           throws SessionClosedException
Checks if the actual session is opened. Does nothing if it is opened; throws an exception otherwise. It shall be used at the beginning of every method which throws SessionClosedException exception.

Throws:
SessionClosedException - thrown if the actual session is closed.

getSession

public it.dtt.ca.CASession getSession()
Get the session associated with this CAObject.

Returns:
the session.

getParent

public CAObject getParent()
Return the parent object of this CAObject.

Returns:
the parent CAObject.