public class AccessAnnotationChecker extends Object implements Serializable
Check is performed as follows when called for a method:
The security annotations checked and their meaning are:
AnonymousAllowed
- allows access to any logged on or not logged
in user. Public access.PermitAll
- allows access to any logged in user but denies access
to anonymous users.RolesAllowed
- allows access there is a logged in user that has
any of the roles mentioned in the annotationDenyAll
- denies access.Constructor and Description |
---|
AccessAnnotationChecker() |
Modifier and Type | Method and Description |
---|---|
AnnotatedElement |
getSecurityTarget(Class<?> cls)
Gets the class to check for security restrictions.
|
AnnotatedElement |
getSecurityTarget(Method method)
Gets the method or class to check for security restrictions.
|
boolean |
hasAccess(Class<?> cls)
Checks if the user defined by the current active servlet request (using
HttpServletRequest.getUserPrincipal() and
HttpServletRequest.isUserInRole(String) has access to the given
class. |
boolean |
hasAccess(Class<?> cls,
javax.servlet.http.HttpServletRequest request)
Checks if the user defined by the request (using
HttpServletRequest.getUserPrincipal() and
HttpServletRequest.isUserInRole(String) has access to the given
class. |
boolean |
hasAccess(Class<?> cls,
Principal principal,
Function<String,Boolean> roleChecker)
Checks if the user defined by the given
Principal and role
checker has access to the given class. |
boolean |
hasAccess(Method method)
Checks if the user defined by the current active servlet request (using
HttpServletRequest.getUserPrincipal() and
HttpServletRequest.isUserInRole(String) has access to the given
method. |
boolean |
hasAccess(Method method,
javax.servlet.http.HttpServletRequest request)
Checks if the user defined by the request (using
HttpServletRequest.getUserPrincipal() and
HttpServletRequest.isUserInRole(String) has access to the given
method. |
boolean |
hasAccess(Method method,
Principal principal,
Function<String,Boolean> roleChecker)
Checks if the user defined by the given
Principal and role
checker has access to the given method. |
public boolean hasAccess(Method method)
HttpServletRequest.getUserPrincipal()
and
HttpServletRequest.isUserInRole(String)
has access to the given
method.method
- the method to check access totrue
if the user has access to the given method,
false
otherwisepublic boolean hasAccess(Class<?> cls)
HttpServletRequest.getUserPrincipal()
and
HttpServletRequest.isUserInRole(String)
has access to the given
class.cls
- the class to check access totrue
if the user has access to the given method,
false
otherwisepublic boolean hasAccess(Method method, javax.servlet.http.HttpServletRequest request)
HttpServletRequest.getUserPrincipal()
and
HttpServletRequest.isUserInRole(String)
has access to the given
method.method
- the method to check access torequest
- the http request to use for user informationtrue
if the user has access to the given method,
false
otherwisepublic boolean hasAccess(Class<?> cls, javax.servlet.http.HttpServletRequest request)
HttpServletRequest.getUserPrincipal()
and
HttpServletRequest.isUserInRole(String)
has access to the given
class.cls
- the class to check access torequest
- the http request to use for user informationtrue
if the user has access to the given method,
false
otherwisepublic boolean hasAccess(Method method, Principal principal, Function<String,Boolean> roleChecker)
Principal
and role
checker has access to the given method.method
- the method to check access toprincipal
- the principal of the userroleChecker
- a function that can answer if a user has a given roletrue
if the user has access to the given method,
false
otherwisepublic boolean hasAccess(Class<?> cls, Principal principal, Function<String,Boolean> roleChecker)
Principal
and role
checker has access to the given class.cls
- the class to check access toprincipal
- the principal of the userroleChecker
- a function that can answer if a user has a given roletrue
if the user has access to the given method,
false
otherwisepublic AnnotatedElement getSecurityTarget(Method method)
method
- the method to look upIllegalArgumentException
- if the method is not publicpublic AnnotatedElement getSecurityTarget(Class<?> cls)
cls
- the class to checkIllegalArgumentException
- if the method is not publicCopyright © 2021. All rights reserved.