@Test public void shouldReturnFalseWhenTokenIdNotInRequest() { HttpServletRequest request = mock(HttpServletRequest.class); given(requestUtils.getTokenId(request)).willReturn(null); boolean authorized = filter.authorize(request, null); assertFalse(authorized); }
@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);  }