improved error logging

This commit is contained in:
2019-02-14 17:28:41 +01:00
parent be31b12d0a
commit b30b40769c
2 changed files with 9 additions and 10 deletions

View File

@ -169,8 +169,8 @@ public class ApiKeyService implements Serializable {
throw new JWTException("AccountControl exception");
}
List<ApiKeyEntity> apiKeys = getUsersApiKeys(userAccount);
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Found {} keys for user {}", apiKeys.size(), userName);
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Found {} keys for user {}", apiKeys.size(), userName);
}
Iterator<ApiKeyEntity> it = apiKeys.iterator();
@ -178,21 +178,20 @@ public class ApiKeyService implements Serializable {
while (keyToLogout == null && it.hasNext()) {
ApiKeyEntity key = it.next();
if (key.getApiKey().equals(apiKey)) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Found API key in database");
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Found API key in database");
}
ZonedDateTime issuedOn = ZonedDateTime.ofInstant(key.getIssuedOn().toInstant(), ZoneOffset.UTC);
String testString = JWTEncoder.encode(password, issuer, issuedOn, key.getAccount().getUsername(), key.getApiKey(), key.getExpiration());
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Successfully created validation JWT for user {}", userName);
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Successfully created validation JWT for user {}", userName);
}
if (authorizationHeader.equals(testString)) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Found valid key for user {}", userName);
}
return key;
}
}
@ -200,7 +199,6 @@ public class ApiKeyService implements Serializable {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("No valid key for user {} found", userName);
}
return null;
}

View File

@ -44,6 +44,7 @@ public class APIExceptionInterceptor {
proceedResponse = context.proceed();
} catch (Exception ex) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(ex.getMessage());
LOGGER.debug("Detailed stacktrace", new Object[]{ex});
}