Class NimbusSignedTokenService
java.lang.Object
com.irurueta.authserver.authorization.infrastructure.keys.NimbusSignedTokenService
- All Implemented Interfaces:
SignedTokenService
Issues and verifies purpose-bound tokens as JWTs signed with the active signing key and verified against the
published keys. Verification checks the signature, the issuer, the timestamps and then the purpose; every failure
is reported the same way, as an empty result.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ClockSource of the current time.private final org.springframework.security.oauth2.jwt.JwtDecoderVerifies tokens.private final org.springframework.security.oauth2.jwt.JwtEncoderSigns tokens.private final StringIssuer written to, and required of, every token.Fields inherited from interface com.irurueta.authserver.authorization.domain.account.SignedTokenService
PURPOSE_CLAIM -
Constructor Summary
ConstructorsConstructorDescriptionNimbusSignedTokenService(org.springframework.security.oauth2.jwt.JwtEncoder encoder, com.nimbusds.jose.jwk.source.JWKSource<com.nimbusds.jose.proc.SecurityContext> jwkSource, Clock clock, String issuer) Creates the service. -
Method Summary
-
Field Details
-
clock
Source of the current time. -
issuer
Issuer written to, and required of, every token. -
encoder
private final org.springframework.security.oauth2.jwt.JwtEncoder encoderSigns tokens. -
decoder
private final org.springframework.security.oauth2.jwt.JwtDecoder decoderVerifies tokens.
-
-
Constructor Details
-
NimbusSignedTokenService
public NimbusSignedTokenService(org.springframework.security.oauth2.jwt.JwtEncoder encoder, com.nimbusds.jose.jwk.source.JWKSource<com.nimbusds.jose.proc.SecurityContext> jwkSource, Clock clock, @Value("${spring.security.oauth2.authorizationserver.issuer}") String issuer) Creates the service.- Parameters:
encoder- signs tokens with the active key.jwkSource- public keys the signatures are verified against.clock- source of the current time.issuer- issuer of the tokens (spring.security.oauth2.authorizationserver.issuer).
-
-
Method Details
-
issue
Issues a signed token.- Specified by:
issuein interfaceSignedTokenService- Parameters:
subject- who or what the token is about.purpose- what the token allows.ttl- how long the token stays valid.- Returns:
- the compact token.
-
verify
Verifies a token.- Specified by:
verifyin interfaceSignedTokenService- Parameters:
token- the compact token.purpose- purpose the token must have been issued for.- Returns:
- the subject, or an empty optional when the token is expired, tampered, malformed, from another issuer or issued for another purpose.
-