use of cz.metacentrum.perun.audit.events.AuditEvent in project perun by CESNET.
the class urn_perun_facility_attribute_def_virt_voShortNames method resolveVirtualAttributeValueChange.
@Override
public List<AuditEvent> resolveVirtualAttributeValueChange(PerunSessionImpl sess, AuditEvent message) throws AttributeNotExistsException, WrongAttributeAssignmentException {
List<AuditEvent> resolvingMessages = new ArrayList<>();
if (message == null)
return resolvingMessages;
if (message instanceof ResourceCreated) {
try {
Facility facility = sess.getPerunBl().getFacilitiesManagerBl().getFacilityById(sess, ((ResourceCreated) message).getResource().getFacilityId());
resolvingMessages.addAll(resolveEvent(sess, facility));
} catch (FacilityNotExistsException e) {
throw new ConsistencyErrorException("Facility for created Resource doesn't exists when resolving messages.", e);
}
} else if (message instanceof ResourceDeleted) {
resolvingMessages.addAll(resolveEvent(sess, ((ResourceDeleted) message).getFacility()));
}
return resolvingMessages;
}
use of cz.metacentrum.perun.audit.events.AuditEvent in project perun by CESNET.
the class UserVirtualAttributeCollectedFromUserExtSource method resolveVirtualAttributeValueChange.
@Override
public List<AuditEvent> resolveVirtualAttributeValueChange(PerunSessionImpl perunSession, AuditEvent message) throws WrongReferenceAttributeValueException, AttributeNotExistsException, WrongAttributeAssignmentException {
List<AuditEvent> resolvingMessages = new ArrayList<>();
if (message == null)
return resolvingMessages;
List<AttributeHandleIdentifier> list = getHandleIdentifiers();
for (AttributeHandleIdentifier attributeHandleIdenfier : list) {
Integer userId = attributeHandleIdenfier.shouldBeEventHandled(message);
if (userId != null) {
try {
User user = perunSession.getPerunBl().getUsersManagerBl().getUserById(perunSession, userId);
AttributeDefinition attributeDefinition = perunSession.getPerunBl().getAttributesManagerBl().getAttributeDefinition(perunSession, getDestinationAttributeName());
resolvingMessages.add(new AttributeChangedForUser(new Attribute(attributeDefinition), user));
} catch (UserNotExistsException e) {
log.warn("User from UserExtSource doesn't exist in Perun. This occurred while parsing message: {}.", message);
}
}
}
return resolvingMessages;
}
use of cz.metacentrum.perun.audit.events.AuditEvent in project perun by CESNET.
the class AuditMessagesManagerImpl method pollConsumerEvents.
@Override
public List<AuditEvent> pollConsumerEvents(PerunSession perunSession, String consumerName) {
checkAuditerConsumerExists(perunSession, consumerName);
try {
List<AuditEvent> eventList = new ArrayList<>();
int lastProcessedId = getLastProcessedId(consumerName);
int maxId = getLastMessageId(perunSession);
if (maxId > lastProcessedId) {
// get events
eventList = jdbc.query("select " + auditMessageMappingSelectQuery + " from auditer_log where id > ? and id <= ? order by id", AUDIT_EVENT_MAPPER, lastProcessedId, maxId);
// update counter
setLastProcessedId(perunSession, consumerName, maxId);
}
return eventList;
} catch (Exception ex) {
throw new InternalErrorException(ex);
}
}
use of cz.metacentrum.perun.audit.events.AuditEvent in project perun by CESNET.
the class urn_perun_user_attribute_def_virt_institutionsCountries method resolveEvent.
private List<AuditEvent> resolveEvent(PerunSessionImpl sess, String key) throws WrongAttributeAssignmentException, AttributeNotExistsException {
List<AuditEvent> resolvingMessages = new ArrayList<>();
List<String> longerDomains = new ArrayList<>();
AttributesManagerBl am = sess.getPerunBl().getAttributesManagerBl();
for (String dnsDomain : am.getEntitylessStringAttributeMapping(sess, DNS_STATE_MAPPING_ATTR.getName()).keySet()) {
if (dnsDomain.endsWith(key) && dnsDomain.length() > key.length()) {
longerDomains.add(dnsDomain);
}
}
log.debug("DNS domain '{}' changed, found longer domains: {}", key, longerDomains);
// find users that are affected by the change - have schacHomeOrganization value ending in key but not ending with longerDomains
List<User> affectedUsers = sess.getPerunBl().getUsersManagerBl().findUsersWithExtSourceAttributeValueEnding(sess, getSourceAttributeName(), key, longerDomains);
for (User user : affectedUsers) {
AttributeDefinition attributeDefinition = am.getAttributeDefinition(sess, getDestinationAttributeName());
resolvingMessages.add(new AttributeChangedForUser(new Attribute(attributeDefinition), user));
}
return resolvingMessages;
}
use of cz.metacentrum.perun.audit.events.AuditEvent in project perun by CESNET.
the class urn_perun_user_attribute_def_virt_loa method resolveVirtualAttributeValueChange.
@Override
public List<AuditEvent> resolveVirtualAttributeValueChange(PerunSessionImpl sess, AuditEvent message) throws AttributeNotExistsException, WrongAttributeAssignmentException {
List<AuditEvent> resolvingMessages = new ArrayList<>();
if (message == null)
return resolvingMessages;
User user = null;
try {
if (message instanceof UserExtSourceAddedToUser) {
user = ((UserExtSourceAddedToUser) message).getUser();
sess.getPerunBl().getUsersManagerBl().checkUserExists(sess, user);
resolvingMessages.add(resolveEvent(sess, user));
} else if (message instanceof UserExtSourceRemovedFromUser) {
user = ((UserExtSourceRemovedFromUser) message).getUser();
sess.getPerunBl().getUsersManagerBl().checkUserExists(sess, user);
resolvingMessages.add(resolveEvent(sess, user));
} else if (message instanceof UserExtSourceUpdated) {
resolvingMessages.add(resolveEvent(sess, sess.getPerunBl().getUsersManagerBl().getUserById(sess, ((UserExtSourceUpdated) message).getUserExtSource().getUserId())));
}
} catch (UserNotExistsException e) {
log.warn("User {} associated with event {} no longer exists while resolving virtual attribute value change for LoA.", user, message.getName());
}
return resolvingMessages;
}
Aggregations