Package s2.auth
Class BearerTokenCallCredentials
- java.lang.Object
-
- io.grpc.CallCredentials
-
- s2.auth.BearerTokenCallCredentials
-
public class BearerTokenCallCredentials extends io.grpc.CallCredentials
Implementation of CallCredentials that adds a bearer token to request metadata. This class is used to authenticate gRPC requests using a bearer token in the Authorization header with the "Bearer" scheme.
-
-
Constructor Summary
Constructors Constructor Description BearerTokenCallCredentials(java.lang.String token)
Creates new bearer token credentials.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
applyRequestMetadata(io.grpc.CallCredentials.RequestInfo requestInfo, java.util.concurrent.Executor executor, io.grpc.CallCredentials.MetadataApplier metadataApplier)
Applies the bearer token to the request metadata.boolean
equals(java.lang.Object other)
Returns whether this credentials implementation is equal to another object.int
hashCode()
Returns a hash code value for this credentials implementation.
-
-
-
Method Detail
-
applyRequestMetadata
public void applyRequestMetadata(io.grpc.CallCredentials.RequestInfo requestInfo, java.util.concurrent.Executor executor, io.grpc.CallCredentials.MetadataApplier metadataApplier)
Applies the bearer token to the request metadata. This method is called by the gRPC framework before each request.- Specified by:
applyRequestMetadata
in classio.grpc.CallCredentials
- Parameters:
requestInfo
- Information about the RPC being calledexecutor
- The executor to use for any asynchronous operationsmetadataApplier
- Interface for applying the resulting metadata
-
hashCode
public int hashCode()
Returns a hash code value for this credentials implementation.- Overrides:
hashCode
in classjava.lang.Object
- Returns:
- A hash code value for this object
-
equals
public boolean equals(java.lang.Object other)
Returns whether this credentials implementation is equal to another object. Two BearerTokenCallCredentials are equal if they have the same token.- Overrides:
equals
in classjava.lang.Object
- Parameters:
other
- The object to compare with- Returns:
- true if the objects are equal, false otherwise
-
-