Package org.pac4j.springframework.security.authentication

Examples of org.pac4j.springframework.security.authentication.ClientAuthenticationToken


 
  public static final String MYOPENID_IDENTIFIER_PATTERN = "http://\\w+\\.myopenid\\.com/?";
 
  public static AuthenticationType getAuthenticationType(Authentication authentication) {
    if (authentication != null && authentication instanceof ClientAuthenticationToken) {
      ClientAuthenticationToken token = (ClientAuthenticationToken) authentication;
      if (token.getUserProfile() instanceof GoogleOpenIdProfile) {
        return AuthenticationType.OPENID_GOOGLE;
      } else if (token.getUserProfile() instanceof TwitterProfile) {
        return AuthenticationType.TWITTER;
      } else if (token.getUserProfile() instanceof GitHubProfile) {
        return AuthenticationType.GITHUB;
      } else {
        throw new IllegalStateException("Invalid user profile type");
      }
    }
View Full Code Here


      redirect(DashboardPage.class);
      return;
    }
   
    HttpServletRequest request = ((ServletWebRequest) RequestCycle.get().getRequest()).getContainerRequest();
    ClientAuthenticationToken token = (ClientAuthenticationToken) request.getSession().getAttribute(Pac4jAuthenticationUtils.AUTH_TOKEN_ATTRIBUTE);
   
    IModel<User> userModel = new GenericEntityModel<Long, User>(new User());
    userModel.getObject().setActive(false);
   
    if (token != null && token.getUserProfile() != null) {
      CommonProfile profile = (CommonProfile) token.getUserProfile();
      if (profile.getEmail() != null) {
        User user = userService.getByUserName(profile.getEmail());
        if (user != null) {
          LOGGER.warn("This email address is already used by another user");
          getSession().warn(getString("register.userName.notUnique"));
View Full Code Here

  @Override
  public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response,
      Authentication authentication) throws ServletException, IOException {
    String targetUrl;
    try {
      ClientAuthenticationToken tokenWithUserDetails = getAuthenticationTokenWithUserDetails(authentication);
      SecurityContextHolder.getContext().setAuthentication(tokenWithUserDetails);
     
      super.onAuthenticationSuccess(request, response, authentication);
      return;
    } catch (UsernameNotFoundException e) {
View Full Code Here

    request.getSession().setAttribute(WebAttributes.AUTHENTICATION_EXCEPTION, exception);
  }
 
  private ClientAuthenticationToken getAuthenticationTokenWithUserDetails(Authentication authentication) {
    Collection<? extends GrantedAuthority> authorities = new ArrayList<GrantedAuthority>();
    ClientAuthenticationToken token = getAuthenticationToken(authentication);
   
    if (token != null) {
      UserDetails userDetails = pac4jUserDetailsService.loadUserDetails(token);
     
      if (userDetails != null) {
        this.userDetailsChecker.check(userDetails);
        authorities = userDetails.getAuthorities();
      }
      ClientAuthenticationToken result =  new ClientAuthenticationToken((Credentials) token.getCredentials(),
          token.getClientName(), token.getUserProfile(), authorities);
      result.setDetails(userDetails);
      return result;
    }
    return null;
  }
View Full Code Here

TOP

Related Classes of org.pac4j.springframework.security.authentication.ClientAuthenticationToken

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.