Class AppleClientSecretGenerator
java.lang.Object
com.irurueta.authserver.authorization.api.web.social.AppleClientSecretGenerator
Generates the client secret Sign in with Apple requires: a JWT signed with ES256 by the key Apple issued
(
iss the team id, sub the client id, aud https://appleid.apple.com, header
kid the key id), valid for a short time. The token request of the framework asks for it each time, so the
secret is cached and renewed when half of its lifetime has passed.
It does not use the JwtEncoder of the server's own signing keys: Apple verifies the secret with the key
registered in its developer account, so only that key can sign it. It is a dedicated Nimbus signer over the Apple
key supplied from the environment.
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) static final StringAudience Apple requires in the client secret.Holds the current secret until it is half way through its life.private final StringClient id registered with Apple (the services id).private final ClockSource of the current time.private final StringId of the key that signs the secret.private static final intThe secret is renewed when this fraction of its lifetime has passed.private final com.nimbusds.jose.crypto.ECDSASignerSigns with the Apple key.private final StringApple developer team id.private final DurationLifetime of a secret. -
Constructor Summary
ConstructorsConstructorDescriptionAppleClientSecretGenerator(SocialProperties.Provider settings, ECPrivateKey key, Clock clock) Creates the generator. -
Method Summary
-
Field Details
-
AUDIENCE
Audience Apple requires in the client secret.- See Also:
-
RENEWAL_DIVISOR
private static final int RENEWAL_DIVISORThe secret is renewed when this fraction of its lifetime has passed.- See Also:
-
clientId
Client id registered with Apple (the services id). -
teamId
Apple developer team id. -
keyId
Id of the key that signs the secret. -
ttl
Lifetime of a secret. -
clock
Source of the current time. -
signer
private final com.nimbusds.jose.crypto.ECDSASigner signerSigns with the Apple key. -
cache
Holds the current secret until it is half way through its life.
-
-
Constructor Details
-
AppleClientSecretGenerator
public AppleClientSecretGenerator(SocialProperties.Provider settings, ECPrivateKey key, Clock clock) Creates the generator.- Parameters:
settings- settings of the Apple provider.key- private key Apple issued.clock- source of the current time.- Throws:
IllegalArgumentException- if the key cannot sign with ES256.
-
-
Method Details
-
clientId
Gets the client id (the Services ID) the secrets are signed for, which is also theclient_idof the token requests and of the authorization requests.- Returns:
- the client id.
-
generate
Returns a client secret that is valid now.- Returns:
- the signed JWT.
-
sign
Signs a new secret.- Returns:
- the serialized JWT.
-