JBoss.orgCommunity Documentation

PicketLink IDM

Reference Guide


Groups are entities that can contain other group or identity objects. They can be associated in a tree like organizational structures. Those don't need to be hierarchical only as single group can be a member of many other groups (can have many parents). Possible relationships between groups are shaped with group types. It can be configured which different group types can be associated or even which group types can or can not contain identity objects. Groups have unique names per group type. This means you can have two groups with the same name but different group type.

Roles are direct typed connections between Identity and Group objects. If you think about a sentence: "John is the Manager of XX Team" what matters is the context. So "John (Identity) is the Manager (RoleType) of XX Team (Group)". The whole sentence describes the Role that John has. This type of information is hard to map with typical Group object as John can be a manager of several different groups and other identities (Marry, Jack, Stan...) can have the same RoleType in context of different groups (XY Team, YY Team). Within each Realm (concept of Realms is described later) we can define several RoleType objects with unique names. Each Role defines a unique combination of Identity, Group and RoleType within Realm. Role concept is very powerful but its not natural in all identity store types. While quite easy to map in a relational database it doesn't fit into every LDAP tree present in organizations. Because of this Role support is optional in the API level

SPI Model contains following interfaces:

Model described above is very flexible as IdentityObjectType is able to map any kind of entities. Identity object and Group/GroupType objects are only one of many possible options (API is a subset of SPI possibilities). IdentityObjectRelationship defines a connection between any two IdentityObject objects. Each IdentityObjectRelationship has a type. To map previously described API two IdentityObjectRelationshipType objects are needed. One to map normal MEMBERSHIP like between an Identity and a Group or Group and Group objects. Second one to map Role concept. For API Role - RoleType refers to the name of the IdentityObjectRelationship. In default Hibernate implementation possible names of IdentityObjectRelationship are kept in a separate table. All of those can be easily redefined to support different kind of API.

The most important part of architecture is a split between the API and the SPI.

API part contains of following interfaces:

SPI part contains of following interfaces

Roles are direct typed connections between Identity and Group objects. If you think about a sentence: "John is the Manager of XX Team" what matters is the context. So "John (Identity) is the Manager (RoleType) of XX Team (Group)". The whole sentence describes the Role that John has. This type of information is hard to map with typical Group object as John can be a manager of several different groups and other identities (Marry, Jack, Stan...) can have the same RoleType in context of different groups (XY Team, YY Team). Within each Realm (concept of Realms is described later) we can define several RoleType objects with unique names. Each Role defines a unique combination of Identity, Group and RoleType within Realm.

Roles are managed with RoleManager interface:

RoleManager roleManager = identitySession.getRoleManager();

roleManager.createRoleType("manager");
RoleType adminRT = roleManager.createRoleType("administrator");

Role role1 = roleManager.createRole("manager", annUser.getId(), parisOffice.getId());
roleManager.createRole(adminRT, stefanUser, itDep);

assertTrue(roleManager.hasRole(stefanUser, itDep, adminRT));
                
            

At the SPI level the main difference between plain association is that IdentityObjectRelationship has a IdentityObjectRelationshipName which is simple mapping of a RoleType used in the API

What is important to note about the Role concept is that it is not natural in all kinds of identity stores. Entities represented on attached figures are easy to map in the database. However in store like LDAP typical relationships are represanted in a more plain manner. For example:

                
dn: uid=admin,ou=People,o=test,dc=portal,dc=example,dc=com
objectclass: top
objectclass: inetOrgPerson
objectclass: person
uid: admin
cn: Java Duke
sn: Duke
userPassword: admin
mail: email@email.com

dn: cn=Administrators,ou=Groups,o=test,dc=portal,dc=example,dc=com
objectClass: top
objectClass: groupOfNames
cn: Administrators
description: Portal admin role
member: uid=admin,ou=People,o=test,dc=portal,dc=example,dc=com
                
            

The whole relationship between User "admin" and Group "Administrators" is described by one attribute value ("member"). In such typical LDAP tree shape there is no place to store additional information that are needed to describe Role shown above. Obviously it is possible to shape LDAP tree in a way that will allow such a mapping but in most cases it is not possible to redesign already used LDAP server tree.

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>
              
           

This part is represented by <stores><identity-store>... element

                
<stores>
   <attribute-stores/>
   <identity-stores>
      <identity-store> ... </identity-store>
      <identity-store> ... </identity-store>
   </identity-stores>
 </stores>
            
            
                
<identity-store>
   <id>Sample Hibernate 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>
      ...
      </identity-object-type>

      ...


      <identity-object-type>
      ...
      </identity-object-type>
   </supported-identity-object-types>
   <options>
      <option>
         <name>persistenceUnit</name>
         <value>jboss-identity-model-xxx</value>
      </option>
      <option>
         <name>otherOption</name>
         <value>value1</value>
         <value>value2</value>
         <value>value3</value>
      </option>
   </options>
</identity-store>
            
            

<identity-store> element:

                
<supported-identity-object-types>
   <identity-object-type>
      <name>OFFICE</name>
      <relationships>
         <relationship>
            <relationship-type-ref>
               JBOSS_IDENTITY_MEMBERSHIP
            </relationship-type-ref>
            <identity-object-type-ref>
               IDENTITY
            </identity-object-type-ref>
         </relationship>
         <relationship>
            <relationship-type-ref>
               JBOSS_IDENTITY_MEMBERSHIP
            </relationship-type-ref>
            <identity-object-type-ref>
               CONFERENCE_ROOM
            </identity-object-type-ref>
         </relationship>
      </relationships>
      <credentials/>
      <attributes/>
      <options/>
   </identity-object-type>

   <identity-object-type>
      <name>IDENTITY</name>
      <relationships>
         <relationship>
            <relationship-type-ref>
               JBOSS_IDENTITY_ROLE
            </relationship-type-ref>
            <identity-object-type-ref>
               COMMUNITY
            </identity-object-type-ref>
         </relationship>
      </relationships>
      <credentials>
         <credential-type>PASSWORD</credential-type>
         <credential-type>BINARY</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>
   </identity-object-type>
</supported-identity-object-types>
            

            

<identity-object-type> element:

This section is represented by <repositories><repository> element

                
<repositories>

   <repository>
      <id>X</id>
      <class>
         org.picketlink.idm.impl.repository.WrapperIdentityStoreRepository
      </class>
      <external-config/>
      <default-identity-store-id>
         Hibernate Identity Store
      </default-identity-store-id>
      <default-attribute-store-id>
         Hibernate Identity Store
      </default-attribute-store-id>
      <options>
   </repository>

   <repository>
      <id>Y</id>
      <class>
         org.picketlink.idm.impl.repository.FallbackIdentityStoreRepository
      </class>
      <external-config/>
      <default-identity-store-id>
         Hibernate Identity Store
      </default-identity-store-id>
      <default-attribute-store-id>
         Hibernate Identity Store
      </default-attribute-store-id>
      <identity-store-mappings>
         <identity-store-mapping>
            <identity-store-id>
               Hibernate Identity Store
            </identity-store-id>
            <identity-object-types>
               <identity-object-type>
                 PROJECT
               </identity-object-type>
               <identity-object-type>
                 PEOPLE
               </identity-object-type>
             </identity-object-types>
             <options/>
         </identity-store-mapping>
         <identity-store-mapping>
            <identity-store-id>
               LDAP Identity Store
            </identity-store-id>
            <identity-object-types>
               <identity-object-type>
                  IDENTITY
               </identity-object-type>
               <identity-object-type>
                  ORGANIZATION
               </identity-object-type>
            </identity-object-types>
            <options/>
         </identity-store-mapping>
      </identity-store-mappings>
      <options/>
   </repository>

</repositories>
            

            

<repository> element contains:

                    
<identity-store>
  <id>Hibernate Identity 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>IDENTITY</name>
      <relationships/>
      <credentials>
        <credential-type>PASSWORD</credential-type>
      </credentials>
        <attributes>
          <attribute>
            <name>user.name.given</name>
            <mapping>user.name.given</mapping>
            <type>text</type>
            <isRequired>false</isRequired>
            <isMultivalued>false</isMultivalued>
            <isReadOnly>false</isReadOnly>
          </attribute>
          <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_MEMBERSHIP</relationship-type-ref>
            <identity-object-type-ref>IDENTITY</identity-object-type-ref>
          </relationship>
          <relationship>
            <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
            <identity-object-type-ref>ORGANIZATION</identity-object-type-ref>
          </relationship>
          <relationship>
            <relationship-type-ref>JBOSS_IDENTITY_ROLE</relationship-type-ref>
            <identity-object-type-ref>IDENTITY</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>
      <option>
        <name>allowNotDefinedAttributes</name>
        <value>true</value>
      </option>
    </options>
  </identity-store>
                            
                

In case 'addHibernateMappings' option is not set to true hibernate configuration need to list all annotated model classes:

                    
<mapping resource="mappings/HibernateRealm.hbm.xml"/>
<mapping resource="mappings/HibernateIdentityObjectCredentialBinaryValue.hbm.xml"/>
<mapping resource="mappings/HibernateIdentityObjectAttributeBinaryValue.hbm.xml"/>
<mapping resource="mappings/HibernateIdentityObject.hbm.xml"/>
<mapping resource="mappings/HibernateIdentityObjectCredential.hbm.xml"/>
<mapping resource="mappings/HibernateIdentityObjectCredentialType.hbm.xml"/>
<mapping resource="mappings/HibernateIdentityObjectAttribute.hbm.xml"/>
<mapping resource="mappings/HibernateIdentityObjectType.hbm.xml"/>
<mapping resource="mappings/HibernateIdentityObjectRelationship.hbm.xml"/>
<mapping resource="mappings/HibernateIdentityObjectRelationshipType.hbm.xml"/>
<mapping resource="mappings/HibernateIdentityObjectRelationshipName.hbm.xml"/>
                            
                

<identity-object-type><options>

<identity-store><options>

                    
<identity-store>
  <id>Sample LDAP Store</id>
  <class>org.picketlink.idm.impl.store.ldap.LDAPIdentityStoreImpl</class>
  <external-config/>
  <supported-relationship-types>
    <relationship-type>JBOSS_IDENTITY_MEMBERSHIP</relationship-type>
  </supported-relationship-types>
  <supported-identity-object-types>
    <identity-object-type>
      <name>IDENTITY</name>
      <relationships/>
      <credentials>
        <credential-type>PASSWORD</credential-type>
      </credentials>
      <attributes>
        <attribute>
          <name>phone</name>
          <mapping>telephoneNumber</mapping>
          <type>text</type>
          <isRequired>false</isRequired>
          <isMultivalued>false</isMultivalued>
          <isReadOnly>false</isReadOnly>
        </attribute>
          <attribute>
          <name>description</name>
          <mapping>description</mapping>
          <type>text</type>
          <isRequired>false</isRequired>
          <isMultivalued>false</isMultivalued>
          <isReadOnly>false</isReadOnly>
        </attribute>
        <attribute>
          <name>carLicense</name>
          <mapping>carLicense</mapping>
          <type>text</type>
          <isRequired>false</isRequired>
          <isMultivalued>false</isMultivalued>
          <isReadOnly>false</isReadOnly>
        </attribute>
      </attributes>
      <options>
        <option>
          <name>idAttributeName</name>
          <value>uid</value>
        </option>
        <option>
          <name>passwordAttributeName</name>
          <value>password</value>
        </option>
        <option>
          <name>ctxDNs</name>
          <value>ou=People,o=test,dc=example,dc=com</value>
        </option>
        <option>
          <name>allowCreateEntry</name>
          <value>true</value>
        </option>
        <option>
          <name>createEntryAttributeValues</name>
          <value>objectClass=top</value>
          <value>objectClass=inetOrgPerson</value>
          <value>sn= </value>
          <value>cn= </value>
        </option>
      </options>
    </identity-object-type>
    <identity-object-type>
      <name>ORGANIZATION</name>
      <relationships>
        <relationship>
          <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
          <identity-object-type-ref>IDENTITY</identity-object-type-ref>
        </relationship>
        <relationship>
          <relationship-type-ref>JBOSS_IDENTITY_MEMBERSHIP</relationship-type-ref>
          <identity-object-type-ref>ORGANIZATION</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>
        <option>
          <name>idAttributeName</name>
          <value>cn</value>
        </option>
        <option>
          <name>ctxDNs</name>
          <value>ou=Organizations,o=test,dc=example,dc=com</value>
        </option>
        <option>
          <name>allowCreateEntry</name>
          <value>true</value>
        </option>
        <option>
          <name>membershipAttributeName</name>
          <value>member</value>
        </option>
        <option>
          <name>isMembershipAttributeDN</name>
          <value>true</value>
        </option>
        <option>
          <name>allowEmptyMemberships</name>
          <value>true</value>
        </option>
        <option>
          <name>createEntryAttributeValues</name>
          <value>objectClass=top</value>
          <value>objectClass=groupOfNames</value>
        </option>
      </options>
    </identity-object-type>
  </supported-identity-object-types>
  <options>
    <option>
      <name>providerURL</name>
      <value>ldap://localhost:10389</value>
    </option>
    <option>
      <name>adminDN</name>
      <value>cn=Directory Manager</value>
    </option>
    <option>
      <name>adminPassword</name>
      <value>password</value>
    </option>
    <option>
      <name>searchTimeLimit</name>
      <value>10000</value>
    </option>
  </options>
</identity-store>
                            
                

The main role of configuration is to define relationship between separate framework components. It also enables to specify a lot of meta data information describing possible connections between IdentityObject types. It is however possible to not define all those meta data information and let the framework to be maximum permissive about allowed operations and lazily create not defined types:

             
<?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://FlexibleRealm</id>
         <repository-id-ref>Flexible Repo</repository-id-ref>
         <identity-type-mappings>
            <user-mapping>USER</user-mapping>
         </identity-type-mappings>
      </realm>
   </realms>
   <repositories>
      <repository>
         <id>Flexible Repo</id>
         <class>org.picketlink.idm.impl.repository.WrapperIdentityStoreRepository</class>
         <external-config/>
         <default-identity-store-id>Hibernate Identity Store</default-identity-store-id>
         <default-attribute-store-id>Hibernate Identity Store</default-attribute-store-id>
         <options>
            <option>
               <name>allowNotDefinedAttributes</name>
               <value>true</value>
            </option>
            <option>
               <name>allowNotDefinedIdentityObjectTypes</name>
               <value>true</value>
            </option>
         </options>
      </repository>
   </repositories>
   <stores>
      <attribute-stores/>
      <identity-stores>
         <identity-store>
            <id>Hibernate Identity 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/>
            <options>
               <option>
                  <name>hibernateSessionFactoryJNDIName</name>
                  <value>java:/jbossidentity/HibernateStoreSessionFactory</value>
               </option>
               <option>
                  <name>populateRelationshipTypes</name>
                  <value>true</value>
               </option>
               <option>
                  <name>populateIdentityObjectTypes</name>
                  <value>true</value>
               </option>
               <option>
                  <name>isRealmAware</name>
                  <value>true</value>
               </option>
               <option>
                  <name>allowNotDefinedAttributes</name>
                  <value>true</value>
               </option>
               <option>
                  <name>allowNotDefinedIdentityObjectTypes</name>
                  <value>true</value>
               </option>
            </options>
         </identity-store>
      </identity-stores>
   </stores>
</jboss-identity>
             
          

On the API level each IdentityType object (Identity and Group) can have associated Attribute objects. All operations are exposed by AttributesManager interface. Each attribute is described with AttributeDescription that contains its properties such as:

  • name - attribute name

  • readonly - if attribute values can be changed

  • multivalued - if attribute can have many values

  • required - if attribute can be removed

  • type - type of attribute values.

Default implementation provides two attribute types:

  • text - java.lang.String object

  • binary - byte[] object

API contains Credential and CredentialType interfaces. CredentialType defines type of credential object. Default implementation supports two types:

Two basic implementations are provided:

Because credentials values are stored as hash or in other encoded form both SPI and API only enables to update and validate credential value and not to read it from persistence store. API enables to only protect Identity objects with credentials. All related management operations are exposed in AttributesManager interface.



User anotherOne = session.getPersistenceManager().createUser("blah1");

session.getAttributesManager().updatePassword(anotherOne, "Password2000");
assertTrue(session.getAttributesManager().validatePassword(anotherOne, "Password2000"));

Credential password = new PasswordCredential("SuperPassword2345");
session.getAttributesManager().updateCredential(anotherOne, password);
assertTrue(session.getAttributesManager().validateCredentials(anotherOne, new Credential[]{password}));

// binary credential
byte[] cert = new byte[512000];
random.nextBytes(cert);
Credential binaryCredential = new BinaryCredential(cert);
session.getAttributesManager().updateCredential(anotherOne, binaryCredential);
assertTrue(session.getAttributesManager().validateCredentials(anotherOne, new Credential[]{binaryCredential}));

            

Now, lets look at the second case, by deploying the idm into the JBoss AS 5. By doing this different services can share the identity component, instead of having its own seperate identity component.

The jobs that need to be done for the deployment in the container is quite simple:

Before we look at it further, lets see the configuration files that jboss idm needed typically. (Say using db back-end, hibernate impl combination)

With regard to the detail of jboss idm configuration file, you can refer to the configuration documentation.

So, if we want to deploy the idm into container with a specified JNDI name, we need to have a deployment file to define the JNDI and other neccessary properties.

For the integration with JBoss AS5, the AS5 has a great deployment feature, we've built our own deployer to extend it, so that the AS can listen on the -jboss-idm.xml suffix file to start the IdentitySessionFactory.

Basically, we had two deployer, one is: IDMConfigParsingDeployer class, which is taking responsible for parsing files that ends with the -jboss-idm.xml suffix into Java object. The other is: IDMDeployer class, this one is to do the real job, which means it might populate the schema, initial dataset into target db, and then start the IdentitySessionFactory, register it into the JNDI with the specified name at last.

We will see a very typical deployment file looks like. (default-jboss-idm.xml)

            
<?xml version="1.0" encoding="UTF-8"?>
<jboss-idm-deployer xmlns="urn:jboss:identity:idm:deployer:v1_0_alpha"
                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                xsi:schemaLocation="urn:jboss:identity:idm:deployer:v1_0_alpha identity-deployer.xsd">
    <JNDIName>java:/IdentitySessionFactory</JNDIName>
    <idmConfigFile>jboss.idm.cfg.xml</idmConfigFile>
    <hibernateDeployer>
     <hibernateConfiguration>jboss.idm.hibernate.cfg.xml</hibernateConfiguration>
<hibernateSessionFactoryJNDIName>java:/IDMHibernateSessionFactory</hibernateSessionFactoryJNDIName>
    </hibernateDeployer>
    <initializers>
        <datasource>java:/jbossidmDS</datasource>
        <sqlInitializer>
            <sqlFile>idm-sql/jboss.idm.@database@.create.sql</sqlFile>
            <exitSQL>select * from jbid_io</exitSQL>
        </sqlInitializer>
    </initializers>
</jboss-idm-deployer>
            
         

detailed information about the deployment file is specified in the identity-deployer.xsd file.

Once you've deployed the idm into JBoss AS5, by using the distribution. It will copy the idm-deployer into the JBoss AS5/server/$config/deployers folder, and the idm folder into the JBoss AS5/server/$config/deploy folder, which contains the default configuration files, like the jboss.idm.cfg.xml, idm-ds.xml etc.