1 package usecase.auth;
2
3 import javax.annotation.Priority;
4 import javax.inject.Inject;
5 import javax.interceptor.AroundInvoke;
6 import javax.interceptor.Interceptor;
7 import javax.interceptor.InvocationContext;
8
9
10
11
12 @Interceptor
13 @AuthenticationRequired
14 @Priority(Interceptor.Priority.APPLICATION+1)
15 public class AuthenticationRequiredInterceptor {
16 @Inject private CurrentUser currentUser;
17
18
19
20
21
22
23
24 @AroundInvoke
25 public Object checkAdmin(InvocationContext invocationContext) throws Exception{
26 if(!currentUser.isLoggedIn()){
27 throw new AuthenticationRequiredException();
28 }
29 return invocationContext.proceed();
30 }
31 }