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 theCryptoToolsto create ajava.security.Signatureand initializes the object for signing with the agent's private key.decryptSymmetricKey(byte[] crypted) Uses theCryptoToolsto decrypt the passed crypted content with the agent's private key.voidEncrypts the private key into a byte array with strong encryption based on a passphrase.booleanThe agent idstatic AnonymousAgentImplbooleanisLocked()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.Returns a XML representation of this object.voidUnlocks 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: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
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
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
Description copied from interface:AgentThe agent id- Specified by:
getIdentifierin interfaceAgent- Overrides:
getIdentifierin classAgentImpl- Returns:
- The agent id.
-
getPublicKey
- Overrides:
getPublicKeyin classAgentImpl- Returns:
- the cryptographic public key of this agent
-
decryptSymmetricKey
public SecretKey decryptSymmetricKey(byte[] crypted) throws AgentLockedException, SerializationException, CryptoException Description 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 Signature createSignature() throws InvalidKeyException, AgentLockedException, 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:
InvalidKeyExceptionAgentLockedException- the private key has not been unlocked yetNoSuchAlgorithmException
-
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
-