@Test public void testEmptyCertificateArrayAvailable() throws Exception { X509Certificate[] certs = new X509Certificate[0]; when(request.getAttribute(X509_REQ_ATTR_NAME)).thenReturn(certs); instance.handle(request, response, chain); verify(response).sendError(HttpServletResponse.SC_FORBIDDEN); }
@Override public void handle(HttpServletRequest request, HttpServletResponse response, HandlerChain chain) throws Exception { String userId = CurrentUser.get(request); if (userId == null) { X509Certificate cert = extractCertificate(request); if (isInvalid(cert)) { respondWithAuthenticationFailure(response); return; } User user = getUser(request, cert); if (user == null) { respondWithAuthenticationFailure(response); return; } userRepository.recordLogin(user, getRemoteAddr(request)); CurrentUser.set(request, user.getUserId(), user.getUsername()); } chain.next(request, response); }
X509AuthenticationHandler extends AuthenticationHandler { @Override public void handle(HttpServletRequest request, HttpServletResponse response, HandlerChain chain) throws Exception { String userId = CurrentUser.get(request); if (userId == null) { X509Certificate cert = extractCertificate(request); if (isInvalid(cert)) { respondWithAuthenticationFailure(response); return; } User user = getUser(request, cert); if (user == null) { respondWithAuthenticationFailure(response); return; } userRepository.recordLogin(user, getRemoteAddr(request)); CurrentUser.set(request, user.getUserId(), user.getUsername()); } chain.next(request, response); } }
X509AuthenticationHandler extends AuthenticationHandler { @Override public void handle(HttpServletRequest request, HttpServletResponse response, HandlerChain chain) throws Exception { String userId = CurrentUser.get(request); if (userId == null) { X509Certificate cert = extractCertificate(request); if (isInvalid(cert)) { respondWithAuthenticationFailure(response); return; } User user = getUser(request, cert); if (user == null) { respondWithAuthenticationFailure(response); return; } userRepository.recordLogin(user, getRemoteAddr(request)); CurrentUser.set(request, user.getUserId(), user.getUsername()); } chain.next(request, response); } protected  X509AuthenticationHandler(UserRepository userRepository, final Graph graph); }
X509AuthenticationHandler extends AuthenticationHandler { @Override public void handle(HttpServletRequest request, HttpServletResponse response, HandlerChain chain) throws Exception { String userId = CurrentUser.get(request); if (userId == null) { X509Certificate cert = extractCertificate(request); if (isInvalid(cert)) { respondWithAuthenticationFailure(response); return; } User user = getUser(request, cert); if (user == null) { respondWithAuthenticationFailure(response); return; } userRepository.recordLogin(user, getRemoteAddr(request)); CurrentUser.set(request, user.getUserId(), user.getUsername()); } chain.next(request, response); } protected  X509AuthenticationHandler(UserRepository userRepository, final Graph graph); @Override void handle(HttpServletRequest request, HttpServletResponse response, HandlerChain chain); }
X509AuthenticationHandler extends AuthenticationHandler { @Override public void handle(HttpServletRequest request, HttpServletResponse response, HandlerChain chain) throws Exception { String userId = CurrentUser.get(request); if (userId == null) { X509Certificate cert = extractCertificate(request); if (isInvalid(cert)) { respondWithAuthenticationFailure(response); return; } User user = getUser(request, cert); if (user == null) { respondWithAuthenticationFailure(response); return; } userRepository.recordLogin(user, getRemoteAddr(request)); CurrentUser.set(request, user.getUserId(), user.getUsername()); } chain.next(request, response); } protected  X509AuthenticationHandler(UserRepository userRepository, final Graph graph); @Override void handle(HttpServletRequest request, HttpServletResponse response, HandlerChain chain); static final String CERTIFICATE_REQUEST_ATTRIBUTE; }