@Beta public class GooglePublicKeysManager extends Object
Beta
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
.
Modifier and Type | Class and Description |
---|---|
static class |
GooglePublicKeysManager.Builder
|
Modifier | Constructor and Description |
---|---|
protected |
GooglePublicKeysManager(GooglePublicKeysManager.Builder builder) |
|
GooglePublicKeysManager(HttpTransport transport,
JsonFactory jsonFactory) |
Modifier and Type | Method and Description |
---|---|
Clock |
getClock()
Returns the clock.
|
long |
getExpirationTimeMilliseconds()
Returns the expiration time in milliseconds to be used with
Clock.currentTimeMillis()
or 0 for none. |
JsonFactory |
getJsonFactory()
Returns the JSON factory.
|
String |
getPublicCertsEncodedUrl()
Returns the public certificates encoded URL.
|
List<PublicKey> |
getPublicKeys()
Returns an unmodifiable view of the public keys.
|
HttpTransport |
getTransport()
Returns the HTTP transport.
|
GooglePublicKeysManager |
refresh()
Forces a refresh of the public certificates downloaded from
getPublicCertsEncodedUrl() . |
public GooglePublicKeysManager(HttpTransport transport, JsonFactory jsonFactory)
transport
- HTTP transportjsonFactory
- JSON factoryprotected GooglePublicKeysManager(GooglePublicKeysManager.Builder builder)
builder
- builderpublic final HttpTransport getTransport()
public final JsonFactory getJsonFactory()
public final String getPublicCertsEncodedUrl()
public final Clock getClock()
public final List<PublicKey> getPublicKeys() throws GeneralSecurityException, IOException
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.
GeneralSecurityException
IOException
public final long getExpirationTimeMilliseconds()
Clock.currentTimeMillis()
or 0
for none.public GooglePublicKeysManager refresh() throws GeneralSecurityException, IOException
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.
GeneralSecurityException
IOException
Copyright © 2010–2022 Google. All rights reserved.