Package i5.las2peer.security
Class GroupAgentImpl
java.lang.Object
i5.las2peer.security.AgentImpl
i5.las2peer.security.GroupAgentImpl
- All Implemented Interfaces:
Agent
,GroupAgent
,MessageReceiver
,XmlAble
,Cloneable
- Direct Known Subclasses:
EthereumGroupAgent
An agent representing a group of other agents.
The storage of the group information is stored encrypted in a similar manner
to
EnvelopeVersion
:
The (symmetric) key to unlock the private key of the group is encrypted
asymmetrically for each entitled agent (i.e. member of the group).-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
GroupAgentImpl
(KeyPair keys, SecretKey secret, Agent[] members) constructor for thecreateGroupAgent(i5.las2peer.api.security.Agent[])
factory simply necessary, since the secret key has to be stated for the constructor of the superclassprotected
GroupAgentImpl
(KeyPair keys, SecretKey secret, Agent[] members, String groupName) constructor for thecreateGroupAgent(i5.las2peer.api.security.Agent[])
factory simply necessary, since the secret key has to be stated for the constructor of the superclassprotected
GroupAgentImpl
(PublicKey pubKey, byte[] encryptedPrivate, HashMap<String, byte[]> htEncryptedKeys) -
Method Summary
Modifier and TypeMethodDescriptionvoid
add a member to the admin list of this groupvoid
Adds a member to the group.void
add a member to this groupvoid
apply()
static GroupAgentImpl
createFromXml
(String xml) factory - create an instance of GroupAgent from its XML representationstatic GroupAgentImpl
createFromXml
(Element root) factory - create an instance of GroupAgent based on a XML nodestatic GroupAgentImpl
createGroupAgent
(Agent[] members) create a new group agent instancestatic GroupAgentImpl
createGroupAgent
(Agent[] members, String groupName) create a new group agent instance with groupNameGetter for the group name.String[]
get an array with the ids of all direct group members without recursionreturns the Agent by whom the private Key of this Group has been unlockedint
getSize()
how many members does this group haveboolean
Check if the agent has a group name set.boolean
Checks if the given agent is a member of this group.boolean
Checks if the given agent is a member of this group.boolean
Check admin rights for member.void
(Re-)Lock the private key.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
remove a member from this groupvoid
removeMember
(String id) remove a member from this groupvoid
revokeAdmin
(Agent a) remove a member from the admin list of this groupvoid
revokeMember
(Agent agent) Revokes a group membership.Returns a XML representation of this object.void
Unlock this group using a given agent.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
-
Field Details
-
groupName
-
adminList
-
-
Constructor Details
-
GroupAgentImpl
protected GroupAgentImpl(PublicKey pubKey, byte[] encryptedPrivate, HashMap<String, byte[]> htEncryptedKeys) throws AgentOperationFailedException- Throws:
AgentOperationFailedException
-
GroupAgentImpl
protected GroupAgentImpl(KeyPair keys, SecretKey secret, Agent[] members) throws AgentOperationFailedException, CryptoException, SerializationException constructor for thecreateGroupAgent(i5.las2peer.api.security.Agent[])
factory simply necessary, since the secret key has to be stated for the constructor of the superclass- Parameters:
keys
-secret
-members
-- Throws:
AgentOperationFailedException
CryptoException
SerializationException
-
GroupAgentImpl
protected GroupAgentImpl(KeyPair keys, SecretKey secret, Agent[] members, String groupName) throws AgentOperationFailedException, CryptoException, SerializationException constructor for thecreateGroupAgent(i5.las2peer.api.security.Agent[])
factory simply necessary, since the secret key has to be stated for the constructor of the superclass- Parameters:
keys
-secret
-members
-groupName
-- Throws:
AgentOperationFailedException
CryptoException
SerializationException
-
-
Method Details
-
addAdmin
add a member to the admin list of this group- Specified by:
addAdmin
in interfaceGroupAgent
- Parameters:
a
-
-
revokeAdmin
remove a member from the admin list of this group- Specified by:
revokeAdmin
in interfaceGroupAgent
- Parameters:
a
-
-
isAdmin
Check admin rights for member.- Specified by:
isAdmin
in interfaceGroupAgent
- Parameters:
a
- Member to check admin rights for.- Returns:
- if agent is admin
-
getGroupName
Description copied from interface:GroupAgent
Getter for the group name.- Specified by:
getGroupName
in interfaceGroupAgent
- Returns:
- The group name.
-
hasGroupName
public boolean hasGroupName()Description copied from interface:GroupAgent
Check if the agent has a group name set.- Specified by:
hasGroupName
in interfaceGroupAgent
- Returns:
- true If a group name is set up.
-
addMember
public void addMember(AgentImpl a) throws CryptoException, SerializationException, AgentLockedException add a member to this group- Parameters:
a
-- Throws:
CryptoException
SerializationException
AgentLockedException
-
getSize
public int getSize()how many members does this group have- Specified by:
getSize
in interfaceGroupAgent
- Returns:
- the number of group members
-
getMemberList
get an array with the ids of all direct group members without recursion- Specified by:
getMemberList
in interfaceGroupAgent
- Returns:
- an array with the ids of all direct member agents
-
getOpeningAgent
returns the Agent by whom the private Key of this Group has been unlocked- Returns:
- the agent, who opened the private key of the group
-
removeMember
remove a member from this group- Parameters:
a
-- Throws:
AgentLockedException
-
removeMember
remove a member from this group- Parameters:
id
-- Throws:
AgentLockedException
-
lockPrivateKey
public void lockPrivateKey()Description copied from class:AgentImpl
(Re-)Lock the private key.- Overrides:
lockPrivateKey
in classAgentImpl
-
toXmlString
Description copied from interface:XmlAble
Returns a XML representation of this object.- Specified by:
toXmlString
in interfaceXmlAble
- Returns:
- a XML String representation
-
createFromXml
factory - create an instance of GroupAgent from its XML representation- Parameters:
xml
-- Returns:
- a group agent
- Throws:
MalformedXMLException
-
createFromXml
factory - create an instance of GroupAgent based on a XML node- Parameters:
root
-- Returns:
- a group agent
- Throws:
MalformedXMLException
-
createGroupAgent
public static GroupAgentImpl createGroupAgent(Agent[] members) throws AgentOperationFailedException, CryptoException, SerializationException create a new group agent instance- Parameters:
members
-- Returns:
- a group agent
- Throws:
AgentOperationFailedException
CryptoException
SerializationException
-
createGroupAgent
public static GroupAgentImpl createGroupAgent(Agent[] members, String groupName) throws AgentOperationFailedException, CryptoException, SerializationException create a new group agent instance with groupName- Parameters:
members
-- Returns:
- a group agent
- Throws:
AgentOperationFailedException
CryptoException
SerializationException
-
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
-
addMember
Description copied from interface:GroupAgent
Adds a member to the group. Only for unlocked groups.- Specified by:
addMember
in interfaceGroupAgent
- Parameters:
agent
- The member to add.- Throws:
AgentLockedException
- If this group is locked.
-
revokeMember
Description copied from interface:GroupAgent
Revokes a group membership. This means that the given agent will not have access to any future updates to agents and contents this group has access to throgh this group. However, existing content may still be available to the revoked member. Ideally, a new key pair for this group will be generated whenever a member is removed. Only for unlocked groups.- Specified by:
revokeMember
in interfaceGroupAgent
- Parameters:
agent
- The member to remove from the group.- Throws:
AgentLockedException
- If this group is locked.
-
hasMember
Description copied from interface:GroupAgent
Checks if the given agent is a member of this group.- Specified by:
hasMember
in interfaceGroupAgent
- Parameters:
agent
- The agent whose membership has to be checked.- Returns:
- true if the given agent is a member of this group.
-
hasMember
Description copied from interface:GroupAgent
Checks if the given agent is a member of this group.- Specified by:
hasMember
in interfaceGroupAgent
- Parameters:
agentId
- The id of the agent whose membership has to be checked.- Returns:
- true if the given agent is a member of this group.
-
unlock
public void unlock(Agent agent) throws AgentAccessDeniedException, AgentOperationFailedException, AgentLockedException Description copied from interface:GroupAgent
Unlock this group using a given agent. Will not work for transitive memberships.- Specified by:
unlock
in interfaceGroupAgent
- 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.
-
apply
-