Search in sources :

Example 1 with AttributesManagerBl

use of cz.metacentrum.perun.core.bl.AttributesManagerBl in project perun by CESNET.

the class ResourcesManagerBlImpl method checkSemanticsOfFacilityAndResourceRequiredAttributes.

/**
 * Checks semantics of all required attributes of given resource and its facility.
 *
 * @param sess session
 * @param resource resource used to get facility and attributes
 * @throws WrongReferenceAttributeValueException WrongReferenceAttributeValueException
 * @throws WrongAttributeAssignmentException WrongAttributeAssignmentException
 */
public void checkSemanticsOfFacilityAndResourceRequiredAttributes(PerunSession sess, Resource resource) throws WrongReferenceAttributeValueException, WrongAttributeAssignmentException {
    AttributesManagerBl attributesManagerBl = getPerunBl().getAttributesManagerBl();
    Facility facility = getFacility(sess, resource);
    List<Attribute> facilityRequiredAttributes = attributesManagerBl.getRequiredAttributes(sess, facility);
    List<Attribute> resourceRequiredAttributes = attributesManagerBl.getRequiredAttributes(sess, resource);
    attributesManagerBl.checkAttributesSemantics(sess, facility, facilityRequiredAttributes);
    attributesManagerBl.checkAttributesSemantics(sess, resource, resourceRequiredAttributes);
}
Also used : Attribute(cz.metacentrum.perun.core.api.Attribute) Facility(cz.metacentrum.perun.core.api.Facility) AttributesManagerBl(cz.metacentrum.perun.core.bl.AttributesManagerBl)

Example 2 with AttributesManagerBl

use of cz.metacentrum.perun.core.bl.AttributesManagerBl 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<>());
}
Also used : ResourcesManagerBl(cz.metacentrum.perun.core.bl.ResourcesManagerBl) FacilitiesManagerBl(cz.metacentrum.perun.core.bl.FacilitiesManagerBl) GroupsManagerBl(cz.metacentrum.perun.core.bl.GroupsManagerBl) Attribute(cz.metacentrum.perun.core.api.Attribute) PerunBl(cz.metacentrum.perun.core.bl.PerunBl) PerunSessionImpl(cz.metacentrum.perun.core.impl.PerunSessionImpl) UsersManagerBl(cz.metacentrum.perun.core.bl.UsersManagerBl) AttributesManagerBl(cz.metacentrum.perun.core.bl.AttributesManagerBl) Before(org.junit.Before)

Example 3 with AttributesManagerBl

use of cz.metacentrum.perun.core.bl.AttributesManagerBl in project perun by CESNET.

the class urn_perun_user_facility_attribute_def_virt_loginTest method setUp.

@Before
public void setUp() throws Exception {
    classInstance = new urn_perun_user_facility_attribute_def_virt_login();
    attributeToCheck = new Attribute();
    userLoginNamespace = new Attribute();
    userLoginNamespace.setValue("user_login_namespace");
    facilityLoginNamespace = new Attribute();
    facilityLoginNamespace.setValue("facility_login_namespace");
    sess = mock(PerunSessionImpl.class);
    PerunBl perunBl = mock(PerunBl.class);
    when(sess.getPerunBl()).thenReturn(perunBl);
    AttributesManagerBl attributesManagerBl = mock(AttributesManagerBl.class);
    when(sess.getPerunBl().getAttributesManagerBl()).thenReturn(attributesManagerBl);
    when(attributesManagerBl.getAttribute(sess, facility, AttributesManager.NS_FACILITY_ATTR_DEF + ":login-namespace")).thenReturn(facilityLoginNamespace);
    when(attributesManagerBl.getAttribute(sess, user, AttributesManager.NS_USER_ATTR_DEF + ":login-namespace:" + facilityLoginNamespace.getValue())).thenReturn(userLoginNamespace);
}
Also used : Attribute(cz.metacentrum.perun.core.api.Attribute) PerunBl(cz.metacentrum.perun.core.bl.PerunBl) PerunSessionImpl(cz.metacentrum.perun.core.impl.PerunSessionImpl) AttributesManagerBl(cz.metacentrum.perun.core.bl.AttributesManagerBl) Before(org.junit.Before)

Example 4 with AttributesManagerBl

use of cz.metacentrum.perun.core.bl.AttributesManagerBl 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);
}
Also used : GroupsManagerBl(cz.metacentrum.perun.core.bl.GroupsManagerBl) Attribute(cz.metacentrum.perun.core.api.Attribute) PerunBl(cz.metacentrum.perun.core.bl.PerunBl) PerunSessionImpl(cz.metacentrum.perun.core.impl.PerunSessionImpl) AttributesManagerBl(cz.metacentrum.perun.core.bl.AttributesManagerBl) Before(org.junit.Before)

Example 5 with AttributesManagerBl

use of cz.metacentrum.perun.core.bl.AttributesManagerBl 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);
}
Also used : GroupsManagerBl(cz.metacentrum.perun.core.bl.GroupsManagerBl) Attribute(cz.metacentrum.perun.core.api.Attribute) PerunBl(cz.metacentrum.perun.core.bl.PerunBl) PerunSessionImpl(cz.metacentrum.perun.core.impl.PerunSessionImpl) AttributesManagerBl(cz.metacentrum.perun.core.bl.AttributesManagerBl) Before(org.junit.Before)

Aggregations

AttributesManagerBl (cz.metacentrum.perun.core.bl.AttributesManagerBl)56 Attribute (cz.metacentrum.perun.core.api.Attribute)48 PerunBl (cz.metacentrum.perun.core.bl.PerunBl)44 PerunSessionImpl (cz.metacentrum.perun.core.impl.PerunSessionImpl)43 Before (org.junit.Before)42 Facility (cz.metacentrum.perun.core.api.Facility)13 GroupsManagerBl (cz.metacentrum.perun.core.bl.GroupsManagerBl)11 User (cz.metacentrum.perun.core.api.User)9 ArrayList (java.util.ArrayList)9 ResourcesManagerBl (cz.metacentrum.perun.core.bl.ResourcesManagerBl)8 ModulesUtilsBl (cz.metacentrum.perun.core.bl.ModulesUtilsBl)6 UsersManagerBl (cz.metacentrum.perun.core.bl.UsersManagerBl)6 AttributeDefinition (cz.metacentrum.perun.core.api.AttributeDefinition)5 AttributeNotExistsException (cz.metacentrum.perun.core.api.exceptions.AttributeNotExistsException)5 InternalErrorException (cz.metacentrum.perun.core.api.exceptions.InternalErrorException)5 WrongAttributeAssignmentException (cz.metacentrum.perun.core.api.exceptions.WrongAttributeAssignmentException)4 WrongReferenceAttributeValueException (cz.metacentrum.perun.core.api.exceptions.WrongReferenceAttributeValueException)4 Group (cz.metacentrum.perun.core.api.Group)3 FacilitiesManagerBl (cz.metacentrum.perun.core.bl.FacilitiesManagerBl)3 AttributeChangedForUser (cz.metacentrum.perun.audit.events.AttributesManagerEvents.AttributeChangedForUser)2