Author: bdaw
Date: 2009-11-13 06:00:24 -0500 (Fri, 13 Nov 2009)
New Revision: 938
Added:
idm/trunk/example/auth/src/main/java/org/
idm/trunk/example/auth/src/main/java/org/jboss/
idm/trunk/example/auth/src/main/java/org/jboss/identity/
idm/trunk/example/auth/src/main/java/org/jboss/identity/idm/
idm/trunk/example/auth/src/main/java/org/jboss/identity/idm/example/
idm/trunk/example/auth/src/main/java/org/jboss/identity/idm/example/auth/
idm/trunk/example/auth/src/main/java/org/jboss/identity/idm/example/auth/SimplePopulationService.java
Modified:
idm/trunk/example/auth/pom.xml
idm/trunk/example/auth/src/main/resources/META-INF/idm-example-auth-jboss-beans.xml
idm/trunk/example/auth/src/main/resources/idm-example-auth.war/protected/index.jsp
idm/trunk/example/auth/src/main/resources/jboss.idm.hibernate.cfg.xml
idm/trunk/integration/jboss5/pom.xml
Log:
- Fix auth example
Modified: idm/trunk/example/auth/pom.xml
===================================================================
--- idm/trunk/example/auth/pom.xml 2009-11-13 09:58:22 UTC (rev 937)
+++ idm/trunk/example/auth/pom.xml 2009-11-13 11:00:24 UTC (rev 938)
@@ -124,6 +124,10 @@
<configuration>
<tasks>
+ <jar
destfile="${basedir}/target/classes/simple-populator.jar"
+ basedir="${basedir}/target/classes/"
+ includes="**/*.class"/>
+
<!-- Exploded -->
<copy
todir="${basedir}/target/idm-example-auth-exploded.sar">
<fileset dir="${basedir}/target/classes"/>
@@ -134,9 +138,12 @@
<!-- Packed -->
<jar
destfile="${basedir}/target/idm-example-auth.war"
-
basedir="${basedir}/target/classes/idm-example-auth.war"
- />
+
basedir="${basedir}/target/classes/idm-example-auth.war"/>
+
+
+
+
<jar
destfile="${basedir}/target/idm-example-auth.sar">
<fileset dir="${basedir}/target/classes/"
excludes="idm-example-auth.war/**"/>
Added:
idm/trunk/example/auth/src/main/java/org/jboss/identity/idm/example/auth/SimplePopulationService.java
===================================================================
---
idm/trunk/example/auth/src/main/java/org/jboss/identity/idm/example/auth/SimplePopulationService.java
(rev 0)
+++
idm/trunk/example/auth/src/main/java/org/jboss/identity/idm/example/auth/SimplePopulationService.java 2009-11-13
11:00:24 UTC (rev 938)
@@ -0,0 +1,88 @@
+/*
+* JBoss, a division of Red Hat
+* Copyright 2009, Red Hat Middleware, LLC, and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+*/
+
+
+package org.jboss.identity.idm.example.auth;
+
+import org.jboss.identity.idm.api.IdentitySession;
+import org.jboss.identity.idm.api.IdentitySessionFactory;
+import org.jboss.identity.idm.api.User;
+import org.jboss.identity.idm.api.Group;
+
+import javax.naming.InitialContext;
+import javax.naming.Context;
+import java.util.logging.Logger;
+
+public class SimplePopulationService
+{
+
+ private static Logger logger =
Logger.getLogger(SimplePopulationService.class.getName());
+
+ private String idmSessionFactoryJNDI = "java:/IdentitySessionFactory";
+
+ public String getIdmSessionFactoryJNDI()
+ {
+ return idmSessionFactoryJNDI;
+ }
+
+ public void setIdmSessionFactoryJNDI(String idmSessionFactoryJNDI)
+ {
+ this.idmSessionFactoryJNDI = idmSessionFactoryJNDI;
+ }
+
+ public void start() throws Exception
+ {
+
+ logger.fine("Starting example population service");
+
+ Context ctx = new InitialContext();
+ IdentitySessionFactory ids =
(IdentitySessionFactory)ctx.lookup(getIdmSessionFactoryJNDI());
+
+ IdentitySession is =
ids.getCurrentIdentitySession("realm://JBossIdentity");
+ is.beginTransaction();
+
+ if (is.getPersistenceManager().getUserCount() == 0 &&
is.getPersistenceManager().getGroupTypeCount("GROUP") == 0)
+ {
+ logger.fine("Database content not present. Populating...");
+
+
+ User userUser = is.getPersistenceManager().createUser("user");
+ User adminUser = is.getPersistenceManager().createUser("admin");
+ Group userGroup = is.getPersistenceManager().createGroup("Users",
"GROUP");
+ Group adminGroup =
is.getPersistenceManager().createGroup("Administrators", "GROUP");
+
+ is.getAttributesManager().updatePassword(userUser, "user");
+ is.getAttributesManager().updatePassword(adminUser, "admin");
+
+ is.getRelationshipManager().associateUser(adminGroup, adminUser);
+ is.getRelationshipManager().associateUser(userGroup, adminUser);
+ is.getRelationshipManager().associateUser(userGroup, userUser);
+
+ }
+
+
+ is.getTransaction().commit();
+
+
+
+ }
+}
Modified:
idm/trunk/example/auth/src/main/resources/META-INF/idm-example-auth-jboss-beans.xml
===================================================================
---
idm/trunk/example/auth/src/main/resources/META-INF/idm-example-auth-jboss-beans.xml 2009-11-13
09:58:22 UTC (rev 937)
+++
idm/trunk/example/auth/src/main/resources/META-INF/idm-example-auth-jboss-beans.xml 2009-11-13
11:00:24 UTC (rev 938)
@@ -11,13 +11,18 @@
<parameter>jboss.idm.cfg.xml</parameter>
</constructor>
<property name="doChecking">true</property>
- <property name="setupLocation">setup.txt</property>
<property
name="idmSessionFactoryJNDI">java:/IdentitySessionFactory</property>
<property
name="hibernateSessionFactoryRegistryName">hibernateSessionFactory</property>
- <property
name="hibernateConfigLocation">jboss.idm.hibernate.cfg.xml</property>
+ <property
name="hibernateConfigLocation">jboss.idm.hibernate.cfg.xml</property>
<depends>TransactionManager</depends>
</bean>
+ <bean name="IDMExamplePopulationService"
+
class="org.jboss.identity.idm.example.auth.SimplePopulationService">
+ <property
name="idmSessionFactoryJNDI">java:/IdentitySessionFactory</property>
+ <depends>idm.example.auth.IDMService</depends>
+ </bean>
+
<application-policy xmlns="urn:jboss:security-beans:1.0"
name="ExampleJBossIdentityIDMSecurityRealm">
<authentication>
<login-module code =
"org.jboss.identity.idm.auth.JBossIdentityIDMLoginModule"
Modified:
idm/trunk/example/auth/src/main/resources/idm-example-auth.war/protected/index.jsp
===================================================================
---
idm/trunk/example/auth/src/main/resources/idm-example-auth.war/protected/index.jsp 2009-11-13
09:58:22 UTC (rev 937)
+++
idm/trunk/example/auth/src/main/resources/idm-example-auth.war/protected/index.jsp 2009-11-13
11:00:24 UTC (rev 938)
@@ -41,7 +41,9 @@
out.println(group.getName());
}
+ is.getTransaction().commit();
+
}
catch (NamingException e)
{
Modified: idm/trunk/example/auth/src/main/resources/jboss.idm.hibernate.cfg.xml
===================================================================
--- idm/trunk/example/auth/src/main/resources/jboss.idm.hibernate.cfg.xml 2009-11-13
09:58:22 UTC (rev 937)
+++ idm/trunk/example/auth/src/main/resources/jboss.idm.hibernate.cfg.xml 2009-11-13
11:00:24 UTC (rev 938)
@@ -28,10 +28,13 @@
<hibernate-configuration>
<session-factory>
+ <property
name="hibernate.cache.provider_class">org.hibernate.cache.HashtableCacheProvider</property>
+
<property name="show_sql">false</property>
<property
name="cache.use_second_level_cache">true</property>
- <property name="cache.use_query_cache">false</property>
+ <property name="cache.use_query_cache">true</property>
+
<property
name="current_session_context_class">thread</property>
<property
name="hibernate.connection.url">jdbc:hsqldb:mem:jbossidm</property>
Modified: idm/trunk/integration/jboss5/pom.xml
===================================================================
--- idm/trunk/integration/jboss5/pom.xml 2009-11-13 09:58:22 UTC (rev 937)
+++ idm/trunk/integration/jboss5/pom.xml 2009-11-13 11:00:24 UTC (rev 938)
@@ -33,12 +33,6 @@
<artifactId>idm-ldap</artifactId>
<version>${version}</version>
</dependency>
- <dependency>
- <groupId>bsh</groupId>
- <artifactId>bsh</artifactId>
- <version>1.3.0</version>
- </dependency>
-
</dependencies>
<!-- Build -->