package ameba.security.shiro.internal;

import org.apache.shiro.authc.Authenticator;
import org.apache.shiro.authz.Authorizer;
import org.apache.shiro.mgt.SecurityManager;
import org.apache.shiro.session.mgt.SessionManager;
import org.apache.shiro.subject.Subject;
import org.glassfish.hk2.api.Factory;
import org.glassfish.hk2.utilities.binding.AbstractBinder;
import org.glassfish.jersey.process.internal.RequestScoped;

import javax.inject.Inject;

/**
 * @author icode
 */
public class ShiroBinder extends AbstractBinder {

    private SecurityManager securityManager;

    public ShiroBinder(SecurityManager securityManager) {
        this.securityManager = securityManager;
    }

    @Override
    protected void configure() {
        bindFactory(SubjectFactory.class)
                .to(Subject.class)
                .in(RequestScoped.class);

        bind(securityManager)
                .to(SecurityManager.class)
                .to(Authenticator.class)
                .to(Authorizer.class)
                .to(SessionManager.class)
                .proxy(false);
    }

    static final class SubjectFactory implements Factory<Subject> {

        @Inject
        private SecurityManager manager;

        @Override
        public Subject provide() {
            return new Subject.Builder(manager).buildSubject();
        }

        @Override
        public void dispose(Subject subject) {

        }
    }
}
@@ -283,67 +283,30 @@
 ish.
-hk2.api.Factory;%0Aimport org.glassfish.hk2.utilities.binding
+jersey.internal.inject
 .Abs
@@ -406,16 +406,52 @@
 .Inject;
+%0Aimport java.util.function.Supplier;
 %0A%0A/**%0A *
@@ -845,17 +845,16 @@
 class);%0A
-%0A
         
@@ -1126,23 +1126,24 @@
 lements 
-Factory
+Supplier
 %3CSubject
@@ -1250,15 +1250,11 @@
 ect 
-provide
+get
 () %7B
@@ -1331,85 +1331,8 @@
    %7D
-%0A%0A        @Override%0A        public void dispose(Subject subject) %7B%0A%0A        %7D
 %0A   

update jersey version.