code: @Override
      public void onAuthenticationSuccess(final HttpServletRequest request,
              final HttpServletResponse response,
              final Authentication authentication)
              throws IOException, ServletException {
          clearAuthenticationAttributes(request);
          final SecurityUser user = (SecurityUser) authentication.getPrincipal();
  
          final String jws = tokenHelper.generateToken(user.getUsername());
  
          // Create token auth Cookie
          final Cookie authCookie = new Cookie(cookie, (jws));
          authCookie.setHttpOnly(true);
          authCookie.setMaxAge(expiresIn);
          authCookie.setPath("/");
  
          // Add cookie to response
          response.addCookie(authCookie);
  
          final UserTokenState userTokenState =
                  new UserTokenStateImpl(jws, expiresIn);
          final String jwtResponse =
                  objectMapper.writeValueAsString(userTokenState);
          response.setContentType("application/json");
          response.getWriter().write(jwtResponse);
      }
docs: {@inheritDoc}