[seam-commits] Seam SVN: r12775 - in modules/security/trunk: api/src/main/java/org/jboss/seam/security/annotations/permission and 4 other directories.
seam-commits at lists.jboss.org
seam-commits at lists.jboss.org
Mon May 24 04:35:29 EDT 2010
Author: shane.bryzak at jboss.com
Date: 2010-05-24 04:35:28 -0400 (Mon, 24 May 2010)
New Revision: 12775
Added:
modules/security/trunk/api/src/main/java/org/jboss/seam/security/annotations/management/EntityName.java
modules/security/trunk/api/src/main/java/org/jboss/seam/security/annotations/management/EntityValue.java
modules/security/trunk/api/src/main/java/org/jboss/seam/security/annotations/permission/PermissionRecipient.java
modules/security/trunk/api/src/main/java/org/jboss/seam/security/annotations/permission/PermissionRecipientType.java
modules/security/trunk/api/src/main/java/org/jboss/seam/security/management/MembershipCache.java
modules/security/trunk/api/src/main/java/org/jboss/seam/security/management/PasswordEncoder.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/MembershipCacheImpl.java
modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/PasswordHashEncoder.java
Removed:
modules/security/trunk/api/src/main/java/org/jboss/seam/security/annotations/management/MemberOf.java
modules/security/trunk/api/src/main/java/org/jboss/seam/security/annotations/management/PasswordSalt.java
modules/security/trunk/api/src/main/java/org/jboss/seam/security/annotations/management/RoleConditional.java
modules/security/trunk/api/src/main/java/org/jboss/seam/security/annotations/management/RoleGroup.java
modules/security/trunk/api/src/main/java/org/jboss/seam/security/annotations/management/RoleType.java
modules/security/trunk/api/src/main/java/org/jboss/seam/security/annotations/management/UserEnabled.java
modules/security/trunk/api/src/main/java/org/jboss/seam/security/annotations/management/UserFirstName.java
modules/security/trunk/api/src/main/java/org/jboss/seam/security/annotations/management/UserLastName.java
modules/security/trunk/api/src/main/java/org/jboss/seam/security/annotations/management/UserPassword.java
modules/security/trunk/api/src/main/java/org/jboss/seam/security/annotations/management/UserPrincipal.java
modules/security/trunk/api/src/main/java/org/jboss/seam/security/annotations/permission/PermissionDiscriminator.java
modules/security/trunk/api/src/main/java/org/jboss/seam/security/annotations/permission/PermissionUser.java
Modified:
modules/security/trunk/api/src/main/java/org/jboss/seam/security/management/IdentityManager.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/permission/JpaPermissionStore.java
Log:
refactor annotations, add PasswordEncoder, MembershipCache interfaces, start work on new JpaIdentityStore implementation
Added: modules/security/trunk/api/src/main/java/org/jboss/seam/security/annotations/management/EntityName.java
===================================================================
--- modules/security/trunk/api/src/main/java/org/jboss/seam/security/annotations/management/EntityName.java (rev 0)
+++ modules/security/trunk/api/src/main/java/org/jboss/seam/security/annotations/management/EntityName.java 2010-05-24 08:35:28 UTC (rev 12775)
@@ -0,0 +1,23 @@
+package org.jboss.seam.security.annotations.management;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+/**
+ *
+ * @author Shane Bryzak
+ */
+ at Target({METHOD,FIELD})
+ at Documented
+ at Retention(RUNTIME)
+ at Inherited
+public @interface EntityName
+{
+
+}
Added: modules/security/trunk/api/src/main/java/org/jboss/seam/security/annotations/management/EntityValue.java
===================================================================
--- modules/security/trunk/api/src/main/java/org/jboss/seam/security/annotations/management/EntityValue.java (rev 0)
+++ modules/security/trunk/api/src/main/java/org/jboss/seam/security/annotations/management/EntityValue.java 2010-05-24 08:35:28 UTC (rev 12775)
@@ -0,0 +1,23 @@
+package org.jboss.seam.security.annotations.management;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+/**
+ *
+ * @author Shane Bryzak
+ */
+ at Target({METHOD,FIELD})
+ at Documented
+ at Retention(RUNTIME)
+ at Inherited
+public @interface EntityValue
+{
+
+}
Deleted: modules/security/trunk/api/src/main/java/org/jboss/seam/security/annotations/management/MemberOf.java
===================================================================
--- modules/security/trunk/api/src/main/java/org/jboss/seam/security/annotations/management/MemberOf.java 2010-05-23 09:42:58 UTC (rev 12774)
+++ modules/security/trunk/api/src/main/java/org/jboss/seam/security/annotations/management/MemberOf.java 2010-05-24 08:35:28 UTC (rev 12775)
@@ -1,24 +0,0 @@
-package org.jboss.seam.security.annotations.management;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.Inherited;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-
-/**
- * Flags an entity field or method as representing the group memberships for a role
- *
- * @author Shane Bryzak
- */
- at Target({METHOD,FIELD})
- at Documented
- at Retention(RUNTIME)
- at Inherited
-public @interface MemberOf
-{
-
-}
Deleted: modules/security/trunk/api/src/main/java/org/jboss/seam/security/annotations/management/PasswordSalt.java
===================================================================
--- modules/security/trunk/api/src/main/java/org/jboss/seam/security/annotations/management/PasswordSalt.java 2010-05-23 09:42:58 UTC (rev 12774)
+++ modules/security/trunk/api/src/main/java/org/jboss/seam/security/annotations/management/PasswordSalt.java 2010-05-24 08:35:28 UTC (rev 12775)
@@ -1,24 +0,0 @@
-package org.jboss.seam.security.annotations.management;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.Inherited;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-
-/**
- * The salt value used to produce the password hash
- *
- * @author Shane Bryzak
- */
- at Target({METHOD,FIELD})
- at Documented
- at Retention(RUNTIME)
- at Inherited
-public @interface PasswordSalt
-{
-
-}
Deleted: modules/security/trunk/api/src/main/java/org/jboss/seam/security/annotations/management/RoleConditional.java
===================================================================
--- modules/security/trunk/api/src/main/java/org/jboss/seam/security/annotations/management/RoleConditional.java 2010-05-23 09:42:58 UTC (rev 12774)
+++ modules/security/trunk/api/src/main/java/org/jboss/seam/security/annotations/management/RoleConditional.java 2010-05-24 08:35:28 UTC (rev 12775)
@@ -1,24 +0,0 @@
-package org.jboss.seam.security.annotations.management;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.Inherited;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-
-/**
- * Flags an entity field or method as representing whether a role is conditional or not
- *
- * @author Shane Bryzak
- */
- at Target({METHOD,FIELD})
- at Documented
- at Retention(RUNTIME)
- at Inherited
-public @interface RoleConditional
-{
-
-}
Deleted: modules/security/trunk/api/src/main/java/org/jboss/seam/security/annotations/management/RoleGroup.java
===================================================================
--- modules/security/trunk/api/src/main/java/org/jboss/seam/security/annotations/management/RoleGroup.java 2010-05-23 09:42:58 UTC (rev 12774)
+++ modules/security/trunk/api/src/main/java/org/jboss/seam/security/annotations/management/RoleGroup.java 2010-05-24 08:35:28 UTC (rev 12775)
@@ -1,23 +0,0 @@
-package org.jboss.seam.security.annotations.management;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.Inherited;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-
-/**
- * Flags an entity field or method as representing the name of the role group
- *
- * @author Shane Bryzak
- */
- at Target({METHOD,FIELD})
- at Documented
- at Retention(RUNTIME)
- at Inherited
-public @interface RoleGroup {
-
-}
Deleted: modules/security/trunk/api/src/main/java/org/jboss/seam/security/annotations/management/RoleType.java
===================================================================
--- modules/security/trunk/api/src/main/java/org/jboss/seam/security/annotations/management/RoleType.java 2010-05-23 09:42:58 UTC (rev 12774)
+++ modules/security/trunk/api/src/main/java/org/jboss/seam/security/annotations/management/RoleType.java 2010-05-24 08:35:28 UTC (rev 12775)
@@ -1,24 +0,0 @@
-package org.jboss.seam.security.annotations.management;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.Inherited;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-
-/**
- * Flags an entity field or method as representing the name of a role
- *
- * @author Shane Bryzak
- */
- at Target({METHOD,FIELD})
- at Documented
- at Retention(RUNTIME)
- at Inherited
-public @interface RoleType
-{
-
-}
Deleted: modules/security/trunk/api/src/main/java/org/jboss/seam/security/annotations/management/UserEnabled.java
===================================================================
--- modules/security/trunk/api/src/main/java/org/jboss/seam/security/annotations/management/UserEnabled.java 2010-05-23 09:42:58 UTC (rev 12774)
+++ modules/security/trunk/api/src/main/java/org/jboss/seam/security/annotations/management/UserEnabled.java 2010-05-24 08:35:28 UTC (rev 12775)
@@ -1,24 +0,0 @@
-package org.jboss.seam.security.annotations.management;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.Inherited;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-
-/**
- * Flags an entity field or method as representing the enabled status of a user
- *
- * @author Shane Bryzak
- */
- at Target({METHOD,FIELD})
- at Documented
- at Retention(RUNTIME)
- at Inherited
-public @interface UserEnabled
-{
-
-}
Deleted: modules/security/trunk/api/src/main/java/org/jboss/seam/security/annotations/management/UserFirstName.java
===================================================================
--- modules/security/trunk/api/src/main/java/org/jboss/seam/security/annotations/management/UserFirstName.java 2010-05-23 09:42:58 UTC (rev 12774)
+++ modules/security/trunk/api/src/main/java/org/jboss/seam/security/annotations/management/UserFirstName.java 2010-05-24 08:35:28 UTC (rev 12775)
@@ -1,24 +0,0 @@
-package org.jboss.seam.security.annotations.management;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.Inherited;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-
-/**
- * Flags an entity field or method as representing the first name of a user
- *
- * @author Shane Bryzak
- */
- at Target({METHOD,FIELD})
- at Documented
- at Retention(RUNTIME)
- at Inherited
-public @interface UserFirstName
-{
-
-}
Deleted: modules/security/trunk/api/src/main/java/org/jboss/seam/security/annotations/management/UserLastName.java
===================================================================
--- modules/security/trunk/api/src/main/java/org/jboss/seam/security/annotations/management/UserLastName.java 2010-05-23 09:42:58 UTC (rev 12774)
+++ modules/security/trunk/api/src/main/java/org/jboss/seam/security/annotations/management/UserLastName.java 2010-05-24 08:35:28 UTC (rev 12775)
@@ -1,24 +0,0 @@
-package org.jboss.seam.security.annotations.management;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.Inherited;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-
-/**
- * Flags an entity field or method as representing the last name of a user
- *
- * @author Shane Bryzak
- */
- at Target({METHOD,FIELD})
- at Documented
- at Retention(RUNTIME)
- at Inherited
-public @interface UserLastName
-{
-
-}
Deleted: modules/security/trunk/api/src/main/java/org/jboss/seam/security/annotations/management/UserPassword.java
===================================================================
--- modules/security/trunk/api/src/main/java/org/jboss/seam/security/annotations/management/UserPassword.java 2010-05-23 09:42:58 UTC (rev 12774)
+++ modules/security/trunk/api/src/main/java/org/jboss/seam/security/annotations/management/UserPassword.java 2010-05-24 08:35:28 UTC (rev 12775)
@@ -1,32 +0,0 @@
-package org.jboss.seam.security.annotations.management;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.Inherited;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-
-/**
- * Flags an entity field or method as representing the password for a user
- *
- * @author Shane Bryzak
- */
- at Target({METHOD,FIELD})
- at Documented
- at Retention(RUNTIME)
- at Inherited
-public @interface UserPassword
-{
- /**
- * The hash algorithm, only used if there is no @PasswordSalt property specified
- */
- String hash() default "";
-
- /**
- * Number of iterations for generating the password hash
- */
- int iterations() default 1000;
-}
Deleted: modules/security/trunk/api/src/main/java/org/jboss/seam/security/annotations/management/UserPrincipal.java
===================================================================
--- modules/security/trunk/api/src/main/java/org/jboss/seam/security/annotations/management/UserPrincipal.java 2010-05-23 09:42:58 UTC (rev 12774)
+++ modules/security/trunk/api/src/main/java/org/jboss/seam/security/annotations/management/UserPrincipal.java 2010-05-24 08:35:28 UTC (rev 12775)
@@ -1,24 +0,0 @@
-package org.jboss.seam.security.annotations.management;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.Inherited;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-
-/**
- * Flags an entity field or method as representing the principal (username) for a user
- *
- * @author Shane Bryzak
- */
- at Target({METHOD,FIELD})
- at Documented
- at Retention(RUNTIME)
- at Inherited
-public @interface UserPrincipal
-{
-
-}
Deleted: modules/security/trunk/api/src/main/java/org/jboss/seam/security/annotations/permission/PermissionDiscriminator.java
===================================================================
--- modules/security/trunk/api/src/main/java/org/jboss/seam/security/annotations/permission/PermissionDiscriminator.java 2010-05-23 09:42:58 UTC (rev 12774)
+++ modules/security/trunk/api/src/main/java/org/jboss/seam/security/annotations/permission/PermissionDiscriminator.java 2010-05-24 08:35:28 UTC (rev 12775)
@@ -1,26 +0,0 @@
-package org.jboss.seam.security.annotations.permission;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.Inherited;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-
-/**
- * Flags an entity field or method as representing the discriminator column in a permission table
- * that contains permissions for both roles and users.
- *
- * @author Shane Bryzak
- */
- at Target({METHOD,FIELD})
- at Documented
- at Retention(RUNTIME)
- at Inherited
-public @interface PermissionDiscriminator
-{
- String userValue() default "user";
- String roleValue() default "role";
-}
Added: modules/security/trunk/api/src/main/java/org/jboss/seam/security/annotations/permission/PermissionRecipient.java
===================================================================
--- modules/security/trunk/api/src/main/java/org/jboss/seam/security/annotations/permission/PermissionRecipient.java (rev 0)
+++ modules/security/trunk/api/src/main/java/org/jboss/seam/security/annotations/permission/PermissionRecipient.java 2010-05-24 08:35:28 UTC (rev 12775)
@@ -0,0 +1,24 @@
+package org.jboss.seam.security.annotations.permission;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+/**
+ * Flags an entity field or method as representing the recipient of a permission.
+ *
+ * @author Shane Bryzak
+ */
+ at Target({METHOD,FIELD})
+ at Documented
+ at Retention(RUNTIME)
+ at Inherited
+public @interface PermissionRecipient
+{
+
+}
Added: modules/security/trunk/api/src/main/java/org/jboss/seam/security/annotations/permission/PermissionRecipientType.java
===================================================================
--- modules/security/trunk/api/src/main/java/org/jboss/seam/security/annotations/permission/PermissionRecipientType.java (rev 0)
+++ modules/security/trunk/api/src/main/java/org/jboss/seam/security/annotations/permission/PermissionRecipientType.java 2010-05-24 08:35:28 UTC (rev 12775)
@@ -0,0 +1,22 @@
+package org.jboss.seam.security.annotations.permission;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+/**
+ *
+ * @author Shane Bryzak
+ */
+ at Target({METHOD,FIELD})
+ at Documented
+ at Retention(RUNTIME)
+ at Inherited
+public @interface PermissionRecipientType {
+
+}
Deleted: modules/security/trunk/api/src/main/java/org/jboss/seam/security/annotations/permission/PermissionUser.java
===================================================================
--- modules/security/trunk/api/src/main/java/org/jboss/seam/security/annotations/permission/PermissionUser.java 2010-05-23 09:42:58 UTC (rev 12774)
+++ modules/security/trunk/api/src/main/java/org/jboss/seam/security/annotations/permission/PermissionUser.java 2010-05-24 08:35:28 UTC (rev 12775)
@@ -1,25 +0,0 @@
-package org.jboss.seam.security.annotations.permission;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.Inherited;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-
-/**
- * Flags an entity field or method as representing the principal (username) that a permission is
- * assigned to.
- *
- * @author Shane Bryzak
- */
- at Target({METHOD,FIELD})
- at Documented
- at Retention(RUNTIME)
- at Inherited
-public @interface PermissionUser
-{
-
-}
Modified: 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/IdentityManager.java 2010-05-23 09:42:58 UTC (rev 12774)
+++ modules/security/trunk/api/src/main/java/org/jboss/seam/security/management/IdentityManager.java 2010-05-24 08:35:28 UTC (rev 12775)
@@ -1,6 +1,5 @@
package org.jboss.seam.security.management;
-import java.security.Principal;
import java.util.List;
import org.picketlink.idm.api.Group;
Added: modules/security/trunk/api/src/main/java/org/jboss/seam/security/management/MembershipCache.java
===================================================================
--- modules/security/trunk/api/src/main/java/org/jboss/seam/security/management/MembershipCache.java (rev 0)
+++ modules/security/trunk/api/src/main/java/org/jboss/seam/security/management/MembershipCache.java 2010-05-24 08:35:28 UTC (rev 12775)
@@ -0,0 +1,11 @@
+package org.jboss.seam.security.management;
+
+/**
+ * Caches user membership for roles and groups
+ *
+ * @author Shane Bryzak
+ */
+public interface MembershipCache
+{
+
+}
Added: modules/security/trunk/api/src/main/java/org/jboss/seam/security/management/PasswordEncoder.java
===================================================================
--- modules/security/trunk/api/src/main/java/org/jboss/seam/security/management/PasswordEncoder.java (rev 0)
+++ modules/security/trunk/api/src/main/java/org/jboss/seam/security/management/PasswordEncoder.java 2010-05-24 08:35:28 UTC (rev 12775)
@@ -0,0 +1,29 @@
+package org.jboss.seam.security.management;
+
+import java.util.Map;
+
+/**
+ * Encodes user passwords for persistent storage
+ *
+ * @author Shane Bryzak
+ *
+ */
+public interface PasswordEncoder
+{
+ /**
+ * Encodes the specified password
+ *
+ * @param password
+ * @return
+ */
+ String encodePassword(String password);
+
+ /**
+ * Encodes the specified password using the provided options
+ *
+ * @param password
+ * @param options
+ * @return
+ */
+ String encodePassword(String password, Map options);
+}
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-05-23 09:42:58 UTC (rev 12774)
+++ modules/security/trunk/impl/src/main/java/org/jboss/seam/security/jaas/SeamLoginModule.java 2010-05-24 08:35:28 UTC (rev 12775)
@@ -1,8 +1,5 @@
package org.jboss.seam.security.jaas;
-import static org.jboss.seam.security.IdentityImpl.ROLES_GROUP;
-
-import java.security.acl.Group;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
@@ -20,7 +17,6 @@
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.slf4j.Logger;
import org.slf4j.LoggerFactory;
Added: 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 (rev 0)
+++ modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/JpaIdentityStore.java 2010-05-24 08:35:28 UTC (rev 12775)
@@ -0,0 +1,202 @@
+package org.jboss.seam.security.management;
+
+import java.io.Serializable;
+import java.util.List;
+
+import javax.enterprise.context.ApplicationScoped;
+
+import org.picketlink.idm.api.Group;
+import org.picketlink.idm.api.IdentityType;
+import org.picketlink.idm.api.Role;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * IdentityStore implementation that allows identity related data to be
+ * persisted in a database via JPA
+ *
+ * @author Shane Bryzak
+ */
+public @ApplicationScoped class JpaIdentityStore implements IdentityStore, Serializable
+{
+ private static final long serialVersionUID = 7729139146633529501L;
+
+ private Logger log = LoggerFactory.getLogger(JpaIdentityStore.class);
+
+ private Class<?> identityObjectEntity;
+ private Class<?> identityObjectRelationshipEntity;
+ private Class<?> identityObjectCredentialEntity;
+ private Class<?> identityObjectAttributeEntity;
+
+ @Inject PasswordEncoder passwordEncoder;
+
+ public boolean addUserToGroup(String username, Group group)
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public boolean authenticate(String username, String password)
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public boolean changePassword(String username, String password)
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public boolean createGroup(String name, String groupType)
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public boolean createRoleType(String roleType)
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public boolean createUser(String username, String password)
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public boolean createUser(String username, String password,
+ String firstname, String lastname)
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public boolean deleteGroup(String name, String groupType)
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public boolean deleteRoleType(String roleType)
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public boolean deleteUser(String username)
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public boolean disableUser(String username)
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public boolean enableUser(String username)
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public Group findGroup(String name, String groupType)
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public List<String> findUsers()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public List<String> findUsers(String filter)
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public boolean grantRole(String username, String roleType, Group group)
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public boolean isUserEnabled(String username)
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public List<String> listGrantableRoleTypes()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public List<Role> listGrantedRoles(String username)
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public List<IdentityType> listGroupMembers(Group group)
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public List<Role> listImpliedRoles(String username)
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public List<IdentityType> listRoleMembers(String roleType, Group group)
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public List<String> listRoleTypes()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public boolean removeUserFromGroup(String username, Group group)
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public boolean revokeRole(String username, String roleType, Group group)
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public boolean roleTypeExists(String roleType)
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public boolean supportsFeature(Feature feature)
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public boolean userExists(String username)
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+}
Added: modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/MembershipCacheImpl.java
===================================================================
--- modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/MembershipCacheImpl.java (rev 0)
+++ modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/MembershipCacheImpl.java 2010-05-24 08:35:28 UTC (rev 12775)
@@ -0,0 +1,10 @@
+package org.jboss.seam.security.management;
+
+/**
+ *
+ * @author Shane Bryzak
+ */
+public class MembershipCacheImpl implements MembershipCache
+{
+
+}
Added: modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/PasswordHashEncoder.java
===================================================================
--- modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/PasswordHashEncoder.java (rev 0)
+++ modules/security/trunk/impl/src/main/java/org/jboss/seam/security/management/PasswordHashEncoder.java 2010-05-24 08:35:28 UTC (rev 12775)
@@ -0,0 +1,45 @@
+package org.jboss.seam.security.management;
+
+import java.util.Map;
+
+/**
+ * Default password encoder, creates password hashes.
+ *
+ * @author Shane Bryzak
+ *
+ */
+public class PasswordHashEncoder implements PasswordEncoder
+{
+ private String passwordHash;
+ private int passwordIterations = 1000;
+
+ public String getPasswordHash()
+ {
+ return passwordHash;
+ }
+
+ public void setPasswordHash(String passwordHash)
+ {
+ this.passwordHash = passwordHash;
+ }
+
+ public int getPasswordIterations()
+ {
+ return passwordIterations;
+ }
+
+ public void setPasswordIterations(int passwordIterations)
+ {
+ this.passwordIterations = passwordIterations;
+ }
+
+ public String encodePassword(String password)
+ {
+ return encodePassword(password, null);
+ }
+
+ public String encodePassword(String password, Map options)
+ {
+ return null;
+ }
+}
Modified: modules/security/trunk/impl/src/main/java/org/jboss/seam/security/permission/JpaPermissionStore.java
===================================================================
--- modules/security/trunk/impl/src/main/java/org/jboss/seam/security/permission/JpaPermissionStore.java 2010-05-23 09:42:58 UTC (rev 12774)
+++ modules/security/trunk/impl/src/main/java/org/jboss/seam/security/permission/JpaPermissionStore.java 2010-05-24 08:35:28 UTC (rev 12775)
@@ -18,10 +18,10 @@
import org.jboss.seam.security.RoleImpl;
import org.jboss.seam.security.annotations.permission.PermissionAction;
-import org.jboss.seam.security.annotations.permission.PermissionDiscriminator;
+import org.jboss.seam.security.annotations.permission.PermissionRecipient;
+import org.jboss.seam.security.annotations.permission.PermissionRecipientType;
import org.jboss.seam.security.annotations.permission.PermissionRole;
import org.jboss.seam.security.annotations.permission.PermissionTarget;
-import org.jboss.seam.security.annotations.permission.PermissionUser;
import org.jboss.seam.security.management.IdentityManager;
//import org.jboss.seam.security.management.JpaIdentityStore;
import org.jboss.seam.security.permission.PermissionMetadata.ActionSet;
@@ -46,12 +46,12 @@
private Class<?> userPermissionClass;
private Class<?> rolePermissionClass;
- private AnnotatedBeanProperty<PermissionUser> userProperty;
+ private AnnotatedBeanProperty<PermissionRecipient> recipientProperty;
private AnnotatedBeanProperty<PermissionRole> roleProperty;
private AnnotatedBeanProperty<PermissionTarget> targetProperty;
private AnnotatedBeanProperty<PermissionAction> actionProperty;
- private AnnotatedBeanProperty<PermissionDiscriminator> discriminatorProperty;
+ private AnnotatedBeanProperty<PermissionRecipientType> recipientTypeProperty;
private AnnotatedBeanProperty<PermissionTarget> roleTargetProperty;
private AnnotatedBeanProperty<PermissionAction> roleActionProperty;
@@ -84,7 +84,7 @@
protected void initProperties()
{
- userProperty = new AnnotatedBeanProperty<PermissionUser>(userPermissionClass, PermissionUser.class);
+ recipientProperty = new AnnotatedBeanProperty<PermissionRecipient>(userPermissionClass, PermissionRecipient.class);
targetProperty = new AnnotatedBeanProperty<PermissionTarget>(userPermissionClass, PermissionTarget.class);
actionProperty = new AnnotatedBeanProperty<PermissionAction>(userPermissionClass, PermissionAction.class);
@@ -104,12 +104,12 @@
roleProperty = new AnnotatedBeanProperty<PermissionRole>(userPermissionClass, PermissionRole.class);
if (roleProperty.isSet())
{
- discriminatorProperty = new AnnotatedBeanProperty<PermissionDiscriminator>(userPermissionClass,
- PermissionDiscriminator.class);
+ recipientTypeProperty = new AnnotatedBeanProperty<PermissionRecipientType>(userPermissionClass,
+ PermissionRecipientType.class);
}
}
- if (!userProperty.isSet())
+ if (!recipientProperty.isSet())
{
throw new RuntimeException("Invalid userPermissionClass " + userPermissionClass.getName() +
" - required annotation @PermissionUser not found on any Field or Method.");
@@ -135,7 +135,7 @@
" - required annotation @PermissionAction not found on any Field or Method.");
}
}
- else if (!discriminatorProperty.isSet())
+ else if (!recipientTypeProperty.isSet())
{
throw new RuntimeException("Invalid userPermissionClass " + userPermissionClass.getName() +
" - no rolePermissionClass set and @PermissionDiscriminator annotation not found on " +
@@ -198,16 +198,16 @@
if (recipient != null)
{
q.append(conditionsAdded ? " and p." : " where p.");
- q.append(isRole ? roleProperty.getName() : userProperty.getName());
+ q.append(isRole ? roleProperty.getName() : recipientProperty.getName());
q.append(" = :recipient");
conditionsAdded = true;
}
// If there is no discrimination, then don't add such a condition to the query
- if (!discrimination.equals(Discrimination.either) && discriminatorProperty != null)
+ if (!discrimination.equals(Discrimination.either) && recipientTypeProperty != null)
{
q.append(conditionsAdded ? " and p." : " where p.");
- q.append(discriminatorProperty.getName());
+ q.append(recipientTypeProperty.getName());
q.append(" = :discriminator");
conditionsAdded = true;
}
@@ -232,7 +232,7 @@
if (recipient != null) query.setParameter("recipient", resolvePrincipalEntity(recipient));
- if (!discrimination.equals(Discrimination.either) && discriminatorProperty != null)
+ if (!discrimination.equals(Discrimination.either) && recipientTypeProperty != null)
{
query.setParameter("discriminator", getDiscriminatorValue(
discrimination.equals(Discrimination.role)));
@@ -339,7 +339,7 @@
return true;
}
- if (!discriminatorProperty.isSet())
+ if (!recipientTypeProperty.isSet())
{
throw new RuntimeException("Could not grant permission, rolePermissionClass not set");
}
@@ -373,14 +373,15 @@
}
else
{
- userProperty.setValue(instance, resolvePrincipalEntity(recipient));
+ recipientProperty.setValue(instance, resolvePrincipalEntity(recipient));
}
- if (discriminatorProperty.isSet())
+ if (recipientTypeProperty.isSet())
{
- PermissionDiscriminator discriminator = discriminatorProperty.getAnnotation();
- discriminatorProperty.setValue(instance, recipientIsRole ? discriminator.roleValue() :
- discriminator.userValue());
+ PermissionRecipientType discriminator = recipientTypeProperty.getAnnotation();
+ // TODO need to populate the correct recipient type
+ //recipientTypeProperty.setValue(instance, recipientIsRole ? discriminator.roleValue() :
+ // discriminator.userValue());
}
lookupEntityManager().persist(instance);
@@ -514,8 +515,10 @@
private String getDiscriminatorValue(boolean isRole)
{
- PermissionDiscriminator discriminator = discriminatorProperty.getAnnotation();
- return isRole ? discriminator.roleValue() : discriminator.userValue();
+ PermissionRecipientType discriminator = recipientTypeProperty.getAnnotation();
+ // TODO fix
+ //return isRole ? discriminator.roleValue() : discriminator.userValue();
+ return null;
}
/**
@@ -620,7 +623,7 @@
Map<String,Principal> principalCache = new HashMap<String,Principal>();
- boolean useDiscriminator = rolePermissionClass == null && discriminatorProperty.isSet();
+ boolean useDiscriminator = rolePermissionClass == null && recipientTypeProperty.isSet();
Map<String,Object> identifierCache = null;
@@ -657,9 +660,11 @@
{
boolean isUser = true;
- if (useDiscriminator &&
- discriminatorProperty.getAnnotation().roleValue().equals(
- discriminatorProperty.getValue(permission)))
+ // TODO fix
+ if (useDiscriminator //&&
+ //recipientTypeProperty.getAnnotation().roleValue().equals(
+ // recipientTypeProperty.getValue(permission)))
+ )
{
isUser = false;
}
@@ -731,7 +736,7 @@
private Principal lookupPrincipal(Map<String,Principal> cache, Object permission, boolean isUser)
{
- Principal principal = resolvePrincipal(isUser ? userProperty.getValue(permission) :
+ Principal principal = resolvePrincipal(isUser ? recipientProperty.getValue(permission) :
roleProperty.getValue(permission), isUser);
String key = (isUser ? "u:" : "r:") + principal.getName();
More information about the seam-commits
mailing list