moved some debug messages to trace
This commit is contained in:
@ -56,16 +56,16 @@ public class JwtMatcher implements CredentialsMatcher {
|
|||||||
if ((submittedJwtObj != null) && (submittedJwtObj.getClass().isAssignableFrom(String.class))) {
|
if ((submittedJwtObj != null) && (submittedJwtObj.getClass().isAssignableFrom(String.class))) {
|
||||||
String submittedJwt = (String) submittedJwtObj;
|
String submittedJwt = (String) submittedJwtObj;
|
||||||
if (apiKeyService.validateJWT(submittedJwt)) {
|
if (apiKeyService.validateJWT(submittedJwt)) {
|
||||||
if (LOGGER.isDebugEnabled()) {
|
if (LOGGER.isTraceEnabled()) {
|
||||||
LOGGER.debug("JWT is valid, checking if it comes from the correct user");
|
LOGGER.trace("JWT is valid, checking if it comes from the correct user");
|
||||||
}
|
}
|
||||||
|
|
||||||
JWTObject jwtObject = apiKeyService.getJWTObject(submittedJwt);
|
JWTObject jwtObject = apiKeyService.getJWTObject(submittedJwt);
|
||||||
String storedUsername = info.getPrincipals().getPrimaryPrincipal().toString();
|
String storedUsername = info.getPrincipals().getPrimaryPrincipal().toString();
|
||||||
if (jwtObject.getUserName().equals(storedUsername)) {
|
if (jwtObject.getUserName().equals(storedUsername)) {
|
||||||
if (jwtObject.getUnqiueId().equals (storedCredentials)) {
|
if (jwtObject.getUnqiueId().equals (storedCredentials)) {
|
||||||
if (LOGGER.isDebugEnabled()) {
|
if (LOGGER.isTraceEnabled()) {
|
||||||
LOGGER.debug("JWT matches user and password is correct");
|
LOGGER.trace("JWT matches user and password is correct");
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
@ -81,8 +81,8 @@ public class JwtMatcher implements CredentialsMatcher {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (LOGGER.isDebugEnabled()) {
|
if (LOGGER.isTraceEnabled()) {
|
||||||
LOGGER.debug("JWT is invalid");
|
LOGGER.trace("JWT is invalid");
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -94,14 +94,13 @@ public final class JWTAuthenticationFilter extends AuthenticatingFilter {
|
|||||||
|
|
||||||
if (isLoggedAttempt(request, response)) {
|
if (isLoggedAttempt(request, response)) {
|
||||||
String jwtToken = getAuthzHeader(request);
|
String jwtToken = getAuthzHeader(request);
|
||||||
if (LOGGER.isDebugEnabled()) {
|
if (LOGGER.isTraceEnabled()) {
|
||||||
LOGGER.debug("found jwtToke in header = {}", jwtToken);
|
LOGGER.trace("found jwtToke in header = {}", jwtToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (jwtToken != null) {
|
if (jwtToken != null) {
|
||||||
JWTObject jwtObject = apiKeyService.getJWTObject(jwtToken);
|
JWTObject jwtObject = apiKeyService.getJWTObject(jwtToken);
|
||||||
return new JWTAuthenticationToken(jwtObject.getUserName(), 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);
|
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
|
* Overwrite cleanup to ensure no exception is thrown if an
|
||||||
|
|||||||
Reference in New Issue
Block a user