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

seam-commits at lists.jboss.org seam-commits at lists.jboss.org
Tue Apr 21 19:49:06 EDT 2009


Author: shane.bryzak at jboss.com
Date: 2009-04-21 19:49:06 -0400 (Tue, 21 Apr 2009)
New Revision: 10555

Added:
   modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/
   modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/Admin.java
   modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/Delete.java
   modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/Insert.java
   modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/PermissionCheck.java
   modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/Read.java
   modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/Restrict.java
   modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/RoleCheck.java
   modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/TokenUsername.java
   modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/TokenValue.java
   modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/Update.java
   modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/management/
   modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/management/PasswordSalt.java
   modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/management/RoleConditional.java
   modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/management/RoleGroups.java
   modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/management/RoleName.java
   modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/management/UserEnabled.java
   modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/management/UserFirstName.java
   modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/management/UserLastName.java
   modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/management/UserPassword.java
   modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/management/UserPrincipal.java
   modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/management/UserRoles.java
   modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/package-info.java
   modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/permission/
   modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/permission/Identifier.java
   modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/permission/Permission.java
   modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/permission/PermissionAction.java
   modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/permission/PermissionDiscriminator.java
   modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/permission/PermissionRole.java
   modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/permission/PermissionTarget.java
   modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/permission/PermissionUser.java
   modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/permission/Permissions.java
Modified:
   modules/trunk/security/pom.xml
   modules/trunk/security/src/main/java/org/jboss/seam/security/AuthorizationException.java
   modules/trunk/security/src/main/java/org/jboss/seam/security/Configuration.java
   modules/trunk/security/src/main/java/org/jboss/seam/security/EntityPermissionChecker.java
Log:
added security annotations

Modified: modules/trunk/security/pom.xml
===================================================================
--- modules/trunk/security/pom.xml	2009-04-21 23:34:35 UTC (rev 10554)
+++ modules/trunk/security/pom.xml	2009-04-21 23:49:06 UTC (rev 10555)
@@ -22,7 +22,11 @@
       <dependency>
          <groupId>org.jboss.webbeans</groupId>
          <artifactId>webbeans-logging</artifactId>
-      </dependency>                    
+      </dependency>
+      <dependency>
+         <groupId>javax.persistence</groupId>
+         <artifactId>persistence-api</artifactId>
+      </dependency>   
    </dependencies>
    
    <build>

Modified: modules/trunk/security/src/main/java/org/jboss/seam/security/AuthorizationException.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/AuthorizationException.java	2009-04-21 23:34:35 UTC (rev 10554)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/AuthorizationException.java	2009-04-21 23:49:06 UTC (rev 10555)
@@ -1,15 +1,14 @@
 package org.jboss.seam.security;
 
-import javax.ejb.ApplicationException;
-
 /**
  * Thrown when an authenticated user has insufficient rights to carry out an action.
  * 
  * @author Shane Bryzak
  */
- at ApplicationException(rollback=true)
 public class AuthorizationException extends RuntimeException
 { 
+   private static final long serialVersionUID = -981091398588455903L;
+
    public AuthorizationException(String message)
    {
       super(message);

Modified: modules/trunk/security/src/main/java/org/jboss/seam/security/Configuration.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/Configuration.java	2009-04-21 23:34:35 UTC (rev 10554)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/Configuration.java	2009-04-21 23:49:06 UTC (rev 10555)
@@ -1,21 +1,12 @@
 package org.jboss.seam.security;
 
-import static org.jboss.seam.ScopeType.APPLICATION;
-import static org.jboss.seam.annotations.Install.BUILT_IN;
-
 import java.util.HashMap;
 
+import javax.context.ApplicationScoped;
+import javax.inject.Produces;
 import javax.security.auth.login.AppConfigurationEntry;
 import javax.security.auth.login.AppConfigurationEntry.LoginModuleControlFlag;
 
-import org.jboss.seam.Component;
-import org.jboss.seam.ScopeType;
-import org.jboss.seam.annotations.Factory;
-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;
-import org.jboss.seam.contexts.Contexts;
 import org.jboss.seam.security.jaas.SeamLoginModule;
 
 /**
@@ -24,10 +15,6 @@
  * @author Shane Bryzak
  *
  */
- at Name("org.jboss.seam.security.configurationFactory")
- at BypassInterceptors
- at Scope(ScopeType.STATELESS)
- at Install(precedence = BUILT_IN)
 public class Configuration
 {
    static final String DEFAULT_JAAS_CONFIG_NAME = "default";   
@@ -58,18 +45,8 @@
          );
    }
    
-   @Factory(value="org.jboss.seam.security.configuration", autoCreate=true, scope=APPLICATION)
-   public javax.security.auth.login.Configuration getConfiguration()
+   @Produces @ApplicationScoped javax.security.auth.login.Configuration getConfiguration()
    {
       return createConfiguration();
    }
-
-   public static javax.security.auth.login.Configuration instance()
-   {
-      if ( !Contexts.isApplicationContextActive() )
-      {
-         throw new IllegalStateException("No active application scope");
-      }
-      return (javax.security.auth.login.Configuration) Component.getInstance("org.jboss.seam.security.configuration");
-   }
 }

Modified: modules/trunk/security/src/main/java/org/jboss/seam/security/EntityPermissionChecker.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/EntityPermissionChecker.java	2009-04-21 23:34:35 UTC (rev 10554)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/EntityPermissionChecker.java	2009-04-21 23:49:06 UTC (rev 10555)
@@ -1,19 +1,10 @@
 package org.jboss.seam.security;
 
-import static org.jboss.seam.ScopeType.APPLICATION;
-import static org.jboss.seam.annotations.Install.BUILT_IN;
-
 import java.lang.reflect.Method;
 
+import javax.context.ApplicationScoped;
 import javax.persistence.EntityManager;
 
-import org.jboss.seam.Component;
-import org.jboss.seam.ScopeType;
-import org.jboss.seam.annotations.Install;
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.annotations.Scope;
-import org.jboss.seam.annotations.Startup;
-import org.jboss.seam.annotations.intercept.BypassInterceptors;
 import org.jboss.seam.annotations.security.Restrict;
 import org.jboss.seam.contexts.Contexts;
 import org.jboss.seam.persistence.PersistenceProvider;
@@ -24,11 +15,7 @@
  * 
  * @author Shane Bryzak
  */
- at Name("org.jboss.seam.security.entityPermissionChecker")
- at Scope(APPLICATION)
- at Install(precedence = BUILT_IN)
- at BypassInterceptors
- at Startup
+ at ApplicationScoped
 public class EntityPermissionChecker
 {
    private String entityManagerName = "entityManager";

Added: modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/Admin.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/Admin.java	                        (rev 0)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/Admin.java	2009-04-21 23:49:06 UTC (rev 10555)
@@ -0,0 +1,25 @@
+package org.jboss.seam.annotations.security;
+
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.TYPE;
+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;
+
+/**
+ * Indicates that the action method requires the user to be a member of the 'admin' role to invoke.
+ * 
+ * @author Shane Bryzak
+ */
+ at Target({TYPE, METHOD})
+ at Documented
+ at Retention(RUNTIME)
+ at Inherited
+ at RoleCheck
+public @interface Admin
+{
+
+}

Added: modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/Delete.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/Delete.java	                        (rev 0)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/Delete.java	2009-04-21 23:49:06 UTC (rev 10555)
@@ -0,0 +1,24 @@
+package org.jboss.seam.security.annotations;
+
+import static java.lang.annotation.ElementType.PARAMETER;
+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, PARAMETER})
+ at Documented
+ at Retention(RUNTIME)
+ at Inherited
+ at PermissionCheck
+public @interface Delete {
+   Class value() default void.class;
+}

Added: modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/Insert.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/Insert.java	                        (rev 0)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/Insert.java	2009-04-21 23:49:06 UTC (rev 10555)
@@ -0,0 +1,24 @@
+package org.jboss.seam.security.annotations;
+
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+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, PARAMETER})
+ at Documented
+ at Retention(RUNTIME)
+ at Inherited
+ at PermissionCheck
+public @interface Insert {
+   Class value() default void.class;
+}

Added: modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/PermissionCheck.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/PermissionCheck.java	                        (rev 0)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/PermissionCheck.java	2009-04-21 23:49:06 UTC (rev 10555)
@@ -0,0 +1,24 @@
+package org.jboss.seam.security.annotations;
+
+import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
+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;
+
+/**
+ * Meta-annotation that designates an annotation as being a permission action, 
+ * requiring a security check prior to invoking the annotated method or class
+ *
+ * @author Shane Bryzak
+ */
+ at Target({ANNOTATION_TYPE})
+ at Documented
+ at Retention(RUNTIME)
+ at Inherited
+public @interface PermissionCheck 
+{
+   String value() default "";
+}

Added: modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/Read.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/Read.java	                        (rev 0)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/Read.java	2009-04-21 23:49:06 UTC (rev 10555)
@@ -0,0 +1,24 @@
+package org.jboss.seam.security.annotations;
+
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+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, PARAMETER})
+ at Documented
+ at Retention(RUNTIME)
+ at Inherited
+ at PermissionCheck
+public @interface Read {
+   Class value() default void.class;
+}

Added: modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/Restrict.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/Restrict.java	                        (rev 0)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/Restrict.java	2009-04-21 23:49:06 UTC (rev 10555)
@@ -0,0 +1,34 @@
+package org.jboss.seam.security.annotations;
+
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.TYPE;
+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;
+
+/**
+ * Used to restrict access to a Seam component, component method or entity.
+ * 
+ * @see org.jboss.seam.security.Identity
+ *
+ * @author Shane Bryzak
+ */
+ at Target({TYPE,METHOD})
+ at Documented
+ at Retention(RUNTIME)
+ at Inherited
+public @interface Restrict 
+{
+   /**
+    * Restrictions may be expressed using any EL expression, and usually
+    * include the use of s:hasRole(...) or s:hasPermission(..., /..).
+    * If no EL expression is explicitly specified, Seam security defaults
+    * the permission to be checked.
+    * 
+    * @return An EL expression that defines the restriction to be checked
+    */
+   String value() default "";
+}

Added: modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/RoleCheck.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/RoleCheck.java	                        (rev 0)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/RoleCheck.java	2009-04-21 23:49:06 UTC (rev 10555)
@@ -0,0 +1,24 @@
+package org.jboss.seam.security.annotations;
+
+import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
+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;
+
+/**
+ * Meta-annotation that designates an annotation as being a role, 
+ * requiring a security check prior to invoking the annotated method or class
+ *
+ * @author Shane Bryzak
+ */
+ at Target({ANNOTATION_TYPE})
+ at Documented
+ at Retention(RUNTIME)
+ at Inherited
+public @interface RoleCheck
+{
+
+}

Added: modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/TokenUsername.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/TokenUsername.java	                        (rev 0)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/TokenUsername.java	2009-04-21 23:49:06 UTC (rev 10555)
@@ -0,0 +1,24 @@
+package org.jboss.seam.security.annotations;
+
+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 username for an authentication token
+ *  
+ * @author Shane Bryzak
+ */
+ at Target({METHOD,FIELD})
+ at Documented
+ at Retention(RUNTIME)
+ at Inherited
+public @interface TokenUsername
+{
+
+}

Added: modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/TokenValue.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/TokenValue.java	                        (rev 0)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/TokenValue.java	2009-04-21 23:49:06 UTC (rev 10555)
@@ -0,0 +1,24 @@
+package org.jboss.seam.security.annotations;
+
+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 value for an authentication token
+ *  
+ * @author Shane Bryzak
+ */
+ at Target({METHOD,FIELD})
+ at Documented
+ at Retention(RUNTIME)
+ at Inherited
+public @interface TokenValue
+{
+
+}

Added: modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/Update.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/Update.java	                        (rev 0)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/Update.java	2009-04-21 23:49:06 UTC (rev 10555)
@@ -0,0 +1,24 @@
+package org.jboss.seam.security.annotations;
+
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+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, PARAMETER})
+ at Documented
+ at Retention(RUNTIME)
+ at Inherited
+ at PermissionCheck
+public @interface Update {
+   Class value() default void.class;
+}

Added: modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/management/PasswordSalt.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/management/PasswordSalt.java	                        (rev 0)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/management/PasswordSalt.java	2009-04-21 23:49:06 UTC (rev 10555)
@@ -0,0 +1,24 @@
+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
+{
+      
+}

Added: modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/management/RoleConditional.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/management/RoleConditional.java	                        (rev 0)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/management/RoleConditional.java	2009-04-21 23:49:06 UTC (rev 10555)
@@ -0,0 +1,24 @@
+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
+{
+
+}

Added: modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/management/RoleGroups.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/management/RoleGroups.java	                        (rev 0)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/management/RoleGroups.java	2009-04-21 23:49:06 UTC (rev 10555)
@@ -0,0 +1,24 @@
+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 RoleGroups
+{
+
+}

Added: modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/management/RoleName.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/management/RoleName.java	                        (rev 0)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/management/RoleName.java	2009-04-21 23:49:06 UTC (rev 10555)
@@ -0,0 +1,24 @@
+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 RoleName
+{
+
+}

Added: modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/management/UserEnabled.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/management/UserEnabled.java	                        (rev 0)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/management/UserEnabled.java	2009-04-21 23:49:06 UTC (rev 10555)
@@ -0,0 +1,24 @@
+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
+{
+
+}

Added: modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/management/UserFirstName.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/management/UserFirstName.java	                        (rev 0)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/management/UserFirstName.java	2009-04-21 23:49:06 UTC (rev 10555)
@@ -0,0 +1,24 @@
+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
+{
+
+}

Added: modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/management/UserLastName.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/management/UserLastName.java	                        (rev 0)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/management/UserLastName.java	2009-04-21 23:49:06 UTC (rev 10555)
@@ -0,0 +1,24 @@
+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
+{
+
+}

Added: modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/management/UserPassword.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/management/UserPassword.java	                        (rev 0)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/management/UserPassword.java	2009-04-21 23:49:06 UTC (rev 10555)
@@ -0,0 +1,32 @@
+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;
+}

Added: modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/management/UserPrincipal.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/management/UserPrincipal.java	                        (rev 0)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/management/UserPrincipal.java	2009-04-21 23:49:06 UTC (rev 10555)
@@ -0,0 +1,24 @@
+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
+{
+
+}

Added: modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/management/UserRoles.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/management/UserRoles.java	                        (rev 0)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/management/UserRoles.java	2009-04-21 23:49:06 UTC (rev 10555)
@@ -0,0 +1,24 @@
+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 list of role memberships for a user
+ *  
+ * @author Shane Bryzak
+ */
+ at Target({METHOD,FIELD})
+ at Documented
+ at Retention(RUNTIME)
+ at Inherited
+public @interface UserRoles
+{
+
+}

Added: modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/package-info.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/package-info.java	                        (rev 0)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/package-info.java	2009-04-21 23:49:06 UTC (rev 10555)
@@ -0,0 +1,7 @@
+/**
+ * Annotations (well, one annotation) for use with Seam security.
+ * 
+ * @see org.jboss.seam.security.Identity
+ */
+package org.jboss.seam.annotations.security;
+

Added: modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/permission/Identifier.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/permission/Identifier.java	                        (rev 0)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/permission/Identifier.java	2009-04-21 23:49:06 UTC (rev 10555)
@@ -0,0 +1,27 @@
+package org.jboss.seam.security.annotations.permission;
+
+import static java.lang.annotation.ElementType.TYPE;
+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;
+
+import org.jboss.seam.security.permission.IdentifierStrategy;
+
+/**
+ * Configures the Identifier strategy to use for instance-based permissions.  The specified class
+ * should implement the IdentifierStrategy interface.
+ *  
+ * @author Shane Bryzak
+ */
+ at Target({TYPE})
+ at Documented
+ at Retention(RUNTIME)
+ at Inherited
+public @interface Identifier
+{  
+   Class<? extends IdentifierStrategy> value() default IdentifierStrategy.class;
+   String name() default "";
+}

Added: modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/permission/Permission.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/permission/Permission.java	                        (rev 0)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/permission/Permission.java	2009-04-21 23:49:06 UTC (rev 10555)
@@ -0,0 +1,25 @@
+package org.jboss.seam.security.annotations.permission;
+
+import static java.lang.annotation.ElementType.TYPE;
+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;
+
+/**
+ * Specifies an allowable permission action for the target class, and allows for an optional bit mask
+ * value for mapping the permission action to a persistent store
+ *
+ * @author Shane Bryzak
+ */
+ at Target({TYPE})
+ at Documented
+ at Retention(RUNTIME)
+ at Inherited
+public @interface Permission
+{
+   String action();
+   long mask() default 0L;
+}

Added: modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/permission/PermissionAction.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/permission/PermissionAction.java	                        (rev 0)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/permission/PermissionAction.java	2009-04-21 23:49:06 UTC (rev 10555)
@@ -0,0 +1,25 @@
+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 action component of a permission, e.g. "update",
+ * "delete".
+ *  
+ * @author Shane Bryzak
+ */
+ at Target({METHOD,FIELD})
+ at Documented
+ at Retention(RUNTIME)
+ at Inherited
+public @interface PermissionAction
+{
+
+}

Added: modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/permission/PermissionDiscriminator.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/permission/PermissionDiscriminator.java	                        (rev 0)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/permission/PermissionDiscriminator.java	2009-04-21 23:49:06 UTC (rev 10555)
@@ -0,0 +1,26 @@
+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/trunk/security/src/main/java/org/jboss/seam/security/annotations/permission/PermissionRole.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/permission/PermissionRole.java	                        (rev 0)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/permission/PermissionRole.java	2009-04-21 23:49:06 UTC (rev 10555)
@@ -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 role that a permission is assigned to.
+ *  
+ * @author Shane Bryzak
+ */
+ at Target({METHOD,FIELD})
+ at Documented
+ at Retention(RUNTIME)
+ at Inherited
+public @interface PermissionRole
+{
+
+}

Added: modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/permission/PermissionTarget.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/permission/PermissionTarget.java	                        (rev 0)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/permission/PermissionTarget.java	2009-04-21 23:49:06 UTC (rev 10555)
@@ -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 target of a permission.
+ *  
+ * @author Shane Bryzak
+ */
+ at Target({METHOD,FIELD})
+ at Documented
+ at Retention(RUNTIME)
+ at Inherited
+public @interface PermissionTarget
+{
+
+}

Added: modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/permission/PermissionUser.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/permission/PermissionUser.java	                        (rev 0)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/permission/PermissionUser.java	2009-04-21 23:49:06 UTC (rev 10555)
@@ -0,0 +1,25 @@
+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
+{
+
+}

Added: modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/permission/Permissions.java
===================================================================
--- modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/permission/Permissions.java	                        (rev 0)
+++ modules/trunk/security/src/main/java/org/jboss/seam/security/annotations/permission/Permissions.java	2009-04-21 23:49:06 UTC (rev 10555)
@@ -0,0 +1,23 @@
+package org.jboss.seam.security.annotations.permission;
+
+import static java.lang.annotation.ElementType.TYPE;
+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;
+
+/**
+ * Specifies a list of permission actions for a class
+ *
+ * @author Shane Bryzak
+ */
+ at Target({TYPE})
+ at Documented
+ at Retention(RUNTIME)
+ at Inherited
+public @interface Permissions
+{
+   Permission[] value() default {};
+}




More information about the seam-commits mailing list