2 Replies Latest reply on Apr 8, 2010 10:16 PM by Michal Petrik

    Implementing own identity store using injection of built in identity stores

    Michal Petrik Newbie

      Hi,
      I'm newbie to Seam and I'm trying to implement this scenario. I have two data stores. One relational database (JpaIdentityStore) for storing application data and also for storing usernames of registered users in my application, but some of them should be authenticated against existing LDAP store (LDAPIdentityStore). I like the features of built-in identity management so in relation to this post: SeamIdentityManagementAndMultipleIdentityStores, I tried to implement my own identity store where these two built-in components should be injected. But I can't get it work. Binding the own implementation of IdentityStore works ok, but unfortunately injection of built-in identity stores doesn't work and injected values are always null.


      Here is code:


      implementation of identity store:




      @Name("hIdentityStore")
      @Install(precedence=Install.APPLICATION)
      @Scope(APPLICATION)
      @BypassInterceptors
      public class HIdentityStore implements IdentityStore, Serializable {
           private static final long serialVersionUID = 3949155281870688263L;
           @In
           LdapIdentityStore ldapUsermap;
           @In
           JpaIdentityStore hJpaDataStore;
           protected FeatureSet featureSet;
           @Create
           public void init() {
                if (featureSet == null) {
                     featureSet = new FeatureSet();
                     featureSet.enableAll();
                }
           }
      
      // continues with implementation of identity store methods



      and in components.xml I have:




      <persistence:managed-persistence-context
                name="entityManager" 
                      auto-create="true" 
                      persistence-unit-jndi-name="@puJndiName@" />
      
      <security:jpa-identity-store 
                name="hJpaDataStore"
                user-class="cz.cvut.fit.hsas.data.User"
                role-class="cz.cvut.fit.hsas.data.Role"/>
        
      <security:ldap-identity-store name="ldapUsermap"
                                    server-address="localhost"
                               server-port="10389"
                                     bind-DN="uid=admin,ou=system"
                               bind-credentials="secret"
                               user-DN-prefix="uid="
                               user-DN-suffix=",ou=people,ou=usermap,o=cvut,c=cz"
                               user-context-DN="ou=people,ou=usermap,o=cvut,c=cz" 
                               user-name-attribute="cvutloginname"
                               user-password-attribute="userpassword"
                               full-name-attribute="cn"
                               first-name-attribute="givenname"
                               last-name-attribute="sn"                   />
      
      <security:identity-manager identity-store="#{hIdentityStore}" 
                                 startupDepends="hJpaDataStore,ldapUsermap"/>



      I'm confused that I even get no warning that LdapIdentityStore and JpaIdentityStore aren't injected because according to documentation I suppose when I annotate some component with @In, the required attribute should be implicitly set to true.


      Thanks for reply...


      Michal