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