Search in sources :

Example 16 with AttributesManagerBl

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);
}
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) AttributesManagerBl(cz.metacentrum.perun.core.bl.AttributesManagerBl) Before(org.junit.Before)

Example 17 with AttributesManagerBl

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);
}
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) AttributesManagerBl(cz.metacentrum.perun.core.bl.AttributesManagerBl) Before(org.junit.Before)

Example 18 with AttributesManagerBl

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);
}
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 19 with AttributesManagerBl

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");
}
Also used : User(cz.metacentrum.perun.core.api.User) CantBeSubmittedException(cz.metacentrum.perun.registrar.exceptions.CantBeSubmittedException) Attribute(cz.metacentrum.perun.core.api.Attribute) PerunBl(cz.metacentrum.perun.core.bl.PerunBl) AttributesManagerBl(cz.metacentrum.perun.core.bl.AttributesManagerBl)

Example 20 with AttributesManagerBl

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;
}
Also used : Group(cz.metacentrum.perun.core.api.Group) CantBeApprovedException(cz.metacentrum.perun.registrar.exceptions.CantBeApprovedException) Attribute(cz.metacentrum.perun.core.api.Attribute) PerunBl(cz.metacentrum.perun.core.bl.PerunBl) InternalErrorException(cz.metacentrum.perun.core.api.exceptions.InternalErrorException) InternalErrorException(cz.metacentrum.perun.core.api.exceptions.InternalErrorException) GroupNotExistsException(cz.metacentrum.perun.core.api.exceptions.GroupNotExistsException) WrongReferenceAttributeValueException(cz.metacentrum.perun.core.api.exceptions.WrongReferenceAttributeValueException) AttributeNotExistsException(cz.metacentrum.perun.core.api.exceptions.AttributeNotExistsException) WrongAttributeValueException(cz.metacentrum.perun.core.api.exceptions.WrongAttributeValueException) PrivilegeException(cz.metacentrum.perun.core.api.exceptions.PrivilegeException) CantBeSubmittedException(cz.metacentrum.perun.registrar.exceptions.CantBeSubmittedException) UserNotExistsException(cz.metacentrum.perun.core.api.exceptions.UserNotExistsException) WrongAttributeAssignmentException(cz.metacentrum.perun.core.api.exceptions.WrongAttributeAssignmentException) PerunException(cz.metacentrum.perun.core.api.exceptions.PerunException) CantBeApprovedException(cz.metacentrum.perun.registrar.exceptions.CantBeApprovedException) AttributesManagerBl(cz.metacentrum.perun.core.bl.AttributesManagerBl)

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