Interface AccessPredicate
- All Superinterfaces:
BiPredicate<Authentication,
ServerCall<?, ?>>
Predicate that can be used to check whether the given
Authentication
has access to the protected
service/method. This interface assumes, that the user is authenticated before the method is called.-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interface
Some helper methods used to createPredicate
s forSocketAddress
es. -
Method Summary
Modifier and TypeMethodDescriptiondefault AccessPredicate
and
(BiPredicate<? super Authentication, ? super ServerCall<?, ?>> other) default AccessPredicate
and
(Predicate<? super Authentication> other) Combines this predicate with the given predicate using theAND
operator.static AccessPredicate
All authenticated users can access the protected instance including anonymous users.static AccessPredicate
denyAll()
Nobody can access the protected instance.static AccessPredicate
fromClientAddress
(Predicate<? super SocketAddress> remoteAddressCheck) Checks that the client connected from the given address.static AccessPredicate
All authenticated users can access the protected instance excluding anonymous users.static AccessPredicate
Only those who have any of the givenGrantedAuthority
can access the protected instance.static AccessPredicate
hasAllAuthorities
(GrantedAuthority... roles) Only those who have all of the givenGrantedAuthority
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
hasAllRoles
(Collection<String> roles) Only those who have all of the given roles can access the protected instance.static AccessPredicate
Only those who have any of the givenGrantedAuthority
can access the protected instance.static AccessPredicate
hasAnyAuthority
(GrantedAuthority... roles) Only those who have any of the givenGrantedAuthority
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
hasAnyRole
(Collection<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 givenGrantedAuthority
can access the protected instance.static AccessPredicate
Only those who have the given role can access the protected instance.default AccessPredicate
negate()
default AccessPredicate
or
(BiPredicate<? super Authentication, ? super ServerCall<?, ?>> other) default AccessPredicate
or
(Predicate<? super Authentication> other) Combines this predicate with the given predicate using theOR
operator.static AccessPredicate
Special constant that symbolizes that everybody (including unauthenticated users) can access the instance (no protection).boolean
test
(Authentication authentication, ServerCall<?, ?> serverCall) Checks whether the given user is authorized to execute the given call.static AccessPredicate
toServerAddress
(Predicate<? super SocketAddress> localAddressCheck) Checks that the client connected to the given server address.
-
Method Details
-
test
Checks whether the given user is authorized to execute the given call.- Specified by:
test
in interfaceBiPredicate<Authentication,
ServerCall<?, ?>> - Parameters:
authentication
- The authentication to check.serverCall
- The secure object being called.- Returns:
- True, if the user has access. False otherwise.
-
negate
- Specified by:
negate
in interfaceBiPredicate<Authentication,
ServerCall<?, ?>>
-
and
Combines this predicate with the given predicate using theAND
operator.- Parameters:
other
- The other predicate to call.- Returns:
- The combined predicate.
-
and
- Specified by:
and
in interfaceBiPredicate<Authentication,
ServerCall<?, ?>>
-
or
Combines this predicate with the given predicate using theOR
operator.- Parameters:
other
- The other predicate to call.- Returns:
- The combined predicate.
-
or
- Specified by:
or
in interfaceBiPredicate<Authentication,
ServerCall<?, ?>>
-
permitAll
Special constant that symbolizes that everybody (including unauthenticated users) can access the instance (no protection).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.- Returns:
- A special constant that symbolizes public access.
-
authenticated
All authenticated users can access the protected instance including anonymous users.Note: The negation of this call is
denyAll()
and NOT all unauthenticated.- Returns:
- A newly created AccessPredicate that always returns true.
-
fullyAuthenticated
All authenticated users can access the protected instance excluding anonymous users.- Returns:
- A newly created AccessPredicate that checks whether the user is explicitly authenticated.
-
denyAll
Nobody can access the protected instance.Note: The negation of this call is
authenticated()
and NOTpermitAll()
.- Returns:
- A newly created AccessPredicate that always returns false.
-
hasRole
Only those who have the given role can access the protected instance.- Parameters:
role
- The role to check for.- Returns:
- A newly created AccessPredicate that only returns true, if the name of the
GrantedAuthority
s matches the given role name.
-
hasAuthority
Only those who have the givenGrantedAuthority
can access the protected instance.- Parameters:
role
- The role to check for.- Returns:
- A newly created AccessPredicate that only returns true, if the
GrantedAuthority
s matches the given role.
-
hasAnyRole
Only those who have any of the given roles can access the protected instance.- Parameters:
roles
- The roles to check for.- Returns:
- A newly created AccessPredicate that only returns true, if the name of the
GrantedAuthority
s matches any of the given role names.
-
hasAnyRole
Only those who have any of the given roles can access the protected instance.- Parameters:
roles
- The roles to check for.- Returns:
- A newly created AccessPredicate that only returns true, if the name of the
GrantedAuthority
s matches any of the given role names.
-
hasAnyAuthority
Only those who have any of the givenGrantedAuthority
can access the protected instance.- Parameters:
roles
- The roles to check for.- Returns:
- A newly created AccessPredicate that only returns true, if the
GrantedAuthority
s matches any of the given roles.
-
hasAnyAuthority
Only those who have any of the givenGrantedAuthority
can access the protected instance.- Parameters:
roles
- The roles to check for.- Returns:
- A newly created AccessPredicate that only returns true, if the
GrantedAuthority
s matches any of the given roles.
-
hasAllRoles
Only those who have all of the given roles can access the protected instance.- Parameters:
roles
- The roles to check for.- Returns:
- A newly created AccessPredicate that only returns true, if the name of the
GrantedAuthority
s matches all of the given role names.
-
hasAllRoles
Only those who have all of the given roles can access the protected instance.- Parameters:
roles
- The roles to check for.- Returns:
- A newly created AccessPredicate that only returns true, if the name of the
GrantedAuthority
s matches all of the given role names.
-
hasAllAuthorities
Only those who have all of the givenGrantedAuthority
can access the protected instance.- Parameters:
roles
- The roles to check for.- Returns:
- A newly created AccessPredicate that only returns true, if the
GrantedAuthority
s matches all of the given roles.
-
hasAllAuthorities
Only those who have any of the givenGrantedAuthority
can access the protected instance.- Parameters:
roles
- The roles to check for.- Returns:
- A newly created AccessPredicate that only returns true, if the
GrantedAuthority
s matches all of the given roles.
-
fromClientAddress
Checks that the client connected from the given address.- Parameters:
remoteAddressCheck
- The check to apply to the client address.- Returns:
- A newly created AccessPredicate that only returns true, if the client address passes the given check.
- See Also:
-
toServerAddress
Checks that the client connected to the given server address.- Parameters:
localAddressCheck
- The check to apply to the server address.- Returns:
- A newly created AccessPredicate that only returns true, if the server address passes the given check.
- See Also:
-