3 Replies Latest reply on Jan 29, 2006 3:55 PM by bill.burke

    Annotations Persistence Unit JACC Integration

    bill.burke

      Wanted to know what you all should think the API should be for the security integration for entity manager. Currently it must be done in persistence.xml:

      <persistence>
       <persistence-unit name="tempdb">
       <properties>
       <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
       <property name="hibernate.jacc.allowed.org.jboss.ejb3.test.jacc.AllEntity" value="insert,update,delete,read"/>
       <property name="hibernate.jacc.allowed.org.jboss.ejb3.test.jacc.StarEntity" value="*"/>
       <property name="hibernate.jacc.allowed.org.jboss.ejb3.test.jacc.SomeEntity" value="insert,delete"/>
      
       <property name="hibernate.jacc.enabled" value="true"/>
       </properties>
       </persistence-unit>
      </persistence>
      


      My thinking is this:
      public enum PersistenceAction {
       INSERT, DELETE, UPDATE, READ, ALL
      }
      
      @Target(TYPE) @Retention(RUNTIME)
      public @interface PersistenceRolesAllowed {
       String[] roles();
       PersistenceAction[] actions() default ALL;
      }
      


      Usage:

      @Entity
      @PersistenceRolesAllowed(roles="everybody")
      public class MyEntity


      @Entity
      @PersistenceRolesAllowed(roles="basic-user", actions={READ})
      public class MyEntity{...}