Skip to content

Commit

Permalink
Merge pull request #2201 from darranl/ELY-2741
Browse files Browse the repository at this point in the history
[ELY-2741] Enhance TRACE logging for the EXTERNAL HTTP mechanism
  • Loading branch information
fjuma authored Sep 19, 2024
2 parents 3217ffb + 9d2d19b commit 7780f81
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -59,19 +59,24 @@ public void evaluateRequest(HttpServerRequest request) throws HttpAuthentication

String remoteUser = request.getRemoteUser();
if (remoteUser == null) {
httpExternal.trace("The remote-user was not obtained from the request");
request.noAuthenticationInProgress();
return;
}

if (authorize(remoteUser)) {
httpExternal.tracef("Authorization of user [%s] succeed", remoteUser);
succeed(request);
} else {
httpExternal.tracef("Authorization of user [%s] failed", remoteUser);
fail(request);
}

}

private boolean authorize(String username) throws HttpAuthenticationException {
httpExternal.tracef("Authorizing username: [%s]",username);

AuthorizeCallback authorizeCallback = new AuthorizeCallback(username, username);
try {
MechanismUtil.handleCallbacks(httpExternal, callbackHandler, authorizeCallback);
Expand All @@ -88,6 +93,7 @@ private void succeed(HttpServerRequest request) throws HttpAuthenticationExcepti
MechanismUtil.handleCallbacks(httpExternal, callbackHandler, AuthenticationCompleteCallback.SUCCEEDED);
request.authenticationComplete();
} catch (AuthenticationMechanismException e) {
httpExternal.trace("Failed to complete successful authentication", e);
throw e.toHttpAuthenticationException();
} catch (UnsupportedCallbackException e) {
throw httpExternal.mechCallbackHandlerFailedForUnknownReason(e).toHttpAuthenticationException();
Expand All @@ -99,6 +105,7 @@ private void fail(HttpServerRequest request) throws HttpAuthenticationException
MechanismUtil.handleCallbacks(httpExternal, callbackHandler, AuthenticationCompleteCallback.FAILED);
request.authenticationFailed(httpExternal.authenticationFailed(), response -> response.setStatusCode(FORBIDDEN));
} catch (AuthenticationMechanismException e) {
httpExternal.trace("Failed authentication not completed", e);
throw e.toHttpAuthenticationException();
} catch (UnsupportedCallbackException e) {
throw httpExternal.mechCallbackHandlerFailedForUnknownReason(e).toHttpAuthenticationException();
Expand Down
2 changes: 1 addition & 1 deletion x500/cert/util/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
<groupId>org.jboss.logging</groupId>
<artifactId>jboss-logging-processor</artifactId>
<scope>provided</scope>
</dependency>
</dependency>
</dependencies>

</project>
Expand Down

0 comments on commit 7780f81

Please sign in to comment.