use of cz.metacentrum.perun.core.api.RichMember in project perun by CESNET.
the class ExtSourcePerun method convertListOfRichMembersToListOfRichUsers.
private List<RichUser> convertListOfRichMembersToListOfRichUsers(List<RichMember> richMembers) throws InternalErrorException {
List<RichUser> richUsers = new ArrayList<>();
if (richMembers == null || richMembers.isEmpty())
return richUsers;
for (RichMember rm : richMembers) {
RichUser ru = new RichUser(rm.getUser(), rm.getUserExtSources(), rm.getUserAttributes());
richUsers.add(ru);
}
return richUsers;
}
use of cz.metacentrum.perun.core.api.RichMember in project perun by CESNET.
the class MembersManagerBlImpl method getRichMembersWithAttributesByNames.
public List<RichMember> getRichMembersWithAttributesByNames(PerunSession sess, Vo vo, List<String> attrsNames) throws InternalErrorException, AttributeNotExistsException {
List<Member> members = new ArrayList<Member>();
members.addAll(perunBl.getMembersManagerBl().getMembers(sess, vo));
List<RichMember> richMembers = this.convertMembersToRichMembers(sess, members);
List<AttributeDefinition> attrsDef = new ArrayList<AttributeDefinition>();
for (String atrrName : attrsNames) {
AttributeDefinition attrDef = perunBl.getAttributesManagerBl().getAttributeDefinition(sess, atrrName);
attrsDef.add(attrDef);
}
List<RichMember> richMembersWithAttributes = this.convertMembersToRichMembersWithAttributes(sess, richMembers, attrsDef);
return richMembersWithAttributes;
}
use of cz.metacentrum.perun.core.api.RichMember in project perun by CESNET.
the class MembersManagerBlImpl method convertMembersToRichMembersWithAttributes.
public List<RichMember> convertMembersToRichMembersWithAttributes(PerunSession sess, List<RichMember> richMembers, List<AttributeDefinition> attrsDef) throws InternalErrorException {
List<AttributeDefinition> usersAttributesDef = new ArrayList<AttributeDefinition>();
List<AttributeDefinition> membersAttributesDef = new ArrayList<AttributeDefinition>();
for (AttributeDefinition attrd : attrsDef) {
if (attrd.getName().startsWith(AttributesManager.NS_USER_ATTR))
usersAttributesDef.add(attrd);
else if (attrd.getName().startsWith(AttributesManager.NS_MEMBER_ATTR))
membersAttributesDef.add(attrd);
}
for (RichMember richMember : richMembers) {
List<Attribute> userAttributes = new ArrayList<Attribute>();
List<Attribute> memberAttributes = new ArrayList<Attribute>();
List<String> userAttrNames = new ArrayList<String>();
for (AttributeDefinition ad : usersAttributesDef) {
userAttrNames.add(ad.getName());
}
userAttributes.addAll(getPerunBl().getAttributesManagerBl().getAttributes(sess, richMember.getUser(), userAttrNames));
List<String> memberAttrNames = new ArrayList<String>();
for (AttributeDefinition ad : membersAttributesDef) {
memberAttrNames.add(ad.getName());
}
memberAttributes.addAll(getPerunBl().getAttributesManagerBl().getAttributes(sess, richMember, memberAttrNames));
richMember.setUserAttributes(userAttributes);
richMember.setMemberAttributes(memberAttributes);
}
return richMembers;
}
use of cz.metacentrum.perun.core.api.RichMember in project perun by CESNET.
the class MembersManagerEntry method getRichMemberById.
public RichMember getRichMemberById(PerunSession sess, int id) throws InternalErrorException, PrivilegeException, MemberNotExistsException {
Utils.checkPerunSession(sess);
Member member = getPerunBl().getMembersManagerBl().getMemberById(sess, id);
Vo vo = getPerunBl().getMembersManagerBl().getMemberVo(sess, member);
// Authorization
if (!AuthzResolver.isAuthorized(sess, Role.VOADMIN, vo) && !AuthzResolver.isAuthorized(sess, Role.VOOBSERVER, vo) && !AuthzResolver.isAuthorized(sess, Role.GROUPADMIN, vo) && !AuthzResolver.isAuthorized(sess, Role.SELF, member)) {
throw new PrivilegeException(sess, "getRichMemberById");
}
return getPerunBl().getMembersManagerBl().getRichMember(sess, member);
}
use of cz.metacentrum.perun.core.api.RichMember in project perun by CESNET.
the class MembersManagerEntry method findCompleteRichMembers.
@Override
public List<RichMember> findCompleteRichMembers(PerunSession sess, List<String> attrsNames, List<String> allowedStatuses, String searchString) throws InternalErrorException, MemberNotExistsException, PrivilegeException, VoNotExistsException, AttributeNotExistsException {
Utils.checkPerunSession(sess);
// Authorization
if (!AuthzResolver.isAuthorized(sess, Role.VOADMIN) && !AuthzResolver.isAuthorized(sess, Role.VOOBSERVER) && !AuthzResolver.isAuthorized(sess, Role.GROUPADMIN) && !AuthzResolver.isAuthorized(sess, Role.FACILITYADMIN)) {
throw new PrivilegeException(sess, "findCompleteRichMembers");
}
List<RichMember> richMembers = getMembersManagerBl().findCompleteRichMembers(sess, attrsNames, allowedStatuses, searchString);
Iterator<RichMember> richMemberIter = richMembers.iterator();
while (richMemberIter.hasNext()) {
RichMember richMember = richMemberIter.next();
//if voadmin or voobserver or groupadmin has right to this member, its ok
if (AuthzResolver.isAuthorized(sess, Role.VOADMIN, richMember) || AuthzResolver.isAuthorized(sess, Role.VOOBSERVER, richMember) || AuthzResolver.isAuthorized(sess, Role.GROUPADMIN, richMember))
continue;
//if not, then try facility admin rights
List<Resource> membersResources = getPerunBl().getResourcesManagerBl().getAssignedResources(sess, richMember);
boolean found = false;
for (Resource resource : membersResources) {
if (AuthzResolver.isAuthorized(sess, Role.FACILITYADMIN, resource)) {
found = true;
break;
}
}
if (found)
continue;
richMemberIter.remove();
}
return getPerunBl().getMembersManagerBl().filterOnlyAllowedAttributes(sess, richMembers, false);
}
Aggregations