@Test (expectedExceptions = IllegalStateException.class) public void shouldThrowSSOExceptionWhenUserIdNotFound() throws SSOException { HttpServletRequest request = mock(HttpServletRequest.class); SSOToken token = mock(SSOToken.class); given(requestUtils.getTokenId(request)).willReturn("TOKEN_ID"); given(ssoTokenFactory.getTokenFromId("TOKEN_ID")).willReturn(token); given(token.getProperty(Constants.UNIVERSAL_IDENTIFIER)).willThrow(SSOException.class); filter.authorize(request, null); fail(); }
@Override public boolean authorize(HttpServletRequest servletRequest, HttpServletResponse servletResponse) { String tokenId = requestUtils.getTokenId(servletRequest); if (StringUtils.isEmpty(tokenId)) { tokenId = servletRequest.getHeader(getCookieHeaderName()); } if (StringUtils.isEmpty(tokenId)) { return false; } SSOToken token = ssoTokenFactory.getTokenFromId(tokenId); if (token == null) { return false; } String userId; try { userId = token.getProperty(Constants.UNIVERSAL_IDENTIFIER); } catch (SSOException e) { debugLogger.error("Failed to get userId", e); throw new IllegalStateException(e); } return sessionService.isSuperUser(userId); }
AdminAuthorizationFilter implements AuthorizationFilter { @Override public boolean authorize(HttpServletRequest servletRequest, HttpServletResponse servletResponse) { String tokenId = requestUtils.getTokenId(servletRequest); if (StringUtils.isEmpty(tokenId)) { tokenId = servletRequest.getHeader(getCookieHeaderName()); } if (StringUtils.isEmpty(tokenId)) { return false; } SSOToken token = ssoTokenFactory.getTokenFromId(tokenId); if (token == null) { return false; } String userId; try { userId = token.getProperty(Constants.UNIVERSAL_IDENTIFIER); } catch (SSOException e) { debugLogger.error("Failed to get userId", e); throw new IllegalStateException(e); } return sessionService.isSuperUser(userId); } }
AdminAuthorizationFilter implements AuthorizationFilter { @Override public boolean authorize(HttpServletRequest servletRequest, HttpServletResponse servletResponse) { String tokenId = requestUtils.getTokenId(servletRequest); if (StringUtils.isEmpty(tokenId)) { tokenId = servletRequest.getHeader(getCookieHeaderName()); } if (StringUtils.isEmpty(tokenId)) { return false; } SSOToken token = ssoTokenFactory.getTokenFromId(tokenId); if (token == null) { return false; } String userId; try { userId = token.getProperty(Constants.UNIVERSAL_IDENTIFIER); } catch (SSOException e) { debugLogger.error("Failed to get userId", e); throw new IllegalStateException(e); } return sessionService.isSuperUser(userId); } @Inject  AdminAuthorizationFilter(SSOTokenFactory ssoTokenFactory, AuthnRequestUtils requestUtils,
            SessionService sessionService, AuthUtilsWrapper authUtilsWrapper); }
AdminAuthorizationFilter implements AuthorizationFilter { @Override public boolean authorize(HttpServletRequest servletRequest, HttpServletResponse servletResponse) { String tokenId = requestUtils.getTokenId(servletRequest); if (StringUtils.isEmpty(tokenId)) { tokenId = servletRequest.getHeader(getCookieHeaderName()); } if (StringUtils.isEmpty(tokenId)) { return false; } SSOToken token = ssoTokenFactory.getTokenFromId(tokenId); if (token == null) { return false; } String userId; try { userId = token.getProperty(Constants.UNIVERSAL_IDENTIFIER); } catch (SSOException e) { debugLogger.error("Failed to get userId", e); throw new IllegalStateException(e); } return sessionService.isSuperUser(userId); } @Inject  AdminAuthorizationFilter(SSOTokenFactory ssoTokenFactory, AuthnRequestUtils requestUtils,
            SessionService sessionService, AuthUtilsWrapper authUtilsWrapper); @Override void initialise(LoggingConfigurator configuration, AuditLogger auditLogger, DebugLogger debugLogger); @Override boolean authorize(HttpServletRequest servletRequest, HttpServletResponse servletResponse); }
AdminAuthorizationFilter implements AuthorizationFilter { @Override public boolean authorize(HttpServletRequest servletRequest, HttpServletResponse servletResponse) { String tokenId = requestUtils.getTokenId(servletRequest); if (StringUtils.isEmpty(tokenId)) { tokenId = servletRequest.getHeader(getCookieHeaderName()); } if (StringUtils.isEmpty(tokenId)) { return false; } SSOToken token = ssoTokenFactory.getTokenFromId(tokenId); if (token == null) { return false; } String userId; try { userId = token.getProperty(Constants.UNIVERSAL_IDENTIFIER); } catch (SSOException e) { debugLogger.error("Failed to get userId", e); throw new IllegalStateException(e); } return sessionService.isSuperUser(userId); } @Inject  AdminAuthorizationFilter(SSOTokenFactory ssoTokenFactory, AuthnRequestUtils requestUtils,
            SessionService sessionService, AuthUtilsWrapper authUtilsWrapper); @Override void initialise(LoggingConfigurator configuration, AuditLogger auditLogger, DebugLogger debugLogger); @Override boolean authorize(HttpServletRequest servletRequest, HttpServletResponse servletResponse);  }