Class PrincipalMapper
java.lang.Object
com.irurueta.authserver.serviceclient.infrastructure.resourceserver.PrincipalMapper
Builds the principals the authorized client manager caches tokens under. There is no security context in the
service client, so every call names its principal.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final intBytes of the digest of the subject token kept in the name.private static final StringKey of the principal of the service client itself. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static StringDigests a token.org.springframework.security.core.AuthenticationserviceClient(String clientId) Builds the principal of the service client, which the client credentials token is cached under.private static StringReads thesubclaim of a JWT without verifying it.org.springframework.security.core.AuthenticationBuilds the principal of a user whose token is exchanged.
-
Field Details
-
SERVICE_CLIENT_KEY
Key of the principal of the service client itself.- See Also:
-
DIGEST_BYTES
private static final int DIGEST_BYTESBytes of the digest of the subject token kept in the name.- See Also:
-
-
Constructor Details
-
PrincipalMapper
public PrincipalMapper()
-
-
Method Details
-
serviceClient
Builds the principal of the service client, which the client credentials token is cached under.- Parameters:
clientId- identifier of the client, used as the name.- Returns:
- the principal.
-
user
Builds the principal of a user whose token is exchanged. Its name is thesubclaim of the token when it is a readable JWT, followed by a digest of the whole token: the claim is not verified here (the authorization server does that), so the digest keeps two different tokens from ever sharing a cached exchange.- Parameters:
subjectToken- access token of the user.- Returns:
- the principal, whose principal object is the token, as the exchange provider expects.
-
subjectOf
Reads thesubclaim of a JWT without verifying it.- Parameters:
token- the token.- Returns:
- the claim, or
"user"when the token is opaque or has no subject.
-
digestOf
Digests a token.- Parameters:
token- the token.- Returns:
- the first bytes of its SHA-256 digest, in hexadecimal.
-