package com.dcit.authority.shiro.filter;

import org.apache.shiro.authc.AuthenticationToken;
import org.apache.shiro.mgt.DefaultSessionStorageEvaluator;
import org.apache.shiro.subject.Subject;
import org.apache.shiro.subject.SubjectContext;
import org.apache.shiro.web.mgt.DefaultWebSubjectFactory;

/**
* <p>Title: CustomizedSubjectFactory</p>
* <p>Description: 对于无状态的TOKEN不创建session 这里都不使用session</p>
* <p>Company: SJZ DC-IT co. LTD</p> 
* @author ZZZ
* @date 2018年9月6日 下午10:15:33
*/
public class CustomizedSubjectFactory extends DefaultWebSubjectFactory {

	private final DefaultSessionStorageEvaluator sessionStorageEvaluator;

    public CustomizedSubjectFactory(DefaultSessionStorageEvaluator sessionStorageEvaluator) {
        this.sessionStorageEvaluator = sessionStorageEvaluator;
    }

	@Override
	public Subject createSubject(SubjectContext context) {
		// 这里都不创建session
        //AuthenticationToken token = context.getAuthenticationToken();
        context.setSessionCreationEnabled(Boolean.FALSE);
        this.sessionStorageEvaluator.setSessionStorageEnabled(Boolean.FALSE);
        return super.createSubject(context);
	}
    
    
	
}
