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.SignaturecreateSignature()Uses theCryptoToolsto create ajava.security.Signatureand initializes the object for signing with the agent's private key.javax.crypto.SecretKeydecryptSymmetricKey(byte[] crypted)Uses theCryptoToolsto decrypt the passed crypted content with the agent's private key.voidencryptPrivateKey(javax.crypto.SecretKey key)Encrypts the private key into a byte array with strong encryption based on a passphrase. to unlock the keybooleanequals(java.lang.Object other)java.lang.StringgetIdentifier()The agent idstatic AnonymousAgentImplgetInstance()java.security.PublicKeygetPublicKey()booleanisLocked()Returns whether the agent is locked or not.voidreceiveMessage(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 theCryptoToolsto sign the passed data with the agent's private key.java.lang.StringtoXmlString()Returns a XML representation of this object.voidunlockPrivateKey(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:XmlAbleReturns a XML representation of this object.- Specified by:
toXmlStringin interfaceXmlAble- Returns:
- a XML String representation
-
receiveMessage
Description copied from class:AgentImplHook to be called by the node where this agent is registered to, when the node receives a message destined to this agent.- Specified by:
receiveMessagein interfaceMessageReceiver- Specified by:
receiveMessagein classAgentImpl- Throws:
MessageException
-
unlockPrivateKey
public void unlockPrivateKey(javax.crypto.SecretKey key)Description copied from class:AgentImplUnlocks the private key.- Overrides:
unlockPrivateKeyin 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:AgentImplEncrypts the private key into a byte array with strong encryption based on a passphrase. to unlock the key- Overrides:
encryptPrivateKeyin classAgentImpl- Parameters:
key- A key that is used to encrypt the agents private key.
-
isLocked
public boolean isLocked()Description copied from interface:AgentReturns whether the agent is locked or not. -
getIdentifier
public java.lang.String getIdentifier()Description copied from interface:AgentThe agent id- Specified by:
getIdentifierin interfaceAgent- Overrides:
getIdentifierin classAgentImpl- Returns:
- The agent id.
-
getPublicKey
public java.security.PublicKey getPublicKey()- Overrides:
getPublicKeyin classAgentImpl- Returns:
- the cryptographic public key of this agent
-
decryptSymmetricKey
public javax.crypto.SecretKey decryptSymmetricKey(byte[] crypted) throws AgentLockedException, SerializationException, CryptoExceptionDescription copied from class:AgentImplUses theCryptoToolsto decrypt the passed crypted content with the agent's private key.- Overrides:
decryptSymmetricKeyin classAgentImpl- Parameters:
crypted- The encrypted content that is decrypted using the agents private key.- Returns:
- Returns a
SecretKeydecrypted 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:AgentImplUses theCryptoToolsto create ajava.security.Signatureand initializes the object for signing with the agent's private key.- Overrides:
createSignaturein classAgentImpl- Returns:
- a
java.security.Signature - Throws:
java.security.InvalidKeyExceptionAgentLockedException- the private key has not been unlocked yetjava.security.NoSuchAlgorithmException
-
signContent
Description copied from class:AgentImplUses theCryptoToolsto sign the passed data with the agent's private key.- Overrides:
signContentin classAgentImpl- Parameters:
plainData- The plain data to sign- Returns:
- Returns a signed version of the input
- Throws:
CryptoExceptionAgentLockedException- the private key has not been unlocked yet
-
equals
public boolean equals(java.lang.Object other)
-