/** 
 * SecurityUrlResourcesMapFactoryBean.java
 * @author 임새미 
 * @since 2016. 10. 7.
 *
 *  	 수정일                     수정자                                       수정내용
 *  -------------	--------	---------------------------
 *  2016. 10. 7. 	    임새미				       최초생성
 * 
 */
package kcg.faics.sec.filter;

import java.util.LinkedHashMap;
import java.util.List;

import javax.annotation.Resource;

import kcg.faics.sec.service.impl.SecurityMapper;

import org.springframework.beans.factory.FactoryBean;
import org.springframework.security.access.ConfigAttribute;
import org.springframework.security.web.util.matcher.RequestMatcher;

/** 
 * SecurityUrlResourcesMapFactoryBean.java
 * 
 * egovframework.rte.fdl.security.intercept.UrlResourcesMapFactoryBean의 DB 데이터 받아오는 부분만 수정
 * 
 * @author 임새미 
 * @since 2016. 10. 7.
 *
 *  	 수정일                     수정자                                       수정내용
 *  -------------	--------	---------------------------
 *  2016. 10. 7. 	    임새미				       최초생성
 * 
 */
public class SecurityUrlResourcesMapFactoryBean implements FactoryBean<LinkedHashMap<RequestMatcher, List<ConfigAttribute>>>  {
	
	@Resource(name = "securityMapper")
	SecurityMapper securityMapper;
	
    private LinkedHashMap<RequestMatcher, List<ConfigAttribute>> resourcesMap;

    public void init() throws Exception {
    	resourcesMap = securityMapper.getRolesAndUrl();
    }

    public LinkedHashMap<RequestMatcher, List<ConfigAttribute>> getObject() throws Exception {
        if (resourcesMap == null) {
            init();
        }
        return resourcesMap;
    }

    @SuppressWarnings("rawtypes")
	public Class<LinkedHashMap> getObjectType() {
        return LinkedHashMap.class;
    }

    public boolean isSingleton() {
        return true;
    }
}
