@Test public void testParseTokenFromAuthHeaderNoBearer() { JwtAuthenticator authenticator = new JwtAuthenticator(TOKEN_PROVIDER, JWT_TOKEN); HttpServletRequest request = mock(HttpServletRequest.class); expect(request.getHeader(HttpHeader.AUTHORIZATION.asString())).andReturn(BASIC_SCHEME + " " + EXPECTED_TOKEN); replay(request); String actualToken = authenticator.getJwtFromBearerAuthorization(request); verify(request); assertNull(actualToken); }
String getJwtFromBearerAuthorization(HttpServletRequest req) { String authorizationHeader = req.getHeader(HttpHeader.AUTHORIZATION.asString()); if (authorizationHeader == null || !authorizationHeader.startsWith(BEARER)) { return null; } else { return authorizationHeader.substring(BEARER.length()).trim(); } }
JwtAuthenticator extends LoginAuthenticator { String getJwtFromBearerAuthorization(HttpServletRequest req) { String authorizationHeader = req.getHeader(HttpHeader.AUTHORIZATION.asString()); if (authorizationHeader == null || !authorizationHeader.startsWith(BEARER)) { return null; } else { return authorizationHeader.substring(BEARER.length()).trim(); } } }
JwtAuthenticator extends LoginAuthenticator { String getJwtFromBearerAuthorization(HttpServletRequest req) { String authorizationHeader = req.getHeader(HttpHeader.AUTHORIZATION.asString()); if (authorizationHeader == null || !authorizationHeader.startsWith(BEARER)) { return null; } else { return authorizationHeader.substring(BEARER.length()).trim(); } } JwtAuthenticator(String authenticationProviderUrl, String cookieName); }
JwtAuthenticator extends LoginAuthenticator { String getJwtFromBearerAuthorization(HttpServletRequest req) { String authorizationHeader = req.getHeader(HttpHeader.AUTHORIZATION.asString()); if (authorizationHeader == null || !authorizationHeader.startsWith(BEARER)) { return null; } else { return authorizationHeader.substring(BEARER.length()).trim(); } } JwtAuthenticator(String authenticationProviderUrl, String cookieName); @Override String getAuthMethod(); @Override void prepareRequest(ServletRequest request); @Override Authentication validateRequest(ServletRequest request, ServletResponse response, boolean mandatory); @Override boolean secureResponse(ServletRequest request, ServletResponse response, boolean mandatory, Authentication.User validatedUser); }
JwtAuthenticator extends LoginAuthenticator { String getJwtFromBearerAuthorization(HttpServletRequest req) { String authorizationHeader = req.getHeader(HttpHeader.AUTHORIZATION.asString()); if (authorizationHeader == null || !authorizationHeader.startsWith(BEARER)) { return null; } else { return authorizationHeader.substring(BEARER.length()).trim(); } } JwtAuthenticator(String authenticationProviderUrl, String cookieName); @Override String getAuthMethod(); @Override void prepareRequest(ServletRequest request); @Override Authentication validateRequest(ServletRequest request, ServletResponse response, boolean mandatory); @Override boolean secureResponse(ServletRequest request, ServletResponse response, boolean mandatory, Authentication.User validatedUser); static final String JWT_TOKEN_REQUEST_ATTRIBUTE; }