package com.steerinfo.auth.shiro.realm;

import java.util.Map;

import org.apache.shiro.authz.AuthorizationInfo;
import org.apache.shiro.subject.PrincipalCollection;
import org.springframework.beans.factory.annotation.Autowired;

import com.steerinfo.framework.controller.RESTfulResult;
import com.steerinfo.framework.user.IUser;
import com.steerinfo.framework.user.UserPayload;

/**
 * 
 * @ClassName: SysUserStatelessRealm 
 * @Description: TODO
 * @author 鄢利
 * @date 2018年7月20日 下午7:48:10 
 *
 */
public class SysUserStatelessRealm extends AbstractStatelessRealm{

    // @Autowired
    //ISysUserService sysUserService;
    
    @Autowired
    OssServiceClient ossService;
    
	@Override
	public IUser findByLogin(UserPayload payload) {
		SysUser sysUser = new SysUser();
		RESTfulResult re = ossService.getUser(payload.getId());
		// System.out.println("re.getData()---------" + re.getData());
		Map m = (Map)re.getData();
		sysUser.setUserId(m.get("userId").toString());
		sysUser.setUserName(m.get("userName").toString());
		sysUser.setUserCode(m.get("userCode").toString());
		sysUser.setPassword(m.get("password").toString());
		sysUser.setOrgCode(m.get("orgCode").toString());
		// SysUser sysUser = sysUserService.selectByUserCode(payload.getUserCode());
		return sysUser;
	}
}
