use of cz.metacentrum.perun.core.bl.AttributesManagerBl in project perun by CESNET.
the class urn_perun_user_attribute_def_def_preferredEduPersonPrincipalNameTest method setUp.
@Before
public void setUp() throws Exception {
classInstance = new urn_perun_user_attribute_def_def_preferredEduPersonPrincipalName();
session = mock(PerunSessionImpl.class);
user = new User(0, "John", "Doe", "", "", "");
attributeToCheck = new Attribute();
reqAttribute = 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, user, AttributesManager.NS_USER_ATTR_VIRT + ":eduPersonPrincipalNames")).thenReturn(reqAttribute);
}
use of cz.metacentrum.perun.core.bl.AttributesManagerBl in project perun by CESNET.
the class urn_perun_user_attribute_def_def_userPreferredCertDNTest method setUp.
@Before
public void setUp() throws Exception {
classInstance = new urn_perun_user_attribute_def_def_userPreferredCertDN();
session = mock(PerunSessionImpl.class);
user = new User(0, "John", "Doe", "", "", "");
attributeToCheck = new Attribute();
reqAttribute = 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, user, AttributesManager.NS_USER_ATTR_DEF + ":userCertDNs")).thenReturn(reqAttribute);
}
use of cz.metacentrum.perun.core.bl.AttributesManagerBl 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.AttributesManagerBl in project perun by CESNET.
the class ElixirBonaFideStatus method canBeSubmitted.
/**
* Validate if the user meets criteria for applying to group.
*/
@Override
public void canBeSubmitted(PerunSession session, Application.AppType appType, Map<String, String> params) throws PerunException {
User user = session.getPerunPrincipal().getUser();
if (user == null) {
throw new CantBeSubmittedException("This module can be set only for registration to Group.");
}
AttributesManagerBl am = ((PerunBl) session.getPerun()).getAttributesManagerBl();
Attribute affiliations = am.getAttribute(session, user, A_U_D_userEduPersonScopedAffiliations);
if (affiliations.getValue() != null) {
List<String> val = affiliations.valueAsList();
for (String affiliation : val) {
if (affiliation.startsWith("faculty@")) {
return;
}
}
}
Attribute rems = am.getAttribute(session, user, A_U_D_userBonaFideStatusRems);
if (rems.getValue() != null) {
return;
}
throw new CantBeSubmittedException("User does not meet the criteria for applying for Bona Fide Status");
}
use of cz.metacentrum.perun.core.bl.AttributesManagerBl in project perun by CESNET.
the class ElixirBonaFideStatus method beforeApprove.
@Override
public Application beforeApprove(PerunSession session, Application app) throws CantBeApprovedException {
Group group = app.getGroup();
if (group == null) {
throw new CantBeApprovedException("This module can be set only for registration to Group.");
}
AttributesManagerBl am = ((PerunBl) session.getPerun()).getAttributesManagerBl();
Attribute attestation;
try {
attestation = am.getAttribute(session, group, A_G_D_groupAttestation);
} catch (Exception e) {
throw new InternalErrorException(e.getMessage(), e);
}
if (attestation == null) {
throw new CantBeApprovedException("Application cannot be approved: Group does not have attestation attribute set.");
}
String newValue = attestation.valueAsString();
if (newValue == null || newValue.isEmpty()) {
throw new CantBeApprovedException("Application cannot be approved: Group does not have attestation value set.");
}
return app;
}
Aggregations