Package i5.las2peer.security
Class AnonymousAgentImpl
java.lang.Object
i5.las2peer.security.AgentImpl
i5.las2peer.security.AnonymousAgentImpl
- All Implemented Interfaces:
Agent
,AnonymousAgent
,MessageReceiver
,XmlAble
,java.lang.Cloneable
public class AnonymousAgentImpl extends AgentImpl implements AnonymousAgent
-
Field Summary
-
Method Summary
Modifier and Type Method Description java.security.Signature
createSignature()
Uses theCryptoTools
to create ajava.security.Signature
and initializes the object for signing with the agent's private key.javax.crypto.SecretKey
decryptSymmetricKey(byte[] crypted)
Uses theCryptoTools
to decrypt the passed crypted content with the agent's private key.void
encryptPrivateKey(javax.crypto.SecretKey key)
Encrypts the private key into a byte array with strong encryption based on a passphrase. to unlock the keyboolean
equals(java.lang.Object other)
java.lang.String
getIdentifier()
The agent idstatic AnonymousAgentImpl
getInstance()
java.security.PublicKey
getPublicKey()
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.java.lang.String
toXmlString()
Returns a XML representation of this object.void
unlockPrivateKey(javax.crypto.SecretKey key)
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
public java.lang.String 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
public void unlockPrivateKey(javax.crypto.SecretKey key)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
public void encryptPrivateKey(javax.crypto.SecretKey key)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
public java.lang.String getIdentifier()Description copied from interface:Agent
The agent id- Specified by:
getIdentifier
in interfaceAgent
- Overrides:
getIdentifier
in classAgentImpl
- Returns:
- The agent id.
-
getPublicKey
public java.security.PublicKey getPublicKey()- Overrides:
getPublicKey
in classAgentImpl
- Returns:
- the cryptographic public key of this agent
-
decryptSymmetricKey
public javax.crypto.SecretKey decryptSymmetricKey(byte[] crypted) throws AgentLockedException, SerializationException, CryptoExceptionDescription 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 java.security.Signature createSignature() throws java.security.InvalidKeyException, AgentLockedException, java.security.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:
java.security.InvalidKeyException
AgentLockedException
- the private key has not been unlocked yetjava.security.NoSuchAlgorithmException
-
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
public boolean equals(java.lang.Object other)
-