Search in sources :

Example 1 with UserExtSourceRemovedFromUser

use of cz.metacentrum.perun.audit.events.UserManagerEvents.UserExtSourceRemovedFromUser in project perun by CESNET.

the class UsersManagerBlImpl method removeUserExtSource.

@Override
public void removeUserExtSource(PerunSession sess, User user, UserExtSource userExtSource) throws UserExtSourceAlreadyRemovedException {
    // First remove all user extSource attributes before removing userExtSource
    try {
        getPerunBl().getAttributesManagerBl().removeAllAttributes(sess, userExtSource);
    } catch (WrongReferenceAttributeValueException | WrongAttributeValueException ex) {
        throw new InternalErrorException("Can't remove userExtSource because there is problem with removing all it's attributes.", ex);
    }
    getUsersManagerImpl().removeUserExtSource(sess, user, userExtSource);
    getPerunBl().getAuditer().log(sess, new UserExtSourceRemovedFromUser(userExtSource, user));
}
Also used : WrongReferenceAttributeValueException(cz.metacentrum.perun.core.api.exceptions.WrongReferenceAttributeValueException) InternalErrorException(cz.metacentrum.perun.core.api.exceptions.InternalErrorException) UserExtSourceRemovedFromUser(cz.metacentrum.perun.audit.events.UserManagerEvents.UserExtSourceRemovedFromUser) WrongAttributeValueException(cz.metacentrum.perun.core.api.exceptions.WrongAttributeValueException)

Example 2 with UserExtSourceRemovedFromUser

use of cz.metacentrum.perun.audit.events.UserManagerEvents.UserExtSourceRemovedFromUser 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;
}
Also used : UserExtSourceAddedToUser(cz.metacentrum.perun.audit.events.UserManagerEvents.UserExtSourceAddedToUser) AttributeChangedForUser(cz.metacentrum.perun.audit.events.AttributesManagerEvents.AttributeChangedForUser) User(cz.metacentrum.perun.core.api.User) UserExtSourceRemovedFromUser(cz.metacentrum.perun.audit.events.UserManagerEvents.UserExtSourceRemovedFromUser) UserExtSourceAddedToUser(cz.metacentrum.perun.audit.events.UserManagerEvents.UserExtSourceAddedToUser) UserNotExistsException(cz.metacentrum.perun.core.api.exceptions.UserNotExistsException) UserExtSourceUpdated(cz.metacentrum.perun.audit.events.UserManagerEvents.UserExtSourceUpdated) ArrayList(java.util.ArrayList) AuditEvent(cz.metacentrum.perun.audit.events.AuditEvent) UserExtSourceRemovedFromUser(cz.metacentrum.perun.audit.events.UserManagerEvents.UserExtSourceRemovedFromUser)

Aggregations

UserExtSourceRemovedFromUser (cz.metacentrum.perun.audit.events.UserManagerEvents.UserExtSourceRemovedFromUser)2 AttributeChangedForUser (cz.metacentrum.perun.audit.events.AttributesManagerEvents.AttributeChangedForUser)1 AuditEvent (cz.metacentrum.perun.audit.events.AuditEvent)1 UserExtSourceAddedToUser (cz.metacentrum.perun.audit.events.UserManagerEvents.UserExtSourceAddedToUser)1 UserExtSourceUpdated (cz.metacentrum.perun.audit.events.UserManagerEvents.UserExtSourceUpdated)1 User (cz.metacentrum.perun.core.api.User)1 InternalErrorException (cz.metacentrum.perun.core.api.exceptions.InternalErrorException)1 UserNotExistsException (cz.metacentrum.perun.core.api.exceptions.UserNotExistsException)1 WrongAttributeValueException (cz.metacentrum.perun.core.api.exceptions.WrongAttributeValueException)1 WrongReferenceAttributeValueException (cz.metacentrum.perun.core.api.exceptions.WrongReferenceAttributeValueException)1 ArrayList (java.util.ArrayList)1