List of usage examples for org.springframework.security.web.util TextEscapeUtils escapeEntities
public static String escapeEntities(String s)
From source file:ch.entwine.weblounge.kernel.security.SpringSecurityFormAuthentication.java
/** * {@inheritDoc}/* www .jav a 2s. c o m*/ * * @see org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter#attemptAuthentication(javax.servlet.http.HttpServletRequest, * javax.servlet.http.HttpServletResponse) */ @Override public Authentication attemptAuthentication(HttpServletRequest request, HttpServletResponse response) throws AuthenticationException, IOException, ServletException { if (postOnly && !"POSTS".equals(request.getMethod())) { throw new AuthenticationServiceException("Authentication method not supported: " + request.getMethod()); } // Get the username String username = StringUtils.trimToEmpty(request.getParameter(SPRING_SECURITY_FORM_USERNAME_KEY)); // Get the password String password = request.getParameter(SPRING_SECURITY_FORM_PASSWORD_KEY); if (password == null) { password = ""; } // Using the extracted credentials, create an authentication request UsernamePasswordAuthenticationToken authRequest = new UsernamePasswordAuthenticationToken(username, password); authRequest.setDetails(authenticationDetailsSource.buildDetails(request)); // Place the last username attempted into HttpSession for views HttpSession session = request.getSession(false); if (session != null || getAllowSessionCreation()) { request.getSession().setAttribute(SPRING_SECURITY_LAST_USERNAME_KEY, TextEscapeUtils.escapeEntities(username)); } return this.getAuthenticationManager().authenticate(authRequest); }
From source file:es.osoco.grails.plugins.otp.web.OneTimePasswordAuthenticationFilter.java
@Override public Authentication attemptAuthentication(HttpServletRequest request, HttpServletResponse response) throws AuthenticationException { if (postOnly && !request.getMethod().equals("POST")) { throw new AuthenticationServiceException("Authentication method not supported: " + request.getMethod()); }//ww w.jav a 2s.c o m String username = obtainUsername(request); String password = obtainPassword(request); username = username == null ? "" : username.trim(); password = password == null ? "" : password; OneTimePasswordAuthenticationToken authRequest = new OneTimePasswordAuthenticationToken(username, password); // Place the last username attempted into HttpSession for views HttpSession session = request.getSession(false); if (session != null || getAllowSessionCreation()) { request.getSession().setAttribute(SPRING_SECURITY_LAST_USERNAME_KEY, TextEscapeUtils.escapeEntities(username)); } // Allow subclasses to set the "details" property setDetails(request, authRequest); return getAuthenticationManager().authenticate(authRequest); }
From source file:net.kamhon.ieagle.security.AuthenticationUtil.java
public Authentication attemptAuthentication(HttpServletRequest request, HttpServletResponse response, String username, String password) throws AuthenticationException { if (postOnly && !request.getMethod().equals("POST")) { throw new AuthenticationServiceException("Authentication method not supported: " + request.getMethod()); }//from w w w. j av a 2 s .co m /*String username = obtainUsername(request); String password = obtainPassword(request);*/ if (username == null) { username = ""; } if (password == null) { password = ""; } username = username.trim(); UsernamePasswordAuthenticationToken authRequest = new UsernamePasswordAuthenticationToken(username, password); // Place the last username attempted into HttpSession for views HttpSession session = request.getSession(false); if (session != null || getAllowSessionCreation()) { request.getSession().setAttribute(SPRING_SECURITY_LAST_USERNAME_KEY, TextEscapeUtils.escapeEntities(username)); } // Allow subclasses to set the "details" property setDetails(request, authRequest); return this.getAuthenticationManager().authenticate(authRequest); }
From source file:org.apdplat.module.security.service.UserDetailsServiceImpl.java
/** * JSP??//from w w w. ja v a 2 s . co m * @param username ?? * @return */ public synchronized static String getMessage(String username) { String result = messages.get(TextEscapeUtils.escapeEntities(username)); LOG.debug("??? " + username + " :" + result); messages.remove(TextEscapeUtils.escapeEntities(username)); return result; }
From source file:org.apdplat.module.security.service.UserDetailsServiceImpl.java
/** * ?//from w w w . j av a 2 s . c o m * @param username ?? * @return ? * @throws UsernameNotFoundException ?? */ @Override public synchronized UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { //spring security????? SPRING_SECURITY_LAST_USERNAME = username; //try catchfinally?? try { if (ipAccessControler.deny(OpenEntityManagerInViewFilter.request)) { message = "IP?"; LOG.info(message); throw new UsernameNotFoundException(message); } return load(username); } catch (UsernameNotFoundException e) { throw e; } finally { LOG.debug("??? " + username + " " + message); messages.put(TextEscapeUtils.escapeEntities(username), message); } }