blob: cd28db655a215e44e6ecdd7b812b5d1b26a7098b [file] [log] [blame]
package org.apache.shiro.cdi.producers;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.mgt.SecurityManager;
import org.apache.shiro.subject.Subject;
import org.apache.shiro.util.ThreadContext;
import javax.enterprise.context.RequestScoped;
import javax.enterprise.inject.Produces;
public class SubjectProducer {
@Produces
@RequestScoped
protected Subject subject(SecurityManager securityManager) {
if (ThreadContext.getSecurityManager() == null) {
ThreadContext.bind(securityManager);
}
return SecurityUtils.getSubject();
}
}