Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add claimTypeMismatch log message #839

Merged
merged 1 commit into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,17 @@
import io.smallrye.jwt.JsonUtils;

/**
* A default implementation of JWTCallerPrincipal that wraps the jose4j JwtClaims.
* A default implementation of JWTCallerPrincipal that wraps the jose4j
* JwtClaims.
*
* @see JwtClaims
*/
public class DefaultJWTCallerPrincipal extends JWTCallerPrincipal {
private final JwtClaims claimsSet;

/**
* Create the DefaultJWTCallerPrincipal from the parsed JWT token and the extracted principal name
* Create the DefaultJWTCallerPrincipal from the parsed JWT token and the
* extracted principal name
*
* @param rawToken - raw token value
* @param tokenType - token type
Expand Down Expand Up @@ -115,7 +117,9 @@ protected Object getClaimValue(String claimName) {
claim = 0L;
}
} catch (MalformedClaimException e) {
PrincipalLogging.log.getGroupsFailure(claimName, e);
Object value = claimsSet.getClaimValue(claimType.name());
PrincipalLogging.log.claimTypeMismatch(claimName, claimType.getType().getSimpleName(),
value.getClass().getSimpleName());
}
break;
case groups:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,4 +193,8 @@ interface PrincipalLogging extends BasicLogger {
@Message(id = 8044, value = "Encrypted token headers must contain a content type header")
void encryptedTokenMissingContentType();

@LogMessage(level = Logger.Level.DEBUG)
@Message(id = 8045, value = "Claim %s's value type is expected to be %s but it is %s")
void claimTypeMismatch(String claimName, String expectedType, String actualType);

}