Package org.springframework.security.web.authentication

Examples of org.springframework.security.web.authentication.WebAuthenticationDetails


            for (String key : data.keySet()) {
                Object object = data.get(key);

                // Extract the data that will be saved.
                if (object instanceof WebAuthenticationDetails) {
                    WebAuthenticationDetails authenticationDetails = (WebAuthenticationDetails) object;
                    results.put("remoteAddress", authenticationDetails.getRemoteAddress());
                    results.put("sessionId", authenticationDetails.getSessionId());
                } else {
                    results.put(key, object.toString());
                }
            }
        }
View Full Code Here


        cap.setServiceProperties(serviceProperties);
        cap.afterPropertiesSet();
        result = cap.authenticate(token);
        verify(validator,times(2)).validate(ticket, serviceUrl);

        token.setDetails(new WebAuthenticationDetails(new MockHttpServletRequest()));
        try {
            cap.authenticate(token);
            fail("Expected Exception");
        }catch(IllegalStateException success) {}
View Full Code Here

    @Before
    public void setUp() throws Exception {
        SecurityContextHolder.clearContext();
        UsernamePasswordAuthenticationToken rodRequest = new UsernamePasswordAuthenticationToken("rod", "koala");
        rodRequest.setDetails(new WebAuthenticationDetails(new MockHttpServletRequest()));
        Authentication rod =
            new UsernamePasswordAuthenticationToken("rod", "koala", AuthorityUtils.createAuthorityList("ROLE_1"));

        manager = mock(AuthenticationManager.class);
        when(manager.authenticate(rodRequest)).thenReturn(rod);
View Full Code Here

   *
   */
  private void login(HttpServletRequest request, String username, String password) {
    WikiUserDetails userDetails = new WikiUserDetails(username, password, true, true, true, true, JAMWikiAuthenticationConfiguration.getDefaultGroupRoles());
    UsernamePasswordAuthenticationToken authentication = new UsernamePasswordAuthenticationToken(userDetails, password, userDetails.getAuthorities());
    authentication.setDetails(new WebAuthenticationDetails(request));
    SecurityContextHolder.getContext().setAuthentication(authentication);
  }
View Full Code Here

  }
 
  public void authenticationCustomer(final HttpServletRequest request, final Customer customer) {
    try {
      UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken(customer.getEmail(), customer.getPassword());
      token.setDetails(new WebAuthenticationDetails(request));
      Authentication authenticatedUser = authenticationManager.authenticate(token);
 
      SecurityContextHolder.getContext().setAuthentication(authenticatedUser);
      request.getSession().setAttribute(HttpSessionSecurityContextRepository.SPRING_SECURITY_CONTEXT_KEY, SecurityContextHolder.getContext());
   
View Full Code Here

 
  public void authenticationUser(final HttpServletRequest request, final User user) {
    try {
   
      UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken(user.getEmail(), user.getPassword());
      token.setDetails(new WebAuthenticationDetails(request));
      Authentication authenticatedUser = authenticationManager.authenticate(token);
 
      SecurityContextHolder.getContext().setAuthentication(authenticatedUser);
      request.getSession().setAttribute(HttpSessionSecurityContextRepository.SPRING_SECURITY_CONTEXT_KEY, SecurityContextHolder.getContext());
   
View Full Code Here

    return result;
  }

  private String convertClientAddress(Authentication authentication) {
    try {
      WebAuthenticationDetails details = (WebAuthenticationDetails) authentication.getDetails();
      return details.getRemoteAddress();
    } catch (ClassCastException e) {
      // securitycontext ist vom falschen Typ!
      return "<unbekannt>";
    }
  }
View Full Code Here

    }
  }

  private String convertClientSessionId(Authentication authentication) {
    try {
      WebAuthenticationDetails details = (WebAuthenticationDetails) authentication.getDetails();
      return details.getSessionId();
    } catch (ClassCastException e) {
      // securitycontext ist vom falschen Typ!
      return "<unbekannt>";
    }
  }
View Full Code Here

   * @see org.saiku.web.service.ISessionService#authenticate(javax.servlet.http.HttpServletRequest, java.lang.String, java.lang.String)
   */
  public void authenticate(HttpServletRequest req, String username, String password) {
    try {
      UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken(username, password);
      token.setDetails(new WebAuthenticationDetails(req));
      Authentication authentication = this.authenticationManager.authenticate(token);
      LOG.debug("Logging in with [{}]", authentication.getPrincipal());
      SecurityContextHolder.getContext().setAuthentication(authentication);
    } catch (BadCredentialsException bd) {
      throw new RuntimeException("Authentication failed for: " + username, bd);
View Full Code Here

        if (!(details instanceof WebAuthenticationDetails)) {
            return "";
        }

        WebAuthenticationDetails webDetails = (WebAuthenticationDetails) details;

        return webDetails.getRemoteAddress();
    }
View Full Code Here

TOP

Related Classes of org.springframework.security.web.authentication.WebAuthenticationDetails

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.