Skip to content

Commit

Permalink
Add claimTypeMismatch log message
Browse files Browse the repository at this point in the history
  • Loading branch information
sberyozkin committed Nov 15, 2024
1 parent 0d578de commit 88e3424
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
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);

}

0 comments on commit 88e3424

Please sign in to comment.