Search in sources :

Example 1 with AttributeSetForUes

use of cz.metacentrum.perun.audit.events.AttributesManagerEvents.AttributeSetForUes in project perun by CESNET.

the class urn_perun_user_attribute_def_virt_institutionsCountriesTest method resolveVirtualAttributeValueChange.

@Test
public void resolveVirtualAttributeValueChange() throws Exception {
    setSchacHomeOrgs("muni.cz;cesnet.cz");
    AttributeDefinition countries = classInstance.getAttributeDefinition();
    when(sess.getPerunBl().getAttributesManagerBl().getAttributeDefinition(sess, "urn:perun:user:attribute-def:virt:institutionsCountries")).thenReturn(countries);
    when(sess.getPerunBl().getUsersManagerBl().getUserById(sess, userExtSource.getUserId())).thenReturn(user);
    AuditEvent uesSet = new AttributeSetForUes(schacHomeOrg, userExtSource);
    List<AuditEvent> msgs = classInstance.resolveVirtualAttributeValueChange(sess, uesSet);
    assertTrue("audit should contain change of institutionsCountries", msgs.get(0).getMessage().contains("friendlyName=<institutionsCountries>"));
}
Also used : AttributeDefinition(cz.metacentrum.perun.core.api.AttributeDefinition) AuditEvent(cz.metacentrum.perun.audit.events.AuditEvent) AttributeSetForUes(cz.metacentrum.perun.audit.events.AttributesManagerEvents.AttributeSetForUes) Test(org.junit.Test)

Example 2 with AttributeSetForUes

use of cz.metacentrum.perun.audit.events.AttributesManagerEvents.AttributeSetForUes in project perun by CESNET.

the class AttributesManagerBlImpl method setAttributeWithoutCheck.

private boolean setAttributeWithoutCheck(PerunSession sess, UserExtSource ues, Attribute attribute) throws WrongAttributeAssignmentException, WrongAttributeValueException {
    getAttributesManagerImpl().checkNamespace(sess, attribute, AttributesManager.NS_UES_ATTR);
    if (getAttributesManagerImpl().isCoreAttribute(sess, attribute))
        throw new WrongAttributeAssignmentException(attribute);
    boolean changed;
    if (isVirtAttribute(sess, attribute)) {
        return getAttributesManagerImpl().setVirtualAttribute(sess, ues, attribute);
    } else {
        changed = getAttributesManagerImpl().setAttribute(sess, ues, attribute);
    }
    if (changed) {
        getPerunBl().getAuditer().log(sess, new AttributeSetForUes(attribute, ues));
        getAttributesManagerImpl().changedAttributeHook(sess, ues, attribute);
    }
    return changed;
}
Also used : WrongAttributeAssignmentException(cz.metacentrum.perun.core.api.exceptions.WrongAttributeAssignmentException) AttributeSetForUes(cz.metacentrum.perun.audit.events.AttributesManagerEvents.AttributeSetForUes)

Aggregations

AttributeSetForUes (cz.metacentrum.perun.audit.events.AttributesManagerEvents.AttributeSetForUes)2 AuditEvent (cz.metacentrum.perun.audit.events.AuditEvent)1 AttributeDefinition (cz.metacentrum.perun.core.api.AttributeDefinition)1 WrongAttributeAssignmentException (cz.metacentrum.perun.core.api.exceptions.WrongAttributeAssignmentException)1 Test (org.junit.Test)1