[seam-commits] Seam SVN: r13296 - in modules/security/trunk/impl/src/main/java/org/jboss/seam/security: jaas and 3 other directories.

seam-commits at lists.jboss.org seam-commits at lists.jboss.org
Thu Jun 24 07:38:25 EDT 2010


Author: shane.bryzak at jboss.com
Date: 2010-06-24 07:38:23 -0400 (Thu, 24 Jun 2010)
New Revision: 13296

Removed:
   modules/security/trunk/impl/src/main/java/org/jboss/seam/security/PasswordCredential.java
Modified:
   modules/security/trunk/impl/src/main/java/org/jboss/seam/security/CredentialsImpl.java
   modules/security/trunk/impl/src/main/java/org/jboss/seam/security/IdentityImpl.java
   modules/security/trunk/impl/src/main/java/org/jboss/seam/security/jaas/SeamLoginModule.java
   modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/JpaIdentityStore.java
   modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/action/UserAction.java
   modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/picketlink/IdentitySessionProducer.java
Log:
use picketlink PasswordCredential implementation


Modified: modules/security/trunk/impl/src/main/java/org/jboss/seam/security/CredentialsImpl.java
===================================================================
--- modules/security/trunk/impl/src/main/java/org/jboss/seam/security/CredentialsImpl.java	2010-06-24 04:25:24 UTC (rev 13295)
+++ modules/security/trunk/impl/src/main/java/org/jboss/seam/security/CredentialsImpl.java	2010-06-24 11:38:23 UTC (rev 13296)
@@ -10,6 +10,7 @@
 import org.jboss.seam.security.events.CredentialsInitializedEvent;
 import org.jboss.seam.security.events.CredentialsUpdatedEvent;
 import org.picketlink.idm.api.Credential;
+import org.picketlink.idm.impl.api.PasswordCredential;
 
 /**
  * The default Credentials implementation.  This implementation allows for a
@@ -77,7 +78,7 @@
    public String getPassword()
    {
       return credential != null && credential instanceof PasswordCredential ? 
-            ((PasswordCredential) credential).getPassword() : null;
+            ((PasswordCredential) credential).getValue() : null;
    }
    
    public void setPassword(String password)
@@ -87,9 +88,9 @@
          this.credential = new PasswordCredential(password);
       }
       else if (this.credential != null && this.credential instanceof PasswordCredential &&
-            ((PasswordCredential) this.credential).getPassword() != password && 
-            ((PasswordCredential) this.credential).getPassword() == null || 
-            !((PasswordCredential) this.credential).getPassword().equals(password))
+            ((PasswordCredential) this.credential).getValue() != password && 
+            ((PasswordCredential) this.credential).getValue() == null || 
+            !((PasswordCredential) this.credential).getValue().equals(password))
       {
          this.credential = new PasswordCredential(password);
          invalid = false;
@@ -100,7 +101,7 @@
    public boolean isSet()
    {
       return getUsername() != null && this.credential != null && 
-        ((PasswordCredential) this.credential).getPassword() != null;
+        ((PasswordCredential) this.credential).getValue() != null;
    }
    
    public boolean isInvalid()

Modified: modules/security/trunk/impl/src/main/java/org/jboss/seam/security/IdentityImpl.java
===================================================================
--- modules/security/trunk/impl/src/main/java/org/jboss/seam/security/IdentityImpl.java	2010-06-24 04:25:24 UTC (rev 13295)
+++ modules/security/trunk/impl/src/main/java/org/jboss/seam/security/IdentityImpl.java	2010-06-24 11:38:23 UTC (rev 13296)
@@ -42,6 +42,7 @@
 import org.jboss.seam.security.events.QuietLoginEvent;
 import org.jboss.seam.security.management.IdentityManager;
 import org.jboss.seam.security.permission.PermissionMapper;
+import org.picketlink.idm.impl.api.PasswordCredential;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -451,8 +452,8 @@
                   if (credentials.getCredential() instanceof PasswordCredential)
                   {
                      PasswordCredential credential = (PasswordCredential) credentials.getCredential();
-                     ( (PasswordCallback) callbacks[i] ).setPassword( credential.getPassword() != null ?
-                           credential.getPassword().toCharArray() : null );                     
+                     ( (PasswordCallback) callbacks[i] ).setPassword( credential.getValue() != null ?
+                           credential.getValue().toCharArray() : null );                     
                   }
                }
                else if (callbacks[i] instanceof IdentityCallback)

Deleted: modules/security/trunk/impl/src/main/java/org/jboss/seam/security/PasswordCredential.java
===================================================================
--- modules/security/trunk/impl/src/main/java/org/jboss/seam/security/PasswordCredential.java	2010-06-24 04:25:24 UTC (rev 13295)
+++ modules/security/trunk/impl/src/main/java/org/jboss/seam/security/PasswordCredential.java	2010-06-24 11:38:23 UTC (rev 13296)
@@ -1,32 +0,0 @@
-package org.jboss.seam.security;
-
-import javax.enterprise.context.RequestScoped;
-
-
-/**
- * Seam implementation of the PicketLink Credential interface
- * 
- * @author Shane Bryzak
- */
- at RequestScoped
-public class PasswordCredential implements org.picketlink.idm.api.Credential
-{
-   private static final CredentialType CREDENTIAL_TYPE = new CredentialType("password");
-   
-   private String password;
-   
-   public PasswordCredential(String password)
-   {
-      this.password = password;
-   }
-   
-   public org.picketlink.idm.api.CredentialType getType()
-   {
-      return CREDENTIAL_TYPE;
-   }
-
-   public String getPassword()
-   {
-      return password;
-   }
-}

Modified: modules/security/trunk/impl/src/main/java/org/jboss/seam/security/jaas/SeamLoginModule.java
===================================================================
--- modules/security/trunk/impl/src/main/java/org/jboss/seam/security/jaas/SeamLoginModule.java	2010-06-24 04:25:24 UTC (rev 13295)
+++ modules/security/trunk/impl/src/main/java/org/jboss/seam/security/jaas/SeamLoginModule.java	2010-06-24 11:38:23 UTC (rev 13296)
@@ -12,13 +12,13 @@
 import javax.security.auth.login.LoginException;
 import javax.security.auth.spi.LoginModule;
 
-import org.jboss.seam.security.PasswordCredential;
 import org.jboss.seam.security.SimplePrincipal;
 import org.jboss.seam.security.callbacks.AuthenticatorCallback;
 import org.jboss.seam.security.callbacks.IdentityCallback;
 import org.jboss.seam.security.callbacks.IdentityManagerCallback;
 import org.jboss.seam.security.management.IdentityManager;
 import org.picketlink.idm.api.Role;
+import org.picketlink.idm.impl.api.PasswordCredential;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 

Modified: modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/JpaIdentityStore.java
===================================================================
--- modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/JpaIdentityStore.java	2010-06-24 04:25:24 UTC (rev 13295)
+++ modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/JpaIdentityStore.java	2010-06-24 11:38:23 UTC (rev 13296)
@@ -52,6 +52,8 @@
    private Logger log = LoggerFactory.getLogger(JpaIdentityStore.class);   
    
    public static final String OPTION_IDENTITY_CLASS_NAME = "identityEntityClassName";
+   public static final String OPTION_CREDENTIAL_CLASS_NAME = "credentialEntityClassName";
+   public static final String OPTION_RELATIONSHIP_CLASS_NAME = "relationshipEntityClassName";
    
    private static final String DEFAULT_USER_IDENTITY_TYPE = "USER";
    private static final String DEFAULT_ROLE_IDENTITY_TYPE = "ROLE";
@@ -78,19 +80,7 @@
    private static final String PROPERTY_ATTRIBUTE_VALUE = "ATTRIBUTE_VALUE";
    private static final String PROPERTY_ROLE_TYPE_NAME = "ROLE_TYPE_NAME";
    
-   /**
-    * 
-    */
-   //@Inject Instance<EntityManager> entityManagerInstance;
-   
-   /**
-    * 
-    */
-   //@Inject CredentialProcessor credentialEncoder;
-   
    private String id;
-   
-   private IdentityStoreConfigurationContext configurationContext;
       
    // Entity classes
    
@@ -146,9 +136,7 @@
    
    public void bootstrap(IdentityStoreConfigurationContext configurationContext)
       throws IdentityException
-   {
-      this.configurationContext = configurationContext;
-      
+   {      
       String clsName = configurationContext.getStoreConfigurationMetaData()
          .getOptionSingleValue(OPTION_IDENTITY_CLASS_NAME);
 
@@ -167,6 +155,30 @@
                "Error initializing JpaIdentityStore - identityClass not set");
       }
       
+      clsName = configurationContext.getStoreConfigurationMetaData()
+         .getOptionSingleValue(OPTION_CREDENTIAL_CLASS_NAME);
+      
+      try
+      {
+         credentialClass = Class.forName(clsName);
+      }
+      catch (ClassNotFoundException e)
+      {
+         throw new IdentityException("Error bootstrapping JpaIdentityStore - no credential entity class found: " + clsName);
+      }      
+      
+      clsName = configurationContext.getStoreConfigurationMetaData()
+         .getOptionSingleValue(OPTION_RELATIONSHIP_CLASS_NAME);
+      
+      try
+      {
+         relationshipClass = Class.forName(clsName);
+      }
+      catch (ClassNotFoundException e)
+      {
+         throw new IdentityException("Error bootstrapping JpaIdentityStore - no relationship entity class found: " + clsName);
+      }      
+      
       configureIdentityId();
       configureIdentityName();
       configureIdentityType();

Modified: modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/action/UserAction.java
===================================================================
--- modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/action/UserAction.java	2010-06-24 04:25:24 UTC (rev 13295)
+++ modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/action/UserAction.java	2010-06-24 11:38:23 UTC (rev 13296)
@@ -9,9 +9,9 @@
 import javax.inject.Inject;
 import javax.inject.Named;
 
-import org.jboss.seam.security.PasswordCredential;
 import org.jboss.seam.security.management.IdentityManager;
 import org.picketlink.idm.api.Role;
+import org.picketlink.idm.impl.api.PasswordCredential;
 
 /**
  * A conversation-scoped component for creating and managing user accounts

Modified: modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/picketlink/IdentitySessionProducer.java
===================================================================
--- modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/picketlink/IdentitySessionProducer.java	2010-06-24 04:25:24 UTC (rev 13295)
+++ modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/picketlink/IdentitySessionProducer.java	2010-06-24 11:38:23 UTC (rev 13296)
@@ -20,10 +20,14 @@
 import org.picketlink.idm.common.exception.IdentityException;
 import org.picketlink.idm.impl.configuration.IdentityConfigurationImpl;
 import org.picketlink.idm.impl.configuration.metadata.IdentityConfigurationMetaDataImpl;
+import org.picketlink.idm.impl.configuration.metadata.IdentityRepositoryConfigurationMetaDataImpl;
 import org.picketlink.idm.impl.configuration.metadata.IdentityStoreConfigurationMetaDataImpl;
+import org.picketlink.idm.impl.configuration.metadata.IdentityStoreMappingMetaDataImpl;
 import org.picketlink.idm.impl.configuration.metadata.RealmConfigurationMetaDataImpl;
 import org.picketlink.idm.spi.configuration.metadata.IdentityConfigurationMetaData;
+import org.picketlink.idm.spi.configuration.metadata.IdentityRepositoryConfigurationMetaData;
 import org.picketlink.idm.spi.configuration.metadata.IdentityStoreConfigurationMetaData;
+import org.picketlink.idm.spi.configuration.metadata.IdentityStoreMappingMetaData;
 import org.picketlink.idm.spi.configuration.metadata.RealmConfigurationMetaData;
 
 /**
@@ -51,12 +55,17 @@
       store.setId("jpa");
       store.setClassName("org.jboss.seam.security.management.JpaIdentityStore");      
       
-      // temporary hack
+      // temporary hack to get the example working
       Map<String,List<String>> options = new HashMap<String,List<String>>();
       options.put(JpaIdentityStore.OPTION_IDENTITY_CLASS_NAME, 
             createOptionList("org.jboss.seam.security.examples.idmconsole.model.IdentityObject"));
       
+      options.put(JpaIdentityStore.OPTION_CREDENTIAL_CLASS_NAME, 
+            createOptionList("org.jboss.seam.security.examples.idmconsole.model.IdentityObjectCredential"));
       
+      options.put(JpaIdentityStore.OPTION_RELATIONSHIP_CLASS_NAME, 
+            createOptionList("org.jboss.seam.security.examples.idmconsole.model.IdentityObjectRelationship"));
+      
       store.setOptions(options);
       stores.add(store);            
       metadata.setIdentityStores(stores);
@@ -64,13 +73,32 @@
       // Create the default realm
       RealmConfigurationMetaDataImpl realm = new RealmConfigurationMetaDataImpl();
       realm.setId("default");      
+      realm.setOptions(new HashMap<String,List<String>>());
       List<RealmConfigurationMetaData> realms = new ArrayList<RealmConfigurationMetaData>();      
       realms.add(realm);
       metadata.setRealms(realms);
+      
+      List<IdentityRepositoryConfigurationMetaData> repositories = new ArrayList<IdentityRepositoryConfigurationMetaData>();
+      IdentityRepositoryConfigurationMetaDataImpl repository = new IdentityRepositoryConfigurationMetaDataImpl();
+      repository.setClassName("org.picketlink.idm.impl.repository.WrapperIdentityStoreRepository");
+      repository.setDefaultAttributeStoreId("jpa");
+      repository.setDefaultIdentityStoreId("jpa");
+      
+      List<IdentityStoreMappingMetaData> mappings = new ArrayList<IdentityStoreMappingMetaData>();
+      IdentityStoreMappingMetaDataImpl mapping = new IdentityStoreMappingMetaDataImpl();
+      List<String> identityObjectTypes = new ArrayList<String>();
+      identityObjectTypes.add("USER");
+      identityObjectTypes.add("GROUP");
+      mapping.setIdentityObjectTypeMappings(identityObjectTypes);
+      mapping.setIdentityStoreId("jpa");
+      mappings.add(mapping);
+      repository.setIdentityStoreToIdentityObjectTypeMappings(mappings);      
+      
+      repositories.add(repository);
+      metadata.setRepositories(repositories);
             
       IdentityConfigurationImpl config = new IdentityConfigurationImpl();
       config.configure(metadata);
-      config.register(this, "identitySessionProducer");
       
       factory = config.buildIdentitySessionFactory();      
    }



More information about the seam-commits mailing list