[seam-commits] Seam SVN: r7707 - in trunk/src/main: org/jboss/seam/security/management and 1 other directory.

seam-commits at lists.jboss.org seam-commits at lists.jboss.org
Wed Mar 26 09:07:11 EDT 2008


Author: shane.bryzak at jboss.com
Date: 2008-03-26 09:07:11 -0400 (Wed, 26 Mar 2008)
New Revision: 7707

Modified:
   trunk/src/main/META-INF/components.xml
   trunk/src/main/org/jboss/seam/security/management/IdentityManager.java
   trunk/src/main/org/jboss/seam/security/management/JpaIdentityStore.java
   trunk/src/main/org/jboss/seam/security/management/LdapIdentityStore.java
Log:
fixed configuration issues

Modified: trunk/src/main/META-INF/components.xml
===================================================================
--- trunk/src/main/META-INF/components.xml	2008-03-26 12:24:34 UTC (rev 7706)
+++ trunk/src/main/META-INF/components.xml	2008-03-26 13:07:11 UTC (rev 7707)
@@ -15,6 +15,7 @@
   <import>org.jboss.seam.jms</import>
   <import>org.jboss.seam.mail</import>
   <import>org.jboss.seam.security</import>
+  <import>org.jboss.seam.security.management</import>  
   <import>org.jboss.seam.captcha</import>
   
 </components>

Modified: trunk/src/main/org/jboss/seam/security/management/IdentityManager.java
===================================================================
--- trunk/src/main/org/jboss/seam/security/management/IdentityManager.java	2008-03-26 12:24:34 UTC (rev 7706)
+++ trunk/src/main/org/jboss/seam/security/management/IdentityManager.java	2008-03-26 13:07:11 UTC (rev 7707)
@@ -24,11 +24,10 @@
  * @author Shane Bryzak
  */
 @Scope(APPLICATION)
- at Name("org.jboss.seam.security.identityManager")
+ at Name("org.jboss.seam.security.management.identityManager")
 @Install(precedence = BUILT_IN)
 public class IdentityManager
 {
-   public static final String IDENTITY_STORE_COMPONENT_NAME = "identityStore";
    public static final String ACCOUNT_PERMISSION_NAME = "seam.account";
    
    public static final String PERMISSION_CREATE = "create";
@@ -38,7 +37,7 @@
    
    private static final LogProvider log = Logging.getLogProvider(IdentityManager.class);   
    
-   private IdentityStore userIdentityStore;
+   private IdentityStore identityStore;
    private IdentityStore roleIdentityStore;
    
    @Create
@@ -48,26 +47,16 @@
    }
    
    protected void initIdentityStore()
-   {
-      if (userIdentityStore == null)
+   {    
+      if (roleIdentityStore == null && identityStore != null)
       {
-         userIdentityStore = (IdentityStore) Component.getInstance(IDENTITY_STORE_COMPONENT_NAME, true);
-      }
-      
-      if (roleIdentityStore == null)
-      {
-         roleIdentityStore = (IdentityStore) Component.getInstance(IDENTITY_STORE_COMPONENT_NAME, true);
-      }      
-
-      if (roleIdentityStore == null && userIdentityStore != null)
-      {
-         roleIdentityStore = userIdentityStore;
+         roleIdentityStore = identityStore;
       }            
       
-      if (userIdentityStore == null || roleIdentityStore == null)
+      if (identityStore == null || roleIdentityStore == null)
       {
-         log.warn("no identity store available - please install an IdentityStore with the name '" +
-               IDENTITY_STORE_COMPONENT_NAME + "' if identity management is required.");
+         log.warn("no identity store available - please configure an identityStore if identity " +
+               "management is required.");
       }
    }  
    
@@ -97,37 +86,37 @@
    public boolean createUser(String name, String password, String firstname, String lastname)
    {
       Identity.instance().checkPermission(ACCOUNT_PERMISSION_NAME, PERMISSION_CREATE);
-      return userIdentityStore.createUser(name, password, firstname, lastname); 
+      return identityStore.createUser(name, password, firstname, lastname); 
    }   
    
    public boolean deleteUser(String name)
    {
       Identity.instance().checkPermission(ACCOUNT_PERMISSION_NAME, PERMISSION_DELETE);
-      return userIdentityStore.deleteUser(name);
+      return identityStore.deleteUser(name);
    }
    
    public boolean enableUser(String name)
    {
       Identity.instance().checkPermission(ACCOUNT_PERMISSION_NAME, PERMISSION_UPDATE);
-      return userIdentityStore.enableUser(name);
+      return identityStore.enableUser(name);
    }
    
    public boolean disableUser(String name)
    {
       Identity.instance().checkPermission(ACCOUNT_PERMISSION_NAME, PERMISSION_UPDATE);
-      return userIdentityStore.disableUser(name);
+      return identityStore.disableUser(name);
    }
    
    public boolean changePassword(String name, String password)
    {
       Identity.instance().checkPermission(ACCOUNT_PERMISSION_NAME, PERMISSION_UPDATE);
-      return userIdentityStore.changePassword(name, password);
+      return identityStore.changePassword(name, password);
    }
    
    public boolean isUserEnabled(String name)
    {
       Identity.instance().checkPermission(ACCOUNT_PERMISSION_NAME, PERMISSION_READ);
-      return userIdentityStore.isUserEnabled(name);
+      return identityStore.isUserEnabled(name);
    }
    
    public boolean grantRole(String name, String role)
@@ -157,7 +146,7 @@
    public boolean userExists(String name)
    {
       Identity.instance().checkPermission(ACCOUNT_PERMISSION_NAME, PERMISSION_READ);
-      return userIdentityStore.userExists(name);
+      return identityStore.userExists(name);
    }
    
    public boolean roleExists(String name)
@@ -168,7 +157,7 @@
    public List<String> listUsers()
    {
       Identity.instance().checkPermission(ACCOUNT_PERMISSION_NAME, PERMISSION_READ);
-      List<String> users = userIdentityStore.listUsers();      
+      List<String> users = identityStore.listUsers();      
       
       Collections.sort(users, new Comparator<String>() {
          public int compare(String value1, String value2) {
@@ -182,7 +171,7 @@
    public List<String> listUsers(String filter)
    {
       Identity.instance().checkPermission(ACCOUNT_PERMISSION_NAME, PERMISSION_READ);
-      List<String> users = userIdentityStore.listUsers(filter);
+      List<String> users = identityStore.listUsers(filter);
       
       Collections.sort(users, new Comparator<String>() {
          public int compare(String value1, String value2) {
@@ -218,17 +207,17 @@
    
    public boolean authenticate(String username, String password)
    {
-      return userIdentityStore.authenticate(username, password);
+      return identityStore.authenticate(username, password);
    }
    
-   public IdentityStore getUserIdentityStore()
+   public IdentityStore getIdentityStore()
    {
-      return userIdentityStore;
+      return identityStore;
    }
    
-   public void setIdentityStore(IdentityStore userIdentityStore)
+   public void setIdentityStore(IdentityStore identityStore)
    {
-      this.userIdentityStore = userIdentityStore;
+      this.identityStore = identityStore;
    }
    
    public IdentityStore getRoleIdentityStore()
@@ -243,7 +232,7 @@
    
    public boolean isEnabled()
    {
-      return userIdentityStore != null && roleIdentityStore != null;
+      return identityStore != null && roleIdentityStore != null;
    }
    
 }

Modified: trunk/src/main/org/jboss/seam/security/management/JpaIdentityStore.java
===================================================================
--- trunk/src/main/org/jboss/seam/security/management/JpaIdentityStore.java	2008-03-26 12:24:34 UTC (rev 7706)
+++ trunk/src/main/org/jboss/seam/security/management/JpaIdentityStore.java	2008-03-26 13:07:11 UTC (rev 7707)
@@ -14,11 +14,14 @@
 import javax.persistence.NoResultException;
 
 import org.jboss.seam.annotations.Create;
+import org.jboss.seam.annotations.Install;
+import org.jboss.seam.annotations.Name;
 import org.jboss.seam.annotations.Observer;
 import org.jboss.seam.annotations.Scope;
 import org.jboss.seam.annotations.intercept.BypassInterceptors;
 import org.jboss.seam.contexts.Contexts;
 import org.jboss.seam.core.Events;
+import org.jboss.seam.core.Expressions;
 import org.jboss.seam.core.Expressions.ValueExpression;
 import org.jboss.seam.security.Identity;
 import org.jboss.seam.security.management.UserAccount.AccountType;
@@ -28,6 +31,8 @@
  * 
  * @author Shane Bryzak
  */
+ at Name("org.jboss.seam.security.management.jpaIdentityStore")
+ at Install(value=false) 
 @Scope(APPLICATION)
 @BypassInterceptors
 public class JpaIdentityStore implements IdentityStore
@@ -89,6 +94,11 @@
    @Create
    public void init()
    {
+      if (entityManager == null)
+      {
+         entityManager = Expressions.instance().createValueExpression("#{entityManager}", EntityManager.class);
+      }
+      
       loadRoles();
       
       if (getFirstNameField() != null)

Modified: trunk/src/main/org/jboss/seam/security/management/LdapIdentityStore.java
===================================================================
--- trunk/src/main/org/jboss/seam/security/management/LdapIdentityStore.java	2008-03-26 12:24:34 UTC (rev 7706)
+++ trunk/src/main/org/jboss/seam/security/management/LdapIdentityStore.java	2008-03-26 13:07:11 UTC (rev 7707)
@@ -19,6 +19,8 @@
 import javax.naming.directory.SearchResult;
 import javax.naming.ldap.InitialLdapContext;
 
+import org.jboss.seam.annotations.Install;
+import org.jboss.seam.annotations.Name;
 import org.jboss.seam.annotations.Scope;
 import org.jboss.seam.annotations.intercept.BypassInterceptors;
 
@@ -27,6 +29,8 @@
  * 
  * @author Shane Bryzak
  */
+ at Name("org.jboss.seam.security.management.ldapIdentityStore")
+ at Install(value=false) 
 @Scope(APPLICATION)
 @BypassInterceptors
 public class LdapIdentityStore implements IdentityStore




More information about the seam-commits mailing list