public interface AccessPredicate extends Predicate<Authentication>
Authentication
has access to the protected
service/method. This interface assumes, that the user is authenticated before the method is called.Modifier and Type | Method and Description |
---|---|
default AccessPredicate |
and(Predicate<? super Authentication> other) |
static AccessPredicate |
authenticated()
All authenticated users can access the protected instance including anonymous users.
|
static AccessPredicate |
denyAll()
Nobody can access the protected instance.
|
static AccessPredicate |
fullyAuthenticated()
All authenticated users can access the protected instance excluding anonymous users.
|
static AccessPredicate |
hasAllAuthorities(Collection<GrantedAuthority> roles)
Only those who have any of the given
GrantedAuthority can access the protected instance. |
static AccessPredicate |
hasAllAuthorities(GrantedAuthority... roles)
Only those who have all of the given
GrantedAuthority can access the protected instance. |
static AccessPredicate |
hasAllRoles(Collection<String> roles)
Only those who have all of the given roles can access the protected instance.
|
static AccessPredicate |
hasAllRoles(String... roles)
Only those who have all of the given roles can access the protected instance.
|
static AccessPredicate |
hasAnyAuthority(Collection<GrantedAuthority> roles)
Only those who have any of the given
GrantedAuthority can access the protected instance. |
static AccessPredicate |
hasAnyAuthority(GrantedAuthority... roles)
Only those who have any of the given
GrantedAuthority can access the protected instance. |
static AccessPredicate |
hasAnyRole(Collection<String> roles)
Only those who have any of the given roles can access the protected instance.
|
static AccessPredicate |
hasAnyRole(String... roles)
Only those who have any of the given roles can access the protected instance.
|
static AccessPredicate |
hasAuthority(GrantedAuthority role)
Only those who have the given
GrantedAuthority can access the protected instance. |
static AccessPredicate |
hasRole(String role)
Only those who have the given role can access the protected instance.
|
default AccessPredicate |
negate() |
default AccessPredicate |
or(Predicate<? super Authentication> other) |
static AccessPredicate |
permitAll()
Special constant that symbolizes that everybody (including unauthenticated users) can access the instance (no
protection).
|
default AccessPredicate negate()
negate
in interface Predicate<Authentication>
default AccessPredicate and(Predicate<? super Authentication> other)
and
in interface Predicate<Authentication>
default AccessPredicate or(Predicate<? super Authentication> other)
or
in interface Predicate<Authentication>
static AccessPredicate permitAll()
Note: This is a special constant, that does not allow execution and mutation. It's sole purpose is to
avoid ambiguity for null
values. It should only be used in ==
comparisons.
static AccessPredicate authenticated()
Note: The negation of this call is denyAll()
and NOT all unauthenticated.
static AccessPredicate fullyAuthenticated()
static AccessPredicate denyAll()
Note: The negation of this call is authenticated()
and NOT permitAll()
.
static AccessPredicate hasRole(String role)
role
- The role to check for.GrantedAuthority
s
matches the given role name.static AccessPredicate hasAuthority(GrantedAuthority role)
GrantedAuthority
can access the protected instance.role
- The role to check for.GrantedAuthority
s matches the
given role.static AccessPredicate hasAnyRole(String... roles)
roles
- The roles to check for.GrantedAuthority
s
matches any of the given role names.static AccessPredicate hasAnyRole(Collection<String> roles)
roles
- The roles to check for.GrantedAuthority
s
matches any of the given role names.static AccessPredicate hasAnyAuthority(GrantedAuthority... roles)
GrantedAuthority
can access the protected instance.roles
- The roles to check for.GrantedAuthority
s matches any of
the given roles.static AccessPredicate hasAnyAuthority(Collection<GrantedAuthority> roles)
GrantedAuthority
can access the protected instance.roles
- The roles to check for.GrantedAuthority
s matches any of
the given roles.static AccessPredicate hasAllRoles(String... roles)
roles
- The roles to check for.GrantedAuthority
s
matches all of the given role names.static AccessPredicate hasAllRoles(Collection<String> roles)
roles
- The roles to check for.GrantedAuthority
s
matches all of the given role names.static AccessPredicate hasAllAuthorities(GrantedAuthority... roles)
GrantedAuthority
can access the protected instance.roles
- The roles to check for.GrantedAuthority
s matches all of
the given roles.static AccessPredicate hasAllAuthorities(Collection<GrantedAuthority> roles)
GrantedAuthority
can access the protected instance.roles
- The roles to check for.GrantedAuthority
s matches all of
the given roles.