package com.steerinfo.auth.shiro.realm;

import java.util.ArrayList;
import java.util.List;

import org.apache.shiro.realm.Realm;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

/**
 * 支持多realm认证
 * @ClassName: ReamlsConfig 
 * @Description: TODO
 * @author 鄢利
 * @date 2018年7月20日 下午4:49:28 
 *
 */
@Configuration
public class ReamlsConfig {

    @Value("${cache.level:2}")
    private String cache;
    
    @Bean(name = "shiroRealms")
    @Primary
    public List<Realm> shiroRealms(@Qualifier("statelessRealm") SysUserStatelessRealm statelessRealm) {
        List<Realm> realms = new ArrayList<>();
        realms.add(statelessRealm);

        return realms;
    }

    @Bean(name = "statelessRealm")
    @Primary
    public SysUserStatelessRealm statelessRealm(){
    	SysUserStatelessRealm realm = new SysUserStatelessRealm();
        return realm;
    }
}
