All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.minlia.rocket.security.authentication.service.AbstractAuthenticationService Maven / Gradle / Ivy

There is a newer version: 2.0.4.1.RELEASE
Show newest version
package com.minlia.rocket.security.authentication.service;

import org.springframework.security.core.Authentication;

/**
 * Created by will on 8/14/17. 框架提供的抽象认证实现
 */
public abstract class AbstractAuthenticationService implements AuthenticationService {

  @Override
  public abstract Authentication authentication(Authentication authentication);

//    public abstract Authentication authentication(Authentication authentication) {
//
//        Assert.notNull(authentication, "No authentication data provided");
//        String username = (String) authentication.getPrincipal();
//        String password = (String) authentication.getCredentials();
//        User user = userQueryService.findOneByUsernameOrEmailOrCellphone(username);
//        if (null == user) {
//            throw new UsernameNotFoundException("User not found: " + username);
//        }
//        if (!encoder.matches(password, user.getPassword())) {
//            throw new BadCredentialsException("Authentication Failed. Username or Password not valid.");
//        }
////        if (user.getRoles() == null) throw new InsufficientAuthenticationException("User has no roles assigned");
////        List authorities = securityService.getAuthorities(user.getRoles());
////        UserContext userContext = UserContext.create(user.getUsername(), authorities);
////        return new UsernamePasswordAuthenticationToken(userContext, null, userContext.getAuthorities());
//
//        return null;
//    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy