public class ServiceAccountJwtAccessCredentials extends Credentials implements JwtProvider, ServiceAccountSigner, QuotaProjectIdProvider
Uses a JSON Web Token (JWT) directly in the request metadata to provide authorization.
Modifier and Type | Class and Description |
---|---|
static class |
ServiceAccountJwtAccessCredentials.Builder |
ServiceAccountSigner.SigningException
GOOGLE_DEFAULT_UNIVERSE
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object obj) |
static ServiceAccountJwtAccessCredentials |
fromPkcs8(String clientId,
String clientEmail,
String privateKeyPkcs8,
String privateKeyId)
Factory using PKCS#8 for the private key.
|
static ServiceAccountJwtAccessCredentials |
fromPkcs8(String clientId,
String clientEmail,
String privateKeyPkcs8,
String privateKeyId,
URI defaultAudience)
Factory using PKCS#8 for the private key.
|
static ServiceAccountJwtAccessCredentials |
fromStream(InputStream credentialsStream)
Returns credentials defined by a Service Account key file in JSON format from the Google
Developers Console.
|
static ServiceAccountJwtAccessCredentials |
fromStream(InputStream credentialsStream,
URI defaultAudience)
Returns credentials defined by a Service Account key file in JSON format from the Google
Developers Console.
|
String |
getAccount() |
String |
getAuthenticationType() |
String |
getClientEmail() |
String |
getClientId() |
PrivateKey |
getPrivateKey() |
String |
getPrivateKeyId() |
String |
getQuotaProjectId() |
Map<String,List<String>> |
getRequestMetadata(URI uri)
Provide the request metadata by putting an access JWT directly in the metadata.
|
void |
getRequestMetadata(URI uri,
Executor executor,
RequestMetadataCallback callback) |
int |
hashCode() |
boolean |
hasRequestMetadata() |
boolean |
hasRequestMetadataOnly() |
JwtCredentials |
jwtWithClaims(JwtClaims newClaims)
Returns a new JwtCredentials instance with modified claims.
|
static ServiceAccountJwtAccessCredentials.Builder |
newBuilder() |
void |
refresh()
Discard any cached data
|
byte[] |
sign(byte[] toSign) |
ServiceAccountJwtAccessCredentials.Builder |
toBuilder() |
String |
toString() |
blockingGetToCallback, getRequestMetadata, getUniverseDomain
public static ServiceAccountJwtAccessCredentials fromPkcs8(String clientId, String clientEmail, String privateKeyPkcs8, String privateKeyId) throws IOException
clientId
- Client ID of the service account from the console. May be null.clientEmail
- Client email address of the service account from the console.privateKeyPkcs8
- RSA private key object for the service account in PKCS#8 format.privateKeyId
- Private key identifier for the service account. May be null.IOException
- if the credential cannot be created from the private key.public static ServiceAccountJwtAccessCredentials fromPkcs8(String clientId, String clientEmail, String privateKeyPkcs8, String privateKeyId, URI defaultAudience) throws IOException
clientId
- Client ID of the service account from the console. May be null.clientEmail
- Client email address of the service account from the console.privateKeyPkcs8
- RSA private key object for the service account in PKCS#8 format.privateKeyId
- Private key identifier for the service account. May be null.defaultAudience
- Audience to use if not provided by transport. May be null.IOException
- if the credential cannot be created from the private key.public static ServiceAccountJwtAccessCredentials fromStream(InputStream credentialsStream) throws IOException
credentialsStream
- the stream with the credential definition.IOException
- if the credential cannot be created from the stream.public static ServiceAccountJwtAccessCredentials fromStream(InputStream credentialsStream, URI defaultAudience) throws IOException
credentialsStream
- the stream with the credential definition.defaultAudience
- Audience to use if not provided by transport. May be null.IOException
- if the credential cannot be created from the stream.public JwtCredentials jwtWithClaims(JwtClaims newClaims)
jwtWithClaims
in interface JwtProvider
newClaims
- new claims. Any unspecified claim fields will default to the the current
values.public String getAuthenticationType()
getAuthenticationType
in class Credentials
public boolean hasRequestMetadata()
hasRequestMetadata
in class Credentials
public boolean hasRequestMetadataOnly()
hasRequestMetadataOnly
in class Credentials
public void getRequestMetadata(URI uri, Executor executor, RequestMetadataCallback callback)
getRequestMetadata
in class Credentials
public Map<String,List<String>> getRequestMetadata(URI uri) throws IOException
getRequestMetadata
in class Credentials
IOException
public void refresh()
refresh
in class Credentials
public final String getClientId()
public final String getClientEmail()
public final PrivateKey getPrivateKey()
public final String getPrivateKeyId()
public String getAccount()
getAccount
in interface ServiceAccountSigner
public byte[] sign(byte[] toSign)
sign
in interface ServiceAccountSigner
public static ServiceAccountJwtAccessCredentials.Builder newBuilder()
public ServiceAccountJwtAccessCredentials.Builder toBuilder()
public String getQuotaProjectId()
getQuotaProjectId
in interface QuotaProjectIdProvider
Copyright © 2024 Google. All rights reserved.