Package i5.las2peer.security
Class UserAgentImpl
java.lang.Object
i5.las2peer.security.AgentImpl
i5.las2peer.security.PassphraseAgentImpl
i5.las2peer.security.UserAgentImpl
- All Implemented Interfaces:
Agent
,PassphraseAgent
,UserAgent
,MessageReceiver
,XmlAble
,Cloneable
- Direct Known Subclasses:
BotAgent
,EthereumAgent
An UserAgent represent a (End)user of the las2peer system.
-
Field Summary
-
Constructor Summary
ModifierConstructorDescriptionprotected
UserAgentImpl
(KeyPair pair, String passphrase, byte[] salt) atm constructor for the MockAgent class, just don't know, how agent creation will take place laterprotected
UserAgentImpl
(PublicKey pubKey, byte[] encryptedPrivate, byte[] salt) create an agent with a locked private key used withincreateFromXml(java.lang.String)
-
Method Summary
Modifier and TypeMethodDescriptionstatic UserAgentImpl
createFromXml
(String xml) sets the state of the object from a string representation resulting from a previoustoXmlString()
call.static UserAgentImpl
createFromXml
(Element root) Sets the state of the object from a string representation resulting from a previoustoXmlString()
call.static UserAgentImpl
createUserAgent
(String passphrase) Create a new UserAgent protected by the given passphrase.getEmail()
get the email address assigned to this agentGetter for the login name.boolean
hasEmail()
has this user a registered email address?boolean
Check if the agent has a login name set.void
Notifies this agent of unregistering from a node.void
receiveMessage
(Message message, AgentContext context) Hook to be called by the node where this agent is registered to, when the node receives a message destined to this agent.void
Set the email address for this user.void
setLoginName
(String loginName) Set the login name for this user.Returns a XML representation of this object.Methods inherited from class i5.las2peer.security.PassphraseAgentImpl
changePassphrase, getPassphrase, getSalt, lockPrivateKey, unlock, unlockPrivateKey
Methods inherited from class i5.las2peer.security.AgentImpl
cloneLocked, createFromXml, createFromXml, createSignature, decryptSymmetricKey, encryptPrivateKey, equals, getEncodedPrivate, getIdentifier, getPublicKey, getResponsibleForAgentSafeId, getRunningAtNode, isLocked, notifyRegistrationTo, 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.api.security.PassphraseAgent
unlock, unlockPrivateKey
-
Field Details
-
sLoginName
-
sEmail
-
-
Constructor Details
-
UserAgentImpl
protected UserAgentImpl(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
-
UserAgentImpl
create an agent with a locked private key used withincreateFromXml(java.lang.String)
- Parameters:
pubKey
-encryptedPrivate
-salt
-
-
-
Method Details
-
getLoginName
Description copied from interface:UserAgent
Getter for the login name. Login names are unique in the network.- Specified by:
getLoginName
in interfaceUserAgent
- Returns:
- The login name.
-
hasLoginName
public boolean hasLoginName()Description copied from interface:UserAgent
Check if the agent has a login name set.- Specified by:
hasLoginName
in interfaceUserAgent
- Returns:
- true If a login name is set up.
-
setLoginName
Description copied from interface:UserAgent
Set the login name for this user. Note that user names are unique in the network. The name will be stored and reserved in the network only onContext.storeAgent(i5.las2peer.api.security.Agent)
. If the name is already taken, the store operation will fail with aLoginNameAlreadyTakenException
.- Specified by:
setLoginName
in interfaceUserAgent
- Parameters:
loginName
- A user name matching [a-zA-Z].*.- Throws:
AgentLockedException
- If the agent is locked.IllegalArgumentException
- If the name is of invalid format.
-
setEmail
Description copied from interface:UserAgent
Set the email address for this user. Note that user names are unique in the network. The address will be stored and reserved in the network only onContext.storeAgent(i5.las2peer.api.security.Agent)
. If the address is already taken, the store operation will fail with aEmailAlreadyTakenException
.- Specified by:
setEmail
in interfaceUserAgent
- Parameters:
email
- A valid email address.- Throws:
AgentLockedException
- If the agent is locked.IllegalArgumentException
- If the email address is of invalid format.
-
toXmlString
Description copied from interface:XmlAble
Returns a XML representation of this object.- Specified by:
toXmlString
in interfaceXmlAble
- Returns:
- a XML String representation
-
createFromXml
sets the state of the object from a string representation resulting from a previoustoXmlString()
call. Usually, a standard constructor is used to get a fresh instance of the class and the set the complete state via this method.- Parameters:
xml
- a String- Returns:
- Returns a new UserAgent instance
- Throws:
MalformedXMLException
-
createUserAgent
public static UserAgentImpl createUserAgent(String passphrase) throws CryptoException, AgentOperationFailedException Create a new UserAgent protected by the given passphrase.- Parameters:
passphrase
- passphrase for the secret key of the new user- Returns:
- Returns a new UserAgent instance
- Throws:
CryptoException
AgentOperationFailedException
-
createFromXml
Sets the state of the object from a string representation resulting from a previoustoXmlString()
call.- Parameters:
root
- parsed XML document- Returns:
- Returns a new UserAgent instance
- Throws:
MalformedXMLException
-
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
-
notifyUnregister
public void notifyUnregister()Description copied from class:AgentImpl
Notifies this agent of unregistering from a node.- Specified by:
notifyUnregister
in interfaceMessageReceiver
- Overrides:
notifyUnregister
in classAgentImpl
-
getEmail
get the email address assigned to this agent -
hasEmail
public boolean hasEmail()has this user a registered email address?
-