public class AnonymousAuthenticationReader extends Object implements GrpcAuthenticationReader
Constructor and Description |
---|
AnonymousAuthenticationReader(String key)
Creates a new AnonymousAuthenticationReader with the given key and
"anonymousUser" as principal with the
ROLE_ANONYMOUS . |
AnonymousAuthenticationReader(String key,
Object principal,
Collection<? extends GrantedAuthority> authorities)
Creates a new AnonymousAuthenticationReader with the given key,principal and authorities.
|
Modifier and Type | Method and Description |
---|---|
Authentication |
readAuthentication(ServerCall<?,?> call,
Metadata headers)
Tries to read the
Authentication information from the given call and metadata. |
public AnonymousAuthenticationReader(String key)
"anonymousUser"
as principal with the
ROLE_ANONYMOUS
.key
- The key to used to identify tokens that were created by this instance.public AnonymousAuthenticationReader(String key, Object principal, Collection<? extends GrantedAuthority> authorities)
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.public Authentication readAuthentication(ServerCall<?,?> call, Metadata headers)
GrpcAuthenticationReader
Authentication
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 subsequent GrpcAuthenticationReader
s should be called. Additionally, the call
will fail as Status.UNAUTHENTICATED
. If the call instead returns null
, then the call processing
will proceed unauthenticated.
readAuthentication
in interface GrpcAuthenticationReader
call
- The call to get that send the request.headers
- The metadata/headers as sent by the client.