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 interfaceSome helper methods used to createPredicates forSocketAddresses. -
Method Summary
Modifier and TypeMethodDescriptiondefault AccessPredicateand(BiPredicate<? super Authentication, ? super ServerCall<?, ?>> other) default AccessPredicateand(Predicate<? super Authentication> other) Combines this predicate with the given predicate using theANDoperator.static AccessPredicateAll authenticated users can access the protected instance including anonymous users.static AccessPredicatedenyAll()Nobody can access the protected instance.static AccessPredicatefromClientAddress(Predicate<? super SocketAddress> remoteAddressCheck) Checks that the client connected from the given address.static AccessPredicateAll authenticated users can access the protected instance excluding anonymous users.static AccessPredicateOnly those who have any of the givenGrantedAuthoritycan access the protected instance.static AccessPredicatehasAllAuthorities(GrantedAuthority... roles) Only those who have all of the givenGrantedAuthoritycan access the protected instance.static AccessPredicatehasAllRoles(String... roles) Only those who have all of the given roles can access the protected instance.static AccessPredicatehasAllRoles(Collection<String> roles) Only those who have all of the given roles can access the protected instance.static AccessPredicateOnly those who have any of the givenGrantedAuthoritycan access the protected instance.static AccessPredicatehasAnyAuthority(GrantedAuthority... roles) Only those who have any of the givenGrantedAuthoritycan access the protected instance.static AccessPredicatehasAnyRole(String... roles) Only those who have any of the given roles can access the protected instance.static AccessPredicatehasAnyRole(Collection<String> roles) Only those who have any of the given roles can access the protected instance.static AccessPredicatehasAuthority(GrantedAuthority role) Only those who have the givenGrantedAuthoritycan access the protected instance.static AccessPredicateOnly those who have the given role can access the protected instance.default AccessPredicatenegate()default AccessPredicateor(BiPredicate<? super Authentication, ? super ServerCall<?, ?>> other) default AccessPredicateor(Predicate<? super Authentication> other) Combines this predicate with the given predicate using theORoperator.static AccessPredicateSpecial constant that symbolizes that everybody (including unauthenticated users) can access the instance (no protection).booleantest(Authentication authentication, ServerCall<?, ?> serverCall) Checks whether the given user is authorized to execute the given call.static AccessPredicatetoServerAddress(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:
testin 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:
negatein interfaceBiPredicate<Authentication,ServerCall<?, ?>>
-
and
Combines this predicate with the given predicate using theANDoperator.- Parameters:
other- The other predicate to call.- Returns:
- The combined predicate.
-
and
- Specified by:
andin interfaceBiPredicate<Authentication,ServerCall<?, ?>>
-
or
Combines this predicate with the given predicate using theORoperator.- Parameters:
other- The other predicate to call.- Returns:
- The combined predicate.
-
or
- Specified by:
orin 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
nullvalues. 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
GrantedAuthoritys matches the given role name.
-
hasAuthority
Only those who have the givenGrantedAuthoritycan access the protected instance.- Parameters:
role- The role to check for.- Returns:
- A newly created AccessPredicate that only returns true, if the
GrantedAuthoritys 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
GrantedAuthoritys 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
GrantedAuthoritys matches any of the given role names.
-
hasAnyAuthority
Only those who have any of the givenGrantedAuthoritycan access the protected instance.- Parameters:
roles- The roles to check for.- Returns:
- A newly created AccessPredicate that only returns true, if the
GrantedAuthoritys matches any of the given roles.
-
hasAnyAuthority
Only those who have any of the givenGrantedAuthoritycan access the protected instance.- Parameters:
roles- The roles to check for.- Returns:
- A newly created AccessPredicate that only returns true, if the
GrantedAuthoritys 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
GrantedAuthoritys 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
GrantedAuthoritys matches all of the given role names.
-
hasAllAuthorities
Only those who have all of the givenGrantedAuthoritycan access the protected instance.- Parameters:
roles- The roles to check for.- Returns:
- A newly created AccessPredicate that only returns true, if the
GrantedAuthoritys matches all of the given roles.
-
hasAllAuthorities
Only those who have any of the givenGrantedAuthoritycan access the protected instance.- Parameters:
roles- The roles to check for.- Returns:
- A newly created AccessPredicate that only returns true, if the
GrantedAuthoritys 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:
-