Search in sources :

Example 1 with SecurityTeamCreated

use of cz.metacentrum.perun.audit.events.SecurityTeamsManagerEvents.SecurityTeamCreated in project perun by CESNET.

the class SecurityTeamsManagerBlImpl method createSecurityTeam.

@Override
public SecurityTeam createSecurityTeam(PerunSession sess, SecurityTeam securityTeam) {
    securityTeam = getSecurityTeamsManagerImpl().createSecurityTeam(sess, securityTeam);
    getPerunBl().getAuditer().log(sess, new SecurityTeamCreated(securityTeam));
    // set creator as security team admin
    User user = sess.getPerunPrincipal().getUser();
    if (user != null) {
        // user can be null in tests
        try {
            AuthzResolverBlImpl.setRole(sess, user, securityTeam, Role.SECURITYADMIN);
        } catch (AlreadyAdminException e) {
            throw new ConsistencyErrorException("Newly created securityTeam already have an admin.", e);
        } catch (RoleCannotBeManagedException e) {
            throw new InternalErrorException(e);
        }
    }
    return securityTeam;
}
Also used : ConsistencyErrorException(cz.metacentrum.perun.core.api.exceptions.ConsistencyErrorException) User(cz.metacentrum.perun.core.api.User) SecurityTeamCreated(cz.metacentrum.perun.audit.events.SecurityTeamsManagerEvents.SecurityTeamCreated) RoleCannotBeManagedException(cz.metacentrum.perun.core.api.exceptions.RoleCannotBeManagedException) InternalErrorException(cz.metacentrum.perun.core.api.exceptions.InternalErrorException) AlreadyAdminException(cz.metacentrum.perun.core.api.exceptions.AlreadyAdminException)

Aggregations

SecurityTeamCreated (cz.metacentrum.perun.audit.events.SecurityTeamsManagerEvents.SecurityTeamCreated)1 User (cz.metacentrum.perun.core.api.User)1 AlreadyAdminException (cz.metacentrum.perun.core.api.exceptions.AlreadyAdminException)1 ConsistencyErrorException (cz.metacentrum.perun.core.api.exceptions.ConsistencyErrorException)1 InternalErrorException (cz.metacentrum.perun.core.api.exceptions.InternalErrorException)1 RoleCannotBeManagedException (cz.metacentrum.perun.core.api.exceptions.RoleCannotBeManagedException)1