[seam-commits] Seam SVN: r12455 - in modules/security/trunk: api/src/main/java/org/jboss/seam/security/management and 2 other directories.

seam-commits at lists.jboss.org seam-commits at lists.jboss.org
Tue Apr 13 06:47:37 EDT 2010


Author: shane.bryzak at jboss.com
Date: 2010-04-13 06:47:35 -0400 (Tue, 13 Apr 2010)
New Revision: 12455

Added:
   modules/security/trunk/api/src/main/java/org/jboss/seam/security/Authenticator.java
   modules/security/trunk/api/src/main/java/org/jboss/seam/security/management/
   modules/security/trunk/api/src/main/java/org/jboss/seam/security/management/IdentityManager.java
   modules/security/trunk/api/src/main/java/org/jboss/seam/security/management/IdentityStore.java
Removed:
   modules/security/trunk/impl/src/main/java/org/jboss/seam/security/Authenticator.java
   modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/IdentityManager.java
   modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/IdentityStore.java
Log:
moved interface classes to API


Copied: modules/security/trunk/api/src/main/java/org/jboss/seam/security/Authenticator.java (from rev 12453, modules/security/trunk/impl/src/main/java/org/jboss/seam/security/Authenticator.java)
===================================================================
--- modules/security/trunk/api/src/main/java/org/jboss/seam/security/Authenticator.java	                        (rev 0)
+++ modules/security/trunk/api/src/main/java/org/jboss/seam/security/Authenticator.java	2010-04-13 10:47:35 UTC (rev 12455)
@@ -0,0 +1,11 @@
+package org.jboss.seam.security;
+
+/**
+ * Authenticator bean type
+ *  
+ * @author Shane Bryzak
+ */
+public interface Authenticator
+{
+   boolean authenticate();
+}

Copied: modules/security/trunk/api/src/main/java/org/jboss/seam/security/management/IdentityManager.java (from rev 12452, modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/IdentityManager.java)
===================================================================
--- modules/security/trunk/api/src/main/java/org/jboss/seam/security/management/IdentityManager.java	                        (rev 0)
+++ modules/security/trunk/api/src/main/java/org/jboss/seam/security/management/IdentityManager.java	2010-04-13 10:47:35 UTC (rev 12455)
@@ -0,0 +1,274 @@
+package org.jboss.seam.security.management;
+
+import java.io.Serializable;
+import java.security.Principal;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
+import javax.annotation.PostConstruct;
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.inject.spi.BeanManager;
+import javax.inject.Inject;
+import javax.inject.Named;
+
+import org.jboss.seam.security.Identity;
+import org.jboss.seam.security.util.Strings;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Identity Management API, deals with user name/password-based identity management.
+ * 
+ * @author Shane Bryzak
+ */
+ at Named @ApplicationScoped
+public class IdentityManager implements Serializable
+{
+   private static final long serialVersionUID = 6864253169970552893L;
+   
+   public static final String USER_PERMISSION_NAME = "seam.user";
+   public static final String ROLE_PERMISSION_NAME = "seam.role";
+   
+   public static final String PERMISSION_CREATE = "create";
+   public static final String PERMISSION_READ = "read";
+   public static final String PERMISSION_UPDATE = "update";
+   public static final String PERMISSION_DELETE = "delete";
+   
+   private Logger log = LoggerFactory.getLogger(IdentityManager.class);
+   
+   @Inject BeanManager manager;
+   @Inject Identity identity;
+   
+   private IdentityStore identityStore;
+   private IdentityStore roleIdentityStore;
+   
+   @PostConstruct
+   public void create()
+   {
+      if (roleIdentityStore == null && identityStore != null)
+      {
+         roleIdentityStore = identityStore;
+      }
+      
+      if (identityStore == null)
+      {
+         log.warn("No identity store available - please configure an identityStore if identity " +
+               "management is required.");
+      }
+      
+      if (roleIdentityStore == null)
+      {
+         log.warn("No role identity store available - please configure a roleIdentityStore if identity " +
+               "management is required.");
+      }
+   }
+   
+   public boolean createUser(String name, String password)
+   {
+      return createUser(name, password, null, null);
+   }
+
+   public boolean createUser(String name, String password, String firstname, String lastname)
+   {
+      identity.checkPermission(USER_PERMISSION_NAME, PERMISSION_CREATE);
+      return identityStore.createUser(name, password, firstname, lastname);
+   }
+   
+   public boolean deleteUser(String name)
+   {
+      identity.checkPermission(USER_PERMISSION_NAME, PERMISSION_DELETE);
+      return identityStore.deleteUser(name);
+   }
+   
+   public boolean enableUser(String name)
+   {
+      identity.checkPermission(USER_PERMISSION_NAME, PERMISSION_UPDATE);
+      return identityStore.enableUser(name);
+   }
+   
+   public boolean disableUser(String name)
+   {
+      identity.checkPermission(USER_PERMISSION_NAME, PERMISSION_UPDATE);
+      return identityStore.disableUser(name);
+   }
+   
+   public boolean changePassword(String name, String password)
+   {
+      identity.checkPermission(USER_PERMISSION_NAME, PERMISSION_UPDATE);
+      return identityStore.changePassword(name, password);
+   }
+   
+   public boolean isUserEnabled(String name)
+   {
+      identity.checkPermission(USER_PERMISSION_NAME, PERMISSION_READ);
+      return identityStore.isUserEnabled(name);
+   }
+   
+   public boolean grantRole(String name, String role)
+   {
+      identity.checkPermission(USER_PERMISSION_NAME, PERMISSION_UPDATE);
+      return roleIdentityStore.grantRole(name, role);
+   }
+   
+   public boolean revokeRole(String name, String role)
+   {
+      identity.checkPermission(USER_PERMISSION_NAME, PERMISSION_UPDATE);
+      return roleIdentityStore.revokeRole(name, role);
+   }
+   
+   public boolean createRole(String role)
+   {
+      identity.checkPermission(ROLE_PERMISSION_NAME, PERMISSION_CREATE);
+      return roleIdentityStore.createRole(role);
+   }
+   
+   public boolean deleteRole(String role)
+   {
+      identity.checkPermission(ROLE_PERMISSION_NAME, PERMISSION_DELETE);
+      return roleIdentityStore.deleteRole(role);
+   }
+   
+   public boolean addRoleToGroup(String role, String group)
+   {
+      identity.checkPermission(ROLE_PERMISSION_NAME, PERMISSION_UPDATE);
+      return roleIdentityStore.addRoleToGroup(role, group);
+   }
+   
+   public boolean removeRoleFromGroup(String role, String group)
+   {
+      identity.checkPermission(ROLE_PERMISSION_NAME, PERMISSION_UPDATE);
+      return roleIdentityStore.removeRoleFromGroup(role, group);
+   }
+   
+   public boolean userExists(String name)
+   {
+      identity.checkPermission(USER_PERMISSION_NAME, PERMISSION_READ);
+      return identityStore.userExists(name);
+   }
+   
+   public boolean roleExists(String name)
+   {
+      return roleIdentityStore.roleExists(name);
+   }
+   
+   public List<String> getUsers()
+   {
+      identity.checkPermission(USER_PERMISSION_NAME, PERMISSION_READ);
+      List<String> users = identityStore.listUsers();
+      
+      Collections.sort(users, new Comparator<String>() {
+         public int compare(String value1, String value2) {
+            return value1.compareTo(value2);
+         }
+      });
+      
+      return users;
+   }
+   
+   public List<String> getUsers(String filter)
+   {
+      identity.checkPermission(USER_PERMISSION_NAME, PERMISSION_READ);
+      List<String> users = identityStore.listUsers(filter);
+      
+      Collections.sort(users, new Comparator<String>() {
+         public int compare(String value1, String value2) {
+            return value1.compareTo(value2);
+         }
+      });
+      
+      return users;
+   }
+   
+   public List<String> getRoles()
+   {
+      identity.checkPermission(ROLE_PERMISSION_NAME, PERMISSION_READ);
+      List<String> roles = roleIdentityStore.listRoles();
+      
+      Collections.sort(roles, new Comparator<String>() {
+         public int compare(String value1, String value2) {
+            return value1.compareTo(value2);
+         }
+      });
+      
+      return roles;
+   }
+   
+   public List<String> getGrantableRoles()
+   {
+      List<String> roles = roleIdentityStore.listGrantableRoles();
+      
+      Collections.sort(roles, new Comparator<String>() {
+         public int compare(String value1, String value2) {
+            return value1.compareTo(value2);
+         }
+      });
+      
+      return roles;
+   }
+   
+   /**
+    * Returns a list of the roles that are explicitly granted to the specified user;
+    * 
+    * @param name The user for which to return a list of roles
+    * @return List containing the names of the granted roles
+    */
+   public List<String> getGrantedRoles(String name)
+   {
+      return roleIdentityStore.getGrantedRoles(name);
+   }
+   
+   /**
+    * Returns a list of roles that are either explicitly or indirectly granted to the specified user.
+    * 
+    * @param name The user for which to return the list of roles
+    * @return List containing the names of the implied roles
+    */
+   public List<String> getImpliedRoles(String name)
+   {
+      return roleIdentityStore.getImpliedRoles(name);
+   }
+   
+   public List<Principal> listMembers(String role)
+   {
+      identity.checkPermission(ROLE_PERMISSION_NAME, PERMISSION_READ);
+      return roleIdentityStore.listMembers(role);
+   }
+   
+   public List<String> getRoleGroups(String name)
+   {
+      return roleIdentityStore.getRoleGroups(name);
+   }
+   
+   public boolean authenticate(String username, String password)
+   {
+      if (Strings.isEmpty(username)) return false;
+      return identityStore.authenticate(username, password);
+   }
+   
+   public IdentityStore getIdentityStore()
+   {
+      return identityStore;
+   }
+   
+   public void setIdentityStore(IdentityStore identityStore)
+   {
+      this.identityStore = identityStore;
+   }
+   
+   public IdentityStore getRoleIdentityStore()
+   {
+      return roleIdentityStore;
+   }
+   
+   public void setRoleIdentityStore(IdentityStore roleIdentityStore)
+   {
+      this.roleIdentityStore = roleIdentityStore;
+   }
+   
+   public boolean isEnabled()
+   {
+      return identityStore != null && roleIdentityStore != null;
+   }
+   
+}

Copied: modules/security/trunk/api/src/main/java/org/jboss/seam/security/management/IdentityStore.java (from rev 12452, modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/IdentityStore.java)
===================================================================
--- modules/security/trunk/api/src/main/java/org/jboss/seam/security/management/IdentityStore.java	                        (rev 0)
+++ modules/security/trunk/api/src/main/java/org/jboss/seam/security/management/IdentityStore.java	2010-04-13 10:47:35 UTC (rev 12455)
@@ -0,0 +1,228 @@
+package org.jboss.seam.security.management;
+
+import java.io.Serializable;
+import java.security.Principal;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * The identity store does the actual work of persisting user accounts and roles in a
+ * database, LDAP directory, etc.  
+ * 
+ * @author Shane Bryzak
+ */
+public interface IdentityStore
+{     
+   public enum Feature { createUser, deleteUser, enableUser, disableUser, changePassword, 
+      createRole, deleteRole, grantRole, revokeRole }
+   
+   /**
+    * Represents a set of optional features that an IdentityStore implementation might support.
+    */
+   public class FeatureSet implements Serializable
+   {                             
+      private static final long serialVersionUID = 1100272929055626911L;
+      
+      private Set<Feature> features;
+
+      public FeatureSet()
+      {
+         this(null);
+      }
+      
+      public FeatureSet(Set<Feature> features)
+      {
+         if (features != null)
+         {
+            this.features = features;
+         }
+         else
+         {
+            this.features = new HashSet<Feature>();
+         }
+      }
+      
+      public Set<Feature> getFeatures()
+      {
+         return features;
+      }
+      
+      public boolean supports(Feature feature)
+      {
+         return features.contains(feature);
+      }
+      
+      public void addFeature(Feature feature)
+      {
+         features.add(feature);
+      }
+      
+      public void removeFeature(Feature feature)
+      {
+         features.remove(feature);
+      }
+      
+      public void enableAll()
+      {
+         for (Feature f : Feature.values()) addFeature(f);
+      }
+   }
+
+   /**
+    * Returns true if the IdentityStore implementation supports the specified feature.
+    * 
+    */
+   boolean supportsFeature(Feature feature);
+
+   /**
+    * Creates a new user with the specified username and password.
+    * @return true if the user was successfully created.
+    */
+   boolean createUser(String username, String password);
+   
+   /**
+    * Creates a new user with the specified username, password, first name and last name.
+    * 
+    * @return true if the user was successfully created.
+    */
+   boolean createUser(String username, String password, String firstname, String lastname);
+   
+   /**
+    * Deletes the user with the specified username.
+    * @return true if the user was successfully deleted.
+    */
+   boolean deleteUser(String name);   
+   
+   /**
+    * Enables the user with the specified username.  Enabled users are able to authenticate.
+    * @return true if the specified user was successfully enabled.
+    */
+   boolean enableUser(String name);
+   
+   /**
+    * Disables the user with the specified username.  Disabled users are unable to authenticate.
+    * @return true if the specified user was successfully disabled.
+    */
+   boolean disableUser(String name);   
+   
+   /**
+    * Returns true if the specified user is enabled.
+    */
+   boolean isUserEnabled(String name);
+   
+   /**
+    * Changes the password of the specified user to the specified password.
+    * @return true if the user's password was successfully changed.
+    */
+   boolean changePassword(String name, String password);   
+   
+   /**
+    * Returns true if the specified user exists.
+    */
+   boolean userExists(String name);
+
+   /**
+    * Creates a new role with the specified role name.
+    * @return true if the role was created successfully.
+    */
+   boolean createRole(String role);
+   
+   /**
+    * Grants the specified role to the specified user.
+    * 
+    * @param name The name of the user
+    * @param role The name of the role to grant to the user.
+    * @return true if the role was successfully granted.
+    */
+   boolean grantRole(String name, String role);
+   
+   /**
+    * Revokes the specified role from the specified user.
+    * 
+    * @param name The name of the user
+    * @param role The name of the role to grant to the user.
+    * @return true if the role was successfully revoked.
+    */
+   boolean revokeRole(String name, String role);
+   
+   /**
+    * Deletes the specified role.
+    * @return true if the role was successfully deleted.
+    */
+   boolean deleteRole(String role);
+   
+   /**
+    * Returns true if the specified role exists.
+    */
+   boolean roleExists(String name);
+   
+   /**
+    * Adds the specified role as a member of the specified group.
+    * 
+    * @param role The name of the role to add as a member
+    * @param group The name of the group that the specified role will be added to.
+    * @return true if the role was successfully added to the group.
+    */
+   boolean addRoleToGroup(String role, String group);
+   
+   /**
+    * Removes the specified role from the specified group.
+    * 
+    * @param role The name of the role to remove from the group.
+    * @param group The group from which to remove the role.
+    * @return true if the role was successfully removed from the group.
+    */
+   boolean removeRoleFromGroup(String role, String group);   
+
+   /**
+    * Returns a list of all users.
+    */
+   List<String> listUsers();
+   
+   /**
+    * Returns a list of all users containing the specified filter text within their username.
+
+    */
+   List<String> listUsers(String filter);
+   
+   /**
+    * Returns a list of all the roles.
+    */
+   List<String> listRoles();
+   
+   /**
+    * Returns a list of roles that can be granted (i.e, excluding conditional roles)
+    */
+   List<String> listGrantableRoles();
+
+   /**
+    * Returns a list of all the roles explicitly granted to the specified user.
+    */
+   List<String> getGrantedRoles(String name);
+   
+   /**
+    * Returns a list of all roles that the specified user is a member of.  This list may contain
+    * roles that may not have been explicitly granted to the user, which are indirectly implied
+    * due to group memberships.
+
+    */
+   List<String> getImpliedRoles(String name);
+   
+   /**
+    * Returns a list of all the groups that the specified role is a member of.
+    */
+   List<String> getRoleGroups(String name);
+   
+   /**
+    * Lists the members of the specified role.
+    */
+   List<Principal> listMembers(String role);
+
+   /**
+    * Authenticates the specified user, using the specified password.
+    * 
+    * @return true if authentication is successful.
+    */
+   boolean authenticate(String username, String password);
+}

Deleted: modules/security/trunk/impl/src/main/java/org/jboss/seam/security/Authenticator.java
===================================================================
--- modules/security/trunk/impl/src/main/java/org/jboss/seam/security/Authenticator.java	2010-04-13 10:44:24 UTC (rev 12454)
+++ modules/security/trunk/impl/src/main/java/org/jboss/seam/security/Authenticator.java	2010-04-13 10:47:35 UTC (rev 12455)
@@ -1,11 +0,0 @@
-package org.jboss.seam.security;
-
-/**
- * Authenticator bean type
- *  
- * @author Shane Bryzak
- */
-public interface Authenticator
-{
-   boolean authenticate();
-}

Deleted: modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/IdentityManager.java
===================================================================
--- modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/IdentityManager.java	2010-04-13 10:44:24 UTC (rev 12454)
+++ modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/IdentityManager.java	2010-04-13 10:47:35 UTC (rev 12455)
@@ -1,274 +0,0 @@
-package org.jboss.seam.security.management;
-
-import java.io.Serializable;
-import java.security.Principal;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.List;
-
-import javax.annotation.PostConstruct;
-import javax.enterprise.context.ApplicationScoped;
-import javax.enterprise.inject.spi.BeanManager;
-import javax.inject.Inject;
-import javax.inject.Named;
-
-import org.jboss.seam.security.Identity;
-import org.jboss.seam.security.util.Strings;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Identity Management API, deals with user name/password-based identity management.
- * 
- * @author Shane Bryzak
- */
- at Named @ApplicationScoped
-public class IdentityManager implements Serializable
-{
-   private static final long serialVersionUID = 6864253169970552893L;
-   
-   public static final String USER_PERMISSION_NAME = "seam.user";
-   public static final String ROLE_PERMISSION_NAME = "seam.role";
-   
-   public static final String PERMISSION_CREATE = "create";
-   public static final String PERMISSION_READ = "read";
-   public static final String PERMISSION_UPDATE = "update";
-   public static final String PERMISSION_DELETE = "delete";
-   
-   private Logger log = LoggerFactory.getLogger(IdentityManager.class);
-   
-   @Inject BeanManager manager;
-   @Inject Identity identity;
-   
-   private IdentityStore identityStore;
-   private IdentityStore roleIdentityStore;
-   
-   @PostConstruct
-   public void create()
-   {
-      if (roleIdentityStore == null && identityStore != null)
-      {
-         roleIdentityStore = identityStore;
-      }
-      
-      if (identityStore == null)
-      {
-         log.warn("No identity store available - please configure an identityStore if identity " +
-               "management is required.");
-      }
-      
-      if (roleIdentityStore == null)
-      {
-         log.warn("No role identity store available - please configure a roleIdentityStore if identity " +
-               "management is required.");
-      }
-   }
-   
-   public boolean createUser(String name, String password)
-   {
-      return createUser(name, password, null, null);
-   }
-
-   public boolean createUser(String name, String password, String firstname, String lastname)
-   {
-      identity.checkPermission(USER_PERMISSION_NAME, PERMISSION_CREATE);
-      return identityStore.createUser(name, password, firstname, lastname);
-   }
-   
-   public boolean deleteUser(String name)
-   {
-      identity.checkPermission(USER_PERMISSION_NAME, PERMISSION_DELETE);
-      return identityStore.deleteUser(name);
-   }
-   
-   public boolean enableUser(String name)
-   {
-      identity.checkPermission(USER_PERMISSION_NAME, PERMISSION_UPDATE);
-      return identityStore.enableUser(name);
-   }
-   
-   public boolean disableUser(String name)
-   {
-      identity.checkPermission(USER_PERMISSION_NAME, PERMISSION_UPDATE);
-      return identityStore.disableUser(name);
-   }
-   
-   public boolean changePassword(String name, String password)
-   {
-      identity.checkPermission(USER_PERMISSION_NAME, PERMISSION_UPDATE);
-      return identityStore.changePassword(name, password);
-   }
-   
-   public boolean isUserEnabled(String name)
-   {
-      identity.checkPermission(USER_PERMISSION_NAME, PERMISSION_READ);
-      return identityStore.isUserEnabled(name);
-   }
-   
-   public boolean grantRole(String name, String role)
-   {
-      identity.checkPermission(USER_PERMISSION_NAME, PERMISSION_UPDATE);
-      return roleIdentityStore.grantRole(name, role);
-   }
-   
-   public boolean revokeRole(String name, String role)
-   {
-      identity.checkPermission(USER_PERMISSION_NAME, PERMISSION_UPDATE);
-      return roleIdentityStore.revokeRole(name, role);
-   }
-   
-   public boolean createRole(String role)
-   {
-      identity.checkPermission(ROLE_PERMISSION_NAME, PERMISSION_CREATE);
-      return roleIdentityStore.createRole(role);
-   }
-   
-   public boolean deleteRole(String role)
-   {
-      identity.checkPermission(ROLE_PERMISSION_NAME, PERMISSION_DELETE);
-      return roleIdentityStore.deleteRole(role);
-   }
-   
-   public boolean addRoleToGroup(String role, String group)
-   {
-      identity.checkPermission(ROLE_PERMISSION_NAME, PERMISSION_UPDATE);
-      return roleIdentityStore.addRoleToGroup(role, group);
-   }
-   
-   public boolean removeRoleFromGroup(String role, String group)
-   {
-      identity.checkPermission(ROLE_PERMISSION_NAME, PERMISSION_UPDATE);
-      return roleIdentityStore.removeRoleFromGroup(role, group);
-   }
-   
-   public boolean userExists(String name)
-   {
-      identity.checkPermission(USER_PERMISSION_NAME, PERMISSION_READ);
-      return identityStore.userExists(name);
-   }
-   
-   public boolean roleExists(String name)
-   {
-      return roleIdentityStore.roleExists(name);
-   }
-   
-   public List<String> getUsers()
-   {
-      identity.checkPermission(USER_PERMISSION_NAME, PERMISSION_READ);
-      List<String> users = identityStore.listUsers();
-      
-      Collections.sort(users, new Comparator<String>() {
-         public int compare(String value1, String value2) {
-            return value1.compareTo(value2);
-         }
-      });
-      
-      return users;
-   }
-   
-   public List<String> getUsers(String filter)
-   {
-      identity.checkPermission(USER_PERMISSION_NAME, PERMISSION_READ);
-      List<String> users = identityStore.listUsers(filter);
-      
-      Collections.sort(users, new Comparator<String>() {
-         public int compare(String value1, String value2) {
-            return value1.compareTo(value2);
-         }
-      });
-      
-      return users;
-   }
-   
-   public List<String> getRoles()
-   {
-      identity.checkPermission(ROLE_PERMISSION_NAME, PERMISSION_READ);
-      List<String> roles = roleIdentityStore.listRoles();
-      
-      Collections.sort(roles, new Comparator<String>() {
-         public int compare(String value1, String value2) {
-            return value1.compareTo(value2);
-         }
-      });
-      
-      return roles;
-   }
-   
-   public List<String> getGrantableRoles()
-   {
-      List<String> roles = roleIdentityStore.listGrantableRoles();
-      
-      Collections.sort(roles, new Comparator<String>() {
-         public int compare(String value1, String value2) {
-            return value1.compareTo(value2);
-         }
-      });
-      
-      return roles;
-   }
-   
-   /**
-    * Returns a list of the roles that are explicitly granted to the specified user;
-    * 
-    * @param name The user for which to return a list of roles
-    * @return List containing the names of the granted roles
-    */
-   public List<String> getGrantedRoles(String name)
-   {
-      return roleIdentityStore.getGrantedRoles(name);
-   }
-   
-   /**
-    * Returns a list of roles that are either explicitly or indirectly granted to the specified user.
-    * 
-    * @param name The user for which to return the list of roles
-    * @return List containing the names of the implied roles
-    */
-   public List<String> getImpliedRoles(String name)
-   {
-      return roleIdentityStore.getImpliedRoles(name);
-   }
-   
-   public List<Principal> listMembers(String role)
-   {
-      identity.checkPermission(ROLE_PERMISSION_NAME, PERMISSION_READ);
-      return roleIdentityStore.listMembers(role);
-   }
-   
-   public List<String> getRoleGroups(String name)
-   {
-      return roleIdentityStore.getRoleGroups(name);
-   }
-   
-   public boolean authenticate(String username, String password)
-   {
-      if (Strings.isEmpty(username)) return false;
-      return identityStore.authenticate(username, password);
-   }
-   
-   public IdentityStore getIdentityStore()
-   {
-      return identityStore;
-   }
-   
-   public void setIdentityStore(IdentityStore identityStore)
-   {
-      this.identityStore = identityStore;
-   }
-   
-   public IdentityStore getRoleIdentityStore()
-   {
-      return roleIdentityStore;
-   }
-   
-   public void setRoleIdentityStore(IdentityStore roleIdentityStore)
-   {
-      this.roleIdentityStore = roleIdentityStore;
-   }
-   
-   public boolean isEnabled()
-   {
-      return identityStore != null && roleIdentityStore != null;
-   }
-   
-}

Deleted: modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/IdentityStore.java
===================================================================
--- modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/IdentityStore.java	2010-04-13 10:44:24 UTC (rev 12454)
+++ modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/IdentityStore.java	2010-04-13 10:47:35 UTC (rev 12455)
@@ -1,228 +0,0 @@
-package org.jboss.seam.security.management;
-
-import java.io.Serializable;
-import java.security.Principal;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-/**
- * The identity store does the actual work of persisting user accounts and roles in a
- * database, LDAP directory, etc.  
- * 
- * @author Shane Bryzak
- */
-public interface IdentityStore
-{     
-   public enum Feature { createUser, deleteUser, enableUser, disableUser, changePassword, 
-      createRole, deleteRole, grantRole, revokeRole }
-   
-   /**
-    * Represents a set of optional features that an IdentityStore implementation might support.
-    */
-   public class FeatureSet implements Serializable
-   {                             
-      private static final long serialVersionUID = 1100272929055626911L;
-      
-      private Set<Feature> features;
-
-      public FeatureSet()
-      {
-         this(null);
-      }
-      
-      public FeatureSet(Set<Feature> features)
-      {
-         if (features != null)
-         {
-            this.features = features;
-         }
-         else
-         {
-            this.features = new HashSet<Feature>();
-         }
-      }
-      
-      public Set<Feature> getFeatures()
-      {
-         return features;
-      }
-      
-      public boolean supports(Feature feature)
-      {
-         return features.contains(feature);
-      }
-      
-      public void addFeature(Feature feature)
-      {
-         features.add(feature);
-      }
-      
-      public void removeFeature(Feature feature)
-      {
-         features.remove(feature);
-      }
-      
-      public void enableAll()
-      {
-         for (Feature f : Feature.values()) addFeature(f);
-      }
-   }
-
-   /**
-    * Returns true if the IdentityStore implementation supports the specified feature.
-    * 
-    */
-   boolean supportsFeature(Feature feature);
-
-   /**
-    * Creates a new user with the specified username and password.
-    * @return true if the user was successfully created.
-    */
-   boolean createUser(String username, String password);
-   
-   /**
-    * Creates a new user with the specified username, password, first name and last name.
-    * 
-    * @return true if the user was successfully created.
-    */
-   boolean createUser(String username, String password, String firstname, String lastname);
-   
-   /**
-    * Deletes the user with the specified username.
-    * @return true if the user was successfully deleted.
-    */
-   boolean deleteUser(String name);   
-   
-   /**
-    * Enables the user with the specified username.  Enabled users are able to authenticate.
-    * @return true if the specified user was successfully enabled.
-    */
-   boolean enableUser(String name);
-   
-   /**
-    * Disables the user with the specified username.  Disabled users are unable to authenticate.
-    * @return true if the specified user was successfully disabled.
-    */
-   boolean disableUser(String name);   
-   
-   /**
-    * Returns true if the specified user is enabled.
-    */
-   boolean isUserEnabled(String name);
-   
-   /**
-    * Changes the password of the specified user to the specified password.
-    * @return true if the user's password was successfully changed.
-    */
-   boolean changePassword(String name, String password);   
-   
-   /**
-    * Returns true if the specified user exists.
-    */
-   boolean userExists(String name);
-
-   /**
-    * Creates a new role with the specified role name.
-    * @return true if the role was created successfully.
-    */
-   boolean createRole(String role);
-   
-   /**
-    * Grants the specified role to the specified user.
-    * 
-    * @param name The name of the user
-    * @param role The name of the role to grant to the user.
-    * @return true if the role was successfully granted.
-    */
-   boolean grantRole(String name, String role);
-   
-   /**
-    * Revokes the specified role from the specified user.
-    * 
-    * @param name The name of the user
-    * @param role The name of the role to grant to the user.
-    * @return true if the role was successfully revoked.
-    */
-   boolean revokeRole(String name, String role);
-   
-   /**
-    * Deletes the specified role.
-    * @return true if the role was successfully deleted.
-    */
-   boolean deleteRole(String role);
-   
-   /**
-    * Returns true if the specified role exists.
-    */
-   boolean roleExists(String name);
-   
-   /**
-    * Adds the specified role as a member of the specified group.
-    * 
-    * @param role The name of the role to add as a member
-    * @param group The name of the group that the specified role will be added to.
-    * @return true if the role was successfully added to the group.
-    */
-   boolean addRoleToGroup(String role, String group);
-   
-   /**
-    * Removes the specified role from the specified group.
-    * 
-    * @param role The name of the role to remove from the group.
-    * @param group The group from which to remove the role.
-    * @return true if the role was successfully removed from the group.
-    */
-   boolean removeRoleFromGroup(String role, String group);   
-
-   /**
-    * Returns a list of all users.
-    */
-   List<String> listUsers();
-   
-   /**
-    * Returns a list of all users containing the specified filter text within their username.
-
-    */
-   List<String> listUsers(String filter);
-   
-   /**
-    * Returns a list of all the roles.
-    */
-   List<String> listRoles();
-   
-   /**
-    * Returns a list of roles that can be granted (i.e, excluding conditional roles)
-    */
-   List<String> listGrantableRoles();
-
-   /**
-    * Returns a list of all the roles explicitly granted to the specified user.
-    */
-   List<String> getGrantedRoles(String name);
-   
-   /**
-    * Returns a list of all roles that the specified user is a member of.  This list may contain
-    * roles that may not have been explicitly granted to the user, which are indirectly implied
-    * due to group memberships.
-
-    */
-   List<String> getImpliedRoles(String name);
-   
-   /**
-    * Returns a list of all the groups that the specified role is a member of.
-    */
-   List<String> getRoleGroups(String name);
-   
-   /**
-    * Lists the members of the specified role.
-    */
-   List<Principal> listMembers(String role);
-
-   /**
-    * Authenticates the specified user, using the specified password.
-    * 
-    * @return true if authentication is successful.
-    */
-   boolean authenticate(String username, String password);
-}



More information about the seam-commits mailing list