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);
}
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);
}
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);
}
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);
}
}
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);
}
}
Aggregations