4 Replies Latest reply on Mar 16, 2011 10:29 AM by Fabricio Carolino

    Custom Identity Store

    Alexandre Dubreuil Newbie


      I have created a custom identity store, which extends the LdapIdentityStore from Seam. I only need to create one method, so I don't need to implement all the IdentityStore interface.

      Then I configure my components.xml to have my IdentityStore used instead of the LdapIdentityStore from Seam. But when I retrieve my custom LdapIdentityStore from the IdentityManager (with identityManager.getIdentityStore();), I cannot cast it to LdapRadarIdentityStore, my custom IdentityStore class implementation.

      The cast to LdapIdentityStore works though... Seems like my custom implementation is not instanciated correctly.

      Any idea?

      LdapRadarIdentityStore ldapIdentityStore = (LdapRadarIdentityStore) identityManager

      In components.xml

           <security:identity-manager identity-store="#{ldapRadarIdentityStore}"
                role-identity-store="#{ldapRadarIdentityStore}" />

      The stack

      Caused by: java.lang.ClassCastException: org.jboss.seam.security.management.LdapIdentityStore
           at com.cgi.sae.radar.session.security.JpaLdapUserRepository.authenticate(JpaLdapUserRepository.java:54)
           at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
           at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
           at java.lang.reflect.Method.invoke(Method.java:585)
           at org.jboss.seam.util.Reflections.invoke(Reflections.java:22)

        • 1. Re: Custom Identity Store
          Wayne Bagguley Newbie

          My guess is that you have to specify what class to use, e.g.

          <security:ldap-identity-store class="com.etc.etc.LdapRadarIdentityStore">

          Or something similar.

          • 2. Re: Custom Identity Store
            Alexandre Dubreuil Newbie

            Yeah, I though about it, but without an EL, there's an error when I launch the server; the class cannot be found. With an EL, there is no reason to explicitly write the full qualified name, since it is defined with the @Name annotation on the class itself.

            I tried some combination but nothing works. The strange thing is that I can cast it to LdapIdentityStore, but not my custom store. That mean the EL is working properly and that Seam find its LdapIdentityStore (it would use JpaIdentityStore if this was not true)...

            Another idea?

            • 3. Re: Custom Identity Store
              Alexandre Dubreuil Newbie

              Okay, found it. Here's how to do it. Make a new component in components.xml, like

                   <component name="ldapRadarIdentityStore"
                        class="com.etc.etc.etc.entity.LdapRadarIdentityStore" startup="true"
                        scope="APPLICATION" >
                        <property name="serverAddress">saew0050</property>

              and delete annotations on your class (your class that should extend the LdapIdentityStore).

              It seems like using the security:ldap-identity... in the .xml would override the

                        role-identity-store="#{ldapRadarIdentityStore}" />

              code, which is pretty logical, so make sure you deleted that part too. The component's properties will do the job.

              Be careful to avoid putting the class (your custom-ldap-anything-stuff) in a hotredeploy folder (thrust me, it doesn't work), since you cannot define a hotredeploy component inside components.xml.

              That's it. Hopes it helps.

              • 4. Re: Custom Identity Store
                Fabricio Carolino Newbie

                and how you passed the param for you class?
                you used the page.xml for passed?
                sorry for my english :(