Oved Ourfali has uploaded a new change for review. Change subject: reports: open reports via webadmin - host or vm gives exception (#855865) ......................................................................
reports: open reports via webadmin - host or vm gives exception (#855865) https://bugzilla.redhat.com/855865 Exception tends to occur in the reports integration. The details of this exception is: org.ovirt.authentication.EngineUserDetails cannot be cast to com.jaspersoft.jasperserver.api.metadata.user.domain.User This shouldn't happen, as jasper is supposed to convert the EngineUserDetails from the token to its own user details, and leave the original details in originalAuthentication field. However, in this patch, when re-authentication is needed, we leave the current authentication object, setting only our user details. That way, jasper doesn't need to recreate their own user details every time. Change-Id: Ie9c2ce53018e2b9d08edb5d0162c584c81ac03d5 Signed-off-by: Oved Ourfali <oourf...@redhat.com> --- M reports/jars/EngineAuthentication/src/main/java/org/ovirt/authentication/EngineSimplePreAuthFilter.java 1 file changed, 12 insertions(+), 2 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-reports refs/changes/45/7945/1 diff --git a/reports/jars/EngineAuthentication/src/main/java/org/ovirt/authentication/EngineSimplePreAuthFilter.java b/reports/jars/EngineAuthentication/src/main/java/org/ovirt/authentication/EngineSimplePreAuthFilter.java index 4218afc..d0d9b67 100755 --- a/reports/jars/EngineAuthentication/src/main/java/org/ovirt/authentication/EngineSimplePreAuthFilter.java +++ b/reports/jars/EngineAuthentication/src/main/java/org/ovirt/authentication/EngineSimplePreAuthFilter.java @@ -88,7 +88,8 @@ public void doFilterHttp(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws IOException, ServletException { Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); - if (authentication == null) { + if (authentication == null || (authentication != null && !authentication.isAuthenticated())) { + logger.debug("authentication context is either null, or not authenticated. Validating session."); SecurityContextHolder.getContext().setAuthentication(getAuthRequest(request)); } else { // The logic here is that if we are already authenticated, and the authentication was done in this pre-auth filter, then we check if we need @@ -102,7 +103,16 @@ EngineUserDetails userDetails = (EngineUserDetails) originalAuthentication.getPrincipal(); // Checking if we need to re-check the session, and acting accordingly if (userDetails.isRecheckSessionIdNeeded()) { - SecurityContextHolder.getContext().setAuthentication(getAuthRequest(request, userDetails.getUserSessionID())); + logger.debug("Rechecking session is needed"); + UsernamePasswordAuthenticationToken token = getAuthRequest(request, userDetails.getUserSessionID()); + // if the token is null then it means we failed authentication + if (token == null) { + logger.debug("Returned token is null. Session was not valid. Setting authenticated to false"); + authentication.setAuthenticated(false); + } else { + logger.debug("Token is not null. Setting it."); + metadataUserDetails.setOriginalAuthentication(token); + } } } } -- To view, visit http://gerrit.ovirt.org/7945 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ie9c2ce53018e2b9d08edb5d0162c584c81ac03d5 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-reports Gerrit-Branch: master Gerrit-Owner: Oved Ourfali <oourf...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches