Search in sources :

Example 1 with AttributeSetForKey

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

the class AttributesManagerBlImpl method setAttributeWithoutCheck.

@Override
public boolean setAttributeWithoutCheck(PerunSession sess, String key, Attribute attribute) throws WrongAttributeAssignmentException, WrongAttributeValueException {
    getAttributesManagerImpl().checkNamespace(sess, attribute, AttributesManager.NS_ENTITYLESS_ATTR);
    if (getAttributesManagerImpl().isCoreAttribute(sess, attribute))
        throw new WrongAttributeAssignmentException(attribute);
    boolean changed;
    if (isVirtAttribute(sess, attribute)) {
        throw new InternalErrorException("Virtual attribute can't be set this way yet. Please set physical attribute.");
    } else {
        changed = getAttributesManagerImpl().setAttribute(sess, key, attribute);
    }
    if (changed) {
        getPerunBl().getAuditer().log(sess, new AttributeSetForKey(attribute, key));
        getAttributesManagerImpl().changedAttributeHook(sess, key, attribute);
    }
    return changed;
}
Also used : WrongAttributeAssignmentException(cz.metacentrum.perun.core.api.exceptions.WrongAttributeAssignmentException) AttributeSetForKey(cz.metacentrum.perun.audit.events.AttributesManagerEvents.AttributeSetForKey) InternalErrorException(cz.metacentrum.perun.core.api.exceptions.InternalErrorException)

Example 2 with AttributeSetForKey

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

the class urn_perun_user_attribute_def_virt_institutionsCountriesTest method resolveVirtualAttributeValueChange2.

@Test
public void resolveVirtualAttributeValueChange2() throws Exception {
    setSchacHomeOrgs("muni.cz;cesnet.cz");
    String czech_republic = "Czech Republic";
    dnsMap.put(".cz", czech_republic);
    AttributeDefinition countries = classInstance.getAttributeDefinition();
    when(sess.getPerunBl().getAttributesManagerBl().getAttributeDefinition(sess, "urn:perun:user:attribute-def:virt:institutionsCountries")).thenReturn(countries);
    Attribute newval = new Attribute(new urn_perun_entityless_attribute_def_def_dnsStateMapping().getAttributeDefinition());
    newval.setValue(czech_republic);
    when(sess.getPerunBl().getUsersManagerBl().findUsersWithExtSourceAttributeValueEnding(eq(sess), eq(SCHAC_HOME_ATTR_NAME), eq(".cz"), any())).thenReturn(Collections.singletonList(user));
    AuditEvent event = new AttributeSetForKey(newval, ".cz");
    List<AuditEvent> msgs = classInstance.resolveVirtualAttributeValueChange(sess, event);
    assertTrue("audit should contain change of institutionsCountries", msgs.get(0).getMessage().contains("friendlyName=<institutionsCountries>"));
}
Also used : Attribute(cz.metacentrum.perun.core.api.Attribute) AttributeSetForKey(cz.metacentrum.perun.audit.events.AttributesManagerEvents.AttributeSetForKey) AttributeDefinition(cz.metacentrum.perun.core.api.AttributeDefinition) AuditEvent(cz.metacentrum.perun.audit.events.AuditEvent) Test(org.junit.Test)

Aggregations

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