shiro-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdem...@apache.org
Subject [1/3] shiro git commit: Initial pass at CDI support (without requiring a shiro.ini file)
Date Tue, 17 Jan 2017 20:56:01 GMT
Repository: shiro
Updated Branches:
  refs/heads/cdi-idea [created] 2f495cc54


http://git-wip-us.apache.org/repos/asf/shiro/blob/59b944c0/support/cdi/cdi-base/src/test/groovy/org/apache/shiro/cdi/EventBusSubscribeTest.groovy
----------------------------------------------------------------------
diff --git a/support/cdi/cdi-base/src/test/groovy/org/apache/shiro/cdi/EventBusSubscribeTest.groovy b/support/cdi/cdi-base/src/test/groovy/org/apache/shiro/cdi/EventBusSubscribeTest.groovy
new file mode 100644
index 0000000..36b7976
--- /dev/null
+++ b/support/cdi/cdi-base/src/test/groovy/org/apache/shiro/cdi/EventBusSubscribeTest.groovy
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.shiro.cdi
+
+import org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner
+import org.apache.shiro.event.EventBus
+import org.junit.Test
+import org.junit.runner.RunWith
+
+import javax.inject.Inject
+
+import static org.junit.Assert.*
+
+@RunWith(CdiTestRunner.class)
+public class EventBusSubscribeTest {
+
+    @Inject
+    EventBus eventBus
+
+    @Inject
+    EventListenerStub listenerStub
+
+    @Inject
+    EventBusAwareStub eventBusAwareStub
+
+    @Test
+    void fireEventTest() {
+
+        // fire an event then make sure the wired component received it.
+        eventBus.publish("EventString")
+        assertEquals "EventString", listenerStub.lastEvent
+    }
+
+    @Test
+    void eventBusAwareTest() {
+        assertSame eventBus, eventBusAwareStub.eventBus
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/shiro/blob/59b944c0/support/cdi/cdi-base/src/test/groovy/org/apache/shiro/cdi/ShiroAnnotationInterceptorsTest.groovy
----------------------------------------------------------------------
diff --git a/support/cdi/cdi-base/src/test/groovy/org/apache/shiro/cdi/ShiroAnnotationInterceptorsTest.groovy b/support/cdi/cdi-base/src/test/groovy/org/apache/shiro/cdi/ShiroAnnotationInterceptorsTest.groovy
new file mode 100644
index 0000000..0fa43a1
--- /dev/null
+++ b/support/cdi/cdi-base/src/test/groovy/org/apache/shiro/cdi/ShiroAnnotationInterceptorsTest.groovy
@@ -0,0 +1,228 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.shiro.cdi
+
+import org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner
+import org.apache.shiro.authz.UnauthenticatedException
+import org.apache.shiro.authz.UnauthorizedException
+import org.apache.shiro.subject.Subject
+import org.apache.shiro.util.ThreadContext
+import org.junit.After
+import org.junit.Test
+import org.junit.runner.RunWith
+
+import javax.inject.Inject
+
+import static org.easymock.EasyMock.*
+import static org.junit.Assert.*
+
+/**
+ * Tests for {@link ShiroAnnotationInterceptor}.
+ */
+@RunWith(CdiTestRunner.class)
+public class ShiroAnnotationInterceptorsTest {
+
+    @Inject
+    private AnnotationTestStub stub
+
+    @Test
+    void doRequiresAuthenticationTrue() {
+
+        def subject = mock(Subject)
+
+        expect(subject.isAuthenticated()).andReturn(true);
+        replay subject
+
+        ThreadContext.bind(subject)
+
+        assertEquals("Test Me", stub.doRequiresAuthentication("Test Me"))
+
+        verify subject
+    }
+
+    @Test
+    void doRequiresAuthenticationFalse() {
+
+        def subject = mock(Subject)
+
+        expect(subject.isAuthenticated()).andReturn(false);
+        replay subject
+
+        ThreadContext.bind(subject)
+
+        try {
+            stub.doRequiresAuthentication("Test Me")
+            fail("expected UnauthenticatedException")
+        }
+        catch(UnauthenticatedException e) {
+            // expected
+        }
+
+        verify subject
+    }
+
+    @Test
+    void doRequiresUserTrue() {
+        def subject = mock(Subject)
+
+        expect(subject.getPrincipal()).andReturn("principal");
+        replay subject
+
+        ThreadContext.bind(subject)
+
+        assertTrue stub.doRequiresUser()
+
+        verify subject
+    }
+
+    @Test
+    void doRequiresUserFalse() {
+
+        def subject = mock(Subject)
+
+        expect(subject.getPrincipal()).andReturn(null);
+        replay subject
+
+        ThreadContext.bind(subject)
+
+        try {
+            stub.doRequiresUser()
+            fail("expected UnauthenticatedException")
+        }
+        catch(UnauthenticatedException e) {
+            // expected
+        }
+
+        verify subject
+    }
+
+    @Test
+    void doRequiresGuestTrue() {
+        def subject = mock(Subject)
+
+        expect(subject.getPrincipal()).andReturn(null);
+        replay subject
+
+        ThreadContext.bind(subject)
+
+        assertTrue stub.doRequiresGuest()
+
+        verify subject
+    }
+
+    @Test
+    void doRequiresGuestFalse() {
+
+        def subject = mock(Subject)
+
+        expect(subject.getPrincipal()).andReturn("principal");
+        replay subject
+
+        ThreadContext.bind(subject)
+
+        try {
+            stub.doRequiresGuest()
+            fail("expected UnauthenticatedException")
+        }
+        catch(UnauthenticatedException e) {
+            // expected
+        }
+
+        verify subject
+    }
+
+
+    @Test
+    void doRequiresRolesTrue() {
+        def subject = mock(Subject)
+
+        subject.checkRoles(Arrays.asList("RoleOne", "RoleTwo"))
+        replay subject
+
+        ThreadContext.bind(subject)
+
+        assertTrue stub.doRequiresRoles()
+
+        verify subject
+    }
+
+    @Test
+    void doRequiresRolesFalse() {
+
+        def subject = mock(Subject)
+
+        subject.checkRoles(Arrays.asList("RoleOne", "RoleTwo"))
+        expectLastCall().andThrow(new UnauthorizedException("Expected test exception") )
+        replay subject
+
+        ThreadContext.bind(subject)
+
+        try {
+            stub.doRequiresRoles()
+            fail("expected UnauthorizedException")
+        }
+        catch(UnauthorizedException e) {
+            // expected
+        }
+
+        verify subject
+    }
+
+    @Test
+    void doRequiresPermissionsTrue() {
+        def subject = mock(Subject)
+
+        subject.checkPermissions("priv:one", "priv:two")
+        replay subject
+
+        ThreadContext.bind(subject)
+
+        assertEquals "true", stub.doRequiresPermissions()
+
+        verify subject
+    }
+
+    @Test
+    void doRequiresPermissionsFalse() {
+
+        def subject = mock(Subject)
+
+        subject.checkPermissions("priv:one", "priv:two")
+        expectLastCall().andThrow(new UnauthorizedException("Expected test exception") )
+        replay subject
+
+        ThreadContext.bind(subject)
+
+        try {
+            stub.doRequiresPermissions()
+            fail("expected UnauthorizedException")
+        }
+        catch(UnauthorizedException e) {
+            // expected
+        }
+
+        verify subject
+    }
+
+    @After
+    void cleanupThread() {
+        ThreadContext.unbindSubject();
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/shiro/blob/59b944c0/support/cdi/cdi-base/src/test/java/org/apache/shiro/cdi/AnnotationTestStub.java
----------------------------------------------------------------------
diff --git a/support/cdi/cdi-base/src/test/java/org/apache/shiro/cdi/AnnotationTestStub.java b/support/cdi/cdi-base/src/test/java/org/apache/shiro/cdi/AnnotationTestStub.java
new file mode 100644
index 0000000..1ec4202
--- /dev/null
+++ b/support/cdi/cdi-base/src/test/java/org/apache/shiro/cdi/AnnotationTestStub.java
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.shiro.cdi;
+
+import org.apache.shiro.authz.annotation.RequiresAuthentication;
+import org.apache.shiro.authz.annotation.RequiresGuest;
+import org.apache.shiro.authz.annotation.RequiresPermissions;
+import org.apache.shiro.authz.annotation.RequiresRoles;
+import org.apache.shiro.authz.annotation.RequiresUser;
+
+import javax.enterprise.context.ApplicationScoped;
+
+@ApplicationScoped
+public class AnnotationTestStub {
+
+    @RequiresAuthentication
+    public String doRequiresAuthentication(String param) {
+        return param;
+    }
+
+    @RequiresUser
+    public boolean doRequiresUser() {
+        return true;
+    }
+
+    @RequiresGuest
+    public boolean doRequiresGuest() {
+        return true;
+    }
+
+    @RequiresRoles({"RoleOne", "RoleTwo"})
+    public boolean doRequiresRoles() {
+        return true;
+    }
+
+    @RequiresPermissions({"priv:one", "priv:two"})
+    public String doRequiresPermissions() {
+        return "true";
+    }
+}

http://git-wip-us.apache.org/repos/asf/shiro/blob/59b944c0/support/cdi/cdi-base/src/test/java/org/apache/shiro/cdi/EventBusAwareStub.java
----------------------------------------------------------------------
diff --git a/support/cdi/cdi-base/src/test/java/org/apache/shiro/cdi/EventBusAwareStub.java b/support/cdi/cdi-base/src/test/java/org/apache/shiro/cdi/EventBusAwareStub.java
new file mode 100644
index 0000000..33b799a
--- /dev/null
+++ b/support/cdi/cdi-base/src/test/java/org/apache/shiro/cdi/EventBusAwareStub.java
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.shiro.cdi;
+
+import org.apache.shiro.event.EventBus;
+import org.apache.shiro.event.EventBusAware;
+
+import javax.enterprise.context.ApplicationScoped;
+
+@ApplicationScoped
+public class EventBusAwareStub implements EventBusAware {
+
+    private EventBus eventBus;
+
+    @Override
+    public void setEventBus(EventBus eventBus) {
+        this.eventBus = eventBus;
+    }
+
+    public EventBus getEventBus() {
+        return eventBus;
+    }
+
+
+}

http://git-wip-us.apache.org/repos/asf/shiro/blob/59b944c0/support/cdi/cdi-base/src/test/java/org/apache/shiro/cdi/EventListenerStub.java
----------------------------------------------------------------------
diff --git a/support/cdi/cdi-base/src/test/java/org/apache/shiro/cdi/EventListenerStub.java b/support/cdi/cdi-base/src/test/java/org/apache/shiro/cdi/EventListenerStub.java
new file mode 100644
index 0000000..ea449ed
--- /dev/null
+++ b/support/cdi/cdi-base/src/test/java/org/apache/shiro/cdi/EventListenerStub.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.shiro.cdi;
+
+import org.apache.shiro.event.Subscribe;
+
+import javax.enterprise.context.ApplicationScoped;
+
+@ApplicationScoped
+public class EventListenerStub {
+
+    private Object lastEvent;
+
+    @Subscribe
+    public void anyEvent(Object event) {
+        this.lastEvent = event;
+    }
+
+    public Object getLastEvent() {
+        return lastEvent;
+    }
+}

http://git-wip-us.apache.org/repos/asf/shiro/blob/59b944c0/support/cdi/cdi-base/src/test/java/org/apache/shiro/cdi/StubConfiguration.java
----------------------------------------------------------------------
diff --git a/support/cdi/cdi-base/src/test/java/org/apache/shiro/cdi/StubConfiguration.java b/support/cdi/cdi-base/src/test/java/org/apache/shiro/cdi/StubConfiguration.java
new file mode 100644
index 0000000..c8a1ee9
--- /dev/null
+++ b/support/cdi/cdi-base/src/test/java/org/apache/shiro/cdi/StubConfiguration.java
@@ -0,0 +1,40 @@
+package org.apache.shiro.cdi;
+
+import org.apache.shiro.authz.Permission;
+import org.apache.shiro.authz.permission.PermissionResolver;
+import org.apache.shiro.mgt.DefaultSecurityManager;
+import org.apache.shiro.mgt.SecurityManager;
+import org.apache.shiro.realm.Realm;
+import org.apache.shiro.realm.text.TextConfigurationRealm;
+import org.apache.shiro.util.Initializable;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.inject.New;
+import javax.enterprise.inject.Produces;
+import javax.enterprise.inject.Typed;
+
+@ApplicationScoped
+class StubConfiguration {
+
+    @Typed({Realm.class, Initializable.class})
+    @Produces
+    private TextConfigurationRealm createTestRealm() {
+        return new TextConfigurationRealm();
+    }
+
+    @Produces
+    private PermissionResolver createPermissionResolver() {
+        return new PermissionResolver() {
+            @Override
+            public Permission resolvePermission(String permissionString) {
+                return null;
+            }
+        };
+    }
+
+    @Produces
+    @ApplicationScoped
+    private SecurityManager securityManager(@New DefaultSecurityManager securityManager) {
+        return securityManager;
+    }
+}

http://git-wip-us.apache.org/repos/asf/shiro/blob/59b944c0/support/cdi/cdi-base/src/test/resources/META-INF/beans.xml
----------------------------------------------------------------------
diff --git a/support/cdi/cdi-base/src/test/resources/META-INF/beans.xml b/support/cdi/cdi-base/src/test/resources/META-INF/beans.xml
new file mode 100644
index 0000000..330c7f6
--- /dev/null
+++ b/support/cdi/cdi-base/src/test/resources/META-INF/beans.xml
@@ -0,0 +1 @@
+<beans/>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/shiro/blob/59b944c0/support/cdi/cdi-core/pom.xml
----------------------------------------------------------------------
diff --git a/support/cdi/cdi-core/pom.xml b/support/cdi/cdi-core/pom.xml
new file mode 100644
index 0000000..ca49b87
--- /dev/null
+++ b/support/cdi/cdi-core/pom.xml
@@ -0,0 +1,109 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License.  You may obtain a copy of the License at
+  ~
+  ~     http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied.  See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+    <parent>
+        <groupId>org.apache.shiro</groupId>
+        <artifactId>shiro-cdi</artifactId>
+        <version>1.4.0-SNAPSHOT</version>
+    </parent>
+
+    <modelVersion>4.0.0</modelVersion>
+    <artifactId>shiro-cdi-core</artifactId>
+    <name>Apache Shiro :: Support :: CDI Core</name>
+    <packaging>bundle</packaging>
+
+    <dependencies>
+
+        <dependency>
+            <groupId>org.apache.shiro</groupId>
+            <artifactId>shiro-cdi-base</artifactId>
+            <version>1.4.0-SNAPSHOT</version>
+        </dependency>
+
+        <dependency>
+            <groupId>javax.enterprise</groupId>
+            <artifactId>cdi-api</artifactId>
+            <version>1.2</version>
+        </dependency>
+
+        <dependency>
+            <groupId>javax.annotation</groupId>
+            <artifactId>javax.annotation-api</artifactId>
+            <version>1.3</version>
+        </dependency>
+
+        <dependency>
+            <groupId>ch.qos.logback</groupId>
+            <artifactId>logback-classic</artifactId>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.deltaspike.modules</groupId>
+            <artifactId>deltaspike-test-control-module-api</artifactId>
+            <version>${deltaspike.version}</version>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.deltaspike.modules</groupId>
+            <artifactId>deltaspike-test-control-module-impl</artifactId>
+            <version>${deltaspike.version}</version>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.deltaspike.cdictrl</groupId>
+            <artifactId>deltaspike-cdictrl-weld</artifactId>
+            <version>${deltaspike.version}</version>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.jboss.weld.se</groupId>
+            <artifactId>weld-se-core</artifactId>
+            <version>2.4.1.Final</version>
+            <scope>test</scope>
+        </dependency>
+
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <extensions>true</extensions>
+                <configuration>
+                    <instructions>
+                        <Bundle-SymbolicName>org.apache.shiro.cdi.core</Bundle-SymbolicName>
+                        <Export-Package>org.apache.shiro.cdi.core*;version=${project.version}</Export-Package>
+                        <Import-Package>
+                            org.apache.shiro*;version="${shiro.osgi.importRange}",
+                            *
+                        </Import-Package>
+                    </instructions>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>

http://git-wip-us.apache.org/repos/asf/shiro/blob/59b944c0/support/cdi/cdi-core/src/main/java/org/apache/shiro/cdi/core/producers/SecurityManagerProducer.java
----------------------------------------------------------------------
diff --git a/support/cdi/cdi-core/src/main/java/org/apache/shiro/cdi/core/producers/SecurityManagerProducer.java b/support/cdi/cdi-core/src/main/java/org/apache/shiro/cdi/core/producers/SecurityManagerProducer.java
new file mode 100644
index 0000000..94e5272
--- /dev/null
+++ b/support/cdi/cdi-core/src/main/java/org/apache/shiro/cdi/core/producers/SecurityManagerProducer.java
@@ -0,0 +1,82 @@
+package org.apache.shiro.cdi.core.producers;
+
+import org.apache.shiro.authc.pam.AuthenticationStrategy;
+import org.apache.shiro.authz.permission.PermissionResolver;
+import org.apache.shiro.authz.permission.RolePermissionResolver;
+import org.apache.shiro.cache.CacheManager;
+import org.apache.shiro.cdi.producers.AbstractSecurityManagerProducer;
+import org.apache.shiro.event.EventBus;
+import org.apache.shiro.mgt.DefaultSecurityManager;
+import org.apache.shiro.mgt.DefaultSubjectFactory;
+import org.apache.shiro.mgt.RememberMeManager;
+import org.apache.shiro.mgt.SecurityManager;
+import org.apache.shiro.mgt.SubjectDAO;
+import org.apache.shiro.mgt.SubjectFactory;
+import org.apache.shiro.realm.Realm;
+import org.apache.shiro.session.mgt.DefaultSessionManager;
+import org.apache.shiro.session.mgt.SessionFactory;
+import org.apache.shiro.session.mgt.SessionManager;
+import org.apache.shiro.session.mgt.eis.MemorySessionDAO;
+import org.apache.shiro.session.mgt.eis.SessionDAO;
+import org.apache.shiro.util.Destroyable;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.inject.Instance;
+import javax.enterprise.inject.New;
+import javax.enterprise.inject.Produces;
+import javax.enterprise.inject.Typed;
+
+public class SecurityManagerProducer extends AbstractSecurityManagerProducer {
+
+    @Produces
+    @ApplicationScoped
+    @Typed({SecurityManager.class, DefaultSecurityManager.class, Destroyable.class})
+    @Override
+    protected DefaultSecurityManager securityManager(@New DefaultSecurityManager securityManager,
+                                                     Instance<Realm> realms,
+                                                     EventBus eventBus,
+                                                     SessionManager sessionManager,
+                                                     Instance<CacheManager> cacheManager,
+                                                     SubjectDAO subjectDAO,
+                                                     SubjectFactory subjectFactory,
+                                                     Instance<RememberMeManager> rememberMeManager,
+                                                     AuthenticationStrategy authenticationStrategy,
+                                                     Instance<PermissionResolver> permissionResolver,
+                                                     Instance<RolePermissionResolver> rolePermissionResolver) {
+
+        return configureSecurityManager(securityManager,
+                                        realms,
+                                        eventBus,
+                                        sessionManager,
+                                        cacheManager,
+                                        subjectDAO,
+                                        subjectFactory,
+                                        rememberMeManager,
+                                        authenticationStrategy,
+                                        permissionResolver,
+                                        rolePermissionResolver);
+    }
+
+    @Produces
+    protected DefaultSubjectFactory subjectFactory(@New DefaultSubjectFactory subjectFactory) {
+        return subjectFactory;
+    }
+
+    @Produces
+    protected SessionManager sessionManager(@New DefaultSessionManager sessionManager,
+                                            SessionDAO sessionDAO,
+                                            SessionFactory sessionFactory) {
+
+        sessionManager.setSessionDAO(sessionDAO);
+        sessionManager.setSessionFactory(sessionFactory);
+        sessionManager.setDeleteInvalidSessions(true); // TODO: add configuration for this.
+        return sessionManager;
+    }
+
+    @Produces
+    protected MemorySessionDAO sessionDAO(@New MemorySessionDAO memorySessionDAO) {
+        return memorySessionDAO;
+    }
+
+
+}

http://git-wip-us.apache.org/repos/asf/shiro/blob/59b944c0/support/cdi/cdi-core/src/main/resources/META-INF/beans.xml
----------------------------------------------------------------------
diff --git a/support/cdi/cdi-core/src/main/resources/META-INF/beans.xml b/support/cdi/cdi-core/src/main/resources/META-INF/beans.xml
new file mode 100644
index 0000000..330c7f6
--- /dev/null
+++ b/support/cdi/cdi-core/src/main/resources/META-INF/beans.xml
@@ -0,0 +1 @@
+<beans/>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/shiro/blob/59b944c0/support/cdi/cdi-core/src/test/groovy/org/apache/shiro/cdi/CdiHackingTest.groovy
----------------------------------------------------------------------
diff --git a/support/cdi/cdi-core/src/test/groovy/org/apache/shiro/cdi/CdiHackingTest.groovy b/support/cdi/cdi-core/src/test/groovy/org/apache/shiro/cdi/CdiHackingTest.groovy
new file mode 100644
index 0000000..d342bb8
--- /dev/null
+++ b/support/cdi/cdi-core/src/test/groovy/org/apache/shiro/cdi/CdiHackingTest.groovy
@@ -0,0 +1,108 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.shiro.cdi
+
+import org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner
+import org.apache.shiro.authz.permission.PermissionResolver
+import org.apache.shiro.cache.CacheManager
+import org.apache.shiro.event.EventBus
+import org.apache.shiro.mgt.DefaultSecurityManager
+import org.apache.shiro.mgt.RememberMeManager
+import org.apache.shiro.mgt.SecurityManager
+import org.apache.shiro.mgt.SubjectDAO
+import org.apache.shiro.mgt.SubjectFactory
+import org.apache.shiro.realm.Realm
+import org.apache.shiro.session.mgt.SessionManager
+import org.apache.shiro.subject.Subject
+import org.junit.Test
+import org.junit.runner.RunWith
+
+import javax.enterprise.context.ApplicationScoped
+import javax.enterprise.inject.Default
+import javax.enterprise.inject.Instance
+import javax.inject.Inject
+
+import static org.hamcrest.Matchers.*
+
+import static org.junit.Assert.*
+
+/**
+ * Hacking around with CDI and Shiro.
+ */
+@RunWith(CdiTestRunner.class)
+@Default
+@ApplicationScoped
+public class CdiHackingTest {
+
+    @Inject
+    private SecurityManager securityManager;
+
+    @Inject
+    private CdiEnvironment cdiEnvironment;
+
+    @Inject
+    private EventBus eventBus;
+
+    @Inject
+    private Instance<Realm> realms;
+
+    @Inject
+    private SessionManager sessionManager
+
+    @Inject
+    private Instance<CacheManager> cacheManager;
+
+    @Inject
+    private SubjectDAO subjectDAO;
+
+    @Inject
+    private SubjectFactory subjectFactory;
+
+    @Inject
+    private Instance<RememberMeManager> rememberMeManager;
+
+    @Inject
+    private Instance<PermissionResolver> permissionResolver;
+
+    @Inject
+    private Subject subject;
+
+    @Test
+    public void doSomeStuff() {
+
+        assertNotNull(eventBus)
+        assertNotNull(subjectFactory)
+        assertNotNull(subjectDAO)
+        assertNotNull(sessionManager)
+
+        assertTrue(rememberMeManager.isUnsatisfied())
+        assertTrue(cacheManager.isUnsatisfied())
+
+        assertNotNull(permissionResolver.get())
+
+        assertSame cdiEnvironment.securityManager, securityManager
+        assertThat securityManager, instanceOf(DefaultSecurityManager)
+
+//        sessionManager.getSession(new DefaultSessionKey("foo"))
+
+        assertFalse subject.isAuthenticated()
+
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/shiro/blob/59b944c0/support/cdi/cdi-core/src/test/java/org/apache/shiro/cdi/StubConfiguration.java
----------------------------------------------------------------------
diff --git a/support/cdi/cdi-core/src/test/java/org/apache/shiro/cdi/StubConfiguration.java b/support/cdi/cdi-core/src/test/java/org/apache/shiro/cdi/StubConfiguration.java
new file mode 100644
index 0000000..5897acc
--- /dev/null
+++ b/support/cdi/cdi-core/src/test/java/org/apache/shiro/cdi/StubConfiguration.java
@@ -0,0 +1,29 @@
+package org.apache.shiro.cdi;
+
+import org.apache.shiro.authz.Permission;
+import org.apache.shiro.authz.permission.PermissionResolver;
+import org.apache.shiro.realm.Realm;
+import org.apache.shiro.realm.text.TextConfigurationRealm;
+import org.apache.shiro.util.Initializable;
+
+import javax.enterprise.inject.Produces;
+import javax.enterprise.inject.Typed;
+
+class StubConfiguration {
+
+    @Typed({Realm.class, Initializable.class})
+    @Produces
+    private TextConfigurationRealm createTestRealm() {
+        return new TextConfigurationRealm();
+    }
+
+    @Produces
+    private PermissionResolver createPermissionResolver() {
+        return new PermissionResolver() {
+            @Override
+            public Permission resolvePermission(String permissionString) {
+                return null;
+            }
+        };
+    }
+}

http://git-wip-us.apache.org/repos/asf/shiro/blob/59b944c0/support/cdi/cdi-core/src/test/resources/META-INF/beans.xml
----------------------------------------------------------------------
diff --git a/support/cdi/cdi-core/src/test/resources/META-INF/beans.xml b/support/cdi/cdi-core/src/test/resources/META-INF/beans.xml
new file mode 100644
index 0000000..330c7f6
--- /dev/null
+++ b/support/cdi/cdi-core/src/test/resources/META-INF/beans.xml
@@ -0,0 +1 @@
+<beans/>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/shiro/blob/59b944c0/support/cdi/cdi-web/pom.xml
----------------------------------------------------------------------
diff --git a/support/cdi/cdi-web/pom.xml b/support/cdi/cdi-web/pom.xml
new file mode 100644
index 0000000..f422dc0
--- /dev/null
+++ b/support/cdi/cdi-web/pom.xml
@@ -0,0 +1,133 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License.  You may obtain a copy of the License at
+  ~
+  ~     http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied.  See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+    <parent>
+        <groupId>org.apache.shiro</groupId>
+        <artifactId>shiro-cdi</artifactId>
+        <version>1.4.0-SNAPSHOT</version>
+    </parent>
+
+    <modelVersion>4.0.0</modelVersion>
+    <artifactId>shiro-cdi-web</artifactId>
+    <name>Apache Shiro :: Support :: CDI Web</name>
+    <packaging>bundle</packaging>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.shiro</groupId>
+            <artifactId>shiro-web</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>javax.servlet</groupId>
+            <artifactId>javax.servlet-api</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.shiro</groupId>
+            <artifactId>shiro-cdi-base</artifactId>
+            <version>1.4.0-SNAPSHOT</version>
+        </dependency>
+
+        <dependency>
+            <groupId>javax.enterprise</groupId>
+            <artifactId>cdi-api</artifactId>
+            <version>1.2</version>
+        </dependency>
+
+        <dependency>
+            <groupId>javax.annotation</groupId>
+            <artifactId>javax.annotation-api</artifactId>
+            <version>1.3</version>
+        </dependency>
+
+        <dependency>
+            <groupId>ch.qos.logback</groupId>
+            <artifactId>logback-classic</artifactId>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.deltaspike.modules</groupId>
+            <artifactId>deltaspike-test-control-module-api</artifactId>
+            <version>${deltaspike.version}</version>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.deltaspike.modules</groupId>
+            <artifactId>deltaspike-test-control-module-impl</artifactId>
+            <version>${deltaspike.version}</version>
+            <scope>test</scope>
+        </dependency>
+
+        <!--<dependency>-->
+            <!--<groupId>org.apache.deltaspike.cdictrl</groupId>-->
+            <!--<artifactId>deltaspike-cdictrl-weld</artifactId>-->
+            <!--<version>${deltaspike.version}</version>-->
+            <!--<scope>test</scope>-->
+        <!--</dependency>-->
+
+        <!--<dependency>-->
+            <!--<groupId>org.jboss.weld.se</groupId>-->
+            <!--<artifactId>weld-se-core</artifactId>-->
+            <!--<version>2.4.1.Final</version>-->
+            <!--<scope>test</scope>-->
+        <!--</dependency>-->
+
+
+        <dependency>
+            <groupId>org.apache.deltaspike.cdictrl</groupId>
+            <artifactId>deltaspike-cdictrl-owb</artifactId>
+            <version>${deltaspike.version}</version>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.openwebbeans</groupId>
+            <artifactId>openwebbeans-impl</artifactId>
+            <version>1.7.0</version>
+            <scope>test</scope>
+        </dependency>
+
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <extensions>true</extensions>
+                <configuration>
+                    <instructions>
+                        <Bundle-SymbolicName>org.apache.shiro.cdi.web</Bundle-SymbolicName>
+                        <Export-Package>org.apache.shiro.cdi.web*;version=${project.version}</Export-Package>
+                        <Import-Package>
+                            org.apache.shiro*;version="${shiro.osgi.importRange}",
+                            *
+                        </Import-Package>
+                    </instructions>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>

http://git-wip-us.apache.org/repos/asf/shiro/blob/59b944c0/support/cdi/cdi-web/src/main/java/org/apache/shiro/cdi/web/CdiWebEnvironment.java
----------------------------------------------------------------------
diff --git a/support/cdi/cdi-web/src/main/java/org/apache/shiro/cdi/web/CdiWebEnvironment.java b/support/cdi/cdi-web/src/main/java/org/apache/shiro/cdi/web/CdiWebEnvironment.java
new file mode 100644
index 0000000..32e76f7
--- /dev/null
+++ b/support/cdi/cdi-web/src/main/java/org/apache/shiro/cdi/web/CdiWebEnvironment.java
@@ -0,0 +1,43 @@
+package org.apache.shiro.cdi.web;
+
+import org.apache.shiro.mgt.SecurityManager;
+import org.apache.shiro.web.env.WebEnvironment;
+import org.apache.shiro.web.filter.mgt.FilterChainResolver;
+import org.apache.shiro.web.mgt.WebSecurityManager;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.inject.Inject;
+import javax.servlet.ServletContext;
+
+@ApplicationScoped
+public class CdiWebEnvironment implements WebEnvironment {
+
+    @Inject
+    private FilterChainResolver filterChainResolver;
+
+    @Inject
+    private WebSecurityManager webSecurityManager;
+
+    @Inject
+    private ServletContext servletContext;
+
+    @Override
+    public FilterChainResolver getFilterChainResolver() {
+        return filterChainResolver;
+    }
+
+    @Override
+    public SecurityManager getSecurityManager() {
+        return webSecurityManager;
+    }
+
+    @Override
+    public WebSecurityManager getWebSecurityManager() {
+        return webSecurityManager;
+    }
+
+    @Override
+    public ServletContext getServletContext() {
+        return servletContext;
+    }
+}

http://git-wip-us.apache.org/repos/asf/shiro/blob/59b944c0/support/cdi/cdi-web/src/main/java/org/apache/shiro/cdi/web/NativeSessions.java
----------------------------------------------------------------------
diff --git a/support/cdi/cdi-web/src/main/java/org/apache/shiro/cdi/web/NativeSessions.java b/support/cdi/cdi-web/src/main/java/org/apache/shiro/cdi/web/NativeSessions.java
new file mode 100644
index 0000000..244de28
--- /dev/null
+++ b/support/cdi/cdi-web/src/main/java/org/apache/shiro/cdi/web/NativeSessions.java
@@ -0,0 +1,17 @@
+package org.apache.shiro.cdi.web;
+
+import javax.inject.Qualifier;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+@Qualifier
+@Retention(RUNTIME)
+@Target({TYPE, METHOD, FIELD, PARAMETER})
+public @interface NativeSessions {
+}

http://git-wip-us.apache.org/repos/asf/shiro/blob/59b944c0/support/cdi/cdi-web/src/main/java/org/apache/shiro/cdi/web/ServletContainerSessions.java
----------------------------------------------------------------------
diff --git a/support/cdi/cdi-web/src/main/java/org/apache/shiro/cdi/web/ServletContainerSessions.java b/support/cdi/cdi-web/src/main/java/org/apache/shiro/cdi/web/ServletContainerSessions.java
new file mode 100644
index 0000000..f2d843d
--- /dev/null
+++ b/support/cdi/cdi-web/src/main/java/org/apache/shiro/cdi/web/ServletContainerSessions.java
@@ -0,0 +1,17 @@
+package org.apache.shiro.cdi.web;
+
+import javax.inject.Qualifier;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+@Qualifier
+@Retention(RUNTIME)
+@Target({TYPE, METHOD, FIELD, PARAMETER})
+public @interface ServletContainerSessions {
+}

http://git-wip-us.apache.org/repos/asf/shiro/blob/59b944c0/support/cdi/cdi-web/src/main/java/org/apache/shiro/cdi/web/Web.java
----------------------------------------------------------------------
diff --git a/support/cdi/cdi-web/src/main/java/org/apache/shiro/cdi/web/Web.java b/support/cdi/cdi-web/src/main/java/org/apache/shiro/cdi/web/Web.java
new file mode 100644
index 0000000..8170c7d
--- /dev/null
+++ b/support/cdi/cdi-web/src/main/java/org/apache/shiro/cdi/web/Web.java
@@ -0,0 +1,14 @@
+package org.apache.shiro.cdi.web;
+
+import javax.inject.Qualifier;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.RetentionPolicy.*;
+import static java.lang.annotation.ElementType.*;
+
+@Qualifier
+@Retention(RUNTIME)
+@Target({TYPE, METHOD, FIELD, PARAMETER})
+public @interface Web {
+}

http://git-wip-us.apache.org/repos/asf/shiro/blob/59b944c0/support/cdi/cdi-web/src/main/java/org/apache/shiro/cdi/web/producers/WebSecurityManagerProducer.java
----------------------------------------------------------------------
diff --git a/support/cdi/cdi-web/src/main/java/org/apache/shiro/cdi/web/producers/WebSecurityManagerProducer.java b/support/cdi/cdi-web/src/main/java/org/apache/shiro/cdi/web/producers/WebSecurityManagerProducer.java
new file mode 100644
index 0000000..9fc78fd
--- /dev/null
+++ b/support/cdi/cdi-web/src/main/java/org/apache/shiro/cdi/web/producers/WebSecurityManagerProducer.java
@@ -0,0 +1,82 @@
+package org.apache.shiro.cdi.web.producers;
+
+import org.apache.shiro.authc.pam.AuthenticationStrategy;
+import org.apache.shiro.authz.permission.PermissionResolver;
+import org.apache.shiro.authz.permission.RolePermissionResolver;
+import org.apache.shiro.cache.CacheManager;
+import org.apache.shiro.cdi.producers.AbstractSecurityManagerProducer;
+import org.apache.shiro.event.EventBus;
+import org.apache.shiro.mgt.DefaultSecurityManager;
+import org.apache.shiro.mgt.RememberMeManager;
+import org.apache.shiro.mgt.SecurityManager;
+import org.apache.shiro.mgt.SubjectDAO;
+import org.apache.shiro.mgt.SubjectFactory;
+import org.apache.shiro.realm.Realm;
+import org.apache.shiro.session.mgt.SessionManager;
+import org.apache.shiro.util.Destroyable;
+import org.apache.shiro.web.filter.mgt.FilterChainResolver;
+import org.apache.shiro.web.filter.mgt.PathMatchingFilterChainResolver;
+import org.apache.shiro.web.mgt.CookieRememberMeManager;
+import org.apache.shiro.web.mgt.DefaultWebSecurityManager;
+import org.apache.shiro.web.mgt.DefaultWebSubjectFactory;
+import org.apache.shiro.web.mgt.WebSecurityManager;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.inject.Instance;
+import javax.enterprise.inject.New;
+import javax.enterprise.inject.Produces;
+import javax.enterprise.inject.Typed;
+
+public class WebSecurityManagerProducer extends AbstractSecurityManagerProducer {
+
+
+    @Produces
+    @ApplicationScoped
+    @Typed({DefaultWebSecurityManager.class,
+            DefaultSecurityManager.class,
+            WebSecurityManager.class,
+            SecurityManager.class,
+            Destroyable.class})
+    @Override
+    protected DefaultWebSecurityManager securityManager(@New(DefaultWebSecurityManager.class) DefaultSecurityManager securityManager,
+                                                        Instance<Realm> realms,
+                                                        EventBus eventBus,
+                                                        SessionManager sessionManager,
+                                                        Instance<CacheManager> cacheManager,
+                                                        SubjectDAO subjectDAO,
+                                                        SubjectFactory subjectFactory,
+                                                        Instance<RememberMeManager> rememberMeManager,
+                                                        AuthenticationStrategy authenticationStrategy,
+                                                        Instance<PermissionResolver> permissionResolver,
+                                                        Instance<RolePermissionResolver> rolePermissionResolver) {
+
+        return configureSecurityManager((DefaultWebSecurityManager) securityManager,
+                                        realms,
+                                        eventBus,
+                                        sessionManager,
+                                        cacheManager,
+                                        subjectDAO,
+                                        subjectFactory,
+                                        rememberMeManager,
+                                        authenticationStrategy,
+                                        permissionResolver,
+                                        rolePermissionResolver);
+    }
+
+    @Produces
+    protected DefaultWebSubjectFactory webSubjectFactory(@New DefaultWebSubjectFactory subjectFactory) {
+        return subjectFactory;
+    }
+
+    @Produces
+    protected RememberMeManager rememberMeManager(@New CookieRememberMeManager rememberMeManager) {
+//        rememberMeManager.setCookie(rememberMeCookieTemplate());
+        return rememberMeManager;
+    }
+
+    @Produces
+    @ApplicationScoped
+    protected FilterChainResolver filterChainResolver(@New PathMatchingFilterChainResolver filterChainResolver) {
+        return filterChainResolver;
+    }
+}

http://git-wip-us.apache.org/repos/asf/shiro/blob/59b944c0/support/cdi/cdi-web/src/main/java/org/apache/shiro/cdi/web/producers/WebSessionManagerProvider.java
----------------------------------------------------------------------
diff --git a/support/cdi/cdi-web/src/main/java/org/apache/shiro/cdi/web/producers/WebSessionManagerProvider.java b/support/cdi/cdi-web/src/main/java/org/apache/shiro/cdi/web/producers/WebSessionManagerProvider.java
new file mode 100644
index 0000000..fd69248
--- /dev/null
+++ b/support/cdi/cdi-web/src/main/java/org/apache/shiro/cdi/web/producers/WebSessionManagerProvider.java
@@ -0,0 +1,25 @@
+package org.apache.shiro.cdi.web.producers;
+
+import org.apache.shiro.cdi.web.ServletContainerSessions;
+import org.apache.shiro.cdi.web.Web;
+import org.apache.shiro.web.session.mgt.ServletContainerSessionManager;
+import org.apache.shiro.web.session.mgt.WebSessionManager;
+
+import javax.enterprise.inject.New;
+import javax.enterprise.inject.Produces;
+
+public class WebSessionManagerProvider {
+
+    @Web
+    @ServletContainerSessions
+    @Produces
+    protected WebSessionManager servletContainerWebSessionManager(@New ServletContainerSessionManager sessionManager) {
+        return sessionManager;
+    }
+
+    @Produces
+    protected WebSessionManager webSessionManager(@ServletContainerSessions WebSessionManager webSessionManager) {
+        return webSessionManager;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/shiro/blob/59b944c0/support/cdi/cdi-web/src/main/resources/META-INF/beans.xml
----------------------------------------------------------------------
diff --git a/support/cdi/cdi-web/src/main/resources/META-INF/beans.xml b/support/cdi/cdi-web/src/main/resources/META-INF/beans.xml
new file mode 100644
index 0000000..330c7f6
--- /dev/null
+++ b/support/cdi/cdi-web/src/main/resources/META-INF/beans.xml
@@ -0,0 +1 @@
+<beans/>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/shiro/blob/59b944c0/support/cdi/cdi-web/src/test/groovy/org/apache/shiro/cdi/web/MoreHackingTest.groovy
----------------------------------------------------------------------
diff --git a/support/cdi/cdi-web/src/test/groovy/org/apache/shiro/cdi/web/MoreHackingTest.groovy b/support/cdi/cdi-web/src/test/groovy/org/apache/shiro/cdi/web/MoreHackingTest.groovy
new file mode 100644
index 0000000..2791d7f
--- /dev/null
+++ b/support/cdi/cdi-web/src/test/groovy/org/apache/shiro/cdi/web/MoreHackingTest.groovy
@@ -0,0 +1,82 @@
+package org.apache.shiro.cdi.web
+
+import org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner
+import org.apache.shiro.cache.CacheManager
+import org.apache.shiro.event.EventBus
+import org.apache.shiro.mgt.RememberMeManager
+import org.apache.shiro.mgt.SubjectDAO
+import org.apache.shiro.mgt.SubjectFactory
+import org.apache.shiro.realm.Realm
+import org.apache.shiro.session.mgt.SessionManager
+import org.apache.shiro.subject.Subject
+import org.apache.shiro.web.mgt.DefaultWebSecurityManager
+import org.apache.shiro.web.mgt.WebSecurityManager
+import org.junit.Test
+import org.junit.runner.RunWith
+
+import javax.enterprise.inject.Instance
+import javax.inject.Inject
+
+import static org.hamcrest.Matchers.instanceOf
+import static org.junit.Assert.*
+
+@RunWith(CdiTestRunner.class)
+public class MoreHackingTest {
+
+
+    @Inject
+    private WebSecurityManager securityManager;
+
+    @Inject
+    private CdiWebEnvironment cdiEnvironment;
+
+    @Inject
+    private EventBus eventBus;
+
+    @Inject
+    private Instance<Realm> realms;
+
+    @Inject
+    private SessionManager sessionManager
+
+    @Inject
+    private Instance<CacheManager> cacheManager;
+
+    @Inject
+    private SubjectDAO subjectDAO;
+
+    @Inject
+    private SubjectFactory subjectFactory;
+
+    @Inject
+    private Instance<RememberMeManager> rememberMeManager;
+
+    @Inject
+    private Subject subject;
+
+    @Test
+    public void doStuff() {
+        assertNotNull(eventBus)
+        assertNotNull(subjectFactory)
+        assertNotNull(subjectDAO)
+        assertNotNull(sessionManager)
+
+        assertFalse(rememberMeManager.isUnsatisfied())
+        assertTrue(cacheManager.isUnsatisfied())
+
+//        assertEquals cdiEnvironment.securityManager, securityManager
+//        assertEquals cdiEnvironment.webSecurityManager, securityManager
+        assertThat securityManager, instanceOf(DefaultWebSecurityManager)
+
+//        assertEquals subjectFactory, ((DefaultSecurityManager)securityManager).getSubjectFactory()
+//        assertThat subjectFactory, instanceOf(DefaultWebSubjectFactory)
+
+//        assertEquals sessionManager, ((DefaultSecurityManager)securityManager).getSessionManager()
+
+//        assertThat sessionManager, instanceOf(WebSessionManager)
+
+        assertFalse subject.isAuthenticated()
+
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/shiro/blob/59b944c0/support/cdi/cdi-web/src/test/java/org/apache/shiro/cdi/web/StubConfiguration.java
----------------------------------------------------------------------
diff --git a/support/cdi/cdi-web/src/test/java/org/apache/shiro/cdi/web/StubConfiguration.java b/support/cdi/cdi-web/src/test/java/org/apache/shiro/cdi/web/StubConfiguration.java
new file mode 100644
index 0000000..4195720
--- /dev/null
+++ b/support/cdi/cdi-web/src/test/java/org/apache/shiro/cdi/web/StubConfiguration.java
@@ -0,0 +1,18 @@
+package org.apache.shiro.cdi.web;
+
+import org.apache.shiro.realm.Realm;
+import org.apache.shiro.realm.text.TextConfigurationRealm;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.inject.Produces;
+
+@ApplicationScoped
+class StubConfiguration {
+
+//    @Typed({Realm.class, Initializable.class})
+    @Produces
+    @ApplicationScoped
+    private Realm createTestRealm() {
+        return new TextConfigurationRealm();
+    }
+}

http://git-wip-us.apache.org/repos/asf/shiro/blob/59b944c0/support/cdi/cdi-web/src/test/resources/META-INF/beans.xml
----------------------------------------------------------------------
diff --git a/support/cdi/cdi-web/src/test/resources/META-INF/beans.xml b/support/cdi/cdi-web/src/test/resources/META-INF/beans.xml
new file mode 100644
index 0000000..330c7f6
--- /dev/null
+++ b/support/cdi/cdi-web/src/test/resources/META-INF/beans.xml
@@ -0,0 +1 @@
+<beans/>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/shiro/blob/59b944c0/support/cdi/pom.xml
----------------------------------------------------------------------
diff --git a/support/cdi/pom.xml b/support/cdi/pom.xml
new file mode 100644
index 0000000..15e9ff6
--- /dev/null
+++ b/support/cdi/pom.xml
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License.  You may obtain a copy of the License at
+  ~
+  ~     http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied.  See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+    <parent>
+        <groupId>org.apache.shiro</groupId>
+        <artifactId>shiro-root</artifactId>
+        <version>1.4.0-SNAPSHOT</version>
+        <relativePath>../../pom.xml</relativePath>
+    </parent>
+
+    <modelVersion>4.0.0</modelVersion>
+    <artifactId>shiro-cdi</artifactId>
+    <name>Apache Shiro :: CDI</name>
+    <packaging>pom</packaging>
+
+    <properties>
+        <jdk.version>1.7</jdk.version>
+        <deltaspike.version>1.7.2</deltaspike.version>
+    </properties>
+
+    <modules>
+        <module>cdi-base</module>
+        <module>cdi-core</module>
+        <module>cdi-web</module>
+    </modules>
+
+</project>
+

http://git-wip-us.apache.org/repos/asf/shiro/blob/59b944c0/support/pom.xml
----------------------------------------------------------------------
diff --git a/support/pom.xml b/support/pom.xml
index 8886f02..a543d30 100644
--- a/support/pom.xml
+++ b/support/pom.xml
@@ -43,6 +43,7 @@
         <module>spring-boot</module>
         <module>servlet-plugin</module>
         <module>jaxrs</module>
+        <module>cdi</module>
     </modules>
 
 </project>


Mime
View raw message