eu.xtreemos.xosd.vo.rca.client
Class RCAClient

java.lang.Object
  extended by eu.xtreemos.system.eventmachine.stage.AbstractStage
      extended by eu.xtreemos.system.eventmachine.stage.AbstractReceivingStage
          extended by eu.xtreemos.system.eventmachine.stage.Abstract2wayStage
              extended by eu.xtreemos.xosd.vo.rca.client.RCAClient
All Implemented Interfaces:
eu.xtreemos.system.eventmachine.queue.IEventHandler, eu.xtreemos.system.eventmachine.stage.IStage

public class RCAClient
extends eu.xtreemos.system.eventmachine.stage.Abstract2wayStage

The service implementing the Resource Certification Authority client. This service runs on each node that is capable of providing services or resources to Virtual Organisations (VO). The service is the node's counterpart of the RCA server, providing a convenient way to store and access the local machine certificates, gather information on the resource (e.g. from the local ResourceMonitor service), and it also generates new public/private key pair, the former of which it then sends to the RCAServer for signing.

Author:
matej.artac@xlab.si

Nested Class Summary
 class RCAClient.RCAClientStorage
           
 
Field Summary
protected  RCAClientProcessor clientProcessor
           
protected  eu.xtreemos.xosd.vo.rca.client.CRCAClientConfig config
           
protected  int keyLength
           
(package private) static org.apache.log4j.Logger logger
           
protected  eu.xtreemos.xosd.resmng.data.ResourceDescriptorRecord myDescriptor
          The resource descriptor of the client's node.
 
Fields inherited from class eu.xtreemos.system.eventmachine.stage.Abstract2wayStage
context, counter, curContext, sink
 
Fields inherited from class eu.xtreemos.system.eventmachine.stage.AbstractReceivingStage
queue
 
Fields inherited from class eu.xtreemos.system.eventmachine.stage.AbstractStage
handlerChain, handlerGroup, handlerThreads, name, running
 
Constructor Summary
RCAClient()
           
 
Method Summary
protected  java.lang.String getAttributes(java.security.cert.X509Certificate attribCert)
          Describe the attributes in the attribute in a human-readable form.
protected  java.lang.String getAttributes(org.bouncycastle.x509.X509V2AttributeCertificate attribCert)
          Describe the attributes in the attribute in a human-readable form.
 java.lang.String getHandledEventType()
           
 java.lang.String getMachineCertificateDetails()
          Opens the certificate currently stored locally and signed by RCA, and returns a string containing the details on the certificate.
 void handleEvent(java.lang.Object event)
           
 void init()
           
 java.lang.Integer initData()
          A maintenance call for initialising the RCA client.
 java.lang.Integer processMyDescriptor(java.util.ArrayList<eu.xtreemos.xosd.resmng.data.ResourceDescriptorRecord> descrs)
           
 java.lang.Integer processMyDescriptorFailure(java.lang.Exception ex)
           
 java.lang.Boolean processRequestCertificate(eu.xtreemos.xosd.vo.rca.RCASignedResponse response)
          The callback that resumes the execution from requestNewCertificate() after the RCAServer's requestCertificate returns a value.
 java.lang.Boolean requestNewCertificate()
          The method generates a new public and private key pair, then sends the public key for certification to the RCA server and obtains the signed attribute certificate.
 
Methods inherited from class eu.xtreemos.system.eventmachine.stage.Abstract2wayStage
getContext, removeContext, SendException, SendReply, setSink
 
Methods inherited from class eu.xtreemos.system.eventmachine.stage.AbstractReceivingStage
dequeue, getSource
 
Methods inherited from class eu.xtreemos.system.eventmachine.stage.AbstractStage
addHandler, addHandler, getName, getShortName, getThreadCount, processEvent, removeHandler, setThreadCount, start, stop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

static org.apache.log4j.Logger logger

keyLength

protected int keyLength

config

protected eu.xtreemos.xosd.vo.rca.client.CRCAClientConfig config

myDescriptor

protected eu.xtreemos.xosd.resmng.data.ResourceDescriptorRecord myDescriptor
The resource descriptor of the client's node. Should be initialised during the start-up or during the first registration request at the very latest.


clientProcessor

protected RCAClientProcessor clientProcessor
Constructor Detail

RCAClient

public RCAClient()
Method Detail

getAttributes

protected java.lang.String getAttributes(java.security.cert.X509Certificate attribCert)
Describe the attributes in the attribute in a human-readable form. The attributes are in the extensions of the certificate.

Parameters:
attribCert - The certificate with the attributes in its extensions.
Returns:
A string containig the enumeration of the known attributes present in the certificate and their values.

getAttributes

protected java.lang.String getAttributes(org.bouncycastle.x509.X509V2AttributeCertificate attribCert)
Describe the attributes in the attribute in a human-readable form. The attributes are stored in the attribute certificate.

Parameters:
attribCert - The attribute certificate do describe.
Returns:
A string containig the enumeration of the known attributes present in the certificate and their values.

getMachineCertificateDetails

public java.lang.String getMachineCertificateDetails()
                                              throws java.lang.Exception
Opens the certificate currently stored locally and signed by RCA, and returns a string containing the details on the certificate.

Returns:
The details on the currently stored and used certificate.
Throws:
java.lang.Exception

requestNewCertificate

public java.lang.Boolean requestNewCertificate()
                                        throws java.lang.Exception
The method generates a new public and private key pair, then sends the public key for certification to the RCA server and obtains the signed attribute certificate. It stores the certificates into the local truststore.

Returns:
True if the request was successful, or false otherwise.
Throws:
java.lang.Exception

processRequestCertificate

public java.lang.Boolean processRequestCertificate(eu.xtreemos.xosd.vo.rca.RCASignedResponse response)
                                            throws java.lang.Exception
The callback that resumes the execution from requestNewCertificate() after the RCAServer's requestCertificate returns a value. The method stores the results into the trust store.

Parameters:
response - The result of the service call.
Returns:
True if the registration succeeds, and false otherwise.
Throws:
java.lang.Exception

getHandledEventType

public java.lang.String getHandledEventType()
Specified by:
getHandledEventType in class eu.xtreemos.system.eventmachine.stage.AbstractReceivingStage

handleEvent

public void handleEvent(java.lang.Object event)
                 throws java.lang.Exception
Specified by:
handleEvent in interface eu.xtreemos.system.eventmachine.queue.IEventHandler
Specified by:
handleEvent in class eu.xtreemos.system.eventmachine.stage.AbstractReceivingStage
Throws:
java.lang.Exception

initData

public java.lang.Integer initData()
A maintenance call for initialising the RCA client. The RCA client needs to find out of the resource descriptor of the node running the RCA client. Please call this method once before using RCAClient.

Returns:
0 if the call was successful.

processMyDescriptor

public java.lang.Integer processMyDescriptor(java.util.ArrayList<eu.xtreemos.xosd.resmng.data.ResourceDescriptorRecord> descrs)

processMyDescriptorFailure

public java.lang.Integer processMyDescriptorFailure(java.lang.Exception ex)

init

public void init()
Specified by:
init in interface eu.xtreemos.system.eventmachine.stage.IStage
Overrides:
init in class eu.xtreemos.system.eventmachine.stage.AbstractStage