moved some debug messages to trace

This commit is contained in:
2019-01-24 16:58:11 +01:00
parent 333508632c
commit 5ab4d99dd3
2 changed files with 9 additions and 18 deletions

View File

@ -56,16 +56,16 @@ public class JwtMatcher implements CredentialsMatcher {
if ((submittedJwtObj != null) && (submittedJwtObj.getClass().isAssignableFrom(String.class))) {
String submittedJwt = (String) submittedJwtObj;
if (apiKeyService.validateJWT(submittedJwt)) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("JWT is valid, checking if it comes from the correct user");
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("JWT is valid, checking if it comes from the correct user");
}
JWTObject jwtObject = apiKeyService.getJWTObject(submittedJwt);
String storedUsername = info.getPrincipals().getPrimaryPrincipal().toString();
if (jwtObject.getUserName().equals(storedUsername)) {
if (jwtObject.getUnqiueId().equals (storedCredentials)) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("JWT matches user and password is correct");
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("JWT matches user and password is correct");
}
return true;
} else {
@ -81,8 +81,8 @@ public class JwtMatcher implements CredentialsMatcher {
return false;
}
} else {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("JWT is invalid");
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("JWT is invalid");
}
return false;
}

View File

@ -94,14 +94,13 @@ public final class JWTAuthenticationFilter extends AuthenticatingFilter {
if (isLoggedAttempt(request, response)) {
String jwtToken = getAuthzHeader(request);
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("found jwtToke in header = {}", jwtToken);
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("found jwtToke in header = {}", jwtToken);
}
if (jwtToken != null) {
JWTObject jwtObject = apiKeyService.getJWTObject(jwtToken);
return new JWTAuthenticationToken(jwtObject.getUserName(), jwtToken);
// return createToken(jwtToken);
}
}
@ -118,14 +117,6 @@ public final class JWTAuthenticationFilter extends AuthenticatingFilter {
return httpRequest.getHeader(AUTHORIZATION_HEADER);
}
private JWTAuthenticationToken createToken(String token) throws AccountSecurityException {
if (apiKeyService.validateJWT(token)) {
JWTObject jwtObject = apiKeyService.getJWTObject(token);
return new JWTAuthenticationToken(jwtObject.getUserName(), token);
} else {
throw new APIException(ApiKeyError.JWT_TOKEN_INVALID, Locale.ENGLISH); // TODO - how to get the correct locale
}
}
/**
* Overwrite cleanup to ensure no exception is thrown if an