Search in sources :

Example 6 with AuthenticationFailureException

use of com.peterphi.usermanager.guice.authentication.AuthenticationFailureException in project stdlib by petergeneric.

the class UserUIServiceImpl method rotateAccessKey.

@Override
public Response rotateAccessKey(final int userId, final String nonce) {
    nonceStore.validate(NONCE_USE, nonce);
    final int localUser = login.getId();
    if (localUser != userId && !login.isAdmin())
        throw new AuthenticationFailureException("Only a User Admin can rotate access keys another user!");
    // Change regular account settings
    accountDao.rotateUserAccessKey(userId);
    return Response.seeOther(URI.create("/user/" + userId)).build();
}
Also used : AuthenticationFailureException(com.peterphi.usermanager.guice.authentication.AuthenticationFailureException) AuthConstraint(com.peterphi.std.guice.common.auth.annotations.AuthConstraint)

Aggregations

AuthConstraint (com.peterphi.std.guice.common.auth.annotations.AuthConstraint)6 AuthenticationFailureException (com.peterphi.usermanager.guice.authentication.AuthenticationFailureException)6 Transactional (com.peterphi.std.guice.database.annotation.Transactional)5 UserEntity (com.peterphi.usermanager.db.entity.UserEntity)3 TemplateCall (com.peterphi.std.guice.web.rest.templating.TemplateCall)2 RoleEntity (com.peterphi.usermanager.db.entity.RoleEntity)2 HashSet (java.util.HashSet)1