use of cz.metacentrum.perun.core.bl.GroupsManagerBl in project perun by CESNET.
the class VOOT method createVOOTGroups.
/**
* This method creates groups used by VOOT, that are represented to end-user. They are created from groups by provider.
*
* @param groups groups from provider
* @return array of groups, that are represented to end-user
* @throws VOOTException if can not read groups by provider
*/
private VOOTGroup[] createVOOTGroups(List<Group> groups) throws VOOTException {
GroupsManagerBl groupManager = perun.getGroupsManagerBl();
VOOTGroup[] vootGroups = new VOOTGroup[groups.size()];
int i = 0;
for (Group group : groups) {
String vootMembership;
try {
if (groupManager.getAdmins(session, group).contains(user)) {
vootMembership = "admin";
} else {
vootMembership = "member";
}
vootGroups[i] = new VOOTGroup(group, groupManager.getVo(session, group).getShortName(), vootMembership);
i++;
} catch (InternalErrorException ex) {
throw new VOOTException("internal_server_error");
}
}
return vootGroups;
}
use of cz.metacentrum.perun.core.bl.GroupsManagerBl in project perun by CESNET.
the class ResourcesManagerBlImpl method assignGroupsToResource.
@Override
public void assignGroupsToResource(PerunSession perunSession, Iterable<Group> groups, Resource resource, boolean async, boolean assignInactive, boolean autoAssignSubgroups) throws WrongAttributeValueException, WrongReferenceAttributeValueException, GroupResourceMismatchException {
for (Group g : groups) {
getPerunBl().getAttributesManagerBl().checkGroupIsFromTheSameVoLikeResource(perunSession, g, resource);
// assign source group
try {
getResourcesManagerImpl().assignGroupToResource(perunSession, g, resource, autoAssignSubgroups);
setAssignedGroupStatusAndActivate(perunSession, resource, async, assignInactive, g);
} catch (GroupAlreadyAssignedException e) {
// silently skip
}
if (autoAssignSubgroups) {
GroupsManagerBl groupsManager = getPerunBl().getGroupsManagerBl();
List<Group> subgroups;
// If it is 'members' group, use all groups from corresponding VO (except for members, they've been assigned already)
if (g.getName().equals(VosManager.MEMBERS_GROUP)) {
subgroups = groupsManager.getAllGroups(perunSession, groupsManager.getVo(perunSession, g));
subgroups.removeIf((group -> group.getName().equals(VosManager.MEMBERS_GROUP)));
} else {
subgroups = groupsManager.getAllSubGroups(perunSession, g);
}
for (Group subgroup : subgroups) {
try {
assignAutomaticGroupToResource(perunSession, g, subgroup, resource);
} catch (GroupAlreadyAssignedException e) {
// silently skip
}
}
}
}
}
use of cz.metacentrum.perun.core.bl.GroupsManagerBl in project perun by CESNET.
the class urn_perun_user_facility_attribute_def_def_defaultUnixGIDTest method setUp.
@Before
public void setUp() throws Exception {
classInstance = new urn_perun_user_facility_attribute_def_def_defaultUnixGID();
attributeToCheck = new Attribute();
attributeToCheck.setValue(5);
namespace = new Attribute();
namespace.setValue("namespace");
unixGroupNamespace = new Attribute();
unixGroupNamespace.setValue("unixGroupNamespace");
resourceGidAttribute = new Attribute();
resourceGidAttribute.setValue("resourceGidAttribute");
groupGidAttribute = new Attribute();
groupGidAttribute.setValue("groupGidAttribute");
sess = mock(PerunSessionImpl.class);
PerunBl perunBl = mock(PerunBl.class);
when(sess.getPerunBl()).thenReturn(perunBl);
AttributesManagerBl attributesManagerBl = mock(AttributesManagerBl.class);
when(perunBl.getAttributesManagerBl()).thenReturn(attributesManagerBl);
when(sess.getPerunBl().getAttributesManagerBl().getAttribute(sess, facility, AttributesManager.NS_FACILITY_ATTR_DEF + ":unixGID-namespace")).thenReturn(namespace);
when(sess.getPerunBl().getAttributesManagerBl().getAttribute(sess, facility, AttributesManager.NS_FACILITY_ATTR_DEF + ":unixGroupName-namespace")).thenReturn(unixGroupNamespace);
when(sess.getPerunBl().getAttributesManagerBl().getAttributeDefinition(sess, AttributesManager.NS_RESOURCE_ATTR_DEF + ":unixGID-namespace:" + namespace.valueAsString())).thenReturn(resourceGidAttribute);
when(sess.getPerunBl().getAttributesManagerBl().getAttributeDefinition(sess, AttributesManager.NS_GROUP_ATTR_DEF + ":unixGID-namespace:" + namespace.valueAsString())).thenReturn(groupGidAttribute);
ResourcesManagerBl resourcesManagerBl = mock(ResourcesManagerBl.class);
when(sess.getPerunBl().getResourcesManagerBl()).thenReturn(resourcesManagerBl);
UsersManagerBl usersManagerBl = mock(UsersManagerBl.class);
when(sess.getPerunBl().getUsersManagerBl()).thenReturn(usersManagerBl);
GroupsManagerBl groupsManagerBl = mock(GroupsManagerBl.class);
when(sess.getPerunBl().getGroupsManagerBl()).thenReturn(groupsManagerBl);
when(sess.getPerunBl().getGroupsManagerBl().getGroupsByAttribute(sess, groupGidAttribute)).thenReturn(new ArrayList<>());
FacilitiesManagerBl facilitiesManagerBl = mock(FacilitiesManagerBl.class);
when(sess.getPerunBl().getFacilitiesManagerBl()).thenReturn(facilitiesManagerBl);
when(sess.getPerunBl().getFacilitiesManagerBl().getAllowedGroups(sess, facility, null, null)).thenReturn(new ArrayList<>());
}
use of cz.metacentrum.perun.core.bl.GroupsManagerBl in project perun by CESNET.
the class urn_perun_group_attribute_def_def_groupStructureSynchronizationEnabledTest method setUp.
@Before
public void setUp() throws Exception {
classInstance = new urn_perun_group_attribute_def_def_groupStructureSynchronizationEnabled();
reqAttribute = new Attribute(classInstance.getAttributeDefinition());
attributeToCheck = new Attribute(classInstance.getAttributeDefinition());
sess = mock(PerunSessionImpl.class);
PerunBl perunBl = mock(PerunBl.class);
when(sess.getPerunBl()).thenReturn(perunBl);
GroupsManagerBl groupsManagerBl = mock(GroupsManagerBl.class);
when(sess.getPerunBl().getGroupsManagerBl()).thenReturn(groupsManagerBl);
when(sess.getPerunBl().getGroupsManagerBl().isGroupSynchronizedFromExternallSource(sess, group)).thenReturn(false);
AttributesManagerBl attributesManagerBl = mock(AttributesManagerBl.class);
when(perunBl.getAttributesManagerBl()).thenReturn(attributesManagerBl);
when(sess.getPerunBl().getAttributesManagerBl().getAttribute(sess, group, GroupsManager.GROUPSYNCHROENABLED_ATTRNAME)).thenReturn(reqAttribute);
when(sess.getPerunBl().getAttributesManagerBl().getAttribute(sess, group, GroupsManager.GROUPSQUERY_ATTRNAME)).thenReturn(reqAttribute);
when(sess.getPerunBl().getAttributesManagerBl().getAttribute(sess, group, GroupsManager.GROUPMEMBERSQUERY_ATTRNAME)).thenReturn(reqAttribute);
when(sess.getPerunBl().getAttributesManagerBl().getAttribute(sess, group, GroupsManager.GROUPEXTSOURCE_ATTRNAME)).thenReturn(reqAttribute);
}
use of cz.metacentrum.perun.core.bl.GroupsManagerBl in project perun by CESNET.
the class urn_perun_group_attribute_def_def_groupSynchronizationTimesTest method setUp.
@Before
public void setUp() throws Exception {
classInstance = new urn_perun_group_attribute_def_def_groupSynchronizationTimes();
syncInterval = new Attribute(classInstance.getAttributeDefinition());
attributeToCheck = new Attribute(classInstance.getAttributeDefinition());
sess = mock(PerunSessionImpl.class);
PerunBl perunBl = mock(PerunBl.class);
when(sess.getPerunBl()).thenReturn(perunBl);
GroupsManagerBl groupsManagerBl = mock(GroupsManagerBl.class);
when(sess.getPerunBl().getGroupsManagerBl()).thenReturn(groupsManagerBl);
when(sess.getPerunBl().getGroupsManagerBl().isGroupSynchronizedFromExternallSource(sess, group)).thenReturn(false);
AttributesManagerBl attributesManagerBl;
attributesManagerBl = mock(AttributesManagerBl.class);
when(perunBl.getAttributesManagerBl()).thenReturn(attributesManagerBl);
when(sess.getPerunBl().getAttributesManagerBl().getAttribute(sess, group, GroupsManager.GROUPSYNCHROINTERVAL_ATTRNAME)).thenReturn(syncInterval);
}
Aggregations