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
ConstructorsModifierConstructorDescriptionprotectedGroupAgentImpl(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 superclassprotectedGroupAgentImpl(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 superclassprotectedGroupAgentImpl(PublicKey pubKey, byte[] encryptedPrivate, HashMap<String, byte[]> htEncryptedKeys) -
Method Summary
Modifier and TypeMethodDescriptionvoidadd a member to the admin list of this groupvoidAdds a member to the group.voidadd a member to this groupvoidapply()static GroupAgentImplcreateFromXml(String xml) factory - create an instance of GroupAgent from its XML representationstatic GroupAgentImplcreateFromXml(Element root) factory - create an instance of GroupAgent based on a XML nodestatic GroupAgentImplcreateGroupAgent(Agent[] members) create a new group agent instancestatic GroupAgentImplcreateGroupAgent(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 unlockedintgetSize()how many members does this group havebooleanCheck if the agent has a group name set.booleanChecks if the given agent is a member of this group.booleanChecks if the given agent is a member of this group.booleanCheck admin rights for member.void(Re-)Lock the private key.voidNotifies this agent of unregistering from a node.voidreceiveMessage(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.voidremove a member from this groupvoidremoveMember(String id) remove a member from this groupvoidrevokeAdmin(Agent a) remove a member from the admin list of this groupvoidrevokeMember(Agent agent) Revokes a group membership.Returns a XML representation of this object.voidUnlock 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, unlockPrivateKeyMethods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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:
AgentOperationFailedExceptionCryptoExceptionSerializationException
-
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:
AgentOperationFailedExceptionCryptoExceptionSerializationException
-
-
Method Details
-
addAdmin
add a member to the admin list of this group- Specified by:
addAdminin interfaceGroupAgent- Parameters:
a-
-
revokeAdmin
remove a member from the admin list of this group- Specified by:
revokeAdminin interfaceGroupAgent- Parameters:
a-
-
isAdmin
Check admin rights for member.- Specified by:
isAdminin interfaceGroupAgent- Parameters:
a- Member to check admin rights for.- Returns:
- if agent is admin
-
getGroupName
Description copied from interface:GroupAgentGetter for the group name.- Specified by:
getGroupNamein interfaceGroupAgent- Returns:
- The group name.
-
hasGroupName
public boolean hasGroupName()Description copied from interface:GroupAgentCheck if the agent has a group name set.- Specified by:
hasGroupNamein 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:
CryptoExceptionSerializationExceptionAgentLockedException
-
getSize
public int getSize()how many members does this group have- Specified by:
getSizein interfaceGroupAgent- Returns:
- the number of group members
-
getMemberList
get an array with the ids of all direct group members without recursion- Specified by:
getMemberListin 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:
lockPrivateKeyin classAgentImpl
-
toXmlString
Description copied from interface:XmlAbleReturns a XML representation of this object.- Specified by:
toXmlStringin 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:
AgentOperationFailedExceptionCryptoExceptionSerializationException
-
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:
AgentOperationFailedExceptionCryptoExceptionSerializationException
-
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
-
notifyUnregister
public void notifyUnregister()Description copied from class:AgentImplNotifies this agent of unregistering from a node.- Specified by:
notifyUnregisterin interfaceMessageReceiver- Overrides:
notifyUnregisterin classAgentImpl
-
addMember
Description copied from interface:GroupAgentAdds a member to the group. Only for unlocked groups.- Specified by:
addMemberin interfaceGroupAgent- Parameters:
agent- The member to add.- Throws:
AgentLockedException- If this group is locked.
-
revokeMember
Description copied from interface:GroupAgentRevokes 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:
revokeMemberin interfaceGroupAgent- Parameters:
agent- The member to remove from the group.- Throws:
AgentLockedException- If this group is locked.
-
hasMember
Description copied from interface:GroupAgentChecks if the given agent is a member of this group.- Specified by:
hasMemberin 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:GroupAgentChecks if the given agent is a member of this group.- Specified by:
hasMemberin 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:GroupAgentUnlock this group using a given agent. Will not work for transitive memberships.- Specified by:
unlockin 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
-