List of usage examples for org.springframework.security.authentication UsernamePasswordAuthenticationToken setDetails
public void setDetails(Object details)
From source file:org.runway.utils.AuthenticationUtils.java
public static void autoLogin(User user, HttpServletRequest request, AuthenticationManager authenticationManager) { // GrantedAuthority[] grantedAuthorities = new GrantedAuthority[] { new GrantedAuthorityImpl( // user.getAuthority()) }; UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken(user.getUsername(), user.getPassword(), user.getAuthorities()); // generate session if one doesn't exist HttpSession session = request.getSession(); token.setDetails(new WebAuthenticationDetails(request)); Authentication authenticatedUser = authenticationManager.authenticate(token); SecurityContextHolder.getContext().setAuthentication(authenticatedUser); // setting role to the session session.setAttribute(HttpSessionSecurityContextRepository.SPRING_SECURITY_CONTEXT_KEY, SecurityContextHolder.getContext()); }
From source file:org.createnet.raptor.auth.service.jwt.JsonUsernamePasswordFilter.java
@Override protected void setDetails(HttpServletRequest request, UsernamePasswordAuthenticationToken authRequest) { authRequest.setDetails(authenticationDetailsSource.buildDetails(request)); }
From source file:de.itsvs.cwtrpc.security.UsernamePasswordRpcAuthenticationFilter.java
protected void updateDetails(HttpServletRequest request, UsernamePasswordAuthenticationToken authentication) { authentication.setDetails(getAuthenticationDetailsSource().buildDetails(request)); }
From source file:com.morevaadin.vaadin7.springsecurity.service.AuthenticationService.java
public void handleAuthentication(String login, String password, HttpServletRequest httpRequest) { UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken(login, password); token.setDetails(new WebAuthenticationDetails(httpRequest)); ServletContext servletContext = httpRequest.getSession().getServletContext(); WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext); AuthenticationManager authManager = wac.getBean(AuthenticationManager.class); Authentication authentication = authManager.authenticate(token); SecurityContextHolder.getContext().setAuthentication(authentication); }
From source file:com.application.model.dao.AuthenticationService.java
public void handleAuthentication(String login, String password, HttpServletRequest httpRequest) { UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken(login, password); token.setDetails(new WebAuthenticationDetails(httpRequest)); ServletContext servletContext = httpRequest.getSession().getServletContext(); WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext); AuthenticationManager authManager = wac.getBean(AuthenticationManager.class); Authentication authentication = authManager.authenticate(token); SecurityContextHolder.getContext().setAuthentication(authentication); }
From source file:com.springsource.greenhouse.account.UsernamePasswordAuthenticationProvider.java
private Authentication authenticatedToken(Account account, Authentication original) { List<GrantedAuthority> authorities = null; UsernamePasswordAuthenticationToken authenticated = new UsernamePasswordAuthenticationToken(account, null, authorities);/*from w w w . ja v a 2s.c o m*/ authenticated.setDetails(original.getDetails()); return authenticated; }
From source file:org.jasig.schedassist.web.security.RemoteUserAuthenticationProcessingFilterImpl.java
public Authentication attemptAuthentication(final HttpServletRequest request, final HttpServletResponse response) throws AuthenticationException { String username = request.getRemoteUser(); String password = ""; UsernamePasswordAuthenticationToken authRequest = new UsernamePasswordAuthenticationToken(username, password);/* w w w. ja va 2 s. c om*/ authRequest.setDetails(authenticationDetailsSource.buildDetails((HttpServletRequest) request)); return this.getAuthenticationManager().authenticate(authRequest); }
From source file:org.messic.server.facade.security.TokenManagementFilter.java
/** * Provided so that subclasses may configure what is put into the authentication request's details property. * /* w w w .j a v a 2 s . co m*/ * @param request that an authentication request is being created for * @param authRequest the authentication request object that should have its details set */ protected void setDetails(HttpServletRequest request, UsernamePasswordAuthenticationToken authRequest) { authRequest.setDetails(authenticationDetailsSource.buildDetails(request)); }
From source file:com.epam.cme.storefront.security.impl.DefaultAutoLoginStrategy.java
@Override public void login(final String username, final String password, final HttpServletRequest request, final HttpServletResponse response) { final UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken(username, password);/*from www . j a v a2s . co m*/ token.setDetails(new WebAuthenticationDetails(request)); try { final Authentication authentication = getAuthenticationManager().authenticate(token); SecurityContextHolder.getContext().setAuthentication(authentication); getCustomerFacade().loginSuccess(); getGuidCookieStrategy().setCookie(request, response); } catch (final Exception e) { SecurityContextHolder.getContext().setAuthentication(null); LOG.error("Failure during autoLogin", e); } }
From source file:fr.xebia.audit.AuditAspectTest.java
@Before public void before() { MockHttpServletRequest request = new MockHttpServletRequest(); request.setRemoteAddr("10.0.0.1"); WebAuthenticationDetails details = new WebAuthenticationDetails(request); UsernamePasswordAuthenticationToken authentication = new UsernamePasswordAuthenticationToken("ze-principal", "ze-credentials"); authentication.setDetails(details); SecurityContextHolder.getContext().setAuthentication(authentication); }