Class GooglePublicKeysManager (1.35.2)

public class GooglePublicKeysManager

Beta
Thread-safe Google public keys manager.

The public keys are loaded from the public certificates endpoint at #getPublicCertsEncodedUrl and cached in this instance. Therefore, for maximum efficiency, applications should use a single globally-shared instance of the GooglePublicKeysManager.

Inheritance

java.lang.Object > GooglePublicKeysManager

Constructors

GooglePublicKeysManager(GooglePublicKeysManager.Builder builder)

protected GooglePublicKeysManager(GooglePublicKeysManager.Builder builder)
Parameter
NameDescription
builderGooglePublicKeysManager.Builder

builder

GooglePublicKeysManager(HttpTransport transport, JsonFactory jsonFactory)

public GooglePublicKeysManager(HttpTransport transport, JsonFactory jsonFactory)
Parameters
NameDescription
transportcom.google.api.client.http.HttpTransport

HTTP transport

jsonFactorycom.google.api.client.json.JsonFactory

JSON factory

Methods

getClock()

public final Clock getClock()

Returns the clock.

Returns
TypeDescription
com.google.api.client.util.Clock

getExpirationTimeMilliseconds()

public final long getExpirationTimeMilliseconds()

Returns the expiration time in milliseconds to be used with Clock#currentTimeMillis() or 0 for none.

Returns
TypeDescription
long

getJsonFactory()

public final JsonFactory getJsonFactory()

Returns the JSON factory.

Returns
TypeDescription
com.google.api.client.json.JsonFactory

getPublicCertsEncodedUrl()

public final String getPublicCertsEncodedUrl()

Returns the public certificates encoded URL.

Returns
TypeDescription
String

getPublicKeys()

public final List<PublicKey> getPublicKeys()

Returns an unmodifiable view of the public keys.

For efficiency, an in-memory cache of the public keys is used here. If this method is called for the first time, or the certificates have expired since last time it has been called (or are within 5 minutes of expiring), #refresh() will be called before returning the value.

Returns
TypeDescription
List<PublicKey>
Exceptions
TypeDescription
GeneralSecurityException
IOException

getTransport()

public final HttpTransport getTransport()

Returns the HTTP transport.

Returns
TypeDescription
com.google.api.client.http.HttpTransport

refresh()

public GooglePublicKeysManager refresh()

Forces a refresh of the public certificates downloaded from #getPublicCertsEncodedUrl.

This method is automatically called from #getPublicKeys() if the public keys have not yet been initialized or if the expiration time is very close, so normally this doesn't need to be called. Only call this method to explicitly force the public keys to be updated.

Returns
TypeDescription
GooglePublicKeysManager
Exceptions
TypeDescription
GeneralSecurityException
IOException