[jboss-cvs] JBossAS SVN: r66053 - in projects/security/security-spi/trunk: src and 8 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Oct 11 18:23:30 EDT 2007
Author: anil.saldhana at jboss.com
Date: 2007-10-11 18:23:30 -0400 (Thu, 11 Oct 2007)
New Revision: 66053
Added:
projects/security/security-spi/trunk/src/main/org/jboss/security/factories/
projects/security/security-spi/trunk/src/main/org/jboss/security/factories/AuthorizationManagerFactory.java
projects/security/security-spi/trunk/src/main/org/jboss/security/factories/SecurityActions.java
projects/security/security-spi/trunk/src/tests/
projects/security/security-spi/trunk/src/tests/org/
projects/security/security-spi/trunk/src/tests/org/jboss/
projects/security/security-spi/trunk/src/tests/org/jboss/test/
projects/security/security-spi/trunk/src/tests/org/jboss/test/security/
projects/security/security-spi/trunk/src/tests/org/jboss/test/security/factories/
projects/security/security-spi/trunk/src/tests/org/jboss/test/security/factories/AuthorizationManagerFactoryTestCase.java
projects/security/security-spi/trunk/src/tests/org/jboss/test/security/factories/TestAuthorizationManager.java
Modified:
projects/security/security-spi/trunk/.classpath
projects/security/security-spi/trunk/pom.xml
projects/security/security-spi/trunk/src/main/org/jboss/security/SecuritySPIActions.java
Log:
AuthorizationManagerFactory
Modified: projects/security/security-spi/trunk/.classpath
===================================================================
--- projects/security/security-spi/trunk/.classpath 2007-10-11 21:48:08 UTC (rev 66052)
+++ projects/security/security-spi/trunk/.classpath 2007-10-11 22:23:30 UTC (rev 66053)
@@ -1,8 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src/main"/>
+ <classpathentry kind="src" path="src/tests"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="var" path="M2_REPO/org/jboss/javaee/jboss-javaee/5.0.0.Beta3/jboss-javaee-5.0.0.Beta3.jar"/>
<classpathentry kind="var" path="M2_REPO/org/jboss/javaee/jboss-jaspi-api/1.0-SNAPSHOT/jboss-jaspi-api-1.0-SNAPSHOT.jar"/>
+ <classpathentry kind="var" path="M2_REPO/junit/junit/3.8.1/junit-3.8.1.jar"/>
<classpathentry kind="output" path="output/classes"/>
</classpath>
Modified: projects/security/security-spi/trunk/pom.xml
===================================================================
--- projects/security/security-spi/trunk/pom.xml 2007-10-11 21:48:08 UTC (rev 66052)
+++ projects/security/security-spi/trunk/pom.xml 2007-10-11 22:23:30 UTC (rev 66053)
@@ -10,7 +10,7 @@
<groupId>jboss</groupId>
<artifactId>jboss-security-spi</artifactId>
<packaging>jar</packaging>
- <version>2.0.1-BETA2</version>
+ <version>2.0.1-GA</version>
<name>JBoss Security SPI</name>
<url>http://labs.jboss.org/portal/jbosssecurity/</url>
<description>JBoss Security is a cross cutting project that handles security for the JEMS projects</description>
@@ -91,9 +91,11 @@
</pluginRepository>
</pluginRepositories>
<build>
- <sourceDirectory>src/main</sourceDirectory>
+ <sourceDirectory>${basedir}/src/main</sourceDirectory>
+ <testSourceDirectory>${basedir}/src/tests</testSourceDirectory>
+ <testOutputDirectory>${basedir}/target/test-classes</testOutputDirectory>
<finalName>${artifactId}</finalName>
- <outputDirectory>output/classes</outputDirectory>
+ <outputDirectory>${basedir}/output/classes</outputDirectory>
<resources>
<resource>
<directory>${basedir}</directory>
@@ -103,17 +105,6 @@
</resource>
</resources>
<plugins>
- <!-- define how we want compilation to take place here, we accept most of the defaults but say that we want the optimization flag set, and define the source and target to be 1.4, these setting will be inherited by child projects -->
- <plugin>
- <artifactId>maven-compiler-plugin</artifactId>
- <version>2.0</version>
- <configuration>
- <optimize>true</optimize>
- <source>1.5</source>
- <target>1.5</target>
- </configuration>
- </plugin>
-
<!-- define that we wish to create src jars -->
<plugin>
<artifactId>maven-source-plugin</artifactId>
@@ -127,58 +118,23 @@
</execution>
</executions>
</plugin>
-
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-jar-plugin</artifactId>
- <version>2.1</version>
- <configuration>
- <archive>
- <addMavenDescriptor>false</addMavenDescriptor>
- </archive>
- </configuration>
- </plugin>
-
- <plugin>
- <artifactId>maven-antrun-plugin</artifactId>
- <version>1.1</version>
- <inherited>true</inherited>
- <executions>
- <execution>
- <id>buildjar</id>
- <phase>package</phase>
- <configuration>
- <tasks>
- <mkdir dir="${basedir}/output/lib"/>
-
- <!-- Define the pattern sets for the spi-->
- <patternset id="spi-includes">
- <include name="org/jboss/security/**"/>
- </patternset>
-
- <!-- Build the Security SPI -->
- <jar jarfile="${basedir}/output/lib/jboss-security-spi.jar" manifest="${basedir}/src/etc/default.mf">
- <fileset dir="${basedir}/output/classes">
- <patternset refid="spi-includes"/>
- </fileset>
- <fileset file="${basedir}/JBossORG-EULA.txt"/>
- </jar>
-
- <!-- Build the source jar -->
- <jar jarfile="${basedir}/output/lib/jboss-security-spi-sources.jar"
- manifest="${basedir}/src/etc/default.mf">
- <fileset dir="${basedir}/src/main"/>
- <fileset file="${basedir}/JBossORG-EULA.txt"/>
- </jar>
-
- </tasks>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
- </executions>
+
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <printSummary>true</printSummary>
+ <disableXmlReport>false</disableXmlReport>
+ <testFailureIgnore>true</testFailureIgnore>
+ <includes>
+ <include>**/**TestCase.java</include>
+ </includes>
+ <forkMode>pertest</forkMode>
+ <argLine>${surefire.jvm.args}</argLine>
+ <useFile>false</useFile>
+ <trimStackTrace>false</trimStackTrace>
+ </configuration>
</plugin>
+
<plugin>
<groupId>org.jboss.maven.plugins</groupId>
<artifactId>maven-jboss-deploy-plugin</artifactId>
@@ -222,5 +178,11 @@
<artifactId>jboss-jaspi-api</artifactId>
<version>1.0-BETA1</version>
</dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ <scope>compile</scope>
+ </dependency>
</dependencies>
</project>
Modified: projects/security/security-spi/trunk/src/main/org/jboss/security/SecuritySPIActions.java
===================================================================
--- projects/security/security-spi/trunk/src/main/org/jboss/security/SecuritySPIActions.java 2007-10-11 21:48:08 UTC (rev 66052)
+++ projects/security/security-spi/trunk/src/main/org/jboss/security/SecuritySPIActions.java 2007-10-11 22:23:30 UTC (rev 66053)
@@ -32,11 +32,10 @@
*/
class SecuritySPIActions
{
- public static ClassLoader getContextClassLoader()
+ static ClassLoader getContextClassLoader()
{
return (ClassLoader) AccessController.doPrivileged( new PrivilegedAction()
{
-
public Object run()
{
return Thread.currentThread().getContextClassLoader();
Added: projects/security/security-spi/trunk/src/main/org/jboss/security/factories/AuthorizationManagerFactory.java
===================================================================
--- projects/security/security-spi/trunk/src/main/org/jboss/security/factories/AuthorizationManagerFactory.java (rev 0)
+++ projects/security/security-spi/trunk/src/main/org/jboss/security/factories/AuthorizationManagerFactory.java 2007-10-11 22:23:30 UTC (rev 66053)
@@ -0,0 +1,52 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, 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.factories;
+
+import java.lang.reflect.Constructor;
+
+import org.jboss.security.AuthorizationManager;
+
+//$Id$
+
+/**
+ * Factory to create instances of AuthorizationManager
+ * @author Anil.Saldhana at redhat.com
+ * @since Oct 11, 2007
+ * @version $Revision$
+ */
+public class AuthorizationManagerFactory
+{
+ private static String fqn = "org.jboss.security.plugins.JBossAuthorizationManager";
+
+ public static AuthorizationManager getAuthorizationManager(String securityDomain)
+ throws Exception
+ {
+ Class clazz = SecurityActions.loadClass(fqn);
+ Constructor ctr = clazz.getConstructor(new Class[] { String.class} );
+ return (AuthorizationManager) ctr.newInstance(new Object[] {securityDomain});
+ }
+
+ public static void setFQN(String name)
+ {
+ fqn = name;
+ }
+}
\ No newline at end of file
Added: projects/security/security-spi/trunk/src/main/org/jboss/security/factories/SecurityActions.java
===================================================================
--- projects/security/security-spi/trunk/src/main/org/jboss/security/factories/SecurityActions.java (rev 0)
+++ projects/security/security-spi/trunk/src/main/org/jboss/security/factories/SecurityActions.java 2007-10-11 22:23:30 UTC (rev 66053)
@@ -0,0 +1,60 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, 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.factories;
+
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+
+//$Id$
+
+/**
+ * Privileged Blocks
+ * @author Anil.Saldhana at redhat.com
+ * @since Oct 11, 2007
+ * @version $Revision$
+ */
+class SecurityActions
+{
+ static ClassLoader getContextClassLoader() throws PrivilegedActionException
+ {
+ return (ClassLoader) AccessController.doPrivileged(new PrivilegedExceptionAction()
+ {
+ public Object run() throws Exception
+ {
+ return Thread.currentThread().getContextClassLoader();
+ }
+ });
+ }
+
+ static Class loadClass(final String fqn) throws PrivilegedActionException
+ {
+ return (Class) AccessController.doPrivileged(new PrivilegedExceptionAction()
+ {
+ public Object run() throws Exception
+ {
+ ClassLoader tcl = Thread.currentThread().getContextClassLoader();
+ return tcl.loadClass(fqn);
+ }
+ });
+ }
+}
\ No newline at end of file
Added: projects/security/security-spi/trunk/src/tests/org/jboss/test/security/factories/AuthorizationManagerFactoryTestCase.java
===================================================================
--- projects/security/security-spi/trunk/src/tests/org/jboss/test/security/factories/AuthorizationManagerFactoryTestCase.java (rev 0)
+++ projects/security/security-spi/trunk/src/tests/org/jboss/test/security/factories/AuthorizationManagerFactoryTestCase.java 2007-10-11 22:23:30 UTC (rev 66053)
@@ -0,0 +1,45 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, 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.factories;
+
+import org.jboss.security.AuthorizationManager;
+import org.jboss.security.factories.AuthorizationManagerFactory;
+
+import junit.framework.TestCase;
+
+//$Id$
+
+/**
+ * Tests for the AuthorizationManagerFactory
+ * @author Anil.Saldhana at redhat.com
+ * @since Oct 11, 2007
+ * @version $Revision$
+ */
+public class AuthorizationManagerFactoryTestCase extends TestCase
+{
+ public void testAuthorizationManagerFactory() throws Exception
+ {
+ AuthorizationManagerFactory.setFQN(TestAuthorizationManager.class.getName());
+ AuthorizationManager am = AuthorizationManagerFactory.getAuthorizationManager("test");
+ assertTrue(am instanceof TestAuthorizationManager);
+ }
+}
\ No newline at end of file
Added: projects/security/security-spi/trunk/src/tests/org/jboss/test/security/factories/TestAuthorizationManager.java
===================================================================
--- projects/security/security-spi/trunk/src/tests/org/jboss/test/security/factories/TestAuthorizationManager.java (rev 0)
+++ projects/security/security-spi/trunk/src/tests/org/jboss/test/security/factories/TestAuthorizationManager.java 2007-10-11 22:23:30 UTC (rev 66053)
@@ -0,0 +1,71 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, 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.factories;
+
+import java.security.Principal;
+import java.security.acl.Group;
+import java.util.Map;
+import java.util.Set;
+
+import org.jboss.security.AuthorizationManager;
+import org.jboss.security.authorization.AuthorizationException;
+import org.jboss.security.authorization.Resource;
+
+//$Id$
+
+/**
+ * Test AuthorizationManager
+ * @author Anil.Saldhana at redhat.com
+ * @since Oct 11, 2007
+ * @version $Revision$
+ */
+public class TestAuthorizationManager implements AuthorizationManager
+{
+ public TestAuthorizationManager(String securityDomain)
+ {
+ }
+
+ public int authorize(Resource resource) throws AuthorizationException
+ {
+ return 0;
+ }
+
+ public boolean doesUserHaveRole(Principal principal, Set roles)
+ {
+ return false;
+ }
+
+ public Group getTargetRoles(Principal targetPrincipal, Map contextMap)
+ {
+ return null;
+ }
+
+ public Set getUserRoles(Principal principal)
+ {
+ return null;
+ }
+
+ public String getSecurityDomain()
+ {
+ return null;
+ }
+}
\ No newline at end of file
More information about the jboss-cvs-commits
mailing list