Class AnonymousAuthenticationReader
java.lang.Object
net.devh.boot.grpc.server.security.authentication.AnonymousAuthenticationReader
- All Implemented Interfaces:
GrpcAuthenticationReader
The AnonymousAuthenticationReader allows users without credentials to get an anonymous identity.
-
Constructor Summary
ConstructorDescriptionCreates a new AnonymousAuthenticationReader with the given key and"anonymousUser"
as principal with theROLE_ANONYMOUS
.AnonymousAuthenticationReader
(String key, Object principal, Collection<? extends GrantedAuthority> authorities) Creates a new AnonymousAuthenticationReader with the given key,principal and authorities. -
Method Summary
Modifier and TypeMethodDescriptionreadAuthentication
(ServerCall<?, ?> call, Metadata headers) Tries to read theAuthentication
information from the given call and metadata.
-
Constructor Details
-
AnonymousAuthenticationReader
Creates a new AnonymousAuthenticationReader with the given key and"anonymousUser"
as principal with theROLE_ANONYMOUS
.- Parameters:
key
- The key to used to identify tokens that were created by this instance.
-
AnonymousAuthenticationReader
public AnonymousAuthenticationReader(String key, Object principal, Collection<? extends GrantedAuthority> authorities) Creates a new AnonymousAuthenticationReader with the given key,principal and authorities.- Parameters:
key
- The key to used to identify tokens that were created by this instance.principal
- The principal which will be used to represent anonymous users.authorities
- The authority list for anonymous users.
-
-
Method Details
-
readAuthentication
Description copied from interface:GrpcAuthenticationReader
Tries to read theAuthentication
information from the given call and metadata.Note: Implementations are free to throw an
AuthenticationException
if no credentials could be found in the call. If an exception is thrown by an implementation then the authentication attempt should be considered as failed and no subsequentGrpcAuthenticationReader
s should be called. Additionally, the call will fail asStatus.UNAUTHENTICATED
. If the call instead returnsnull
, then the call processing will proceed unauthenticated.- Specified by:
readAuthentication
in interfaceGrpcAuthenticationReader
- Parameters:
call
- The call to get that send the request.headers
- The metadata/headers as sent by the client.- Returns:
- The authentication object or null if no authentication is present.
-