Package i5.las2peer.security
Class PassphraseAgentImpl
java.lang.Object
i5.las2peer.security.AgentImpl
i5.las2peer.security.PassphraseAgentImpl
- All Implemented Interfaces:
Agent
,PassphraseAgent
,MessageReceiver
,XmlAble
,Cloneable
- Direct Known Subclasses:
MonitoringAgent
,ServiceAgentImpl
,UserAgentImpl
Base class for pass phrase protected agents.
-
Constructor Summary
ModifierConstructorDescriptionprotected
PassphraseAgentImpl
(KeyPair pair, String passphrase, byte[] salt) atm constructor for the MockAgent class, just don't know, how agent creation will take place laterprotected
PassphraseAgentImpl
(PublicKey pubKey, byte[] encodedPrivate, byte[] salt) create an agent with a locked private key used withinAgentImpl.createFromXml(java.io.File)
-
Method Summary
Modifier and TypeMethodDescriptionvoid
changePassphrase
(String passphrase) Change the passphrase for unlocking the private key.Gets the current passphraseprotected byte[]
getSalt()
provide access to salt for subclasses (security risk? - probably not)void
(Re-)Lock the private key.void
Unlocks this agent.void
unlockPrivateKey
(String passphrase) Methods inherited from class i5.las2peer.security.AgentImpl
cloneLocked, createFromXml, createFromXml, createFromXml, createFromXml, createSignature, decryptSymmetricKey, encryptPrivateKey, equals, getEncodedPrivate, getIdentifier, getPublicKey, getResponsibleForAgentSafeId, getRunningAtNode, isLocked, notifyRegistrationTo, notifyUnregister, receiveMessage, 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.serialization.XmlAble
toXmlString
-
Constructor Details
-
PassphraseAgentImpl
protected PassphraseAgentImpl(KeyPair pair, String passphrase, byte[] salt) throws AgentOperationFailedException, CryptoException atm constructor for the MockAgent class, just don't know, how agent creation will take place later- Parameters:
pair
-passphrase
-salt
-- Throws:
AgentOperationFailedException
CryptoException
-
PassphraseAgentImpl
create an agent with a locked private key used withinAgentImpl.createFromXml(java.io.File)
- Parameters:
pubKey
-encodedPrivate
-salt
-
-
-
Method Details
-
unlock
public void unlock(String passphrase) throws AgentAccessDeniedException, AgentOperationFailedException Description copied from interface:PassphraseAgent
Unlocks this agent.- Specified by:
unlock
in interfacePassphraseAgent
- Parameters:
passphrase
- The passphrase to unlock this agent.- Throws:
AgentAccessDeniedException
- If the passphrase is not valid.AgentOperationFailedException
- If the agent's private key can not be deserialized.
-
unlockPrivateKey
public void unlockPrivateKey(String passphrase) throws AgentAccessDeniedException, AgentOperationFailedException - Specified by:
unlockPrivateKey
in interfacePassphraseAgent
- Parameters:
passphrase
- The passphrase to unlock this agent.- Throws:
AgentAccessDeniedException
- If the passphrase is not valid.AgentOperationFailedException
- If the agent's private key can not be deserialized.
-
getSalt
protected byte[] getSalt()provide access to salt for subclasses (security risk? - probably not)- Returns:
- the random salt used to encode the private key
-
changePassphrase
public void changePassphrase(String passphrase) throws AgentOperationFailedException, AgentLockedException Change the passphrase for unlocking the private key. The key has to be unlocked first, of course.- Parameters:
passphrase
-- Throws:
AgentOperationFailedException
AgentLockedException
-
lockPrivateKey
public void lockPrivateKey()Description copied from class:AgentImpl
(Re-)Lock the private key.- Overrides:
lockPrivateKey
in classAgentImpl
-
getPassphrase
Gets the current passphrase- Returns:
- Returns the passphrase of this agent
- Throws:
AgentLockedException
-