SimpleUserService.java 1.8 KB
Newer Older
ibizdev's avatar
ibizdev committed
1 2 3 4 5 6 7 8 9 10 11 12 13
package cn.ibizlab.util.service;

import cn.ibizlab.util.security.AuthenticationUser;
import cn.ibizlab.util.client.IBZUAAFeignClient;
import cn.ibizlab.util.client.IBZOUFeignClient;

import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;
import org.springframework.util.DigestUtils;
import org.springframework.util.StringUtils;
import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
ibizdev's avatar
ibizdev committed
14
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
ibizdev's avatar
ibizdev committed
15 16 17 18 19 20

/**
 * 实体[IBZUSER] 服务对象接口实现
 */
@Primary
@Service("SimpleUserService")
ibizdev's avatar
ibizdev committed
21
@ConditionalOnExpression("(!${ibiz.enablePermissionValid:false})&&'${ibiz.auth.service:SimpleUserService}'.equals('SimpleUserService')")
ibizdev's avatar
ibizdev committed
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
public class SimpleUserService implements AuthenticationUserService{

	@Override
	public AuthenticationUser loadUserByUsername(String username) {
		AuthenticationUser user = new AuthenticationUser();
		String[] data=username.split("[|]");
		String loginname=username;
		String domains="";
		String password="";

		if(data.length==2) {
			loginname=data[0].trim();
			domains=data[1].trim();
		}

		user.setUserid(username);
		user.setUsercode(loginname);
		user.setUsername(username);
		user.setLoginname(loginname);
		user.setPersonname(loginname);
		user.setDomain(domains);
		user.setPassword(password);
		user.setOrgid(domains);
		user.setOrgcode(domains);
		user.setOrgname(domains);

		return user;
	}

	@Override
	public AuthenticationUser loadUserByLogin(String username, String password) {
		AuthenticationUser authuserdetail = loadUserByUsername(username);
		return authuserdetail;
	}



	@Override
	public void resetByUsername(String username) {

	}

}