[jboss-cvs] JBossAS SVN: r69468 - in projects/security/security-jboss-sx/trunk/acl: src/main/org/jboss/security/acl and 4 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Jan 29 16:04:54 EST 2008
Author: sguilhen at redhat.com
Date: 2008-01-29 16:04:54 -0500 (Tue, 29 Jan 2008)
New Revision: 69468
Added:
projects/security/security-jboss-sx/trunk/acl/src/main/org/jboss/security/acl/Util.java
projects/security/security-jboss-sx/trunk/acl/src/tests/org/jboss/test/security/acl/PersistenceTest.java
projects/security/security-jboss-sx/trunk/acl/src/tests/resources/
projects/security/security-jboss-sx/trunk/acl/src/tests/resources/META-INF/
projects/security/security-jboss-sx/trunk/acl/src/tests/resources/META-INF/persistence.xml
Modified:
projects/security/security-jboss-sx/trunk/acl/.classpath
projects/security/security-jboss-sx/trunk/acl/.project
projects/security/security-jboss-sx/trunk/acl/pom.xml
projects/security/security-jboss-sx/trunk/acl/src/main/org/jboss/security/acl/ACLEntryImpl.java
projects/security/security-jboss-sx/trunk/acl/src/main/org/jboss/security/acl/ACLImpl.java
projects/security/security-jboss-sx/trunk/acl/src/main/org/jboss/security/acl/ACLProviderImpl.java
projects/security/security-jboss-sx/trunk/acl/src/main/org/jboss/security/acl/BasicACLPermission.java
projects/security/security-jboss-sx/trunk/acl/src/main/org/jboss/security/acl/BitMaskPermission.java
projects/security/security-jboss-sx/trunk/acl/src/main/org/jboss/security/acl/CompositeACLPermission.java
projects/security/security-jboss-sx/trunk/acl/src/tests/org/jboss/test/security/acl/ACLProviderUnitTestCase.java
projects/security/security-jboss-sx/trunk/acl/src/tests/org/jboss/test/security/acl/ACLUnitTestCase.java
projects/security/security-jboss-sx/trunk/acl/src/tests/org/jboss/test/security/acl/ACLUseTestCase.java
projects/security/security-jboss-sx/trunk/acl/src/tests/org/jboss/test/security/acl/TestResource.java
Log:
Added persistence capabilities to the ACL implementation.
Modified: projects/security/security-jboss-sx/trunk/acl/.classpath
===================================================================
--- projects/security/security-jboss-sx/trunk/acl/.classpath 2008-01-29 20:58:01 UTC (rev 69467)
+++ projects/security/security-jboss-sx/trunk/acl/.classpath 2008-01-29 21:04:54 UTC (rev 69468)
@@ -1,13 +1,46 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
+ <classpathentry excluding="**/*.java" including="JBossORG-EULA.txt" kind="src" path=""/>
<classpathentry kind="src" path="src/main"/>
- <classpathentry kind="src" path="src/resources"/>
- <classpathentry excluding="resources/" kind="src" output="target/test-classes" path="src/tests"/>
+ <classpathentry excluding="**/*.java" including="**/*.dtd|**/*.xsd|**/*.xml" kind="src" path="src/resources"/>
+ <classpathentry including="**/*.java;resources/*" kind="src" output="target/test-classes" path="src/tests"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3"/>
- <classpathentry kind="var" path="M2_REPO/org/jboss/security/identity-impl/2.0.2-SNAPSHOT/identity-impl-2.0.2-SNAPSHOT.jar"/>
- <classpathentry kind="var" path="M2_REPO/org/jboss/security/acl-spi/2.0.2.Beta3/acl-spi-2.0.2.Beta3.jar"/>
+ <classpathentry kind="var" path="M2_REPO/antlr/antlr/2.7.6/antlr-2.7.6.jar"/>
+ <classpathentry kind="var" path="M2_REPO/log4j/log4j/1.2.14/log4j-1.2.14.jar"/>
+ <classpathentry kind="var" path="M2_REPO/asm/asm-attrs/1.5.3/asm-attrs-1.5.3.jar"/>
+ <classpathentry kind="var" path="M2_REPO/commons-logging/commons-logging/1.0.4/commons-logging-1.0.4.jar"/>
+ <classpathentry kind="var" path="M2_REPO/apache-httpclient/commons-httpclient/2.0.2/commons-httpclient-2.0.2.jar"/>
+ <classpathentry kind="var" path="M2_REPO/javax/transaction/jta/1.0.1B/jta-1.0.1B.jar"/>
+ <classpathentry kind="var" path="M2_REPO/net/sf/ehcache/ehcache/1.2.3/ehcache-1.2.3.jar"/>
+ <classpathentry kind="var" path="M2_REPO/apache-slide/webdavlib/2.0/webdavlib-2.0.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/hibernate/hibernate-annotations/3.3.0.ga/hibernate-annotations-3.3.0.ga.jar"/>
+ <classpathentry kind="var" path="M2_REPO/jboss/javassist/3.3.ga/javassist-3.3.ga.jar"/>
+ <classpathentry kind="var" path="M2_REPO/jboss/profiler/jvmti/jboss-profiler-jvmti/1.0.0.CR5/jboss-profiler-jvmti-1.0.0.CR5.jar"/>
+ <classpathentry kind="var" path="M2_REPO/apache-log4j/log4j/1.2.14/log4j-1.2.14.jar"/>
+ <classpathentry kind="var" path="M2_REPO/apache-xerces/xml-apis/2.7.1/xml-apis-2.7.1.jar"/>
+ <classpathentry kind="var" path="M2_REPO/commons-collections/commons-collections/2.1.1/commons-collections-2.1.1.jar"/>
+ <classpathentry kind="var" path="M2_REPO/jboss/jboss-common-core/2.0.2.GA/jboss-common-core-2.0.2.GA.jar"/>
+ <classpathentry kind="var" path="M2_REPO/hsqldb/hsqldb/1.8.0.2/hsqldb-1.8.0.2.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/hibernate/hibernate-entitymanager/3.3.1.ga/hibernate-entitymanager-3.3.1.ga.jar"/>
+ <classpathentry kind="var" path="M2_REPO/jboss/jboss-logging-log4j/2.0.2.GA/jboss-logging-log4j-2.0.2.GA.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/jboss/security/acl-spi/2.0.2-SNAPSHOT/acl-spi-2.0.2-SNAPSHOT.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/jboss/jboss-test/1.0.4.GA/jboss-test-1.0.4.GA.jar"/>
+ <classpathentry kind="var" path="M2_REPO/asm/asm/1.5.3/asm-1.5.3.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/jboss/jboss-common-core/2.2.1.GA/jboss-common-core-2.2.1.GA.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/jboss/security/authorization-spi/2.0.2.Beta3/authorization-spi-2.0.2.Beta3.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/jboss/security/identity-impl/2.0.2-SNAPSHOT/identity-impl-2.0.2-SNAPSHOT.jar" sourcepath="M2_REPO/org/jboss/security/identity-impl/2.0.2-SNAPSHOT/identity-impl-2.0.2-SNAPSHOT-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/junit/junit/3.8.1/junit-3.8.1.jar"/>
+ <classpathentry kind="var" path="M2_REPO/jboss/jboss-logging-spi/2.0.2.GA/jboss-logging-spi-2.0.2.GA.jar"/>
+ <classpathentry kind="var" path="M2_REPO/cglib/cglib/2.1_3/cglib-2.1_3.jar"/>
+ <classpathentry kind="var" path="M2_REPO/ant/ant/1.6.5/ant-1.6.5.jar"/>
+ <classpathentry kind="var" path="M2_REPO/javax/persistence/persistence-api/1.0/persistence-api-1.0.jar"/>
+ <classpathentry kind="var" path="M2_REPO/jboss/jboss-common-logging-spi/2.0.4.GA/jboss-common-logging-spi-2.0.4.GA.jar"/>
+ <classpathentry kind="var" path="M2_REPO/jboss/jboss-common-logging-log4j/2.0.4.GA/jboss-common-logging-log4j-2.0.4.GA.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/hibernate/hibernate-validator/3.0.0.ga/hibernate-validator-3.0.0.ga.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/hibernate/hibernate/3.2.4.sp1/hibernate-3.2.4.sp1.jar"/>
+ <classpathentry kind="var" path="M2_REPO/dom4j/dom4j/1.6.1/dom4j-1.6.1.jar"/>
+ <classpathentry kind="var" path="M2_REPO/ant/ant-junit/1.6.5/ant-junit-1.6.5.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/hibernate/hibernate-commons-annotations/3.0.0.ga/hibernate-commons-annotations-3.0.0.ga.jar"/>
<classpathentry kind="var" path="M2_REPO/org/jboss/security/identity-spi/2.0.2.Beta3/identity-spi-2.0.2.Beta3.jar"/>
- <classpathentry kind="var" path="M2_REPO/org/jboss/security/authorization-spi/2.0.2.Beta3/authorization-spi-2.0.2.Beta3.jar"/>
- <classpathentry kind="output" path="target/eclipse-classes"/>
+ <classpathentry kind="output" path="target/classes"/>
</classpath>
Modified: projects/security/security-jboss-sx/trunk/acl/.project
===================================================================
--- projects/security/security-jboss-sx/trunk/acl/.project 2008-01-29 20:58:01 UTC (rev 69467)
+++ projects/security/security-jboss-sx/trunk/acl/.project 2008-01-29 21:04:54 UTC (rev 69468)
@@ -1,17 +1,13 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>acl</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
+<projectDescription>
+ <name>jboss-security-acl</name>
+ <comment>JBoss Security is a cross cutting project that handles security for the JEMS projects</comment>
+ <projects/>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
\ No newline at end of file
Modified: projects/security/security-jboss-sx/trunk/acl/pom.xml
===================================================================
--- projects/security/security-jboss-sx/trunk/acl/pom.xml 2008-01-29 20:58:01 UTC (rev 69467)
+++ projects/security/security-jboss-sx/trunk/acl/pom.xml 2008-01-29 21:04:54 UTC (rev 69468)
@@ -83,6 +83,9 @@
<testResources>
<testResource>
<directory>src/tests/resources/</directory>
+ <includes>
+ <include>**/*.xml</include>
+ </includes>
</testResource>
<testResource>
<directory>src/main</directory>
@@ -93,6 +96,7 @@
<dependency>
<groupId>org.jboss.security</groupId>
<artifactId>acl-spi</artifactId>
+ <version>2.0.2-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.jboss.security</groupId>
@@ -114,6 +118,30 @@
<scope>runtime</scope>
</dependency>
<dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate</artifactId>
+ <version>3.2.4.sp1</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-annotations</artifactId>
+ <version>3.3.0.ga</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-entitymanager</artifactId>
+ <version>3.3.1.ga</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>hsqldb</groupId>
+ <artifactId>hsqldb</artifactId>
+ <version>1.8.0.2</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>apache-log4j</groupId>
<artifactId>log4j</artifactId>
<scope>compile</scope>
@@ -132,7 +160,7 @@
<groupId>org.jboss.security</groupId>
<artifactId>identity-impl</artifactId>
<version>2.0.2-SNAPSHOT</version>
- <scope>test</scope>
+ <scope>compile</scope>
</dependency>
</dependencies>
</project>
Modified: projects/security/security-jboss-sx/trunk/acl/src/main/org/jboss/security/acl/ACLEntryImpl.java
===================================================================
--- projects/security/security-jboss-sx/trunk/acl/src/main/org/jboss/security/acl/ACLEntryImpl.java 2008-01-29 20:58:01 UTC (rev 69467)
+++ projects/security/security-jboss-sx/trunk/acl/src/main/org/jboss/security/acl/ACLEntryImpl.java 2008-01-29 21:04:54 UTC (rev 69468)
@@ -21,30 +21,70 @@
*/
package org.jboss.security.acl;
+import java.io.Serializable;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.ManyToOne;
+import javax.persistence.PostLoad;
+import javax.persistence.PrePersist;
+import javax.persistence.Table;
+import javax.persistence.Transient;
+
import org.jboss.security.identity.Identity;
/**
* <p>
- * This class represents an entry in the Access Control List (ACL), and associates a permission
- * to an identity. This implementation only stores permissions of type <code>BitMaskPermission</code>,
+ * This class represents an entry in the Access Control List (ACL), and associates a permission
+ * to an identity. This implementation only stores permissions of type {@code BitMaskPermission},
* and can also only check permissions of that type.
* </p>
*
* @author <a href="mailto:sguilhen at redhat.com">Stefan Guilhen</a>
*/
-public class ACLEntryImpl implements ACLEntry
+ at Entity
+ at Table(name = "ACL_ENTRY")
+public class ACLEntryImpl implements ACLEntry, Serializable
{
- private final BitMaskPermission permission;
+ private static final long serialVersionUID = -2985214023383451768L;
- private final Identity identity;
+ @Id
+ @GeneratedValue
+ private long entryID;
+ @Transient
+ private BitMaskPermission permission;
+
+ /* persist only the bitmask */
+ private int bitMask;
+
+ @Transient
+ private Identity identity;
+
+ /* persist the string representation of the identity */
+ private String identityString;
+
+ @ManyToOne
+ private ACLImpl acl;
+
/**
* <p>
- * Builds an instance of <code>ACLEntry</code> with the specified permission and identity.
+ * Builds an instance of {@code ACLEntryImpl}. This constructor is required by the JPA
+ * specification.
* </p>
+ */
+ ACLEntryImpl()
+ {
+ }
+
+ /**
+ * <p>
+ * Builds an instance of {@code ACLEntryImpl} with the specified permission and identity.
+ * </p>
*
- * @param permission the <code>ACLPermission</code> granted to the associated identity.
- * @param identity the <code>Identity</code> for which the permission is being granted.
+ * @param permission the {@code ACLPermission} granted to the associated identity.
+ * @param identity the {@code Identity} for which the permission is being granted.
*/
public ACLEntryImpl(BitMaskPermission permission, Identity identity)
{
@@ -52,6 +92,60 @@
this.identity = identity;
}
+ /**
+ * <p>
+ * Obtains the persistent id of this {@code ACLEntryImpl}.
+ * </p>
+ *
+ * @return a {@code long} representing the persistent id this entry.
+ */
+ public long getACLEntryId()
+ {
+ return this.entryID;
+ }
+
+ /**
+ * <p>
+ * Method called by the JPA layer before persisting the fields.
+ * </p>
+ */
+ @PrePersist
+ @SuppressWarnings("unused")
+ private void setPersistentFields()
+ {
+ if (this.permission != null)
+ this.bitMask = this.permission.getMaskValue();
+ this.identityString = Util.getIdentityAsString(this.identity);
+ }
+
+ /**
+ * <p>
+ * Method called by the JPA layer after loading the persisted object.
+ * </p>
+ */
+ @PostLoad
+ @SuppressWarnings("unused")
+ private void loadState()
+ {
+ if (this.permission != null)
+ throw new IllegalStateException("ACLEntry permission has already been set");
+ this.permission = new CompositeACLPermission(this.bitMask);
+
+ if (this.identity != null)
+ throw new IllegalStateException("ACLEntry identity has already been set");
+ this.identity = Util.getIdentityFromString(identityString);
+ }
+
+ public ACLImpl getAcl()
+ {
+ return this.acl;
+ }
+
+ public void setAcl(ACLImpl acl)
+ {
+ this.acl = acl;
+ }
+
/*
* (non-Javadoc)
* @see org.jboss.security.acl.ACLEntry#getIdentity()
@@ -85,4 +179,20 @@
// simple implementation: if any bit matches, return true.
return (this.permission.getMaskValue() & bitmaskPermission.getMaskValue()) != 0;
}
+
+ /*
+ * (non-Javadoc)
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (obj instanceof ACLEntryImpl)
+ {
+ ACLEntryImpl entry = (ACLEntryImpl) obj;
+ return entry.permission.getMaskValue() == this.permission.getMaskValue()
+ && entry.getIdentity().getName().equals(this.identity.getName());
+ }
+ return false;
+ }
}
Modified: projects/security/security-jboss-sx/trunk/acl/src/main/org/jboss/security/acl/ACLImpl.java
===================================================================
--- projects/security/security-jboss-sx/trunk/acl/src/main/org/jboss/security/acl/ACLImpl.java 2008-01-29 20:58:01 UTC (rev 69467)
+++ projects/security/security-jboss-sx/trunk/acl/src/main/org/jboss/security/acl/ACLImpl.java 2008-01-29 21:04:54 UTC (rev 69468)
@@ -21,12 +21,24 @@
*/
package org.jboss.security.acl;
+import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.OneToMany;
+import javax.persistence.Table;
+import javax.persistence.Transient;
+
+import org.hibernate.annotations.Cascade;
import org.jboss.security.authorization.Resource;
import org.jboss.security.identity.Identity;
@@ -38,19 +50,46 @@
*
* @author <a href="mailto:sguilhen at redhat.com">Stefan Guilhen</a>
*/
-public class ACLImpl implements ACL
+ at Entity
+ at Table(name = "ACL")
+public class ACLImpl implements ACL, Serializable
{
+ private static final long serialVersionUID = -6390609071167528812L;
- private final Resource resource;
+ @Id
+ @GeneratedValue
+ private long aclID;
- private final Map<Identity, ACLEntry> entries;
+ @Transient
+ private Resource resource;
+ @Column(name = "resource")
+ private String resourceAsString;
+
+ @Transient
+ private Map<Identity, ACLEntry> entriesMap;
+
+ @OneToMany(mappedBy = "acl", fetch = FetchType.EAGER, cascade =
+ {CascadeType.REMOVE, CascadeType.PERSIST})
+ @Cascade(
+ {org.hibernate.annotations.CascadeType.DELETE_ORPHAN})
+ private Collection<ACLEntryImpl> entries;
+
/**
* <p>
- * Builds an instance of <code>ACLImpl</code> for the specified resource.
+ * Builds an instance of {@code ACLImpl}. This constructor is required by the JPA specification.
* </p>
+ */
+ ACLImpl()
+ {
+ }
+
+ /**
+ * <p>
+ * Builds an instance of {@code ACLImpl} for the specified resource.
+ * </p>
*
- * @param resource a reference to the <code>Resource</code> associated with
+ * @param resource a reference to the {@code Resource} associated with
* the ACL being constructed.
*/
public ACLImpl(Resource resource)
@@ -60,32 +99,56 @@
/**
* <p>
- * Builds an instance of <code>ACLImpl</code> for the specified resource, and initialize
+ * Builds an instance of {@code ACLImpl} for the specified resource, and initialize
* it with the specified entries.
* </p>
*
- * @param resource a reference to the <code>Resource</code> associated with
+ * @param resource a reference to the {@code Resource} associated with
* the ACL being constructed.
- * @param entries a <code>Collection</code> containing the ACL's initial entries.
+ * @param entries a {@code Collection} containing the ACL's initial entries.
*/
public ACLImpl(Resource resource, Collection<ACLEntry> entries)
{
this.resource = resource;
- this.entries = new HashMap<Identity, ACLEntry>();
- for (ACLEntry entry : entries)
- this.entries.put(entry.getIdentity(), entry);
+ this.resourceAsString = Util.getResourceAsString(resource);
+ this.entries = new ArrayList<ACLEntryImpl>();
+ this.entriesMap = new HashMap<Identity, ACLEntry>();
+ if (entries != null)
+ {
+ for (ACLEntry entry : entries)
+ {
+ ACLEntryImpl entryImpl = (ACLEntryImpl) entry;
+ entryImpl.setAcl(this);
+ this.entries.add(entryImpl);
+ this.entriesMap.put(entryImpl.getIdentity(), entryImpl);
+ }
+ }
}
+ /**
+ * <p>
+ * Obtains the persistent id of this {@code ACLImpl}.
+ * </p>
+ *
+ * @return a {@code long} representing the persistent id this ACL.
+ */
+ public long getACLId()
+ {
+ return this.aclID;
+ }
+
/*
* (non-Javadoc)
* @see org.jboss.security.acl.ACL#addEntry(org.jboss.security.acl.ACLEntry)
*/
public boolean addEntry(ACLEntry entry)
{
- // don't add a null entry or an entry that already exists.
- if (entry == null || this.entries.get(entry.getIdentity()) != null)
+ // don't add a null entry or an entry that already existSELECT * FROM ACL_ENTRYs.
+ if (entry == null || this.entriesMap.get(entry.getIdentity()) != null)
return false;
- this.entries.put(entry.getIdentity(), entry);
+ this.entries.add((ACLEntryImpl) entry);
+ ((ACLEntryImpl) entry).setAcl(this);
+ this.entriesMap.put(entry.getIdentity(), entry);
return true;
}
@@ -95,16 +158,25 @@
*/
public boolean removeEntry(ACLEntry entry)
{
- return (this.entries.remove(entry.getIdentity()) != null);
+ this.entriesMap.remove(entry.getIdentity());
+ return this.entries.remove(entry);
}
/*
* (non-Javadoc)
* @see org.jboss.security.acl.ACL#getEntries()
*/
- public Collection<ACLEntry> getEntries()
+ public Collection<? extends ACLEntry> getEntries()
{
- return Collections.unmodifiableCollection(this.entries.values());
+ if (this.entriesMap == null)
+ {
+ this.entriesMap = new HashMap<Identity, ACLEntry>();
+ for (ACLEntry entry : this.getEntries())
+ {
+ this.entriesMap.put(entry.getIdentity(), entry);
+ }
+ }
+ return Collections.unmodifiableCollection(this.entries);
}
/*
@@ -116,6 +188,13 @@
return this.resource;
}
+ public void setResource(Resource resource)
+ {
+ if (this.resource != null)
+ throw new IllegalStateException("ACL resource has already been set");
+ this.resource = resource;
+ }
+
/*
* (non-Javadoc)
* @see org.jboss.security.acl.ACL#isGranted(org.jboss.security.acl.ACLPermission, org.jboss.security.identity.Identity)
@@ -123,7 +202,7 @@
public boolean isGranted(ACLPermission permission, Identity identity)
{
// lookup the entry corresponding to the specified identity.
- ACLEntry entry = this.entries.get(identity);
+ ACLEntry entry = this.entriesMap.get(identity);
if (entry != null)
{
// check the permission associated with the identity.
@@ -131,5 +210,4 @@
}
return false;
}
-
}
Modified: projects/security/security-jboss-sx/trunk/acl/src/main/org/jboss/security/acl/ACLProviderImpl.java
===================================================================
--- projects/security/security-jboss-sx/trunk/acl/src/main/org/jboss/security/acl/ACLProviderImpl.java 2008-01-29 20:58:01 UTC (rev 69467)
+++ projects/security/security-jboss-sx/trunk/acl/src/main/org/jboss/security/acl/ACLProviderImpl.java 2008-01-29 21:04:54 UTC (rev 69468)
@@ -21,14 +21,22 @@
*/
package org.jboss.security.acl;
+import java.util.ArrayList;
+import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.EntityTransaction;
+import javax.persistence.NoResultException;
+import javax.persistence.Persistence;
+
import org.jboss.security.authorization.Resource;
/**
* <p>
- * This class is a simple <code>ACLProvider</code> implementation that maintains the ACLs in memory. It is
+ * This class is a simple {@code ACLProvider} implementation that maintains the ACLs in memory. It is
* used mainly for testing purposes.
* </p>
*
@@ -40,14 +48,17 @@
// in memory cache of the created ACLs.
private final Map<Resource, ACL> aclMap;
+ private final EntityManagerFactory factory;
+
/**
* <p>
- * Creates an instance of <code>ACLProviderImpl</code>.
+ * Creates an instance of {@code ACLProviderImpl}.
* </p>
*/
public ACLProviderImpl()
{
this.aclMap = new HashMap<Resource, ACL>();
+ this.factory = Persistence.createEntityManagerFactory("ACL");
}
/*
@@ -56,13 +67,43 @@
*/
public ACL createACL(Resource resource)
{
+ return this.createACL(resource, new ArrayList<ACLEntry>());
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.security.acl.ACLProvider#createACL(org.jboss.security.authorization.Resource, java.util.Collection)
+ */
+ public ACL createACL(Resource resource, Collection<ACLEntry> entries)
+ {
if (resource == null)
throw new IllegalArgumentException("ACLs cannot be created for null resources");
+
+ // check the cache first.
ACL acl = this.aclMap.get(resource);
if (acl == null)
{
- acl = new ACLImpl(resource);
- this.aclMap.put(resource, acl);
+ EntityManager entityManager = this.factory.createEntityManager();
+ EntityTransaction transaction = entityManager.getTransaction();
+ transaction.begin();
+ try
+ {
+ // create a new ACL and persist it to the database.
+ acl = new ACLImpl(resource, entries);
+ entityManager.persist(acl);
+ // add the newly-created ACL to the cache.
+ this.aclMap.put(resource, acl);
+ transaction.commit();
+ }
+ catch (RuntimeException re)
+ {
+ re.printStackTrace();
+ transaction.rollback();
+ }
+ finally
+ {
+ entityManager.close();
+ }
}
return acl;
}
@@ -82,16 +123,58 @@
*/
public boolean removeACL(Resource resource)
{
- return this.aclMap.remove(resource) != null;
+ boolean result = false;
+
+ EntityManager entityManager = this.factory.createEntityManager();
+ EntityTransaction transaction = entityManager.getTransaction();
+ transaction.begin();
+ try
+ {
+ // find the ACL associated with the specified resource and remove it from the database.
+ ACL acl = this.findACLByResource(resource, entityManager);
+ if (acl != null)
+ {
+ entityManager.remove(acl);
+ // remove the ACL from the cache.
+ result = this.aclMap.remove(resource) != null;
+ }
+ transaction.commit();
+ }
+ catch (RuntimeException re)
+ {
+ re.printStackTrace();
+ transaction.rollback();
+ }
+ finally
+ {
+ entityManager.close();
+ }
+ return result;
}
/*
* (non-Javadoc)
- * @see org.jboss.security.acl.ACLProvider#retrieveACL(org.jboss.security.authorization.Resource)
+ * @see org.jboss.security.acl.ACLProvider#getACL(org.jboss.security.authorization.Resource)
*/
- public ACL retrieveACL(Resource resource)
+ public ACL getACL(Resource resource)
{
- return this.aclMap.get(resource);
+ // check the cache first.
+ ACL acl = this.aclMap.get(resource);
+ if (acl == null)
+ {
+ EntityManager entityManager = this.factory.createEntityManager();
+ try
+ {
+ acl = this.findACLByResource(resource, entityManager);
+ if (acl != null)
+ this.aclMap.put(resource, acl);
+ }
+ finally
+ {
+ entityManager.close();
+ }
+ }
+ return acl;
}
/*
@@ -100,9 +183,63 @@
*/
public boolean updateACL(ACL acl)
{
- if (!this.aclMap.containsKey(acl.getResource()))
+ if (((ACLImpl) acl).getACLId() == 0)
return false;
- return this.aclMap.put(acl.getResource(), acl) != null;
+
+ EntityManager entityManager = this.factory.createEntityManager();
+ EntityTransaction transaction = entityManager.getTransaction();
+ transaction.begin();
+ try
+ {
+ for (ACLEntry entry : acl.getEntries())
+ {
+ // persist the new entries that might have been added to the ACL.
+ ACLEntryImpl entryImpl = (ACLEntryImpl) entry;
+ if (entryImpl.getACLEntryId() == 0)
+ entityManager.persist(entryImpl);
+ }
+ // merge will take care of the entries that might have been removed.
+ entityManager.merge(acl);
+ // update the cache.
+ this.aclMap.put(acl.getResource(), acl);
+ transaction.commit();
+ return true;
+ }
+ catch (RuntimeException re)
+ {
+ re.printStackTrace();
+ transaction.rollback();
+ }
+ finally
+ {
+ entityManager.close();
+ }
+ return false;
}
+ /**
+ * <p>
+ * Searches the database for the {@code ACL} associated with the specified resource.
+ * </p>
+ *
+ * @param resource the {@code Resource} that is associated with the {@code ACL} being searched.
+ * @param entityManager the {@code EntityManager} used to search the database.
+ * @return the {@code ACL} retrieved from the database, or {@code null} if no {@code ACL} could be found.
+ */
+ private ACLImpl findACLByResource(Resource resource, EntityManager entityManager)
+ {
+ ACLImpl acl = null;
+ try
+ {
+ acl = (ACLImpl) entityManager.createQuery(
+ "SELECT a FROM ACLImpl a WHERE a.resourceAsString LIKE '" + Util.getResourceAsString(resource) + "'")
+ .getSingleResult();
+ acl.setResource(resource);
+ }
+ catch (NoResultException nre)
+ {
+ // ignore the exception when no ACL could be found for the given resource.
+ }
+ return acl;
+ }
}
Modified: projects/security/security-jboss-sx/trunk/acl/src/main/org/jboss/security/acl/BasicACLPermission.java
===================================================================
--- projects/security/security-jboss-sx/trunk/acl/src/main/org/jboss/security/acl/BasicACLPermission.java 2008-01-29 20:58:01 UTC (rev 69467)
+++ projects/security/security-jboss-sx/trunk/acl/src/main/org/jboss/security/acl/BasicACLPermission.java 2008-01-29 21:04:54 UTC (rev 69468)
@@ -44,7 +44,7 @@
/**
* <p>
- * Buils an instance of <code>BasicACLPermission</code>.
+ * Buils an instance of {@code BasicACLPermission}.
* </p>
*
* @param mask an integer representing the permission's mask value.
Modified: projects/security/security-jboss-sx/trunk/acl/src/main/org/jboss/security/acl/BitMaskPermission.java
===================================================================
--- projects/security/security-jboss-sx/trunk/acl/src/main/org/jboss/security/acl/BitMaskPermission.java 2008-01-29 20:58:01 UTC (rev 69467)
+++ projects/security/security-jboss-sx/trunk/acl/src/main/org/jboss/security/acl/BitMaskPermission.java 2008-01-29 21:04:54 UTC (rev 69468)
@@ -35,7 +35,7 @@
* Obtains the bitmask value of the permission.
* </p>
*
- * @return an <code>int</code> representing the value of the bitmask.
+ * @return an {@code int} representing the value of the bitmask.
*/
public int getMaskValue();
}
\ No newline at end of file
Modified: projects/security/security-jboss-sx/trunk/acl/src/main/org/jboss/security/acl/CompositeACLPermission.java
===================================================================
--- projects/security/security-jboss-sx/trunk/acl/src/main/org/jboss/security/acl/CompositeACLPermission.java 2008-01-29 20:58:01 UTC (rev 69467)
+++ projects/security/security-jboss-sx/trunk/acl/src/main/org/jboss/security/acl/CompositeACLPermission.java 2008-01-29 21:04:54 UTC (rev 69468)
@@ -37,10 +37,10 @@
/**
* <p>
- * Builds an instance of <code>CompositeACLPermission</code> with the specified bitmask value.
+ * Builds an instance of {@code CompositeACLPermission} with the specified bitmask value.
* </p>
*
- * @param mask an <code>int</code> representing the bitmask value of the permission being created.
+ * @param mask an {@code int} representing the bitmask value of the permission being created.
*/
public CompositeACLPermission(int mask)
{
@@ -49,10 +49,10 @@
/**
* <p>
- * Builds an instance of <code>CompositeACLPermission</code> with the given basic permissions.
+ * Builds an instance of {@code CompositeACLPermission} with the given basic permissions.
* </p>
*
- * @param permissions a comma-separated list of <code>BasicACLPermission</code>s.
+ * @param permissions a comma-separated list of {@code BasicACLPermission}s.
*/
public CompositeACLPermission(BasicACLPermission... permissions)
{
Added: projects/security/security-jboss-sx/trunk/acl/src/main/org/jboss/security/acl/Util.java
===================================================================
--- projects/security/security-jboss-sx/trunk/acl/src/main/org/jboss/security/acl/Util.java (rev 0)
+++ projects/security/security-jboss-sx/trunk/acl/src/main/org/jboss/security/acl/Util.java 2008-01-29 21:04:54 UTC (rev 69468)
@@ -0,0 +1,179 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.security.acl;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+
+import org.jboss.security.authorization.Resource;
+import org.jboss.security.identity.Identity;
+import org.jboss.security.identity.plugins.IdentityFactory;
+
+/**
+ * <p>
+ * Utility class used by the {@code ACL} implementation.
+ * </p>
+ *
+ * @author <a href="mailto:sguilhen at redhat.com">Stefan Guilhen</a>
+ */
+public class Util
+{
+
+ /**
+ * <p>
+ * Returns a {@code String} representation of the specified resource. The format of this representation
+ * is as follows: {@code resource_fqn:resource_id}, where {@code resource_fqn} is the fully-qualified
+ * name of the resource class, and {@code resource_id} is the unique identifier of the resource.
+ * </p>
+ *
+ * @param resource the {@code Resource} to be converted.
+ * @return a {@code String} representation of the resource.
+ */
+ public static String getResourceAsString(Resource resource)
+ {
+ String resourceString = null;
+ if (resource != null)
+ {
+ String resourceClass = resource.getClass().getCanonicalName();
+ resourceString = resourceClass + ":" + getResourceKey(resource);
+ }
+ return resourceString;
+ }
+
+ /**
+ * <p>
+ * Returns a {@code String} representation of the specified identity. The format of this representation
+ * is as follows: {@code identity_fqn:identity_name}, where {@code identity_fqn} is the fully-qualified
+ * name of the identity class, and {@code identity_name} is a {@code String} representing the name of
+ * the identity.
+ * </p>
+ *
+ * @param identity the {@code Identity} to be converted.
+ * @return a {@code String} representation of the identity.
+ */
+ public static String getIdentityAsString(Identity identity)
+ {
+ String identityString = null;
+ if (identity != null)
+ identityString = identity.getClass().getCanonicalName() + ":" + identity.getName();
+ return identityString;
+ }
+
+ /**
+ * <p>
+ * Builds and returns an identity from the specified {@code String} representation. It parses the
+ * {@code identityString} argument, and passes the parsed identity class, and identity name to
+ * the {@code IdentityFactory} to retrieve an instance of {@code Identity}.
+ * </p>
+ *
+ * @param identityString a {@code String} representation of the identity to be created.
+ * @return the constructed {@code Identity} instance.
+ */
+ public static Identity getIdentityFromString(String identityString)
+ {
+ Identity identity = null;
+ if (identityString != null)
+ {
+ String[] identityParts = identityString.split(":");
+ if (identityParts.length != 2)
+ throw new IllegalArgumentException("Malformed identity String: " + identityString);
+ try
+ {
+ identity = IdentityFactory.createIdentity(identityParts[0], identityParts[1]);
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+ return identity;
+ }
+
+ /**
+ * <p>
+ * Obtains an {@code Object} that can represent the specified resource uniquely. It first tries to find
+ * a {@code Field} annotated with a {@code javax.persistence.Id} annotation. If such field is found, the
+ * method tries to read the field's value. If no annotated field is found, this method just tries to
+ * invoke a {@code getId()} method on the resource.
+ * </p>
+ *
+ * @param resource the {@code Resource} whose id is to be retrieved.
+ * @return an {@code Object} representing the resource's id, or {@code null} if no id could be found
+ * according to the rules used by this method for retrieving the resource's id.
+ */
+ private static Object getResourceKey(Resource resource)
+ {
+ Class<? extends Resource> resourceClass = resource.getClass();
+ Object resourceKey = null;
+ // first search for a field with a javax.persistence.Id annotation.
+ for (Field field : resourceClass.getDeclaredFields())
+ {
+ if (field.getAnnotation(javax.persistence.Id.class) != null)
+ {
+ // found a field - try to get its value reflectively.
+ try
+ {
+ resourceKey = field.get(resource);
+ }
+ catch (Exception e)
+ {
+ // in case of error, try executing the field getter method.
+ String fieldName = field.getName();
+ String methodName = "get" + fieldName.substring(0, 1).toUpperCase() + fieldName.substring(1);
+ resourceKey = executeNoArgMethod(resource, methodName);
+ }
+ break;
+ }
+ }
+
+ // if the above fails, try to simply locate a getId method.
+ if (resourceKey == null)
+ resourceKey = executeNoArgMethod(resource, "getId");
+ return resourceKey;
+ }
+
+ /**
+ * <p>
+ * Invokes a no-arg method reflectively in the specified target, and returns the result.
+ * </p>
+ *
+ * @param target the {@code Object} to be invoked.
+ * @param methodName a {@code String} representing the name of the method to be invoked.
+ * @return an {@code Object} containing the result of the invocation, or {@code null} if an
+ * the method is {@code void} or if an error occurs when invoking the method using reflection.
+ */
+ @SuppressWarnings("all")
+ private static Object executeNoArgMethod(Object target, String methodName)
+ {
+ Class<?> targetClass = target.getClass();
+ try
+ {
+ Method method = targetClass.getMethod(methodName, null);
+ return method.invoke(target, null);
+ }
+ catch (Exception e)
+ {
+ // ignore exception and return null.
+ return null;
+ }
+ }
+}
Modified: projects/security/security-jboss-sx/trunk/acl/src/tests/org/jboss/test/security/acl/ACLProviderUnitTestCase.java
===================================================================
--- projects/security/security-jboss-sx/trunk/acl/src/tests/org/jboss/test/security/acl/ACLProviderUnitTestCase.java 2008-01-29 20:58:01 UTC (rev 69467)
+++ projects/security/security-jboss-sx/trunk/acl/src/tests/org/jboss/test/security/acl/ACLProviderUnitTestCase.java 2008-01-29 21:04:54 UTC (rev 69468)
@@ -37,7 +37,7 @@
/**
* <p>
- * This <code>TestCase</code> tests the funcionality exposed by the <code>ACLProvider</code>
+ * This {@code TestCase} tests the funcionality exposed by the {@code ACLProvider}
* interface
* </p>
*
@@ -45,8 +45,12 @@
*/
public class ACLProviderUnitTestCase extends TestCase
{
- TestResource[] resources;
+ private TestResource[] resources;
+ private Collection<ACL> createdACLs;
+
+ private ACLProvider provider;
+
@Override
protected void setUp() throws Exception
{
@@ -54,8 +58,17 @@
this.resources = new TestResource[10];
for (int index = 0; index < this.resources.length; index++)
this.resources[index] = new TestResource(index + 1);
+ this.createdACLs = new ArrayList<ACL>();
+ this.provider = new ACLProviderImpl();
}
+ @Override
+ protected void tearDown() throws Exception
+ {
+ for (ACL acl : this.createdACLs)
+ this.provider.removeACL(acl);
+ }
+
/**
* <p>
* Tests the creation of ACLs for resources.
@@ -65,33 +78,30 @@
*/
public void testACLCreation() throws Exception
{
- ACLProvider provider = new ACLProviderImpl();
// assert no ACL exists for any of the resources.
for (int index = 0; index < this.resources.length; index++)
- assertNull(provider.retrieveACL(this.resources[index]));
+ assertNull(this.provider.getACL(this.resources[index]));
// create ACLs for half of the resources.
for (int index = 0; index < this.resources.length / 2; index++)
{
- ACL acl = provider.createACL(this.resources[index]);
+ ACL acl = this.provider.createACL(this.resources[index]);
+ this.createdACLs.add(acl);
assertNotNull(acl);
assertEquals("Unexpected entries found", 0, acl.getEntries().size());
assertEquals("Unexpected resource", this.resources[index], acl.getResource());
- // assert that both createACL and retrieveACL return a reference to the same ACL just created.
- assertEquals("Retrieved unexpected ACL for resource", acl, provider.createACL(this.resources[index]));
- assertEquals("Retrieved unexpected ACL for resource", acl, provider.retrieveACL(this.resources[index]));
}
// assert no ACL still exists for the remaining resources.
int index = (this.resources.length / 2) + 1;
for (; index < this.resources.length; index++)
- assertNull(provider.retrieveACL(this.resources[index]));
+ assertNull(this.provider.getACL(this.resources[index]));
// assert that an ACL cannot be created for a null resource.
boolean caughtException = false;
try
{
- provider.createACL(null);
+ this.provider.createACL(null);
}
catch (IllegalArgumentException iae)
{
@@ -109,9 +119,9 @@
*/
public void testACLUpdate() throws Exception
{
- ACLProvider provider = new ACLProviderImpl();
// create an empty ACL.
- ACL acl = provider.createACL(this.resources[0]);
+ ACL acl = this.provider.createACL(this.resources[0]);
+ this.createdACLs.add(acl);
assertEquals("Unexpected entries found", 0, acl.getEntries().size());
// add some entries to the ACL.
@@ -121,26 +131,26 @@
ACLEntry entry = new ACLEntryImpl(BasicACLPermission.CREATE, IdentityFactory.createIdentity("Identity" + i));
acl.addEntry(entry);
}
- assertTrue("Failed to update the ACL", provider.updateACL(acl));
+ assertTrue("Failed to update the ACL", this.provider.updateACL(acl));
// retrieve the ACL again and check it has the added entries.
- acl = provider.retrieveACL(this.resources[0]);
+ acl = this.provider.getACL(this.resources[0]);
assertEquals("Invalid number of entries", entriesNumber, acl.getEntries().size());
// now remove one of the entries.
ACLEntry entry = acl.getEntries().iterator().next();
acl.removeEntry(entry);
- assertTrue("Failed to update the ACL", provider.updateACL(acl));
+ assertTrue("Failed to update the ACL", this.provider.updateACL(acl));
// retrieve the ACL again and check it has one less entry.
- acl = provider.retrieveACL(this.resources[0]);
+ acl = this.provider.getACL(this.resources[0]);
assertEquals("Invalid number of entries", entriesNumber - 1, acl.getEntries().size());
// assert that update fails for an ACL not managed by the provider.
Collection<ACLEntry> entries = new ArrayList<ACLEntry>();
entries.add(new ACLEntryImpl(BasicACLPermission.UPDATE, IdentityFactory.createIdentity("Another Identity")));
ACL otherACL = new ACLImpl(this.resources[1], entries);
- assertFalse(provider.updateACL(otherACL));
+ assertFalse(this.provider.updateACL(otherACL));
}
/**
@@ -152,25 +162,26 @@
*/
public void testACLRemoval() throws Exception
{
- ACLProvider provider = new ACLProviderImpl();
ACL[] acls = new ACL[this.resources.length];
for (int index = 0; index < this.resources.length; index++)
- acls[index] = provider.createACL(this.resources[index]);
+ {
+ acls[index] = this.provider.createACL(this.resources[index]);
+ this.createdACLs.add(acls[index]);
+ }
// remove some ACLs.
for (int index = 0; index < this.resources.length / 2; index++)
{
- assertTrue(provider.removeACL(acls[index]));
+ assertTrue(this.provider.removeACL(acls[index]));
// assert no ACL is associated to the resources anymore.
- assertNull(provider.retrieveACL(this.resources[index]));
+ assertNull(this.provider.getACL(this.resources[index]));
// removing an ACL that is not managed anymore by the provider must return false.
- assertFalse(provider.removeACL(acls[index]));
+ assertFalse(this.provider.removeACL(acls[index]));
}
// assert the remaining resources are still associated with an ACL.
int index = (this.resources.length / 2) + 1;
for (; index < this.resources.length; index++)
- assertNotNull(provider.retrieveACL(this.resources[index]));
-
+ assertNotNull(this.provider.getACL(this.resources[index]));
}
}
Modified: projects/security/security-jboss-sx/trunk/acl/src/tests/org/jboss/test/security/acl/ACLUnitTestCase.java
===================================================================
--- projects/security/security-jboss-sx/trunk/acl/src/tests/org/jboss/test/security/acl/ACLUnitTestCase.java 2008-01-29 20:58:01 UTC (rev 69467)
+++ projects/security/security-jboss-sx/trunk/acl/src/tests/org/jboss/test/security/acl/ACLUnitTestCase.java 2008-01-29 21:04:54 UTC (rev 69468)
@@ -37,7 +37,7 @@
/**
* <p>
- * This <code>TestCase</code> tests the funcionality exposed by the <code>ACL</code> interface.
+ * This {@code TestCase} tests the funcionality exposed by the {@code ACL} interface.
* </p>
*
* @author <a href="mailto:sguilhen at redhat.com">Stefan Guilhen</a>
@@ -57,7 +57,7 @@
for (int i = 0; i < ACL_SIZE; i++)
this.identities[i] = IdentityFactory.createIdentity("Identity" + i);
// create an entry with a basic permission.
- this.entries = new ACLEntry[ACL_SIZE];
+ this.entries = new ACLEntryImpl[ACL_SIZE];
this.entries[0] = new ACLEntryImpl(BasicACLPermission.READ, this.identities[0]);
// build the remaining entries with composite permissions.
this.entries[1] = new ACLEntryImpl(new CompositeACLPermission(), this.identities[1]);
@@ -69,7 +69,7 @@
/**
* <p>
- * Tests the execution of the <code>isGranted</code> method with different permissions and
+ * Tests the execution of the {@code isGranted} method with different permissions and
* identities.
* </p>
*
Modified: projects/security/security-jboss-sx/trunk/acl/src/tests/org/jboss/test/security/acl/ACLUseTestCase.java
===================================================================
--- projects/security/security-jboss-sx/trunk/acl/src/tests/org/jboss/test/security/acl/ACLUseTestCase.java 2008-01-29 20:58:01 UTC (rev 69467)
+++ projects/security/security-jboss-sx/trunk/acl/src/tests/org/jboss/test/security/acl/ACLUseTestCase.java 2008-01-29 21:04:54 UTC (rev 69468)
@@ -22,11 +22,13 @@
package org.jboss.test.security.acl;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.List;
import junit.framework.TestCase;
import org.jboss.security.acl.ACL;
+import org.jboss.security.acl.ACLEntry;
import org.jboss.security.acl.ACLEntryImpl;
import org.jboss.security.acl.ACLProvider;
import org.jboss.security.acl.ACLProviderImpl;
@@ -38,16 +40,16 @@
/**
* <p>
- * This <code>TestCase</code> tests some ACL use cases.
+ * This {@code TestCase} tests some ACL use cases.
* </p>
*
* @author <a href="mailto:sguilhen at redhat.com">Stefan Guilhen</a>
*/
public class ACLUseTestCase extends TestCase
{
- private static final int TOTAL_RESOURCES = 25000;
+ private static final int TOTAL_RESOURCES = 5000;
- private static final int TOTAL_IDENTITIES = 100;
+ private static final int TOTAL_IDENTITIES = 50;
private TestResource[] resources;
@@ -63,10 +65,7 @@
// create the resources used in the tests.
this.resources = new TestResource[TOTAL_RESOURCES];
for (int i = 0; i < TOTAL_RESOURCES; i++)
- {
- this.resources[i] = new TestResource(i);
- this.resources[i].setResourceName("Resource" + i);
- }
+ this.resources[i] = new TestResource(i, "Resource" + i);
// create the identities used in the tests.
this.identities = new Identity[TOTAL_IDENTITIES];
@@ -80,7 +79,7 @@
// create the ACLs for the resources.
for (int i = 0; i < TOTAL_RESOURCES; i++)
{
- ACL acl = this.provider.createACL(this.resources[i]);
+ Collection<ACLEntry> entries = new ArrayList<ACLEntry>();
// add the entries ("even" identities can read "even" resources)
for (int j = 0; j < TOTAL_IDENTITIES; j++)
{
@@ -88,27 +87,27 @@
{
// let some identities have all permissions.
if (j % 5 == 0)
- acl.addEntry(new ACLEntryImpl(allPermission, this.identities[j]));
+ entries.add(new ACLEntryImpl(allPermission, this.identities[j]));
else
- acl.addEntry(new ACLEntryImpl(readPermission, this.identities[j]));
+ entries.add(new ACLEntryImpl(readPermission, this.identities[j]));
}
else
{
- acl.addEntry(new ACLEntryImpl(noPermission, this.identities[j]));
+ entries.add(new ACLEntryImpl(noPermission, this.identities[j]));
}
}
- this.provider.updateACL(acl);
+ this.provider.createACL(this.resources[i], entries);
}
}
- @Override
- protected void tearDown() throws Exception
- {
- for (TestResource resource : this.resources)
- this.provider.removeACL(resource);
- this.resources = null;
- this.identities = null;
- }
+ // @Override
+ // protected void tearDown() throws Exception
+ // {
+ // for (TestResource resource : this.resources)
+ // this.provider.removeACL(resource);
+ // this.resources = null;
+ // this.identities = null;
+ // }
/**
* <p>
@@ -170,7 +169,6 @@
this.removeResource(index, identity);
assertNull(this.resources[index]);
}
-
}
/**
@@ -178,8 +176,8 @@
* Utility method that uses ACLs to decide which resources the specified identity should be able to read.
* </p>
*
- * @param identity the <code>Identity</code> for which the resources are being filtered.
- * @return an array of <code>TestResource</code> containig the resources the identity is allowed to read.
+ * @param identity the {@code Identity} for which the resources are being filtered.
+ * @return an array of {@code TestResource} containig the resources the identity is allowed to read.
*/
private TestResource[] filterResources(Identity identity)
{
@@ -187,7 +185,7 @@
for (TestResource resource : this.resources)
{
// first retrieve the ACL associated with the resource.
- ACL acl = this.provider.retrieveACL(resource);
+ ACL acl = this.provider.getACL(resource);
// then check the identity has the READ permission on the resource.
if (acl.isGranted(BasicACLPermission.READ, identity))
{
@@ -200,16 +198,16 @@
/**
* <p>
* Utility method that uses ACLs to decide if the specified identity is allowed to update the resource. If
- * it is, the resource's name is changed to <code>Changed Name</code>.
+ * it is, the resource's name is changed to {@code Changed Name}.
* </p>
*
- * @param resource the <code>TestResource</code> to be updated.
- * @param identity the <code>Identity</code> that wants to update the resource.
+ * @param resource the {@code TestResource} to be updated.
+ * @param identity the {@code Identity} that wants to update the resource.
*/
private void updateResource(TestResource resource, Identity identity)
{
// update the resource's name, checking the identity's permission first.
- ACL acl = this.provider.retrieveACL(resource);
+ ACL acl = this.provider.getACL(resource);
assertNotNull(acl);
if (acl.isGranted(BasicACLPermission.UPDATE, identity))
resource.setResourceName("Changed Name");
@@ -221,13 +219,13 @@
* the resources array.
* </p>
*
- * @param resourceIndex the index of the <code>TestResource</code> to be removed in the resources array.
- * @param identity the <code>Identity</code> that wants to remove the resource.
+ * @param resourceIndex the index of the {@code TestResource} to be removed in the resources array.
+ * @param identity the {@code Identity} that wants to remove the resource.
*/
private void removeResource(int resourceIndex, Identity identity)
{
// check the identity's permission.
- ACL acl = this.provider.retrieveACL(this.resources[resourceIndex]);
+ ACL acl = this.provider.getACL(this.resources[resourceIndex]);
assertNotNull(acl);
if (acl.isGranted(BasicACLPermission.DELETE, identity))
this.resources[resourceIndex] = null;
Added: projects/security/security-jboss-sx/trunk/acl/src/tests/org/jboss/test/security/acl/PersistenceTest.java
===================================================================
--- projects/security/security-jboss-sx/trunk/acl/src/tests/org/jboss/test/security/acl/PersistenceTest.java (rev 0)
+++ projects/security/security-jboss-sx/trunk/acl/src/tests/org/jboss/test/security/acl/PersistenceTest.java 2008-01-29 21:04:54 UTC (rev 69468)
@@ -0,0 +1,342 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.security.acl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.EntityTransaction;
+import javax.persistence.Persistence;
+
+import junit.framework.TestCase;
+
+import org.jboss.security.acl.ACL;
+import org.jboss.security.acl.ACLEntry;
+import org.jboss.security.acl.ACLEntryImpl;
+import org.jboss.security.acl.ACLImpl;
+import org.jboss.security.acl.BasicACLPermission;
+import org.jboss.security.acl.CompositeACLPermission;
+import org.jboss.security.acl.Util;
+import org.jboss.security.identity.plugins.IdentityFactory;
+
+/**
+ * <p>
+ * This {@code TestCase} tests the functionality of the persistence layer added to the {@code ACL} implementation classes.
+ * It uses an in-memory hsql test database, so there is no need to perform any special database cleanup in case one of the
+ * tests fail. Every time the tests are run a clean new database is used.
+ * </p>
+ *
+ * @author <a href="mailto:sguilhen at redhat.com">Stefan Guilhen</a>
+ */
+public class PersistenceTest extends TestCase
+{
+ private static final EntityManagerFactory entityManagerFactory = Persistence.createEntityManagerFactory("ACL");
+
+ private EntityManager entityManager;
+
+ private List<ACLEntryImpl> persistedEntries;
+
+ private List<ACLImpl> persistedACLs;
+
+ /*
+ * (non-Javadoc)
+ * @see junit.framework.TestCase#setUp()
+ */
+ @Override
+ protected void setUp() throws Exception
+ {
+ this.entityManager = entityManagerFactory.createEntityManager();
+ this.persistedACLs = new ArrayList<ACLImpl>();
+ this.persistedEntries = new ArrayList<ACLEntryImpl>();
+
+ // create the test entries.
+ this.persistedEntries
+ .add(new ACLEntryImpl(BasicACLPermission.READ, IdentityFactory.createIdentity("Identity-1")));
+ this.persistedEntries.add(new ACLEntryImpl(new CompositeACLPermission(BasicACLPermission.CREATE,
+ BasicACLPermission.READ), IdentityFactory.createIdentity("Identity-2")));
+ this.persistedEntries.add(new ACLEntryImpl(new CompositeACLPermission(BasicACLPermission.values()),
+ IdentityFactory.createIdentity("Identity-3")));
+
+ // create the test acls.
+ this.persistedACLs.add(new ACLImpl(new TestResource(100, "Resource-1")));
+ this.persistedACLs.add(new ACLImpl(new TestResource(200, "Resource-2"), new ArrayList<ACLEntry>(
+ this.persistedEntries)));
+
+ // persist everything.
+ for (ACL acl : this.persistedACLs)
+ this.persistEntity(acl);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see junit.framework.TestCase#tearDown()
+ */
+ @Override
+ protected void tearDown() throws Exception
+ {
+ // remove the persisted entities - removing the acl also removes the entries.
+ for (ACLImpl acl : this.persistedACLs)
+ {
+ // re-attach the acl before removing.
+ ACLImpl attachedACL = this.entityManager.find(ACLImpl.class, acl.getACLId());
+ this.removeEntity(attachedACL);
+ }
+
+ // assert the acls have been removed.
+ for (ACLImpl acl : this.persistedACLs)
+ assertNull(this.entityManager.find(ACLImpl.class, acl.getACLId()));
+
+ // assert the entries have been also removed.
+ for (ACLEntryImpl entry : this.persistedEntries)
+ assertNull(this.entityManager.find(ACLEntryImpl.class, entry.getACLEntryId()));
+
+ if (this.entityManager != null)
+ entityManager.close();
+ }
+
+ /**
+ * <p>
+ * Tests persisting the {@code ACLEntry} objects to a database.
+ * </p>
+ *
+ * @throws Exception if an error occurs when running the test.
+ */
+ public void testPersistACLEntry() throws Exception
+ {
+ // assert the entries have been created by checking if the auto-generated id has been set on each entry.
+ assertTrue("Entry1 id value has not been generated", this.persistedEntries.get(0).getACLEntryId() > 0);
+ assertTrue("Entry2 id value has not been generated", this.persistedEntries.get(1).getACLEntryId() > 0);
+ assertTrue("Entry3 id value has not been generated", this.persistedEntries.get(2).getACLEntryId() > 0);
+
+ }
+
+ /**
+ * <p>
+ * Tests searching for the persisted {@code ACLEntry} objects.
+ * </p>
+ *
+ * @throws Exception if an error occurs when running the test.
+ */
+ public void testSearchACLEntry() throws Exception
+ {
+ // clear the entity manager so that it goes to the database when searching for entries.
+ this.entityManager.clear();
+
+ // load the entries from the database using their primary key and validate them.
+ for (ACLEntryImpl entry : this.persistedEntries)
+ {
+ ACLEntryImpl loadedEntry = this.entityManager.find(ACLEntryImpl.class, entry.getACLEntryId());
+ assertNotNull("Entry could not be retrieved by primary key", loadedEntry);
+ assertEquals(entry, loadedEntry);
+ }
+
+ // execute some queries and validate the results.
+ ACLEntryImpl entry = this.persistedEntries.get(1);
+ ACLEntryImpl queryResult = (ACLEntryImpl) this.entityManager.createQuery(
+ "SELECT e FROM ACLEntryImpl e WHERE e.identityString LIKE '"
+ + Util.getIdentityAsString(entry.getIdentity()) + "'").getSingleResult();
+ assertNotNull("Entry2 could not be retrieved by it's identity", queryResult);
+ assertEquals(entry, queryResult);
+
+ entry = this.persistedEntries.get(0);
+ queryResult = (ACLEntryImpl) this.entityManager.createQuery(
+ "SELECT e FROM ACLEntryImpl e WHERE e.bitMask = " + BasicACLPermission.READ.getMaskValue())
+ .getSingleResult();
+ assertNotNull("Entry1 could not be retrieved by it's bitmask value", queryResult);
+ assertEquals(entry, queryResult);
+ }
+
+ /**
+ * <p>
+ * Tests persisting the {@code ACL} objects to a database.
+ * </p>
+ *
+ * @throws Exception if an error occurs when running the test.
+ */
+ public void testPersistACL() throws Exception
+ {
+ // assert the ACLs and their associated entries have been persisted
+ for (ACLImpl acl : this.persistedACLs)
+ {
+ assertTrue("ACL id value has not been generated", acl.getACLId() > 0);
+ for (ACLEntry entry : acl.getEntries())
+ assertTrue("ACL entry has not been persisted", ((ACLEntryImpl) entry).getACLEntryId() > 0);
+ }
+ }
+
+ /**
+ * <p>
+ * Tests searching for the persisted {@code ACL} objects.
+ * </p>
+ *
+ * @throws Exception if an error occurs when running the test.
+ */
+ public void testSearchACL() throws Exception
+ {
+ // clear the entity manager's cache.
+ this.entityManager.clear();
+
+ // load the ACLs from the database using their primary key and validate them.
+ ACLImpl loadedACL1 = this.entityManager.find(ACLImpl.class, this.persistedACLs.get(0).getACLId());
+ assertNotNull("ACL1 could not be retrieved", loadedACL1);
+ assertEquals("Loaded ACL contains unexpected number of entries", 0, loadedACL1.getEntries().size());
+ assertNull(loadedACL1.getResource());
+
+ ACLImpl loadedACL2 = this.entityManager.find(ACLImpl.class, this.persistedACLs.get(1).getACLId());
+ assertNotNull("ACL2 could not be retrieved", loadedACL2);
+ assertEquals("Loaded ACL contains unexpected number of entries", 3, loadedACL2.getEntries().size());
+ assertTrue(loadedACL2.getEntries().contains(this.persistedEntries.get(0)));
+ assertTrue(loadedACL2.getEntries().contains(this.persistedEntries.get(1)));
+ assertTrue(loadedACL2.getEntries().contains(this.persistedEntries.get(2)));
+ assertNull(loadedACL2.getResource());
+
+ // find the ACLs using the resource and validate the result.
+ ACLImpl acl = this.persistedACLs.get(0);
+ ACLImpl queryResult = (ACLImpl) this.entityManager.createQuery(
+ "SELECT a FROM ACLImpl a WHERE a.resourceAsString LIKE '" + Util.getResourceAsString(acl.getResource())
+ + "'").getSingleResult();
+ assertNotNull("ACL1 could not be retrieved by it's resource", queryResult);
+ assertEquals("Queried ACL id does not match the expected id", acl.getACLId(), queryResult.getACLId());
+ assertEquals("Queried ACL contains unexpected number of entries", 0, queryResult.getEntries().size());
+
+ acl = this.persistedACLs.get(1);
+ queryResult = (ACLImpl) this.entityManager.createQuery(
+ "SELECT a FROM ACLImpl a WHERE a.resourceAsString LIKE '" + Util.getResourceAsString(acl.getResource())
+ + "'").getSingleResult();
+ assertNotNull("ACL2 could not be retrieved by it's resource", queryResult);
+ assertEquals("Queried ACL id does not match the expected id", acl.getACLId(), queryResult.getACLId());
+ assertEquals("Queried ACL contains unexpected number of entries", 3, queryResult.getEntries().size());
+ assertTrue(queryResult.getEntries().contains(this.persistedEntries.get(0)));
+ assertTrue(queryResult.getEntries().contains(this.persistedEntries.get(1)));
+ assertTrue(queryResult.getEntries().contains(this.persistedEntries.get(2)));
+
+ }
+
+ /**
+ * <p>
+ * Tests updating the persisted {@code ACL} objects.
+ * </p>
+ *
+ * @throws Exception if an error occurs when running the test.
+ */
+ public void testUpdateACL() throws Exception
+ {
+ // add some entries to the acls and remove one of the existing entries from ACL2.
+ ACLEntryImpl entry4 = new ACLEntryImpl(BasicACLPermission.CREATE, IdentityFactory.createIdentity("Identity-4"));
+ ACLEntryImpl entry5 = new ACLEntryImpl(new CompositeACLPermission(BasicACLPermission.CREATE,
+ BasicACLPermission.DELETE), IdentityFactory.createIdentity("Identity-5"));
+ ACLEntryImpl entry6 = new ACLEntryImpl(new CompositeACLPermission(BasicACLPermission.values()), IdentityFactory
+ .createIdentity("Identity-6"));
+
+ ACLImpl acl1 = null;
+ ACLImpl acl2 = null;
+ EntityTransaction transaction = this.entityManager.getTransaction();
+ transaction.begin();
+ try
+ {
+ acl1 = this.entityManager.merge(this.persistedACLs.get(0));
+ acl1.addEntry(entry4);
+ acl1.addEntry(entry5);
+
+ acl2 = this.entityManager.merge(this.persistedACLs.get(1));
+ acl2.addEntry(entry6);
+ acl2.removeEntry(this.persistedEntries.get(0));
+ transaction.commit();
+ }
+ catch (RuntimeException re)
+ {
+ re.printStackTrace();
+ transaction.rollback();
+ }
+
+ // add the new entries to the persisted entries collection.
+ this.persistedEntries.add(entry4);
+ this.persistedEntries.add(entry5);
+ this.persistedEntries.add(entry6);
+
+ // clear the entity manager's cache.
+ this.entityManager.clear();
+
+ // load the ACLs again and validate the changes.
+ ACLImpl loadedACL1 = this.entityManager.find(ACLImpl.class, acl1.getACLId());
+ assertNotNull("ACL1 could not be retrieved", loadedACL1);
+ assertEquals("Loaded ACL contains unexpected number of entries", 2, loadedACL1.getEntries().size());
+ assertTrue(loadedACL1.getEntries().contains(entry4));
+ assertTrue(loadedACL1.getEntries().contains(entry5));
+
+ ACLImpl loadedACL2 = this.entityManager.find(ACLImpl.class, acl2.getACLId());
+ assertNotNull("ACL2 could not be retrieved", loadedACL2);
+ assertEquals("Loaded AC2 contains unexpected number of entries", 3, loadedACL2.getEntries().size());
+ assertFalse(loadedACL2.getEntries().contains(this.persistedEntries.get(0)));
+ assertTrue(loadedACL2.getEntries().contains(this.persistedEntries.get(1)));
+ assertTrue(loadedACL2.getEntries().contains(this.persistedEntries.get(2)));
+ assertTrue(loadedACL2.getEntries().contains(entry6));
+ }
+
+ /**
+ * <p>
+ * Persists the specified entity to the database.
+ * </p>
+ *
+ * @param entity an {@code Object} representing the entity to be persisted.
+ */
+ private void persistEntity(Object entity)
+ {
+ EntityTransaction transaction = this.entityManager.getTransaction();
+ transaction.begin();
+ try
+ {
+ this.entityManager.persist(entity);
+ transaction.commit();
+ }
+ catch (RuntimeException re)
+ {
+ re.printStackTrace();
+ transaction.rollback();
+ }
+ }
+
+ /**
+ * <p>
+ * Removes the specified entity from the database.
+ * </p>
+ *
+ * @param entity an {@code Object} representing the entity to be removed.
+ */
+ private void removeEntity(Object entity)
+ {
+ EntityTransaction transaction = this.entityManager.getTransaction();
+ transaction.begin();
+ try
+ {
+ this.entityManager.remove(entity);
+ transaction.commit();
+ }
+ catch (RuntimeException re)
+ {
+ re.printStackTrace();
+ transaction.rollback();
+ }
+ }
+}
Modified: projects/security/security-jboss-sx/trunk/acl/src/tests/org/jboss/test/security/acl/TestResource.java
===================================================================
--- projects/security/security-jboss-sx/trunk/acl/src/tests/org/jboss/test/security/acl/TestResource.java 2008-01-29 20:58:01 UTC (rev 69467)
+++ projects/security/security-jboss-sx/trunk/acl/src/tests/org/jboss/test/security/acl/TestResource.java 2008-01-29 21:04:54 UTC (rev 69468)
@@ -21,35 +21,55 @@
*/
package org.jboss.test.security.acl;
+import java.io.Serializable;
import java.util.Map;
+import javax.persistence.Id;
+
import org.jboss.security.authorization.Resource;
import org.jboss.security.authorization.ResourceType;
/**
* <p>
- * A simple <code>Resource</code> implementation for test purposes.
+ * A simple {@code Resource} implementation for testing purposes.
* </p>
*
* @author <a href="mailto:sguilhen at redhat.com">Stefan Guilhen</a>
*/
-public class TestResource implements Resource
+public class TestResource implements Resource, Serializable
{
+ private static final long serialVersionUID = -3581842532933324293L;
+
+ @Id
private final int resourceId;
private String name;
/**
* <p>
- * Creates an instance of <code>TestResource</code> with the specified id.
+ * Creates an instance of {@code TestResource} with the specified id.
* </p>
*
- * @param resourceId an <code>int</code> representing the id of the resource.
+ * @param resourceId an {@code int} representing the id of the resource.
*/
public TestResource(int resourceId)
{
+ this(resourceId, null);
+ }
+
+ /**
+ * <p>
+ * Creates an instance of {@code TestResource} with the specified id and name.
+ * </p>
+ *
+ * @param resourceId an {@code int} representing the id of the resource.
+ * @param resourceName a {@code String} representing the name of the resource.
+ */
+ public TestResource(int resourceId, String resourceName)
+ {
this.resourceId = resourceId;
+ this.name = resourceName;
}
/**
@@ -57,7 +77,7 @@
* Gets the id of this resource.
* </p>
*
- * @return an <code>int</code> representing the id of this resource.
+ * @return an {@code int} representing the id of this resource.
*/
public int getResourceId()
{
@@ -69,7 +89,7 @@
* Gets the name of this resource.
* </p>
*
- * @return a <code>String</code> representing the name of this resource.
+ * @return a {@code String} representing the name of this resource.
*/
public String getResourceName()
{
@@ -81,7 +101,7 @@
* Defines the name of this resource.
* </p>
*
- * @param name a <code>String</code> containing the name to be set.
+ * @param name a {@code String} containing the name to be set.
*/
public void setResourceName(String name)
{
Added: projects/security/security-jboss-sx/trunk/acl/src/tests/resources/META-INF/persistence.xml
===================================================================
--- projects/security/security-jboss-sx/trunk/acl/src/tests/resources/META-INF/persistence.xml (rev 0)
+++ projects/security/security-jboss-sx/trunk/acl/src/tests/resources/META-INF/persistence.xml 2008-01-29 21:04:54 UTC (rev 69468)
@@ -0,0 +1,21 @@
+<persistence xmlns="http://java.sun.com/xml/ns/persistence"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
+ version="1.0">
+ <persistence-unit name="ACL" transaction-type="RESOURCE_LOCAL">
+ <provider>org.hibernate.ejb.HibernatePersistence</provider>
+ <class>org.jboss.security.acl.ACLImpl</class>
+ <class>org.jboss.security.acl.ACLEntryImpl</class>
+ <exclude-unlisted-classes>true</exclude-unlisted-classes>
+ <properties>
+ <property name="hibernate.connection.url" value="jdbc:hsqldb:mem:unit-testing-jpa"/>
+ <!-- <property name="hibernate.connection.url" value="jdbc:hsqldb:hsql://localhost:9001/firstdb"/> -->
+ <property name="hibernate.connection.driver_class" value="org.hsqldb.jdbcDriver"/>
+ <property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect"/>
+ <property name="hibernate.hbm2ddl.auto" value="update"/> <!-- create-drop -->
+ <property name="hibernate.connection.username" value="sa"/>
+ <property name="hibernate.connection.password" value=""/>
+ <!-- <property name="hibernate.show_sql" value="true"/> -->
+ </properties>
+ </persistence-unit>
+</persistence>
More information about the jboss-cvs-commits
mailing list