Search in sources :

Example 41 with PerunBl

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

the class urn_perun_user_attribute_def_def_vsupPreferredMailTest method setUp.

@Before
public void setUp() throws Exception {
    classInstance = new urn_perun_user_attribute_def_def_vsupPreferredMail();
    session = mock(PerunSessionImpl.class);
    user = new User(0, "John", "Doe", "", "", "");
    attributeToCheck = new Attribute();
    PerunBl perunBl = mock(PerunBl.class);
    when(session.getPerunBl()).thenReturn(perunBl);
}
Also used : User(cz.metacentrum.perun.core.api.User) Attribute(cz.metacentrum.perun.core.api.Attribute) PerunBl(cz.metacentrum.perun.core.bl.PerunBl) PerunSessionImpl(cz.metacentrum.perun.core.impl.PerunSessionImpl) Before(org.junit.Before)

Example 42 with PerunBl

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

the class urn_perun_user_attribute_def_def_login_namespace_vsupTest method setUp.

@Before
public void setUp() throws Exception {
    classInstance = new urn_perun_user_attribute_def_def_login_namespace_vsup();
    session = mock(PerunSessionImpl.class);
    user = new User();
    attributeToCheck = new Attribute();
    attributeToCheck.setNamespace(AttributesManager.NS_USER_ATTR_DEF);
    attributeToCheck.setFriendlyName("login-namespace:vsup");
    PerunBl perunBl = mock(PerunBl.class);
    when(session.getPerunBl()).thenReturn(perunBl);
    ModulesUtilsBl modulesUtilsBl = mock(ModulesUtilsBl.class);
    when(perunBl.getModulesUtilsBl()).thenReturn(modulesUtilsBl);
    UsersManagerBl usersManagerBl = mock(UsersManagerBl.class);
    when(perunBl.getUsersManagerBl()).thenReturn(usersManagerBl);
    PasswordManagerModule module = mock(GenericPasswordManagerModule.class);
    when(session.getPerunBl().getUsersManagerBl().getPasswordManagerModule(session, "vsup")).thenReturn(module);
}
Also used : User(cz.metacentrum.perun.core.api.User) ModulesUtilsBl(cz.metacentrum.perun.core.bl.ModulesUtilsBl) Attribute(cz.metacentrum.perun.core.api.Attribute) PasswordManagerModule(cz.metacentrum.perun.core.implApi.modules.pwdmgr.PasswordManagerModule) GenericPasswordManagerModule(cz.metacentrum.perun.core.impl.modules.pwdmgr.GenericPasswordManagerModule) PerunBl(cz.metacentrum.perun.core.bl.PerunBl) PerunSessionImpl(cz.metacentrum.perun.core.impl.PerunSessionImpl) UsersManagerBl(cz.metacentrum.perun.core.bl.UsersManagerBl) Before(org.junit.Before)

Example 43 with PerunBl

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

the class urn_perun_user_attribute_def_def_uid_namespaceTest method setUp.

@Before
public void setUp() throws Exception {
    classInstance = new urn_perun_user_attribute_def_def_uid_namespace();
    session = mock(PerunSessionImpl.class);
    user = new User(0, "John", "Doe", "", "", "");
    attributeToCheck = new Attribute();
    attributeToCheck.setFriendlyName("name:param");
    minUid = new Attribute();
    maxUid = new Attribute();
    PerunBl perunBl = mock(PerunBl.class);
    when(session.getPerunBl()).thenReturn(perunBl);
    AttributesManagerBl attributesManagerBl = mock(AttributesManagerBl.class);
    when(session.getPerunBl().getAttributesManagerBl()).thenReturn(attributesManagerBl);
    when(session.getPerunBl().getAttributesManagerBl().getAttribute(session, "param", AttributesManager.NS_ENTITYLESS_ATTR_DEF + ":namespace-minUID")).thenReturn(minUid);
    when(session.getPerunBl().getAttributesManagerBl().getAttribute(session, "param", AttributesManager.NS_ENTITYLESS_ATTR_DEF + ":namespace-maxUID")).thenReturn(maxUid);
    UsersManagerBl usersManagerBl = mock(UsersManagerBl.class);
    when(session.getPerunBl().getUsersManagerBl()).thenReturn(usersManagerBl);
}
Also used : User(cz.metacentrum.perun.core.api.User) 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 44 with PerunBl

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

the class BBMRICollections method canBeApproved.

/**
 * Checks whether all collection IDs found in user input really exists in Perun.
 * If not, CantBeApproved exception is thrown.
 *
 * @param session who approves the application
 * @param app     unchanged application
 * @throws CantBeApprovedException if at least one collection ID does not exist in Perun
 */
public void canBeApproved(PerunSession session, Application app) throws PerunException {
    // get perun and beans from session
    PerunBl perun = (PerunBl) session.getPerun();
    Vo vo = app.getVo();
    // get all collection IDs from Perun
    String directoryGroupName = getDirectoryGroupNameFromApplication(session, app);
    Group directoryGroup;
    try {
        directoryGroup = perun.getGroupsManager().getGroupByName(session, vo, directoryGroupName);
    } catch (GroupNotExistsException e) {
        throw new InternalErrorException("Target group does not exist");
    }
    Set<String> collectionIDsInPerun = getCollectionIDs(session, perun, directoryGroup);
    // get the field of application with the collections
    Set<String> collectionIDsInApplication = getCollectionIDsFromApplication(session, app);
    // get non-existing collections
    collectionIDsInApplication.removeAll(collectionIDsInPerun);
    // difference must be empty
    if (!collectionIDsInApplication.isEmpty()) {
        throw new CantBeApprovedException("Collections " + collectionIDsInApplication + " do not exist." + "If you approve the application, these collections will be skipped.", "", "", "", true);
    }
}
Also used : GroupNotExistsException(cz.metacentrum.perun.core.api.exceptions.GroupNotExistsException) CantBeApprovedException(cz.metacentrum.perun.registrar.exceptions.CantBeApprovedException) PerunBl(cz.metacentrum.perun.core.bl.PerunBl) InternalErrorException(cz.metacentrum.perun.core.api.exceptions.InternalErrorException)

Example 45 with PerunBl

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

the class BBMRINetworks method canBeApproved.

/**
 * Checks whether all network IDs found in user input really exists in Perun.
 * If not, CantBeApproved exception is thrown.
 *
 * @param session who approves the application
 * @param app     unchanged application
 * @throws CantBeApprovedException if at least one network ID does not exist in Perun
 */
public void canBeApproved(PerunSession session, Application app) throws PerunException {
    // get perun and beans from session
    PerunBl perun = (PerunBl) session.getPerun();
    Vo vo = app.getVo();
    // get all network IDs from Perun
    Group networksGroup = perun.getGroupsManagerBl().getGroupByName(session, vo, NETWORKS_GROUP_NAME);
    Set<String> neworksIDsInPerun = getNetworkIDs(session, perun, networksGroup);
    // get the field of application with the collections
    Set<String> networkIDsInApplication = getNetworkIDsFromApplication(session, app);
    // get non-existing collections
    networkIDsInApplication.removeAll(neworksIDsInPerun);
    // difference must be empty
    if (!networkIDsInApplication.isEmpty()) {
        throw new CantBeApprovedException("Networks with IDs: " + networkIDsInApplication + " do not exist." + "If you approve the application, these networks will be skipped.", "", "", "", true);
    }
}
Also used : Group(cz.metacentrum.perun.core.api.Group) CantBeApprovedException(cz.metacentrum.perun.registrar.exceptions.CantBeApprovedException) PerunBl(cz.metacentrum.perun.core.bl.PerunBl) Vo(cz.metacentrum.perun.core.api.Vo)

Aggregations

PerunBl (cz.metacentrum.perun.core.bl.PerunBl)130 Attribute (cz.metacentrum.perun.core.api.Attribute)93 Before (org.junit.Before)65 PerunSessionImpl (cz.metacentrum.perun.core.impl.PerunSessionImpl)64 AttributesManagerBl (cz.metacentrum.perun.core.bl.AttributesManagerBl)48 User (cz.metacentrum.perun.core.api.User)41 InternalErrorException (cz.metacentrum.perun.core.api.exceptions.InternalErrorException)37 ArrayList (java.util.ArrayList)22 Vo (cz.metacentrum.perun.core.api.Vo)21 Facility (cz.metacentrum.perun.core.api.Facility)19 UserExtSource (cz.metacentrum.perun.core.api.UserExtSource)19 ModulesUtilsBl (cz.metacentrum.perun.core.bl.ModulesUtilsBl)19 ExtSource (cz.metacentrum.perun.core.api.ExtSource)16 Member (cz.metacentrum.perun.core.api.Member)16 AttributeNotExistsException (cz.metacentrum.perun.core.api.exceptions.AttributeNotExistsException)16 UserExtSourceExistsException (cz.metacentrum.perun.core.api.exceptions.UserExtSourceExistsException)16 UsersManagerBl (cz.metacentrum.perun.core.bl.UsersManagerBl)15 WrongAttributeAssignmentException (cz.metacentrum.perun.core.api.exceptions.WrongAttributeAssignmentException)14 GroupsManagerBl (cz.metacentrum.perun.core.bl.GroupsManagerBl)13 Group (cz.metacentrum.perun.core.api.Group)12