]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CSPACE-870 Integrated Spring Security 3.0.2.CI-SNAPSHOT and Spring 3.0.0.RELEASE...
authorSanjay Dalal <sanjay.dalal@berkeley.edu>
Tue, 9 Feb 2010 22:32:22 +0000 (22:32 +0000)
committerSanjay Dalal <sanjay.dalal@berkeley.edu>
Tue, 9 Feb 2010 22:32:22 +0000 (22:32 +0000)
Refactored DatabaseRealm and CSpaceJBossDBLoginModule (needs package change in login-config.xml of JBoss).
ant deploy is required to copy the Spring specific jars to cspace/lib (of cspace domain). See services/common/lib/README.txt
Spring security is enabled by default. Anonymous access is also enabled by default (allows all tests to run without HTTP basic auth). Security tests could be run with client side security enabled (no need to bounce the server)

A    services/authentication/service/src/main/java/org/collectionspace/authentication/realm
A    services/authentication/service/src/main/java/org/collectionspace/authentication/realm/CSpaceRealm.java
A  + services/authentication/service/src/main/java/org/collectionspace/authentication/realm/CSpaceDbRealm.java
A    services/authentication/service/src/main/java/org/collectionspace/authentication/spring
A    services/authentication/service/src/main/java/org/collectionspace/authentication/spring/CSpaceUserDetailsService.java
A    services/authentication/service/src/main/java/org/collectionspace/authentication/spring/CSpaceAuthorityGranter.java
D    services/authentication/service/src/main/java/org/collectionspace/authentication/CSpaceJBossDBLoginModule.java
D    services/authentication/service/src/main/java/org/collectionspace/authentication/DatabaseRealm.java
A    services/authentication/service/src/main/java/org/collectionspace/authentication/jaas
A  + services/authentication/service/src/main/java/org/collectionspace/authentication/jaas/CSpaceJBossDBLoginModule.java
M    services/authentication/service/src/main/resources/config/jboss-login-config.xml
M    services/authentication/service/pom.xml
M    services/authentication/service/build.xml
M    services/JaxRsServiceProvider/src/main/webapp/WEB-INF/web.xml
A    services/JaxRsServiceProvider/src/main/webapp/WEB-INF/login.conf
A    services/JaxRsServiceProvider/src/main/webapp/WEB-INF/applicationContext-security.xml
M    services/JaxRsServiceProvider/pom.xml
M    services/JaxRsServiceProvider/build.xml
A    services/common/lib/spring
AM   services/common/lib/spring/org.springframework.asm-3.0.0.BUILD-20100208195804.jar
AM   services/common/lib/spring/org.springframework.jdbc-3.0.0.BUILD-20100208195804.jar
AM   services/common/lib/spring/spring-security-web-3.0.2.CI-SNAPSHOT.jar
AM   services/common/lib/spring/org.springframework.context-3.0.0.BUILD-20100208195804.jar
AM   services/common/lib/spring/spring-security-acl-3.0.2.CI-SNAPSHOT.jar
AM   services/common/lib/spring/org.springframework.beans-3.0.0.BUILD-20100208195804.jar
AM   services/common/lib/spring/org.springframework.core-3.0.0.BUILD-20100208195804.jar
AM   services/common/lib/spring/spring-security-config-3.0.2.CI-SNAPSHOT.jar
AM   services/common/lib/spring/org.springframework.web-3.0.0.BUILD-20100208195804.jar
AM   services/common/lib/spring/spring-security-core-3.0.2.CI-SNAPSHOT.jar
AM   services/common/lib/spring/org.springframework.expression-3.0.0.BUILD-20100208195804.jar
AM   services/common/lib/spring/org.springframework.aop-3.0.0.BUILD-20100208195804.jar
M    services/common/lib/README.txt
M    services/common/build.xml

27 files changed:
services/JaxRsServiceProvider/build.xml
services/JaxRsServiceProvider/pom.xml
services/JaxRsServiceProvider/src/main/webapp/WEB-INF/applicationContext-security.xml [new file with mode: 0644]
services/JaxRsServiceProvider/src/main/webapp/WEB-INF/login.conf [new file with mode: 0644]
services/JaxRsServiceProvider/src/main/webapp/WEB-INF/web.xml
services/authentication/service/build.xml
services/authentication/service/pom.xml
services/authentication/service/src/main/java/org/collectionspace/authentication/jaas/CSpaceJBossDBLoginModule.java [moved from services/authentication/service/src/main/java/org/collectionspace/authentication/CSpaceJBossDBLoginModule.java with 93% similarity]
services/authentication/service/src/main/java/org/collectionspace/authentication/realm/CSpaceDbRealm.java [moved from services/authentication/service/src/main/java/org/collectionspace/authentication/DatabaseRealm.java with 95% similarity]
services/authentication/service/src/main/java/org/collectionspace/authentication/realm/CSpaceRealm.java [new file with mode: 0644]
services/authentication/service/src/main/java/org/collectionspace/authentication/spring/CSpaceAuthorityGranter.java [new file with mode: 0644]
services/authentication/service/src/main/java/org/collectionspace/authentication/spring/CSpaceUserDetailsService.java [new file with mode: 0644]
services/authentication/service/src/main/resources/config/jboss-login-config.xml
services/common/build.xml
services/common/lib/README.txt
services/common/lib/spring/org.springframework.aop-3.0.0.BUILD-20100208195804.jar [new file with mode: 0644]
services/common/lib/spring/org.springframework.asm-3.0.0.BUILD-20100208195804.jar [new file with mode: 0644]
services/common/lib/spring/org.springframework.beans-3.0.0.BUILD-20100208195804.jar [new file with mode: 0644]
services/common/lib/spring/org.springframework.context-3.0.0.BUILD-20100208195804.jar [new file with mode: 0644]
services/common/lib/spring/org.springframework.core-3.0.0.BUILD-20100208195804.jar [new file with mode: 0644]
services/common/lib/spring/org.springframework.expression-3.0.0.BUILD-20100208195804.jar [new file with mode: 0644]
services/common/lib/spring/org.springframework.jdbc-3.0.0.BUILD-20100208195804.jar [new file with mode: 0644]
services/common/lib/spring/org.springframework.web-3.0.0.BUILD-20100208195804.jar [new file with mode: 0644]
services/common/lib/spring/spring-security-acl-3.0.2.CI-SNAPSHOT.jar [new file with mode: 0644]
services/common/lib/spring/spring-security-config-3.0.2.CI-SNAPSHOT.jar [new file with mode: 0644]
services/common/lib/spring/spring-security-core-3.0.2.CI-SNAPSHOT.jar [new file with mode: 0644]
services/common/lib/spring/spring-security-web-3.0.2.CI-SNAPSHOT.jar [new file with mode: 0644]

index a96d191c550cc007dbdd9c01b8a684ea84922e0e..5f804c64afd3ae03052cd612971a80f0440e4871 100644 (file)
     <target name="hotdeploy-unix" if="osfamily-unix">
         <exec executable="mvn" failonerror="true">
             <arg value="properties:read-project-properties" />
-            <arg value="cargo:undeploy" />
-            <arg value="cargo:deploy" />
+            <arg value="cargo:deployer-undeploy" />
+            <arg value="cargo:deployer-deploy" />
             <arg value="-Dmaven.test.skip=true" />
             <arg value="-f" />
             <arg value="${basedir}/pom.xml" />
             <arg value="/c" />
             <arg value="mvn.bat" />
             <arg value="properties:read-project-properties" />
-            <arg value="cargo:undeploy" />
-            <arg value="cargo:deploy" />
+            <arg value="cargo:deployer-undeploy" />
+            <arg value="cargo:deployer-deploy" />
             <arg value="-Dmaven.test.skip=true" />
             <arg value="-f" />
             <arg value="${basedir}/pom.xml" />
index f3c1cd753d645e65f53c3c01a228d673d30585c3..11e164e06ce32b041e949da0f44f49e6dc5168d4 100644 (file)
@@ -1,21 +1,23 @@
 <?xml version="1.0" encoding="UTF-8"?>\r
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">\r
-    \r
+\r
     <parent>\r
         <artifactId>org.collectionspace.services.main</artifactId>\r
         <groupId>org.collectionspace.services</groupId>\r
         <version>1.0</version>\r
     </parent>\r
 \r
-    \r
+\r
     <modelVersion>4.0.0</modelVersion>\r
     <groupId>org.collectionspace.services</groupId>\r
     <artifactId>org.collectionspace.services.jaxrs.provider</artifactId>\r
     <packaging>war</packaging>\r
     <version>1.0</version>\r
     <name>services.jaxrs.provider</name>\r
-\r
-\r
+    <properties>\r
+        <spring.version>3.0.0.RELEASE</spring.version>\r
+        <spring.security.version>3.0.2.CI-SNAPSHOT</spring.security.version>\r
+    </properties>\r
     <dependencies>\r
         <dependency>\r
             <groupId>org.collectionspace.services</groupId>\r
             <version>1.5.2</version>\r
         </dependency>\r
 \r
+        <!-- dependencies on spring security & framework are runtime deps only -->\r
+        <!-- the following list is kept to make sure domain has these packages -->\r
+        <!-- in the cspace/lib directory -->\r
+        <dependency>\r
+            <groupId>org.springframework.security</groupId>\r
+            <artifactId>spring-security-core</artifactId>\r
+            <version>${spring.security.version}</version>\r
+            <scope>provided</scope>\r
+        </dependency>\r
+        <dependency>\r
+            <groupId>org.springframework.security</groupId>\r
+            <artifactId>spring-security-config</artifactId>\r
+            <version>${spring.security.version}</version>\r
+            <scope>provided</scope>\r
+        </dependency>\r
+        <dependency>\r
+            <groupId>org.springframework.security</groupId>\r
+            <artifactId>spring-security-web</artifactId>\r
+            <version>${spring.security.version}</version>\r
+            <scope>provided</scope>\r
+        </dependency>\r
+        <dependency>\r
+            <groupId>org.springframework.security</groupId>\r
+            <artifactId>spring-security-acl</artifactId>\r
+            <version>${spring.security.version}</version>\r
+            <scope>provided</scope>\r
+        </dependency>\r
+        <dependency>\r
+            <groupId>org.springframework</groupId>\r
+            <artifactId>spring-context</artifactId>\r
+            <version>${spring.version}</version>\r
+            <scope>provided</scope>\r
+        </dependency>\r
+        <dependency>\r
+            <groupId>org.springframework</groupId>\r
+            <artifactId>spring-web</artifactId>\r
+            <version>${spring.version}</version>\r
+            <scope>provided</scope>\r
+        </dependency>\r
+        <dependency>\r
+            <groupId>org.springframework</groupId>\r
+            <artifactId>spring-webmvc</artifactId>\r
+            <version>${spring.version}</version>\r
+            <scope>provided</scope>\r
+        </dependency>\r
+        <dependency>\r
+            <groupId>org.springframework</groupId>\r
+            <artifactId>spring-aop</artifactId>\r
+            <version>${spring.version}</version>\r
+            <scope>provided</scope>\r
+        </dependency>\r
         <!-- javax -->\r
 \r
         <!-- jboss -->\r
             <plugin>\r
                 <groupId>org.codehaus.cargo</groupId>\r
                 <artifactId>cargo-maven2-plugin</artifactId>\r
+                <version>0.3-SNAPSHOT</version>\r
                 <!-- Container configuration -->\r
                 <configuration>\r
                     <container>\r
-                        <containerId>jboss42x</containerId>\r
+                        <containerId>jboss4x</containerId>\r
                         <home>${jboss.dir}</home>\r
                         <type>remote</type>\r
                     </container>\r
diff --git a/services/JaxRsServiceProvider/src/main/webapp/WEB-INF/applicationContext-security.xml b/services/JaxRsServiceProvider/src/main/webapp/WEB-INF/applicationContext-security.xml
new file mode 100644 (file)
index 0000000..9570d1c
--- /dev/null
@@ -0,0 +1,47 @@
+<!--
+    Document   : applicationContext-security.xml
+    Created on :
+    Author     :
+    Copyright 2010 University of California at Berkeley
+    Description:
+        spring security namespace for CS service layer
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:s="http://www.springframework.org/schema/security"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
+       http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.0.xsd">
+    <s:http use-expressions="true">
+        <s:intercept-url pattern="/**" access="permitAll" />
+        <s:http-basic />
+        <s:logout />
+    </s:http>
+
+    <s:authentication-manager>
+        <s:authentication-provider ref="jaasAuthenticationProvider" user-service-ref="userDetailsService"/>
+    </s:authentication-manager>
+
+    <bean id="jaasAuthenticationProvider"
+          class="org.springframework.security.authentication.jaas.JaasAuthenticationProvider">
+        <property name="loginContextName">
+            <value>cspace</value> <!-- value should be same as in application-policy in JBoss login-config.xml -->
+        </property>
+        <property name="loginConfig">
+            <value>/WEB-INF/login.conf</value> <!-- filler, not used at runtime -->
+        </property>
+        <property name="callbackHandlers">
+            <list>
+                <bean class="org.springframework.security.authentication.jaas.JaasNameCallbackHandler"/>
+                <bean class="org.springframework.security.authentication.jaas.JaasPasswordCallbackHandler"/>
+            </list>
+        </property>
+        <property name="authorityGranters">
+            <list>
+                <bean class="org.collectionspace.authentication.spring.CSpaceAuthorityGranter"/>
+            </list>
+        </property>
+    </bean>
+
+    <bean id="userDetailsService" class="org.collectionspace.authentication.spring.CSpaceUserDetailsService">
+    </bean>
+</beans>
diff --git a/services/JaxRsServiceProvider/src/main/webapp/WEB-INF/login.conf b/services/JaxRsServiceProvider/src/main/webapp/WEB-INF/login.conf
new file mode 100644 (file)
index 0000000..e69de29
index 5660b37af46bf14dd9781431420a4a25ed0535ac..13b44e4127b558606215c6159a4ebd893e23d680 100644 (file)
         <param-value>/</param-value>
     </context-param>
 
+    <!--
+      - Location of the XML file that defines the root application context
+      - Applied by ContextLoaderListener.
+      -->
+    <context-param>
+        <param-name>contextConfigLocation</param-name>
+        <param-value>
+            /WEB-INF/applicationContext-security.xml
+        </param-value>
+    </context-param>
+    
+    <filter>
+        <filter-name>springSecurityFilterChain</filter-name>
+        <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
+    </filter>
+
+    <filter-mapping>
+      <filter-name>springSecurityFilterChain</filter-name>
+      <url-pattern>/*</url-pattern>
+    </filter-mapping>
+
     <!-- Listeners -->
+    
+    <!--
+      - Loads the root application context of this web app at startup.
+      - The application context is then available via
+      - WebApplicationContextUtils.getWebApplicationContext(servletContext).
+    -->
+    <listener>
+        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
+    </listener>
+
+    <!--
+      - Publishes events for session creation and destruction through the application
+      - context. Optional unless concurrent session control is being used.
+      -->
+    <listener>
+      <listener-class>org.springframework.security.web.session.HttpSessionEventPublisher</listener-class>
+    </listener>
+
+    <listener>
+        <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
+    </listener>
+
     <listener>
         <listener-class>
             org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap
index 02ff80cee89219bf4569c4776360b4836060d407..596d5e4c54311018a98f3b43995d5065ecf79e59 100644 (file)
@@ -3,7 +3,7 @@
     <description>\r
         collectionspace authentication service\r
     </description>\r
-  <!-- set global properties for this build -->\r
+    <!-- set global properties for this build -->\r
     <property name="services.trunk" value="../../.."/>\r
     <!-- enviornment should be declared before reading build.properties -->\r
     <property environment="env" />\r
     </condition>\r
 \r
     <target name="init">\r
-    <!-- Create the time stamp -->\r
+        <!-- Create the time stamp -->\r
         <tstamp/>\r
     </target>\r
 \r
 \r
     <target name="package" depends="package-unix,package-windows"\r
-  description="Package CollectionSpace Services" />\r
+            description="Package CollectionSpace Services" />\r
     <target name="package-unix" if="osfamily-unix">\r
         <exec executable="mvn" failonerror="true">\r
             <arg value="package" />\r
@@ -51,7 +51,7 @@
     </target>\r
 \r
     <target name="install" depends="package,install-unix,install-windows"\r
-  description="Install" />\r
+            description="Install" />\r
     <target name="install-unix" if="osfamily-unix">\r
         <exec executable="mvn" failonerror="true">\r
             <arg value="install" />\r
@@ -74,9 +74,9 @@
             <arg value="${mvn.opts}" />\r
         </exec>\r
     </target>\r
-    \r
+\r
     <target name="clean" depends="clean-unix,clean-windows"\r
-  description="Delete target directories" >\r
+            description="Delete target directories" >\r
         <delete dir="${build}"/>\r
     </target>\r
     <target name="clean-unix" if="osfamily-unix">\r
     </target>\r
 \r
     <target name="deploy" depends="install"\r
-    description="deploy authentication service in ${jboss.server.cspace}">\r
+            description="deploy authentication service in ${jboss.server.cspace}">\r
         <copy file="${basedir}/target/${authentication.jar}" todir="${jboss.server.cspace}/lib"/>\r
         <copy todir="${jboss.server.cspace}/cspace/services">\r
             <fileset dir="${src}/main/resources/"/>\r
     </target>\r
 \r
     <target name="undeploy"\r
-    description="undeploy authentication service from ${jboss.server.cspace}">\r
+            description="undeploy authentication service from ${jboss.server.cspace}">\r
         <delete file="${jboss.server.cspace}/lib/${authentication.jar}"/>\r
         <echo message="Remove authentication-policy cspace from ${jboss.server.cspace}/conf/login-config.xml"/>\r
-         <echo message="See Authentication Service Configuration Guide on wiki.collectionspace.org for more details"/>\r
+        <echo message="See Authentication Service Configuration Guide on wiki.collectionspace.org for more details"/>\r
     </target>\r
 \r
     <target name="dist"\r
-    description="generate distribution for authentication service" depends="package">\r
+            description="generate distribution for authentication service" depends="package">\r
         <copy todir="${services.trunk}/${dist.lib.cspace}">\r
             <fileset file="${basedir}/target/${authentication.jar}"/>\r
         </copy>\r
index 4ee88351143537cce374c0fa2f7a12e691840f72..15da9a5f0f8ecb7edfba6ae72c8d5df4802b8eba 100644 (file)
@@ -16,6 +16,7 @@
         <jboss.version>4.2.3.GA</jboss.version>
         <jboss.ejb.version>3.0</jboss.ejb.version>
         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+        <spring.security.version>3.0.2.CI-SNAPSHOT</spring.security.version>
     </properties>
 
     <dependencies>
             <artifactId>jbosssx</artifactId>
             <version>4.2.3.GA</version>
         </dependency>
+
+        <dependency>
+            <groupId>org.springframework.security</groupId>
+            <artifactId>spring-security-core</artifactId>
+            <version>${spring.security.version}</version>
+            <scope>provided</scope>
+        </dependency>
+
     </dependencies>
 
     <build>
@@ -21,7 +21,7 @@
  *  See the License for the specific language governing permissions and\r
  *  limitations under the License.\r
  */\r
-package org.collectionspace.authentication;\r
+package org.collectionspace.authentication.jaas;\r
 \r
 import java.security.acl.Group;\r
 import java.util.ArrayList;\r
@@ -32,6 +32,7 @@ import java.util.Map;
 import javax.security.auth.Subject;\r
 import javax.security.auth.callback.CallbackHandler;\r
 import javax.security.auth.login.LoginException;\r
+import org.collectionspace.authentication.realm.CSpaceDbRealm;\r
 import org.jboss.security.auth.spi.UsernamePasswordLoginModule;\r
 \r
 /**\r
@@ -40,7 +41,7 @@ import org.jboss.security.auth.spi.UsernamePasswordLoginModule;
  */\r
 public class CSpaceJBossDBLoginModule extends UsernamePasswordLoginModule {\r
 \r
-    private DatabaseRealm realm;\r
+    private CSpaceDbRealm realm;\r
 \r
     /**\r
      * Initialize CSpaceDBLoginModule\r
@@ -58,7 +59,7 @@ public class CSpaceJBossDBLoginModule extends UsernamePasswordLoginModule {
     public void initialize(Subject subject, CallbackHandler callbackHandler,\r
             Map sharedState, Map options) {\r
         super.initialize(subject, callbackHandler, sharedState, options);\r
-        realm = new DatabaseRealm(options);\r
+        realm = new CSpaceDbRealm(options);\r
     }\r
     //disabled due to classloading problem\r
 //    private Logger logger = LoggerFactory.getLogger(CSpaceDBLoginModule.class);\r
similarity index 95%
rename from services/authentication/service/src/main/java/org/collectionspace/authentication/DatabaseRealm.java
rename to services/authentication/service/src/main/java/org/collectionspace/authentication/realm/CSpaceDbRealm.java
index 5d1f265a00c4668b4c00885b1f00759c679edaf8..dc948e6d73aa5b99b55724cdedd77d4615bc36ef 100644 (file)
@@ -47,7 +47,7 @@
  * To change this template, choose Tools | Templates
  * and open the template in the editor.
  */
-package org.collectionspace.authentication;
+package org.collectionspace.authentication.realm;
 
 import java.lang.reflect.Constructor;
 import java.security.Principal;
@@ -67,14 +67,15 @@ import javax.sql.DataSource;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.collectionspace.authentication.CSpaceTenant;
 
 /**
- * DatabaseRealm provides access to user, password, role, tenant database
+ * CSpaceDbRealm provides access to user, password, role, tenant database
  * @author 
  */
-public class DatabaseRealm {
+public class CSpaceDbRealm implements CSpaceRealm {
 
-    private static Log log = LogFactory.getLog(DatabaseRealm.class);
+    private static Log log = LogFactory.getLog(CSpaceDbRealm.class);
     private String datasourceName;
     private String principalsQuery;
     private String rolesQuery;
@@ -82,10 +83,10 @@ public class DatabaseRealm {
     private boolean suspendResume;
 
     /**
-     * create DatabaseRelam 
+     * CSpace Database Realm
      * @param datasourceName datasource name
      */
-    public DatabaseRealm(Map options) {
+    public CSpaceDbRealm(Map options) {
         datasourceName = (String) options.get("dsJndiName");
         if (datasourceName == null) {
             datasourceName = "java:/DefaultDS";
@@ -115,7 +116,8 @@ public class DatabaseRealm {
 
     }
 
-    String getUsersPassword(String username) throws LoginException {
+    @Override
+    public String getUsersPassword(String username) throws LoginException {
 
         String password = null;
         Connection conn = null;
@@ -174,7 +176,8 @@ public class DatabaseRealm {
      * the authenticated user.
      * @return collection containing the roles
      */
-    Collection<Group> getRoles(String username, String principalClassName, String groupClassName) throws LoginException {
+    @Override
+    public Collection<Group> getRoles(String username, String principalClassName, String groupClassName) throws LoginException {
 
         if (log.isDebugEnabled()) {
             log.debug("getRoleSets using rolesQuery: " + rolesQuery + ", username: " + username);
@@ -279,7 +282,8 @@ public class DatabaseRealm {
      * the authenticated user.
      * @return collection containing the roles
      */
-    Collection<Group> getTenants(String username, String groupClassName) throws LoginException {
+    @Override
+    public Collection<Group> getTenants(String username, String groupClassName) throws LoginException {
 
         if (log.isDebugEnabled()) {
             log.debug("getTenants using tenantsQuery: " + tenantsQuery + ", username: " + username);
diff --git a/services/authentication/service/src/main/java/org/collectionspace/authentication/realm/CSpaceRealm.java b/services/authentication/service/src/main/java/org/collectionspace/authentication/realm/CSpaceRealm.java
new file mode 100644 (file)
index 0000000..d635916
--- /dev/null
@@ -0,0 +1,60 @@
+/**
+ *  This document is a part of the source code and related artifacts
+ *  for CollectionSpace, an open source collections management system
+ *  for museums and related institutions:
+
+ *  http://www.collectionspace.org
+ *  http://wiki.collectionspace.org
+
+ *  Copyright 2009 University of California at Berkeley
+
+ *  Licensed under the Educational Community License (ECL), Version 2.0.
+ *  You may not use this file except in compliance with this License.
+
+ *  You may obtain a copy of the ECL 2.0 License at
+
+ *  https://source.collectionspace.org/collection-space/LICENSE.txt
+
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package org.collectionspace.authentication.realm;
+
+import java.security.acl.Group;
+import java.util.Collection;
+import javax.security.auth.login.LoginException;
+
+/**
+ * CSpaceRealm defines interface for CollectionSpace Realm
+ */
+public interface CSpaceRealm {
+
+        /**
+     * Obtain password for the given user
+     * @param username
+     * @return
+     * @throws LoginException
+     */
+    public String getUsersPassword(String username) throws LoginException;
+
+    /**
+     * Obtain the roles for the authenticated user.
+     * @return collection containing the roles
+     */
+    public Collection<Group> getRoles(String username, String principalClassName, String groupClassName) throws LoginException;
+
+    /**
+     * Obtain the tenants for the authenticated user.
+     * @return collection containing the roles
+     */
+    public Collection<Group> getTenants(String username, String groupClassName) throws LoginException;
+
+}
diff --git a/services/authentication/service/src/main/java/org/collectionspace/authentication/spring/CSpaceAuthorityGranter.java b/services/authentication/service/src/main/java/org/collectionspace/authentication/spring/CSpaceAuthorityGranter.java
new file mode 100644 (file)
index 0000000..b228d10
--- /dev/null
@@ -0,0 +1,69 @@
+/**
+ *  This document is a part of the source code and related artifacts
+ *  for CollectionSpace, an open source collections management system
+ *  for museums and related institutions:
+
+ *  http://www.collectionspace.org
+ *  http://wiki.collectionspace.org
+
+ *  Copyright 2009 University of California at Berkeley
+
+ *  Licensed under the Educational Community License (ECL), Version 2.0.
+ *  You may not use this file except in compliance with this License.
+
+ *  You may obtain a copy of the ECL 2.0 License at
+
+ *  https://source.collectionspace.org/collection-space/LICENSE.txt
+
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *//**
+ *  This document is a part of the source code and related artifacts
+ *  for CollectionSpace, an open source collections management system
+ *  for museums and related institutions:
+
+ *  http://www.collectionspace.org
+ *  http://wiki.collectionspace.org
+
+ *  Copyright 2009 University of California at Berkeley
+
+ *  Licensed under the Educational Community License (ECL), Version 2.0.
+ *  You may not use this file except in compliance with this License.
+
+ *  You may obtain a copy of the ECL 2.0 License at
+
+ *  https://source.collectionspace.org/collection-space/LICENSE.txt
+
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package org.collectionspace.authentication.spring;
+import java.security.Principal;
+import java.util.HashSet;
+import java.util.Set;
+import org.springframework.security.authentication.jaas.AuthorityGranter;
+
+/**
+ *
+ * @author 
+ */
+public class CSpaceAuthorityGranter implements AuthorityGranter {
+    public Set<String> grant(Principal principal) {
+        Set<String> rtnSet = new HashSet<String>();
+
+
+        return rtnSet;
+    }
+}
diff --git a/services/authentication/service/src/main/java/org/collectionspace/authentication/spring/CSpaceUserDetailsService.java b/services/authentication/service/src/main/java/org/collectionspace/authentication/spring/CSpaceUserDetailsService.java
new file mode 100644 (file)
index 0000000..92bf5c4
--- /dev/null
@@ -0,0 +1,89 @@
+/**
+ *  This document is a part of the source code and related artifacts
+ *  for CollectionSpace, an open source collections management system
+ *  for museums and related institutions:
+
+ *  http://www.collectionspace.org
+ *  http://wiki.collectionspace.org
+
+ *  Copyright 2009 University of California at Berkeley
+
+ *  Licensed under the Educational Community License (ECL), Version 2.0.
+ *  You may not use this file except in compliance with this License.
+
+ *  You may obtain a copy of the ECL 2.0 License at
+
+ *  https://source.collectionspace.org/collection-space/LICENSE.txt
+
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *//**
+ *  This document is a part of the source code and related artifacts
+ *  for CollectionSpace, an open source collections management system
+ *  for museums and related institutions:
+
+ *  http://www.collectionspace.org
+ *  http://wiki.collectionspace.org
+
+ *  Copyright 2009 University of California at Berkeley
+
+ *  Licensed under the Educational Community License (ECL), Version 2.0.
+ *  You may not use this file except in compliance with this License.
+
+ *  You may obtain a copy of the ECL 2.0 License at
+
+ *  https://source.collectionspace.org/collection-space/LICENSE.txt
+
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package org.collectionspace.authentication.spring;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.springframework.dao.DataAccessException;
+import org.springframework.security.core.GrantedAuthority;
+import org.springframework.security.core.authority.AuthorityUtils;
+import org.springframework.security.core.userdetails.User;
+import org.springframework.security.core.userdetails.UserDetails;
+import org.springframework.security.core.userdetails.UserDetailsService;
+import org.springframework.security.core.userdetails.UsernameNotFoundException;
+
+/**
+ * A CollectionSpace UserDetailsService for spring
+ */
+//FIXME remove test/mockup code
+public class CSpaceUserDetailsService implements UserDetailsService {
+
+    private Map<String, User> users = new HashMap<String, User>();
+    private List<GrantedAuthority> auths = AuthorityUtils.createAuthorityList("ROLE_USER");
+
+    public CSpaceUserDetailsService() {
+        users.put("test", new User("test", "", true, true, true, true, auths));
+        users.put("valid", new User("valid", "", true, true, true, true, auths));
+        users.put("locked", new User("locked", "", true, true, true, false, auths));
+        users.put("disabled", new User("disabled", "", false, true, true, true, auths));
+        users.put("credentialsExpired", new User("credentialsExpired", "", true, true, false, true, auths));
+        users.put("expired", new User("expired", "", true, false, true, true, auths));
+    }
+
+    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException, DataAccessException {
+        if (users.get(username) == null) {
+            throw new UsernameNotFoundException("User not found: " + username);
+        }
+
+        return users.get(username);
+    }
+}
index e5b0f7b81b6de0e3133a8f1792d47e1f6dcfb09b..afcc12948d50575beb9bb6da952816001b0067f6 100644 (file)
@@ -18,7 +18,7 @@ copy before the "other" application-policy
 
 <application-policy name="cspace">
     <authentication>
-        <login-module code="org.collectionspace.authentication.CSpaceJBossDBLoginModule"
+        <login-module code="org.collectionspace.authentication.jaas.CSpaceJBossDBLoginModule"
                       flag="required">
             <module-option name="dsJndiName">CspaceDS</module-option>
             <module-option name="hashAlgorithm">SHA-256</module-option>
index 3a725fdfa55f0e5d2bc532bb612c31897e4b1790..5c96bed25fe4bdaad98795c9ba06150c36ea57e6 100644 (file)
@@ -3,7 +3,7 @@
     <description>
         collectionspace services common
     </description>
-  <!-- set global properties for this build -->
+    <!-- set global properties for this build -->
     <property name="services.trunk" value="../.."/>
     <!-- enviornment should be declared before reading build.properties -->
     <property environment="env" />
     </condition>
 
     <target name="init" >
-    <!-- Create the time stamp -->
+        <!-- Create the time stamp -->
         <tstamp/>
     </target>
 
     <target name="package" depends="package-unix,package-windows"
-  description="Package CollectionSpace Services" />
+            description="Package CollectionSpace Services" />
     <target name="package-unix" if="osfamily-unix">
         <exec executable="mvn" failonerror="true">
             <arg value="package" />
@@ -50,7 +50,7 @@
     </target>
 
     <target name="install" depends="package,install-unix,install-windows"
-  description="Install" />
+            description="Install" />
     <target name="install-unix" if="osfamily-unix">
         <exec executable="mvn" failonerror="true">
             <arg value="install" />
@@ -73,9 +73,9 @@
             <arg value="${mvn.opts}" />
         </exec>
     </target>
-    
+
     <target name="clean" depends="clean-unix,clean-windows"
-  description="Delete target directories" >
+            description="Delete target directories" >
         <delete dir="${build}"/>
     </target>
     <target name="clean-unix" if="osfamily-unix">
         </exec>
     </target>
 
-    <target name="jpa"
-    description="one time upgrade jpa binaries in ${jboss.server.cspace}">
-        <move todir="${jboss.server.cspace}/jpa-upgrade/lib">
+    <target name="deploy_jpa"
+            description="deploy jpa binaries in ${jboss.server.cspace}">
+        <move todir="${jboss.server.cspace}/jpa-upgrade/lib" overwrite="false">
             <filelist dir="${jboss.server.cspace}/lib">
                 <file name="hibernate-annotations.jar"/>
                 <file name="hibernate-entitymanager.jar"/>
         </copy>
     </target>
 
+    <target name="deploy_spring"
+            description="deploy spring binaries in ${jboss.server.cspace}">
+        <copy todir="${jboss.server.cspace}/lib">
+            <fileset dir="${basedir}/lib/spring"/>
+        </copy>
+    </target>
+
     <target name="deploy" depends="install"
-    description="deploy common elements in ${jboss.server.cspace}">
+            description="deploy common elements in ${jboss.server.cspace}">
+        <antcall target="deploy_jpa" />
+        <antcall target="deploy_spring" />
         <copy todir="${jboss.server.cspace}/cspace/config/services">
             <fileset dir="${basedir}/src/main/config"/>
         </copy>
     </target>
 
     <target name="undeploy"
-    description="undeploy common elements from ${jboss.server.cspace}">
+            description="undeploy common elements from ${jboss.server.cspace}">
         <delete failonerror="false" dir="${jboss.server.cspace}/cspace/config/services"/>
     </target>
 
+    <target name="dist_jpa"
+            description="dist jpa binaries in ${dist.server.cspace}">
+        <copy todir="${services.trunk}/${dist.server.cspace}/lib">
+            <fileset dir="${basedir}/lib/jpa-upgrade"/>
+        </copy>
+    </target>
+
+    <target name="dist_spring"
+            description="dist spring binaries in ${dist.server.cspace}">
+        <copy todir="${services.trunk}/${dist.server.cspace}/lib">
+            <fileset dir="${basedir}/lib/spring"/>
+        </copy>
+    </target>
+
     <target name="dist"
-    description="generate distribution for common elements" depends="package">
+            description="generate distribution for common elements" depends="package">
+        <antcall target="dist_jpa" />
+        <antcall target="dist_spring" />
         <copy todir="${services.trunk}/${dist.server.cspace}/cspace/config/services">
             <fileset dir="${basedir}/src/main/config"/>
         </copy>
index 6df592750677be03c49ed911df9b10ebc61a7746..424649fd9ac8ff01ce108c482f5aa202ba85faf0 100644 (file)
@@ -1,6 +1,11 @@
 This lib directory contains binaries required to run the common layer
-in JBoss container. Corresponding binaries (if present) in JBoss domain are
+in JBoss container. Corresponding binaries (if present) in JBoss cspace domain are
 either upgraded/replaced with a one-time execution task.
 
 For jpa upgrade in mercury 0.4, the task is 'ant jpa' executed at
-service/common level.
+service/common level. From 0.5 the following tasks are added.
+
+ant deploy_jpa (replaces jpa task, deploys jpa jars to JBoss cspace domain)
+ant dist_jpa (copies required jpa jars to dist)
+ant deploy_spring (deploys spring framework and spring security jars to JBoss cspace domain)
+ant dist_spring (copies required spring framework and security jars to dist)
diff --git a/services/common/lib/spring/org.springframework.aop-3.0.0.BUILD-20100208195804.jar b/services/common/lib/spring/org.springframework.aop-3.0.0.BUILD-20100208195804.jar
new file mode 100644 (file)
index 0000000..d7da1ca
Binary files /dev/null and b/services/common/lib/spring/org.springframework.aop-3.0.0.BUILD-20100208195804.jar differ
diff --git a/services/common/lib/spring/org.springframework.asm-3.0.0.BUILD-20100208195804.jar b/services/common/lib/spring/org.springframework.asm-3.0.0.BUILD-20100208195804.jar
new file mode 100644 (file)
index 0000000..1875d69
Binary files /dev/null and b/services/common/lib/spring/org.springframework.asm-3.0.0.BUILD-20100208195804.jar differ
diff --git a/services/common/lib/spring/org.springframework.beans-3.0.0.BUILD-20100208195804.jar b/services/common/lib/spring/org.springframework.beans-3.0.0.BUILD-20100208195804.jar
new file mode 100644 (file)
index 0000000..d260aff
Binary files /dev/null and b/services/common/lib/spring/org.springframework.beans-3.0.0.BUILD-20100208195804.jar differ
diff --git a/services/common/lib/spring/org.springframework.context-3.0.0.BUILD-20100208195804.jar b/services/common/lib/spring/org.springframework.context-3.0.0.BUILD-20100208195804.jar
new file mode 100644 (file)
index 0000000..eb86d8a
Binary files /dev/null and b/services/common/lib/spring/org.springframework.context-3.0.0.BUILD-20100208195804.jar differ
diff --git a/services/common/lib/spring/org.springframework.core-3.0.0.BUILD-20100208195804.jar b/services/common/lib/spring/org.springframework.core-3.0.0.BUILD-20100208195804.jar
new file mode 100644 (file)
index 0000000..9c32f0d
Binary files /dev/null and b/services/common/lib/spring/org.springframework.core-3.0.0.BUILD-20100208195804.jar differ
diff --git a/services/common/lib/spring/org.springframework.expression-3.0.0.BUILD-20100208195804.jar b/services/common/lib/spring/org.springframework.expression-3.0.0.BUILD-20100208195804.jar
new file mode 100644 (file)
index 0000000..091bca2
Binary files /dev/null and b/services/common/lib/spring/org.springframework.expression-3.0.0.BUILD-20100208195804.jar differ
diff --git a/services/common/lib/spring/org.springframework.jdbc-3.0.0.BUILD-20100208195804.jar b/services/common/lib/spring/org.springframework.jdbc-3.0.0.BUILD-20100208195804.jar
new file mode 100644 (file)
index 0000000..bf7b868
Binary files /dev/null and b/services/common/lib/spring/org.springframework.jdbc-3.0.0.BUILD-20100208195804.jar differ
diff --git a/services/common/lib/spring/org.springframework.web-3.0.0.BUILD-20100208195804.jar b/services/common/lib/spring/org.springframework.web-3.0.0.BUILD-20100208195804.jar
new file mode 100644 (file)
index 0000000..8e476b1
Binary files /dev/null and b/services/common/lib/spring/org.springframework.web-3.0.0.BUILD-20100208195804.jar differ
diff --git a/services/common/lib/spring/spring-security-acl-3.0.2.CI-SNAPSHOT.jar b/services/common/lib/spring/spring-security-acl-3.0.2.CI-SNAPSHOT.jar
new file mode 100644 (file)
index 0000000..1e03817
Binary files /dev/null and b/services/common/lib/spring/spring-security-acl-3.0.2.CI-SNAPSHOT.jar differ
diff --git a/services/common/lib/spring/spring-security-config-3.0.2.CI-SNAPSHOT.jar b/services/common/lib/spring/spring-security-config-3.0.2.CI-SNAPSHOT.jar
new file mode 100644 (file)
index 0000000..7f94595
Binary files /dev/null and b/services/common/lib/spring/spring-security-config-3.0.2.CI-SNAPSHOT.jar differ
diff --git a/services/common/lib/spring/spring-security-core-3.0.2.CI-SNAPSHOT.jar b/services/common/lib/spring/spring-security-core-3.0.2.CI-SNAPSHOT.jar
new file mode 100644 (file)
index 0000000..6367a82
Binary files /dev/null and b/services/common/lib/spring/spring-security-core-3.0.2.CI-SNAPSHOT.jar differ
diff --git a/services/common/lib/spring/spring-security-web-3.0.2.CI-SNAPSHOT.jar b/services/common/lib/spring/spring-security-web-3.0.2.CI-SNAPSHOT.jar
new file mode 100644 (file)
index 0000000..aede9eb
Binary files /dev/null and b/services/common/lib/spring/spring-security-web-3.0.2.CI-SNAPSHOT.jar differ