Package i5.las2peer.security
Class AnonymousAgentImpl
java.lang.Object
i5.las2peer.security.AgentImpl
i5.las2peer.security.AnonymousAgentImpl
- All Implemented Interfaces:
Agent
,AnonymousAgent
,MessageReceiver
,XmlAble
,Cloneable
-
Field Summary
Fields inherited from interface i5.las2peer.api.security.AnonymousAgent
IDENTIFIER, LOGIN_NAME
-
Method Summary
Modifier and TypeMethodDescriptionUses theCryptoTools
to create ajava.security.Signature
and initializes the object for signing with the agent's private key.decryptSymmetricKey
(byte[] crypted) Uses theCryptoTools
to decrypt the passed crypted content with the agent's private key.void
Encrypts the private key into a byte array with strong encryption based on a passphrase.boolean
The agent idstatic AnonymousAgentImpl
boolean
isLocked()
Returns whether the agent is locked or not.void
receiveMessage
(Message message, AgentContext c) Hook to be called by the node where this agent is registered to, when the node receives a message destined to this agent.byte[]
signContent
(byte[] plainData) Uses theCryptoTools
to sign the passed data with the agent's private key.Returns a XML representation of this object.void
Unlocks the private key.Methods inherited from class i5.las2peer.security.AgentImpl
cloneLocked, createFromXml, createFromXml, createFromXml, createFromXml, getEncodedPrivate, getResponsibleForAgentSafeId, getRunningAtNode, lockPrivateKey, notifyRegistrationTo, notifyUnregister
-
Method Details
-
getInstance
-
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
-
unlockPrivateKey
Description copied from class:AgentImpl
Unlocks the private key.- Overrides:
unlockPrivateKey
in classAgentImpl
- Parameters:
key
- A key that is used to unlock the agents private key.
-
encryptPrivateKey
Description copied from class:AgentImpl
Encrypts the private key into a byte array with strong encryption based on a passphrase. to unlock the key- Overrides:
encryptPrivateKey
in classAgentImpl
- Parameters:
key
- A key that is used to encrypt the agents private key.
-
isLocked
public boolean isLocked()Description copied from interface:Agent
Returns whether the agent is locked or not. -
getIdentifier
Description copied from interface:Agent
The agent id- Specified by:
getIdentifier
in interfaceAgent
- Overrides:
getIdentifier
in classAgentImpl
- Returns:
- The agent id.
-
getPublicKey
- Overrides:
getPublicKey
in classAgentImpl
- Returns:
- the cryptographic public key of this agent
-
decryptSymmetricKey
public SecretKey decryptSymmetricKey(byte[] crypted) throws AgentLockedException, SerializationException, CryptoException Description copied from class:AgentImpl
Uses theCryptoTools
to decrypt the passed crypted content with the agent's private key.- Overrides:
decryptSymmetricKey
in classAgentImpl
- Parameters:
crypted
- The encrypted content that is decrypted using the agents private key.- Returns:
- Returns a
SecretKey
decrypted from the crypted input and the agent's private key - Throws:
AgentLockedException
- the private key has not been unlocked yetSerializationException
- If an issue occurs with deserializing the given and decrypted data.CryptoException
- If an issue occurs with decryption.
-
createSignature
public Signature createSignature() throws InvalidKeyException, AgentLockedException, NoSuchAlgorithmExceptionDescription copied from class:AgentImpl
Uses theCryptoTools
to create ajava.security.Signature
and initializes the object for signing with the agent's private key.- Overrides:
createSignature
in classAgentImpl
- Returns:
- a
java.security.Signature
- Throws:
InvalidKeyException
AgentLockedException
- the private key has not been unlocked yetNoSuchAlgorithmException
-
signContent
Description copied from class:AgentImpl
Uses theCryptoTools
to sign the passed data with the agent's private key.- Overrides:
signContent
in classAgentImpl
- Parameters:
plainData
- The plain data to sign- Returns:
- Returns a signed version of the input
- Throws:
CryptoException
AgentLockedException
- the private key has not been unlocked yet
-
equals
-