Package i5.las2peer.security
Class EthereumGroupAgent
java.lang.Object
i5.las2peer.security.AgentImpl
i5.las2peer.security.GroupAgentImpl
i5.las2peer.security.EthereumGroupAgent
- All Implemented Interfaces:
Agent,GroupAgent,MessageReceiver,XmlAble,java.lang.Cloneable
public class EthereumGroupAgent extends GroupAgentImpl
-
Field Summary
-
Constructor Summary
Constructors Modifier Constructor Description protectedEthereumGroupAgent(java.security.KeyPair pair, javax.crypto.SecretKey secret, byte[] salt, java.lang.String groupName, Agent[] members, java.lang.String ethereumMnemonic)protectedEthereumGroupAgent(java.security.PublicKey pubKey, byte[] encryptedPrivate, java.util.HashMap<java.lang.String,byte[]> htEncryptedKeys, java.lang.String ethereumMnemonic, java.lang.String ethereumAddress) -
Method Summary
Modifier and Type Method Description static EthereumGroupAgentcreateEthereumGroupAgentWithClient(java.lang.String groupName, ReadWriteRegistryClient regClient, Agent[] members)Creates new agent with given passphrase and login name.static EthereumGroupAgentcreateFromXml(java.lang.String xml)static EthereumGroupAgentcreateFromXml(org.w3c.dom.Element root)java.lang.StringgetEthereumAddress()org.web3j.crypto.CredentialsgetEthereumCredentials()java.lang.StringgetEthereumMnemonic()ReadWriteRegistryClientgetRegistryClient()Gets registry client that uses the agent's credentials.booleanisLocked()Returns whether the agent is locked or not.voidlockPrivateKey()Removes decrypted private key and the registry client (which contains user credentials).java.lang.StringtoXmlString()Returns a XML representation of this object.voidunlock(Agent agent)Unlock this group using a given agent.Methods inherited from class i5.las2peer.security.GroupAgentImpl
addAdmin, addMember, addMember, apply, createGroupAgent, createGroupAgent, getGroupName, getMemberList, getOpeningAgent, getSize, hasGroupName, hasMember, hasMember, isAdmin, notifyUnregister, receiveMessage, removeMember, removeMember, revokeAdmin, revokeMemberMethods inherited from class i5.las2peer.security.AgentImpl
cloneLocked, createFromXml, createFromXml, createSignature, decryptSymmetricKey, encryptPrivateKey, equals, getEncodedPrivate, getIdentifier, getPublicKey, getResponsibleForAgentSafeId, getRunningAtNode, notifyRegistrationTo, signContent, unlockPrivateKey
-
Constructor Details
-
EthereumGroupAgent
protected EthereumGroupAgent(java.security.KeyPair pair, javax.crypto.SecretKey secret, byte[] salt, java.lang.String groupName, Agent[] members, java.lang.String ethereumMnemonic) throws AgentOperationFailedException, CryptoException, SerializationException -
EthereumGroupAgent
protected EthereumGroupAgent(java.security.PublicKey pubKey, byte[] encryptedPrivate, java.util.HashMap<java.lang.String,byte[]> htEncryptedKeys, java.lang.String ethereumMnemonic, java.lang.String ethereumAddress) throws AgentOperationFailedException- Throws:
AgentOperationFailedException
-
-
Method Details
-
lockPrivateKey
public void lockPrivateKey()Removes decrypted private key and the registry client (which contains user credentials).- Overrides:
lockPrivateKeyin classGroupAgentImpl
-
unlock
public void unlock(Agent agent) throws AgentAccessDeniedException, AgentOperationFailedException, AgentLockedExceptionDescription copied from interface:GroupAgentUnlock this group using a given agent. Will not work for transitive memberships.- Specified by:
unlockin interfaceGroupAgent- Overrides:
unlockin classGroupAgentImpl- Parameters:
agent- A direct member of this group, must be unlocked.- Throws:
AgentAccessDeniedException- If the given agent is not a direct member of this group.AgentOperationFailedException- If the agent's private key can not be deserialized.AgentLockedException- If agent is locked.
-
isLocked
public boolean isLocked()Description copied from interface:AgentReturns whether the agent is locked or not. -
toXmlString
public java.lang.String toXmlString()Description copied from interface:XmlAbleReturns a XML representation of this object.- Specified by:
toXmlStringin interfaceXmlAble- Overrides:
toXmlStringin classGroupAgentImpl- Returns:
- a XML String representation
-
createEthereumGroupAgentWithClient
public static EthereumGroupAgent createEthereumGroupAgentWithClient(java.lang.String groupName, ReadWriteRegistryClient regClient, Agent[] members) throws CryptoException, AgentOperationFailedException, SerializationExceptionCreates new agent with given passphrase and login name.- Parameters:
groupName- name matching [a-zA-Z].{3,31} (hopefully UTF-8 characters, let's not get too crazy)- Returns:
- new EthereumAgent instance
- Throws:
CryptoException- if there is an internal error during Ethereum key creationAgentOperationFailedExceptionSerializationException
-
getRegistryClient
Gets registry client that uses the agent's credentials. May benull; will need to add an "at" here use {link #unlock(String)}. -
getEthereumAddress
public java.lang.String getEthereumAddress()- Returns:
- address of the Ethereum key pair associated with the agent
-
getEthereumMnemonic
public java.lang.String getEthereumMnemonic() -
getEthereumCredentials
- Throws:
AgentLockedException
-
createFromXml
- Throws:
MalformedXMLException
-
createFromXml
public static EthereumGroupAgent createFromXml(org.w3c.dom.Element root) throws MalformedXMLException- Throws:
MalformedXMLException
-