Chapter 13. Needed files

Although the best way to start playing with the framework is to look at Maven2 sample project mentioned above lets list minimal set of configuration files. To setup the basic framework core depending on hibernate IdentityStore two files will be needed

idm-config.xml - that will set proper configuration for all framework components described in section above. Sample one below.

              
<?xml version="1.0" encoding="UTF-8"?>
<jboss-identity xmlns="urn:picketlink:idm:config:v1_0_0_ga"
                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                xsi:schemaLocation="urn:picketlink:idm:config:v1_0_0_ga identity-config.xsd">
    <realms>
        <realm>
            <id>realm://JBossIdentityExample/SampleRealm</id>
            <repository-id-ref>Sample Repository</repository-id-ref>
            <identity-type-mappings>
                <user-mapping>USER</user-mapping>
            </identity-type-mappings>
        </realm>
    </realms>
    <repositories>
        <repository>
            <id>Sample Repository</id>
            <class>org.picketlink.idm.impl.repository.WrapperIdentityStoreRepository</class>
            <external-config/>
            <default-identity-store-id>Sample DB Store</default-identity-store-id>
            <default-attribute-store-id>Sample DB Store</default-attribute-store-id>
        </repository>
    </repositories>
    <stores>
        <attribute-stores/>
        <identity-stores>
            <identity-store>
                <id>Sample DB Store</id>
                <class>org.picketlink.idm.impl.store.hibernate.HibernateIdentityStoreImpl</class>
                <external-config/>
                <supported-relationship-types>
                    <relationship-type>JBOSS_IDENTITY_MEMBERSHIP</relationship-type>
                    <relationship-type>JBOSS_IDENTITY_ROLE</relationship-type>
                </supported-relationship-types>
                <supported-identity-object-types>
                    <identity-object-type>
                        <name>USER</name>
                        <relationships>
                            <relationship>
                                <relationship-type-ref>JBOSS_IDENTITY_ROLE</relationship-type-ref>
                                <identity-object-type-ref>GROUP</identity-object-type-ref>
                            </relationship>
                        </relationships>
                        <credentials>
                            <credential-type>PASSWORD</credential-type>
                        </credentials>
                        <attributes>
                            <attribute>
                                <name>picture</name>
                                <mapping>user.picture</mapping>
                                <type>binary</type>
                                <isRequired>false</isRequired>
                                <isMultivalued>false</isMultivalued>
                                <isReadOnly>false</isReadOnly>
                            </attribute>
                        </attributes>
                        <options/>
                    </identity-object-type>
                    <identity-object-type>
                        <name>ORGANIZATION</name>
                        <relationships>
                            <relationship>
                                <relationship-type-ref>JBOSS_IDENTITY_ROLE</relationship-type-ref>
                                <identity-object-type-ref>USER</identity-object-type-ref>
                            </relationship>
                            <relationship>
                                <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
                                <identity-object-type-ref>USER</identity-object-type-ref>
                            </relationship>
                            <relationship>
                                <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
                                <identity-object-type-ref>GROUP</identity-object-type-ref>
                            </relationship>
                        </relationships>
                        <credentials/>
                        <attributes/>
                        <options/>
                    </identity-object-type>
                    <identity-object-type>
                        <name>GROUP</name>
                        <relationships>
                            <relationship>
                                <relationship-type-ref>JBOSS_IDENTITY_ROLE</relationship-type-ref>
                                <identity-object-type-ref>USER</identity-object-type-ref>
                            </relationship>
                            <relationship>
                                <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
                                <identity-object-type-ref>USER</identity-object-type-ref>
                            </relationship>
                            <relationship>
                                <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
                                <identity-object-type-ref>GROUP</identity-object-type-ref>
                            </relationship>
                        </relationships>
                        <credentials/>
                        <attributes/>
                        <options/>
                    </identity-object-type>
                </supported-identity-object-types>
                <options>
                    <option>
                        <name>hibernateConfiguration</name>
                        <value>hibernate-jboss-identity.cfg.xml</value>
                    </option>
                    <option>
                        <name>populateRelationshipTypes</name>
                        <value>true</value>
                    </option>
                    <option>
                        <name>populateIdentityObjectTypes</name>
                        <value>true</value>
                    </option>
                    <option>
                        <name>allowNotDefinedAttributes</name>
                        <value>true</value>
                    </option>
                    <option>
                        <name>isRealmAware</name>
                        <value>true</value>
                    </option>
                </options>
            </identity-store>
        </identity-stores>
    </stores>
</jboss-identity>
              
           

hibernate.cfg.xml - hibernate SessionFactory setup

              
<!DOCTYPE hibernate-configuration PUBLIC
   "-//Hibernate/Hibernate Configuration DTD//EN"
   "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
   <session-factory>


       <property name="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</property>

       <property name="show_sql">false</property>
       <property name="cache.use_second_level_cache">true</property>
       <property name="cache.use_query_cache">true</property>


       <property name="current_session_context_class">thread</property>

       <!--<property name="connection.datasource"></property>-->

       <property name="hibernate.connection.url">jdbc:hsqldb:mem:unit-testing-jpa1</property>
       <property name="hibernate.connection.driver_class">org.hsqldb.jdbcDriver</property>
       <property name="hibernate.dialect">org.hibernate.dialect.HSQLDialect</property>
       <property name="hibernate.hbm2ddl.auto">create-drop</property>
       <property name="hibernate.connection.username">sa</property>
       <property name="hibernate.connection.password"></property>

   </session-factory>
</hibernate-configuration>