Package i5.las2peer.security
Class ServiceAgentImpl
java.lang.Object
i5.las2peer.security.AgentImpl
i5.las2peer.security.PassphraseAgentImpl
i5.las2peer.security.ServiceAgentImpl
- All Implemented Interfaces:
Agent
,PassphraseAgent
,ServiceAgent
,MessageReceiver
,XmlAble
,Cloneable
A service agent represents a service and its access rights in the las2peer setting.
-
Constructor Summary
ModifierConstructorDescriptionprotected
ServiceAgentImpl
(ServiceNameVersion service, KeyPair pair, String passphrase, byte[] salt) create a new service agentprotected
ServiceAgentImpl
(ServiceNameVersion service, PublicKey pubKey, byte[] encodedPrivate, byte[] salt) create a new service agent -
Method Summary
Modifier and TypeMethodDescriptionstatic ServiceAgentImpl
createFromXml
(String xml) factory: create a new service agent from the given XML representationstatic ServiceAgentImpl
createFromXml
(Element rootElement) factory: create a service agent from the given xml representationstatic ServiceAgentImpl
createServiceAgent
(ServiceNameVersion service, String passphrase) create a completely new ServiceAgent for a given service class the id will be generated randomlystatic ServiceAgentImpl
createServiceAgent
(String serviceName, String passphrase) Deprecated.static ServiceAgentImpl
generateNewAgent
(String forService, String passPhrase) Deprecated.get the actual service instance bound to this agentget the name of the service class, this service agent belongs tohandle
(RMITask task, AgentContext agentContext) execute a RMITaskinvoke a service methodboolean
is this (service) agent registered for running a service?void
notifyRegistrationTo
(Node node) notify this service agent, that it has been registered (for usage) at the given nodevoid
Notifies this agent of unregistering from a node.void
Hook to be called by the node where this agent is registered to, when the node receives a message destined to this agent.static long
serviceNameToTopicId
(String service) Gets the service topic id for the given service nameReturns a XML representation of this object.Methods inherited from class i5.las2peer.security.PassphraseAgentImpl
changePassphrase, getPassphrase, getSalt, lockPrivateKey, unlock, unlockPrivateKey
Methods inherited from class i5.las2peer.security.AgentImpl
cloneLocked, createFromXml, createFromXml, createSignature, decryptSymmetricKey, encryptPrivateKey, equals, getEncodedPrivate, getIdentifier, getPublicKey, getResponsibleForAgentSafeId, getRunningAtNode, isLocked, signContent, unlockPrivateKey
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface i5.las2peer.api.security.Agent
getIdentifier, isLocked
Methods inherited from interface i5.las2peer.api.security.PassphraseAgent
unlock, unlockPrivateKey
-
Constructor Details
-
ServiceAgentImpl
protected ServiceAgentImpl(ServiceNameVersion service, KeyPair pair, String passphrase, byte[] salt) throws AgentOperationFailedException, CryptoException create a new service agent- Parameters:
service
-pair
-passphrase
-salt
-- Throws:
AgentOperationFailedException
CryptoException
-
ServiceAgentImpl
protected ServiceAgentImpl(ServiceNameVersion service, PublicKey pubKey, byte[] encodedPrivate, byte[] salt) create a new service agent- Parameters:
service
-pubKey
-encodedPrivate
-salt
-
-
-
Method Details
-
getServiceNameVersion
get the name of the service class, this service agent belongs to- Specified by:
getServiceNameVersion
in interfaceServiceAgent
- Returns:
- class name of the corresponding service
-
toXmlString
Description copied from interface:XmlAble
Returns a XML representation of this object.- Specified by:
toXmlString
in interfaceXmlAble
- Returns:
- a XML String representation
-
receiveMessage
Description copied from class:AgentImpl
Hook to be called by the node where this agent is registered to, when the node receives a message destined to this agent.- Specified by:
receiveMessage
in interfaceMessageReceiver
- Specified by:
receiveMessage
in classAgentImpl
- Throws:
MessageException
-
notifyUnregister
public void notifyUnregister()Description copied from class:AgentImpl
Notifies this agent of unregistering from a node.- Specified by:
notifyUnregister
in interfaceMessageReceiver
- Overrides:
notifyUnregister
in classAgentImpl
-
generateNewAgent
@Deprecated public static ServiceAgentImpl generateNewAgent(String forService, String passPhrase) throws CryptoException, AgentOperationFailedException Deprecated.Please usecreateServiceAgent(ServiceNameVersion, String)
instead- Parameters:
forService
-passPhrase
-- Returns:
- Returns a new ServiceAgent instance
- Throws:
CryptoException
AgentOperationFailedException
-
createServiceAgent
public static ServiceAgentImpl createServiceAgent(ServiceNameVersion service, String passphrase) throws CryptoException, AgentOperationFailedException create a completely new ServiceAgent for a given service class the id will be generated randomly- Parameters:
service
- class name of the new servicepassphrase
- a pass phrase for the private key of the agent- Returns:
- a new ServiceAgent
- Throws:
CryptoException
AgentOperationFailedException
-
createServiceAgent
@Deprecated public static ServiceAgentImpl createServiceAgent(String serviceName, String passphrase) throws CryptoException, AgentOperationFailedException Deprecated.create a ServiceAgent for version 1.0 Can be used to generate ServiceAgent for jUnit tests, since in this case las2peer loads classes using the default class loader and thus does not require version information.- Parameters:
serviceName
-passphrase
-- Returns:
- Returns a new service agent instance
- Throws:
CryptoException
AgentOperationFailedException
-
createFromXml
factory: create a new service agent from the given XML representation- Parameters:
xml
- String containing XML information- Returns:
- a service agent
- Throws:
MalformedXMLException
-
createFromXml
factory: create a service agent from the given xml representation- Parameters:
rootElement
-- Returns:
- a service agent
- Throws:
MalformedXMLException
-
notifyRegistrationTo
notify this service agent, that it has been registered (for usage) at the given node- Specified by:
notifyRegistrationTo
in interfaceMessageReceiver
- Overrides:
notifyRegistrationTo
in classAgentImpl
- Parameters:
node
-- Throws:
AgentException
-
serviceNameToTopicId
Gets the service topic id for the given service name- Parameters:
service
-- Returns:
- Returns the service topic id
-
isRunning
public boolean isRunning()is this (service) agent registered for running a service?- Returns:
- true, if the agent is running at a Las2peer node
-
invoke
public Object invoke(String method, Object[] parameters) throws IllegalArgumentException, ServiceMethodNotFoundException, IllegalAccessException, InvocationTargetException, InternalSecurityException invoke a service method- Parameters:
method
-parameters
-- Returns:
- result of the method invocation
- Throws:
InternalSecurityException
InvocationTargetException
IllegalAccessException
ServiceMethodNotFoundException
IllegalArgumentException
SecurityException
-
handle
public Serializable handle(RMITask task, AgentContext agentContext) throws ServiceInvocationException execute a RMITask- Parameters:
task
-agentContext
-- Returns:
- result of the method invocation
- Throws:
ServiceInvocationException
SecurityException
IllegalArgumentException
-
getServiceInstance
get the actual service instance bound to this agent- Returns:
- the instance of the curresponding service currently running at the las2peer node
-
createServiceAgent(ServiceNameVersion, String)
instead