use of i5.las2peer.security.UserAgentImpl in project Distributed-Noracle-Backend by Distributed-Noracle.
the class NoracleSpaceService method getSubscribers.
@Override
public SpaceSubscribersList getSubscribers(String spaceId) throws ServiceInvocationException {
if (spaceId == null || spaceId.isEmpty()) {
throw new InvocationBadArgumentException("No space id given");
}
try {
UserAgentImpl inviteAgent = this.getInviteAgent(spaceId);
GroupAgent memberAgent = this.getMemberAgent(spaceId);
memberAgent.unlock(Context.get().getMainAgent());
String[] memberIds = memberAgent.getMemberList();
SpaceSubscribersList subscribers = new SpaceSubscribersList();
for (int i = 0; i < memberIds.length; i++) {
if (!memberIds[i].equals(inviteAgent.getIdentifier())) {
UserAgentImpl agent = (UserAgentImpl) Context.get().fetchAgent(memberIds[i]);
NoracleAgentProfile profile = new NoracleAgentProfile();
profile.setName(agent.getLoginName());
subscribers.add(profile);
}
}
return subscribers;
} catch (Exception e) {
throw new ServiceInvocationException("Could not fetch list", e);
}
}
use of i5.las2peer.security.UserAgentImpl in project Distributed-Noracle-Backend by Distributed-Noracle.
the class NoracleSpaceService method getInviteAgent.
private UserAgentImpl getInviteAgent(String spaceId) throws AgentNotFoundException, AgentOperationFailedException, EnvelopeAccessDeniedException, EnvelopeNotFoundException, EnvelopeOperationFailedException {
String inviteAgentEnvelopeId = getInviteMappingIdentifier(spaceId);
Envelope inviteAgentMapping = Context.get().requestEnvelope(inviteAgentEnvelopeId);
String inviteAgentId = (String) inviteAgentMapping.getContent();
UserAgentImpl inviteAgent = (UserAgentImpl) Context.get().fetchAgent(inviteAgentId);
return inviteAgent;
}
use of i5.las2peer.security.UserAgentImpl in project Distributed-Noracle-Backend by Distributed-Noracle.
the class NoracleSpaceService method joinSpace.
public void joinSpace(String spaceId, String spaceSecret) throws ServiceInvocationException {
if (spaceId == null || spaceId.isEmpty()) {
throw new InvocationBadArgumentException("No space id given");
} else if (spaceSecret == null || spaceSecret.isEmpty()) {
throw new ServiceAccessDeniedException("No space secret given");
}
try {
UserAgentImpl inviteAgent = this.getInviteAgent(spaceId);
inviteAgent.unlock(spaceSecret);
GroupAgent memberAgent = this.getMemberAgent(spaceId);
memberAgent.unlock(inviteAgent);
memberAgent.addMember(Context.get().getMainAgent());
Context.get().storeAgent(memberAgent);
} catch (AgentAccessDeniedException e) {
throw new ServiceAccessDeniedException("Could not unlock agent", e);
} catch (Exception e) {
throw new ServiceInvocationException("Could not join space", e);
}
}
Aggregations