001package usecase.auth; 002 003import javax.annotation.Priority; 004import javax.inject.Inject; 005import javax.interceptor.AroundInvoke; 006import javax.interceptor.Interceptor; 007import javax.interceptor.InvocationContext; 008 009/** 010 * Classe interceptor per negare un'operazione ad un utente bannato. 011 */ 012@Interceptor 013@DenyBannedUsers 014@Priority(Interceptor.Priority.APPLICATION+2) 015public class DenyBannedUsersInterceptor { 016 @Inject private CurrentUser currentUser; 017 018 @AroundInvoke 019 public Object checkAdmin(InvocationContext invocationContext) throws Exception{ 020 if(currentUser.isLoggedIn() && currentUser.getBanDuration() != null){ 021 throw new BannedUserException(currentUser.getBanDuration()); 022 } 023 return invocationContext.proceed(); 024 } 025}