Author: jeff.yuchang
Date: 2009-06-19 06:04:09 -0400 (Fri, 19 Jun 2009)
New Revision: 619
Added:
idm/trunk/example/auth-simple/
idm/trunk/example/auth-simple/pom.xml
idm/trunk/example/auth-simple/src/
idm/trunk/example/auth-simple/src/main/
idm/trunk/example/auth-simple/src/main/java/
idm/trunk/example/auth-simple/src/main/resources/
idm/trunk/example/auth-simple/src/main/resources/idm-example-auth-assembly.xml
idm/trunk/example/auth-simple/src/main/resources/idm-example-auth.war/
idm/trunk/example/auth-simple/src/main/resources/idm-example-auth.war/WEB-INF/
idm/trunk/example/auth-simple/src/main/resources/idm-example-auth.war/WEB-INF/context.xml
idm/trunk/example/auth-simple/src/main/resources/idm-example-auth.war/WEB-INF/idm-auth-jboss-beans.xml
idm/trunk/example/auth-simple/src/main/resources/idm-example-auth.war/WEB-INF/jboss-web.xml
idm/trunk/example/auth-simple/src/main/resources/idm-example-auth.war/WEB-INF/web.xml
idm/trunk/example/auth-simple/src/main/resources/idm-example-auth.war/index.jsp
idm/trunk/example/auth-simple/src/main/resources/idm-example-auth.war/login.jsp
idm/trunk/example/auth-simple/src/main/resources/idm-example-auth.war/protected/
idm/trunk/example/auth-simple/src/main/resources/idm-example-auth.war/protected/index.jsp
idm/trunk/example/auth-simple/src/test/
idm/trunk/example/auth-simple/src/test/java/
idm/trunk/example/auth-simple/src/test/resources/
idm/trunk/integration/deployer/src/main/resources/setupdata.txt
Modified:
idm/trunk/integration/deployer/pom.xml
idm/trunk/integration/deployer/src/main/java/org/jboss/identity/idm/integration/jboss5/jaxb2/HibernateInitializerType.java
idm/trunk/integration/deployer/src/main/resources/META-INF/default-jboss-idm.xml
idm/trunk/integration/deployer/src/main/resources/deployer-assembly.xml
idm/trunk/integration/deployer/src/main/resources/identity-deployer.xsd
idm/trunk/integration/deployer/src/main/resources/idm-assembly.xml
idm/trunk/pom.xml
Log:
* Add the auth-simple example. (using the deployer mechanism, which means need to deploy
the war after the idm component)
* Adding the initialize data from the setupdata.txt. (Mainly the data for the auth
example)
Added: idm/trunk/example/auth-simple/pom.xml
===================================================================
--- idm/trunk/example/auth-simple/pom.xml (rev 0)
+++ idm/trunk/example/auth-simple/pom.xml 2009-06-19 10:04:09 UTC (rev 619)
@@ -0,0 +1,100 @@
+<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">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.jboss.identity.idm.example</groupId>
+ <version>1.0.0-SNAPSHOT</version>
+ <artifactId>example-auth-simple</artifactId>
+ <packaging>jar</packaging>
+ <name>Example - JEE authentication (using deployer)</name>
+ <description>Example maven2 project using JBoss Identity IDM
component.</description>
+ <licenses>
+ <license>
+ <name>lgpl</name>
+ <
url>http://repository.jboss.com/licenses/lgpl.txt</url>
+ </license>
+ </licenses>
+
+ <repositories>
+ <repository>
+ <id>repository.jboss.org</id>
+ <name>JBoss Repository</name>
+ <layout>default</layout>
+ <
url>http://repository.jboss.org/maven2/</url>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ </repository>
+
+ <repository>
+ <id>snapshots.jboss.org</id>
+ <name>JBoss Snapshots Repository</name>
+ <layout>default</layout>
+ <
url>http://snapshots.jboss.org/maven2/</url>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ <releases>
+ <enabled>false</enabled>
+ </releases>
+ </repository>
+ </repositories>
+
+ <pluginRepositories>
+ <pluginRepository>
+ <
id>java.net maven repository</id>
+ <
url>http://download.java.net/maven/2/</url>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ </pluginRepository>
+ </pluginRepositories>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <!--<version>2.4.3</version>-->
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <target>1.5</target>
+ <source>1.5</source>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <configuration>
+ <excludes>
+ <exclude>*</exclude>
+ </excludes>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>single</id>
+ <phase>package</phase>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ <configuration>
+ <finalName>idm-example-auth.war</finalName>
+ <appendAssemblyId>false</appendAssemblyId>
+ <ignoreDirFormatExtensions>true</ignoreDirFormatExtensions>
+ <descriptors>
+
<descriptor>src/main/resources/idm-example-auth-assembly.xml</descriptor>
+ </descriptors>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
Added: idm/trunk/example/auth-simple/src/main/resources/idm-example-auth-assembly.xml
===================================================================
--- idm/trunk/example/auth-simple/src/main/resources/idm-example-auth-assembly.xml
(rev 0)
+++
idm/trunk/example/auth-simple/src/main/resources/idm-example-auth-assembly.xml 2009-06-19
10:04:09 UTC (rev 619)
@@ -0,0 +1,15 @@
+<assembly
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/xsd/assembly-1.1.0-SNAPSHOT.xsd">
+ <id>config</id>
+ <formats>
+ <format>dir</format>
+ </formats>
+ <includeBaseDirectory>false</includeBaseDirectory>
+ <fileSets>
+ <fileSet>
+ <directory>src/main/resources/idm-example-auth.war</directory>
+ <outputDirectory>/</outputDirectory>
+ </fileSet>
+ </fileSets>
+
+</assembly>
\ No newline at end of file
Added:
idm/trunk/example/auth-simple/src/main/resources/idm-example-auth.war/WEB-INF/context.xml
===================================================================
---
idm/trunk/example/auth-simple/src/main/resources/idm-example-auth.war/WEB-INF/context.xml
(rev 0)
+++
idm/trunk/example/auth-simple/src/main/resources/idm-example-auth.war/WEB-INF/context.xml 2009-06-19
10:04:09 UTC (rev 619)
@@ -0,0 +1,4 @@
+<?xml version="1.0"?>
+<Context>
+
+</Context>
\ No newline at end of file
Added:
idm/trunk/example/auth-simple/src/main/resources/idm-example-auth.war/WEB-INF/idm-auth-jboss-beans.xml
===================================================================
---
idm/trunk/example/auth-simple/src/main/resources/idm-example-auth.war/WEB-INF/idm-auth-jboss-beans.xml
(rev 0)
+++
idm/trunk/example/auth-simple/src/main/resources/idm-example-auth.war/WEB-INF/idm-auth-jboss-beans.xml 2009-06-19
10:04:09 UTC (rev 619)
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <application-policy xmlns="urn:jboss:security-beans:1.0"
name="ExampleJBossIdentityIDMSecurityRealm">
+ <authentication>
+ <login-module code =
"org.jboss.identity.idm.auth.JBossIdentityIDMLoginModule"
+ flag = "required">
+ <module-option
name="identitySessionFactoryJNDIName">java:/IdentitySessionFactory</module-option>
+ <module-option
name="realmName">realm://JBossIdentity</module-option>
+ <module-option
name="roleGroupTypeName">GROUP</module-option>
+ <module-option
name="additionalRole">Authenticated</module-option>
+ <module-option
name="transactionAware">true</module-option>
+ </login-module>
+ </authentication>
+ </application-policy>
+
+</deployment>
Added:
idm/trunk/example/auth-simple/src/main/resources/idm-example-auth.war/WEB-INF/jboss-web.xml
===================================================================
---
idm/trunk/example/auth-simple/src/main/resources/idm-example-auth.war/WEB-INF/jboss-web.xml
(rev 0)
+++
idm/trunk/example/auth-simple/src/main/resources/idm-example-auth.war/WEB-INF/jboss-web.xml 2009-06-19
10:04:09 UTC (rev 619)
@@ -0,0 +1,9 @@
+<?xml version="1.0"?>
+
+<!DOCTYPE jboss-web PUBLIC
+ "-//JBoss//DTD Web Application 5.0//EN"
+ "http://www.jboss.org/j2ee/dtd/jboss-web_5_0.dtd">
+<jboss-web>
+ <security-domain>ExampleJBossIdentityIDMSecurityRealm</security-domain>
+ <context-root>idm-example-auth</context-root>
+</jboss-web>
\ No newline at end of file
Added:
idm/trunk/example/auth-simple/src/main/resources/idm-example-auth.war/WEB-INF/web.xml
===================================================================
--- idm/trunk/example/auth-simple/src/main/resources/idm-example-auth.war/WEB-INF/web.xml
(rev 0)
+++
idm/trunk/example/auth-simple/src/main/resources/idm-example-auth.war/WEB-INF/web.xml 2009-06-19
10:04:09 UTC (rev 619)
@@ -0,0 +1,29 @@
+<!DOCTYPE web-app PUBLIC
+ "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
+ "http://java.sun.com/dtd/web-app_2_3.dtd" >
+
+<web-app>
+ <display-name>Simple Secured Application</display-name>
+
+
+ <security-constraint>
+ <web-resource-collection>
+ <web-resource-name>Authenticated</web-resource-name>
+ <url-pattern>/protected/*</url-pattern>
+ </web-resource-collection>
+ <auth-constraint>
+ <role-name>Authenticated</role-name>
+ </auth-constraint>
+ </security-constraint>
+ <login-config>
+ <auth-method>FORM</auth-method>
+ <form-login-config>
+ <form-login-page>/login.jsp</form-login-page>
+ <form-error-page>/login.jsp</form-error-page>
+ </form-login-config>
+ </login-config>
+ <security-role>
+ <role-name>Authenticated</role-name>
+ </security-role>
+
+</web-app>
Added: idm/trunk/example/auth-simple/src/main/resources/idm-example-auth.war/index.jsp
===================================================================
--- idm/trunk/example/auth-simple/src/main/resources/idm-example-auth.war/index.jsp
(rev 0)
+++
idm/trunk/example/auth-simple/src/main/resources/idm-example-auth.war/index.jsp 2009-06-19
10:04:09 UTC (rev 619)
@@ -0,0 +1,31 @@
+<%@ page import="java.security.Principal" %>
+<html>
+<body>
+<h2>Hello World!</h2>
+<p>
+ Try to login with default users: user/user or admin/admin
+</p>
+<a href="./protected/">protected content</a>
+
+<%
+ String logout = request.getParameter("logout");
+ if (logout != null && logout.equals("true"))
+ {
+ request.getSession().invalidate();
+ }
+%>
+</br>
+<%
+ Principal principal = request.getUserPrincipal();
+ if (principal != null)
+ {
+%>
+Logged in user:
+<%
+ out.println(principal.getName());
+ }
+%>
+</br>
+<a href="./index.jsp?logout=true">Logout!</a>
+</body>
+</html>
Added: idm/trunk/example/auth-simple/src/main/resources/idm-example-auth.war/login.jsp
===================================================================
--- idm/trunk/example/auth-simple/src/main/resources/idm-example-auth.war/login.jsp
(rev 0)
+++
idm/trunk/example/auth-simple/src/main/resources/idm-example-auth.war/login.jsp 2009-06-19
10:04:09 UTC (rev 619)
@@ -0,0 +1,22 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html
xmlns="http://www.w3.org/1999/xhtml"
xmlns:fb="http://www.facebook.com/2008/fbml">
+<META HTTP-EQUIV = "Pragma" CONTENT="no-cache">
+<title>Security Login Page </title>
+<body>
+<h2>Form Login</h2>
+<FORM METHOD=POST ACTION="j_security_check">
+<p>
+<strong> Enter user ID and password: </strong>
+<BR>
+<strong> User ID</strong> <input type="text" size="20"
name="j_username">
+<strong> Password </strong> <input type="password"
size="20" name="j_password">
+<BR>
+<BR>
+<strong> And then click this button: </strong>
+<input type="submit" name="login" value="Login">
+</p>
+
+</form>
+</body>
+</html>
\ No newline at end of file
Added:
idm/trunk/example/auth-simple/src/main/resources/idm-example-auth.war/protected/index.jsp
===================================================================
---
idm/trunk/example/auth-simple/src/main/resources/idm-example-auth.war/protected/index.jsp
(rev 0)
+++
idm/trunk/example/auth-simple/src/main/resources/idm-example-auth.war/protected/index.jsp 2009-06-19
10:04:09 UTC (rev 619)
@@ -0,0 +1,62 @@
+<%@ page import="java.security.Principal" %>
+<%@ page import="javax.naming.Context" %>
+<%@ page import="javax.naming.InitialContext" %>
+<%@ page import="org.jboss.identity.idm.api.IdentitySessionFactory" %>
+<%@ page import="javax.naming.NamingException" %>
+<%@ page import="org.jboss.identity.idm.api.Group" %>
+<%@ page import="java.util.Collection" %>
+<%@ page import="org.jboss.identity.idm.api.IdentitySession" %>
+<%@ page import="javax.transaction.UserTransaction" %>
+<%@ page language="java" contentType="text/html; charset=utf-8"
+ pageEncoding="utf-8"%>
+<%@ page import="java.security.Principal" %>
+<html>
+<body>
+<h2>Protected page!</h2>
+</br>
+Secured content. Logged in user:
+<%
+ Principal principal = request.getUserPrincipal();
+ if (principal != null)
+ {
+ out.println(principal.getName());
+ }
+%>
+
+</br>
+</br>
+<%
+ Context ctx = new InitialContext();
+ try
+ {
+ IdentitySessionFactory ids =
(IdentitySessionFactory)ctx.lookup("java:/IdentitySessionFactory");
+ IdentitySession is =
ids.getCurrentIdentitySession("realm://JBossIdentity");
+
+ UserTransaction tx = (UserTransaction)ctx.lookup("UserTransaction");
+ tx.begin();
+
+ Collection<Group> groups =
is.getRelationshipManager().findAssociatedGroups(principal.getName(), "GROUP",
null);
+
+ out.println("Groups associated with user: ");
+
+ for (Group group : groups)
+ {
+ out.println(group.getName());
+ }
+
+ tx.commit();
+
+ }
+ catch (Exception e)
+ {
+ out.println("Failed to obtain IdentitySessionFactory: ");
+ e.printStackTrace();
+ }
+
+%>
+
+</br>
+</br>
+<a href="../index.jsp?logout=true">Logout!</a>
+</body>
+</html>
\ No newline at end of file
Modified: idm/trunk/integration/deployer/pom.xml
===================================================================
--- idm/trunk/integration/deployer/pom.xml 2009-06-19 05:39:27 UTC (rev 618)
+++ idm/trunk/integration/deployer/pom.xml 2009-06-19 10:04:09 UTC (rev 619)
@@ -38,6 +38,16 @@
<artifactId>idm-ldap</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.jboss.identity.idm</groupId>
+ <artifactId>idm-auth</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.identity.idm</groupId>
+ <artifactId>idm-cache</artifactId>
+ <version>${project.version}</version>
+ </dependency>
<dependency>
<groupId>org.jboss.identity.idm.integration</groupId>
<artifactId>idm-jboss5</artifactId>
@@ -101,7 +111,8 @@
<configuration>
<excludes>
<exclude>META-INF/*.xml</exclude>
- <exclude>**/*.xml</exclude>
+ <exclude>**/*.xml</exclude>
+ <exclude>**/*.txt</exclude>
</excludes>
</configuration>
</plugin>
Modified:
idm/trunk/integration/deployer/src/main/java/org/jboss/identity/idm/integration/jboss5/jaxb2/HibernateInitializerType.java
===================================================================
---
idm/trunk/integration/deployer/src/main/java/org/jboss/identity/idm/integration/jboss5/jaxb2/HibernateInitializerType.java 2009-06-19
05:39:27 UTC (rev 618)
+++
idm/trunk/integration/deployer/src/main/java/org/jboss/identity/idm/integration/jboss5/jaxb2/HibernateInitializerType.java 2009-06-19
10:04:09 UTC (rev 619)
@@ -26,8 +26,6 @@
* <sequence>
* <element name="doChecking"
type="{http://www.w3.org/2001/XMLSchema}boolean"/>
* <element name="setupLocation"
type="{http://www.w3.org/2001/XMLSchema}string"/>
- * <element name="hibernateSessionFactoryRegistryName"
type="{http://www.w3.org/2001/XMLSchema}string"/>
- * <element name="hibernateConfigLocation"
type="{http://www.w3.org/2001/XMLSchema}string"/>
* </sequence>
* </restriction>
* </complexContent>
@@ -39,19 +37,13 @@
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "hibernateInitializerType", propOrder = {
"doChecking",
- "setupLocation",
- "hibernateSessionFactoryRegistryName",
- "hibernateConfigLocation"
+ "setupLocation"
})
public class HibernateInitializerType {
protected boolean doChecking;
@XmlElement(required = true)
protected String setupLocation;
- @XmlElement(required = true)
- protected String hibernateSessionFactoryRegistryName;
- @XmlElement(required = true)
- protected String hibernateConfigLocation;
/**
* Gets the value of the doChecking property.
@@ -93,52 +85,4 @@
this.setupLocation = value;
}
- /**
- * Gets the value of the hibernateSessionFactoryRegistryName property.
- *
- * @return
- * possible object is
- * {@link String }
- *
- */
- public String getHibernateSessionFactoryRegistryName() {
- return hibernateSessionFactoryRegistryName;
- }
-
- /**
- * Sets the value of the hibernateSessionFactoryRegistryName property.
- *
- * @param value
- * allowed object is
- * {@link String }
- *
- */
- public void setHibernateSessionFactoryRegistryName(String value) {
- this.hibernateSessionFactoryRegistryName = value;
- }
-
- /**
- * Gets the value of the hibernateConfigLocation property.
- *
- * @return
- * possible object is
- * {@link String }
- *
- */
- public String getHibernateConfigLocation() {
- return hibernateConfigLocation;
- }
-
- /**
- * Sets the value of the hibernateConfigLocation property.
- *
- * @param value
- * allowed object is
- * {@link String }
- *
- */
- public void setHibernateConfigLocation(String value) {
- this.hibernateConfigLocation = value;
- }
-
}
Modified:
idm/trunk/integration/deployer/src/main/resources/META-INF/default-jboss-idm.xml
===================================================================
---
idm/trunk/integration/deployer/src/main/resources/META-INF/default-jboss-idm.xml 2009-06-19
05:39:27 UTC (rev 618)
+++
idm/trunk/integration/deployer/src/main/resources/META-INF/default-jboss-idm.xml 2009-06-19
10:04:09 UTC (rev 619)
@@ -10,9 +10,13 @@
</hibernateDeployer>
<initializers>
<datasource>java:/jbossidmDS</datasource>
- <sqlInitializer>
+ <!-- sqlInitializer>
<sqlFile>idm-sql/jboss.idm.@database@.create.sql</sqlFile>
<exitSQL>select * from jbid_io</exitSQL>
- </sqlInitializer>
+ </sqlInitializer-->
+ <hibernateInitializer>
+ <doChecking>true</doChecking>
+ <setupLocation>setupdata.txt</setupLocation>
+ </hibernateInitializer>
</initializers>
</jboss-idm-deployer>
Modified: idm/trunk/integration/deployer/src/main/resources/deployer-assembly.xml
===================================================================
--- idm/trunk/integration/deployer/src/main/resources/deployer-assembly.xml 2009-06-19
05:39:27 UTC (rev 618)
+++ idm/trunk/integration/deployer/src/main/resources/deployer-assembly.xml 2009-06-19
10:04:09 UTC (rev 619)
@@ -28,6 +28,8 @@
<include>org.jboss.identity.idm:idm-api</include>
<include>org.jboss.identity.idm:idm-common</include>
<include>org.jboss.identity.idm:idm-spi</include>
+ <include>org.jboss.identity.idm:idm-auth</include>
+ <include>org.jboss.identity.idm:idm-cache</include>
</includes>
</dependencySet>
</dependencySets>
Modified: idm/trunk/integration/deployer/src/main/resources/identity-deployer.xsd
===================================================================
--- idm/trunk/integration/deployer/src/main/resources/identity-deployer.xsd 2009-06-19
05:39:27 UTC (rev 618)
+++ idm/trunk/integration/deployer/src/main/resources/identity-deployer.xsd 2009-06-19
10:04:09 UTC (rev 619)
@@ -38,8 +38,6 @@
<xs:sequence>
<xs:element name="doChecking" type="xs:boolean" />
<xs:element name="setupLocation" type="xs:string" />
- <xs:element name="hibernateSessionFactoryRegistryName"
type="xs:string" />
- <xs:element name="hibernateConfigLocation" type="xs:string"
/>
</xs:sequence>
</xs:complexType>
Modified: idm/trunk/integration/deployer/src/main/resources/idm-assembly.xml
===================================================================
--- idm/trunk/integration/deployer/src/main/resources/idm-assembly.xml 2009-06-19 05:39:27
UTC (rev 618)
+++ idm/trunk/integration/deployer/src/main/resources/idm-assembly.xml 2009-06-19 10:04:09
UTC (rev 619)
@@ -14,6 +14,7 @@
<include>jboss.idm.hibernate.cfg.xml</include>
<include>META-INF/default-jboss-idm.xml</include>
<include>META-INF/jboss-dependency.xml</include>
+ <include>setupdata.txt</include>
</includes>
</fileSet>
</fileSets>
Added: idm/trunk/integration/deployer/src/main/resources/setupdata.txt
===================================================================
--- idm/trunk/integration/deployer/src/main/resources/setupdata.txt
(rev 0)
+++ idm/trunk/integration/deployer/src/main/resources/setupdata.txt 2009-06-19 10:04:09
UTC (rev 619)
@@ -0,0 +1,77 @@
+import
org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectRelationshipType;
+import org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObject;
+import org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectType;
+import org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectRelationship;
+import
org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectCredentialType;
+import org.jboss.identity.idm.impl.model.hibernate.HibernateIdentityObjectCredential;
+import org.jboss.identity.idm.impl.model.hibernate.HibernateRealm;
+import org.jboss.identity.idm.impl.api.PasswordCredential;
+
+
+try
+{
+ session = SessionFactory.openSession();
+ tx = session.beginTransaction();
+
+ HibernateRealm realm = new HibernateRealm("realm://JBossIdentity");
+ session.save(realm);
+
+ HibernateIdentityObjectType typeUser = new
HibernateIdentityObjectType("USER");
+ HibernateIdentityObjectType typeGroup = new
HibernateIdentityObjectType("GROUP");
+
+ session.save(typeUser);
+ session.save(typeGroup);
+
+ HibernateIdentityObject userUserObject = new HibernateIdentityObject("user",
typeUser, realm);
+ HibernateIdentityObject userGroupObject = new
HibernateIdentityObject("User", typeGroup, realm);
+ HibernateIdentityObject adminUserObject = new
HibernateIdentityObject("admin", typeUser, realm);
+ HibernateIdentityObject adminGroupObject = new
HibernateIdentityObject("Admin", typeGroup, realm);
+
+ session.save(userUserObject);
+ session.save(userGroupObject);
+ session.save(adminUserObject);
+ session.save(adminGroupObject);
+
+ HibernateIdentityObjectCredentialType passwordType = new
HibernateIdentityObjectCredentialType("PASSWORD");
+
+ session.save(passwordType);
+
+ HibernateIdentityObjectCredential pass1 = new HibernateIdentityObjectCredential();
+ PasswordCredential passwordValue = new PasswordCredential("user");
+ pass1.setType(passwordType);
+ pass1.setTextValue(passwordValue.getEncodedValue().toString());
+ userUserObject.addCredential(pass1);
+
+ session.save(pass1);
+
+ HibernateIdentityObjectCredential pass2 = new HibernateIdentityObjectCredential();
+ passwordValue = new PasswordCredential("admin");
+ pass2.setType(passwordType);
+ pass2.setTextValue(passwordValue.getEncodedValue().toString());
+ adminUserObject.addCredential(pass2);
+
+
+ session.save(pass2);
+
+ HibernateIdentityObjectRelationshipType membership = new
HibernateIdentityObjectRelationshipType("JBOSS_IDENTITY_MEMBERSHIP");
+
+ session.save(membership);
+
+ HibernateIdentityObjectRelationship rel1 = new
HibernateIdentityObjectRelationship(membership, adminGroupObject, adminUserObject);
+ HibernateIdentityObjectRelationship rel2 = new
HibernateIdentityObjectRelationship(membership, userGroupObject, adminUserObject);
+ HibernateIdentityObjectRelationship rel3 = new
HibernateIdentityObjectRelationship(membership, userGroupObject, userUserObject);
+
+ session.save(rel1);
+ session.save(rel2);
+ session.save(rel3);
+
+ session.flush();
+
+ tx.commit();
+}
+finally
+{
+ if (session != null) {
+ session.close();
+ }
+}
Modified: idm/trunk/pom.xml
===================================================================
--- idm/trunk/pom.xml 2009-06-19 05:39:27 UTC (rev 618)
+++ idm/trunk/pom.xml 2009-06-19 10:04:09 UTC (rev 619)
@@ -28,6 +28,7 @@
<module>integration</module>
<module>example/simple</module>
<module>example/auth</module>
+ <module>example/auth-simple</module>
</modules>
<profiles>