List of usage examples for org.springframework.security.core AuthenticationException getMessage
public String getMessage()
From source file:de.tudarmstadt.ukp.clarin.webanno.webapp.security.SpringAuthenticatedWebSession.java
@Override public boolean authenticate(String username, String password) { boolean authenticated = false; try {//from w w w .ja va 2 s.c om Authentication authentication = authenticationManager .authenticate(new UsernamePasswordAuthenticationToken(username, password)); SecurityContextHolder.getContext().setAuthentication(authentication); authenticated = authentication.isAuthenticated(); } catch (AuthenticationException e) { log.warn(format("User '%s' failed to login. Reason: %s", username, e.getMessage())); authenticated = false; } return authenticated; }
From source file:de.tudarmstadt.ukp.csniper.webapp.security.SpringAuthenticatedWebSession.java
@Override public boolean authenticate(String username, String password) { boolean authenticated = false; try {/*from ww w. ja va2 s . co m*/ Authentication authentication = authenticationManager .authenticate(new UsernamePasswordAuthenticationToken(username, password)); SecurityContextHolder.getContext().setAuthentication(authentication); authenticated = authentication.isAuthenticated(); } catch (AuthenticationException e) { log.warn(format("User '%s' failed to login. Reason: %s", username, e.getMessage())); error(format("User '%s' failed to login. Reason: %s", username, e.getMessage())); authenticated = false; } return authenticated; }
From source file:de.steilerdev.myVerein.server.security.rest.RestAuthenticationFailureHandler.java
@Override public void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response, AuthenticationException exception) throws IOException, ServletException { logger.warn("[{}] Authentication failed: {}", SecurityHelper.getClientIpAddr(request), exception.getMessage()); if (!response.isCommitted()) { response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Authentication failed: " + exception.getMessage()); }/*from w w w . java 2s . c o m*/ }
From source file:com.sentinel.rest.handlers.HttpAuthenticationEntryPoint.java
@Override public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException) throws IOException, ServletException { LOG.trace("Method: commence called."); response.sendError(HttpServletResponse.SC_UNAUTHORIZED, authException.getMessage()); LOG.trace("Method: commence finished."); }
From source file:org.owasp.webgoat.AjaxAuthenticationEntryPoint.java
public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException) throws IOException, ServletException { if (request.getHeader("x-requested-with") != null) { response.sendError(401, authException.getMessage()); } else {/* www.j a v a 2 s . c o m*/ super.commence(request, response, authException); } }
From source file:com.evolveum.midpoint.web.security.MidPointAuthWebSession.java
@Override public boolean authenticate(String username, String password) { LOGGER.debug("Authenticating '{}' {} password in web session.", new Object[] { username, (StringUtils.isEmpty(password) ? "without" : "with") }); boolean authenticated; try {//w w w . j a v a 2s. co m Authentication authentication = authenticationProvider .authenticate(new UsernamePasswordAuthenticationToken(username, password)); SecurityContextHolder.getContext().setAuthentication(authentication); authenticated = authentication.isAuthenticated(); auditEvent(authentication, username, OperationResultStatus.SUCCESS); } catch (AuthenticationException ex) { String key = ex.getMessage() != null ? ex.getMessage() : "web.security.provider.unavailable"; MidPointApplication app = (MidPointApplication) getSession().getApplication(); error(app.getString(key)); LOGGER.debug("Couldn't authenticate user.", ex); authenticated = false; auditEvent(null, username, OperationResultStatus.FATAL_ERROR); } return authenticated; }
From source file:org.awesomeagile.webapp.security.AwesomeAgileAuthenticationEntryPoint.java
@Override public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException) throws IOException, ServletException { response.addHeader("WWW-Authenticate", "AwesomeAgile"); response.sendError(HttpServletResponse.SC_UNAUTHORIZED, authException.getMessage()); }
From source file:cn.org.once.cstack.config.Http401EntryPoint.java
public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException arg) throws IOException, ServletException { // Maybe change the log level... log.warn("Access Denied [ " + request.getRequestURL().toString() + "] : " + arg.getMessage()); response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Access unauthorized"); }
From source file:org.awesomeagile.testing.google.FakeGoogleController.java
@ResponseBody @ExceptionHandler({ AuthenticationException.class }) public ResponseEntity<String> handleAuthenticationException(AuthenticationException ex) { return ResponseEntity.status(HttpStatus.UNAUTHORIZED).body(ex.getMessage()); }
From source file:org.createnet.raptor.auth.service.controller.AuthenticationController.java
@RequestMapping(value = "${jwt.route.authentication.path}", method = RequestMethod.POST) @ApiOperation(value = "Login an user with provided credentials", notes = "", response = JwtResponse.class, nickname = "login") public ResponseEntity<?> login(@RequestBody JwtRequest authenticationRequest) throws AuthenticationException { try {/*from w w w . jav a 2s . co m*/ final Authentication authentication = authenticationManager .authenticate(new UsernamePasswordAuthenticationToken(authenticationRequest.username, authenticationRequest.password)); SecurityContextHolder.getContext().setAuthentication(authentication); // Reload password post-security so we can generate token final UserDetails userDetails = userDetailsService.loadUserByUsername(authenticationRequest.username); final Token token = tokenService.createLoginToken((User) userDetails); // Return the token return ResponseEntity.ok(new JwtResponse((User) userDetails, token.getToken())); } catch (AuthenticationException ex) { logger.error("Authentication exception: {}", ex.getMessage()); return ResponseEntity.status(HttpStatus.UNAUTHORIZED).body("Authentication failed"); } }