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

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

import javax.annotation.Resource;

import kcg.imis.sec.mapper.SecurityMapper;

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

/**
  * @FileName : SecurityUrlResourcesMapFactoryBean.java
  * @Project : 국제해양프로젝트
  * @Date : 2018. 3. 29. 
  * @작성자 : Moon
  * @변경이력 : 
  * @프로그램 설명 :
 */
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;
    }
}
