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

    Custom Identity Store

    dubreuia

      Hi,


      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?
      Thanks.


      LdapRadarIdentityStore ldapIdentityStore = (LdapRadarIdentityStore) identityManager
                          .getIdentityStore();
      



      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
          waynebagguley

          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
            dubreuia

            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
              dubreuia

              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>
                              <etc>...</etc>
                   </component>
              


              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


                   <security:identity-manager
                        identity-store="#{ldapRadarIdentityStore}"
                        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
                carolinofr

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