]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CSPACE-1050 merged authz prototype from sanjay's sandbox to trunk. requires the follo...
authorSanjay Dalal <sanjay.dalal@berkeley.edu>
Wed, 24 Mar 2010 23:46:37 +0000 (23:46 +0000)
committerSanjay Dalal <sanjay.dalal@berkeley.edu>
Wed, 24 Mar 2010 23:46:37 +0000 (23:46 +0000)
ant clean undeploy deploy at the trunk level
may require nuking org/collectionspace, org/jvnet, com/sun packages from local maven repository before building
ant create_db at the trunk level
test: mvn test at the trunk level

note: authorization is disabled at runtime as permissions database is not yet populated with permissions for the test user (role admin)

_M   trunk
A  + trunk/services/authentication/service/src/main/java/org/collectionspace/authentication/AuthN.java
A  + trunk/services/authentication/service/src/main/java/org/collectionspace/authentication/spring/SpringSecurityContextUtils.java
M    trunk/services/authentication/service/src/main/java/org/collectionspace/authentication/spring/CSpaceUserDetailsService.java
M    trunk/services/authentication/service/src/main/java/org/collectionspace/authentication/spring/CSpaceAuthorityGranter.java
M    trunk/services/authentication/service/src/main/java/org/collectionspace/authentication/CSpaceTenant.java
A  + trunk/services/authentication/service/src/main/java/org/collectionspace/authentication/SecurityContextUtils.java
_M   trunk/services/authentication/service/src/main/resources/config/web-security-config.xml
M    trunk/services/authentication/service/pom.xml
M    trunk/services/authentication/jaxb/src/test/resources/META-INF/persistence.xml
D    trunk/services/authentication/jaxb/src/test/resources/log4j.properties
M    trunk/services/authentication/jaxb/src/main/resources/authentication_identity_provider.xsd
M    trunk/services/authentication/pom.xml
M    trunk/services/authentication/pstore/src/test/resources/META-INF/persistence.xml
D    trunk/services/authentication/pstore/src/test/resources/log4j.properties
M    trunk/services/authentication/pstore/src/main/resources/db/mysql/authentication_index.sql
M    trunk/services/authentication/pstore/src/main/resources/db/mysql/test_authentication.sql
M    trunk/services/authentication/pstore/src/main/resources/db/mysql/authentication.sql
M    trunk/services/authentication/pstore/pom.xml
_M   trunk/services/collectionobject/service/src
_M   trunk/services/collectionobject/service/pom.xml
_M   trunk/services/collectionobject/jaxb/src/main/resources/collectionobjects_common.xsd
_M   trunk/services/JaxRsServiceProvider
M    trunk/services/JaxRsServiceProvider/nb-configuration.xml
MM   trunk/services/JaxRsServiceProvider/src/main/java/org/collectionspace/services/jaxrs/CollectionSpaceJaxRsApplication.java
M    trunk/services/JaxRsServiceProvider/src/main/resources/META-INF/persistence.xml
A  + trunk/services/JaxRsServiceProvider/src/main/resources/urls.properties
M    trunk/services/JaxRsServiceProvider/src/main/webapp/WEB-INF/web.xml
M    trunk/services/JaxRsServiceProvider/src/main/webapp/WEB-INF/applicationContext-security.xml
M    trunk/services/JaxRsServiceProvider/pom.xml
A  + trunk/services/common/lib/spring/aopalliance-1.0.jar
A  + trunk/services/common/lib/spring/org.springframework.transaction-3.0.0.RELEASE.jar
D    trunk/services/common/lib/spring/spring-security-core-3.0.1.RELEASE.jar
A  + trunk/services/common/lib/spring/spring-security-core-3.0.2.RELEASE.jar
D    trunk/services/common/lib/spring/spring-security-acl-3.0.1.RELEASE.jar
A  + trunk/services/common/lib/spring/spring-security-acl-3.0.2.RELEASE.jar
A  + trunk/services/common/lib/spring/ehcache-1.6.2.jar
A  + trunk/services/common/lib/spring/org.springframework.context.support-3.0.0.BUILD-20100208195804.jar
D    trunk/services/common/lib/spring/spring-security-config-3.0.1.RELEASE.jar
A  + trunk/services/common/lib/spring/spring-security-config-3.0.2.RELEASE.jar
D    trunk/services/common/lib/spring/spring-security-web-3.0.1.RELEASE.jar
A  + trunk/services/common/lib/spring/spring-security-web-3.0.2.RELEASE.jar
M    trunk/services/common/src/main/java/org/collectionspace/services/common/context/AbstractServiceContextImpl.java
A  + trunk/services/common/src/main/java/org/collectionspace/services/common/security/SecurityInterceptor.java
_M   trunk/services/common/src/main/java/org/collectionspace/services/common/document/DocumentUtils.java
_M   trunk/services/common/src/main/java/org/collectionspace/services/common/document/DocumentWrapper.java
_M   trunk/services/common/src/main/java/org/collectionspace/services/common/document/AbstractDocumentHandlerImpl.java
_M   trunk/services/common/src/main/java/org/collectionspace/services/common/document/DocumentFilter.java
_M   trunk/services/common/src/main/java/org/collectionspace/services/common/document/DocumentNotFoundException.java
_M   trunk/services/common/src/main/java/org/collectionspace/services/common/document/DocumentHandler.java
_M   trunk/services/common/src/main/java/org/collectionspace/services/common/document/DocumentException.java
_M   trunk/services/common/src/main/java/org/collectionspace/services/common/document/BadRequestException.java
M    trunk/services/common/src/main/config/log/jboss-log4j-release.xml
M    trunk/services/common/src/main/config/log/jboss-log4j.xml
_M   trunk/services/common/src/main/resources/service-config.xsd
M    trunk/services/common/pom.xml
M    trunk/services/common/build.xml
M    trunk/services/pom.xml
_M   trunk/services/id
_M   trunk/services/id/service/src/test/java/org/collectionspace/services/id/test/StringIDGeneratorPartTest.java
_M   trunk/services/id/service/src/test/java/org/collectionspace/services/id/test/AlphabeticIDGeneratorPartTest.java
_M   trunk/services/id/service/src/test/java/org/collectionspace/services/id/test/SettableIDGeneratorTest.java
_M   trunk/services/id/service/src/test/java/org/collectionspace/services/id/test/YearIDGeneratorPartTest.java
_M   trunk/services/id/service/src/test/java/org/collectionspace/services/id/test/NumericIDGeneratorPartTest.java
_M   trunk/services/id/service/src/test/java/org/collectionspace/services/id/test/BaseIDGeneratorTest.java
_M   trunk/services/id/service/src/main/java/org/collectionspace/services/id/AlphabeticIDGeneratorPart.java
_M   trunk/services/id/service/src/main/java/org/collectionspace/services/id/YearIDGeneratorPart.java
_M   trunk/services/id/service/src/main/java/org/collectionspace/services/id/NumericIDGeneratorPart.java
_M   trunk/services/id/service/src/main/java/org/collectionspace/services/id/StringIDGeneratorPart.java
_M   trunk/services/id/service/src/main/java/org/collectionspace/services/id/IDGeneratorPart.java
_M   trunk/services/id/service/src/main/java/org/collectionspace/services/id/BaseIDGenerator.java
M    trunk/services/account/service/src/main/java/org/collectionspace/services/account/AccountResource.java
M    trunk/services/account/service/pom.xml
M    trunk/services/build.xml
A  + trunk/services/authorization
AM + trunk/services/authorization/service
A  + trunk/services/authorization/service/src
A  + trunk/services/authorization/service/src/test
A  + trunk/services/authorization/service/src/test/java
A  + trunk/services/authorization/service/src/test/java/org
A  + trunk/services/authorization/service/src/test/java/org/collectionspace
A  + trunk/services/authorization/service/src/test/java/org/collectionspace/services
A  + trunk/services/authorization/service/src/test/java/org/collectionspace/services/authorization
A  + trunk/services/authorization/service/src/test/java/org/collectionspace/services/authorization/test
A  + trunk/services/authorization/service/src/test/java/org/collectionspace/services/authorization/test/AuthorizationSeedTest.java
A  + trunk/services/authorization/service/src/test/resources
A  + trunk/services/authorization/service/src/test/resources/applicationContext-authorization-test.xml
A  + trunk/services/authorization/service/src/test/resources/test-data
A  + trunk/services/authorization/service/src/test/resources/test-data/test-permissions.xml
A  + trunk/services/authorization/service/src/test/resources/log4j.properties
A  + trunk/services/authorization/service/src/main
A  + trunk/services/authorization/service/src/main/java
A  + trunk/services/authorization/service/src/main/java/org
A  + trunk/services/authorization/service/src/main/java/org/collectionspace
A  + trunk/services/authorization/service/src/main/java/org/collectionspace/services
A  + trunk/services/authorization/service/src/main/java/org/collectionspace/services/authorization
A  + trunk/services/authorization/service/src/main/java/org/collectionspace/services/authorization/spring
A  + trunk/services/authorization/service/src/main/java/org/collectionspace/services/authorization/spring/SpringPermissionManager.java
A  + trunk/services/authorization/service/src/main/java/org/collectionspace/services/authorization/spring/CSpaceSecurityMetadataSource.java
A  + trunk/services/authorization/service/src/main/java/org/collectionspace/services/authorization/spring/SpringAuthorizationProvider.java
A  + trunk/services/authorization/service/src/main/java/org/collectionspace/services/authorization/spring/SpringPermissionEvaluator.java
A  + trunk/services/authorization/service/src/main/java/org/collectionspace/services/authorization/CSpaceResource.java
A  + trunk/services/authorization/service/src/main/java/org/collectionspace/services/authorization/CSpaceResourceImpl.java
A  + trunk/services/authorization/service/src/main/java/org/collectionspace/services/authorization/URIResourceImpl.java
A  + trunk/services/authorization/service/src/main/java/org/collectionspace/services/authorization/AuthZ.java
A  + trunk/services/authorization/service/src/main/java/org/collectionspace/services/authorization/spi
A  + trunk/services/authorization/service/src/main/java/org/collectionspace/services/authorization/spi/CSpacePermissionManager.java
A  + trunk/services/authorization/service/src/main/java/org/collectionspace/services/authorization/spi/CSpaceAuthorizationProvider.java
A  + trunk/services/authorization/service/src/main/java/org/collectionspace/services/authorization/spi/CSpacePermissionEvaluator.java
A  + trunk/services/authorization/service/src/main/java/org/collectionspace/services/authorization/CSpaceAction.java
A  + trunk/services/authorization/service/src/main/resources
A  + trunk/services/authorization/service/src/main/resources/applicationContext-authorization.xml
A  + trunk/services/authorization/service/pom.xml
A  + trunk/services/authorization/service/build.xml
AM + trunk/services/authorization/jaxb
A  + trunk/services/authorization/jaxb/.classpath
A  + trunk/services/authorization/jaxb/.project
A  + trunk/services/authorization/jaxb/src
A  + trunk/services/authorization/jaxb/src/test
A  + trunk/services/authorization/jaxb/src/test/resources
A  + trunk/services/authorization/jaxb/src/test/resources/META-INF
A  + trunk/services/authorization/jaxb/src/test/resources/META-INF/persistence.xml
A  + trunk/services/authorization/jaxb/src/test/resources/log4j.properties
A  + trunk/services/authorization/jaxb/src/test/resources/hibernate.cfg.xml
A  + trunk/services/authorization/jaxb/src/main
A  + trunk/services/authorization/jaxb/src/main/resources
A  + trunk/services/authorization/jaxb/src/main/resources/authorization_provider.xsd
A  + trunk/services/authorization/jaxb/pom.xml
A  + trunk/services/authorization/jaxb/.settings
A  + trunk/services/authorization/jaxb/.settings/org.eclipse.jdt.core.prefs
A  + trunk/services/authorization/jaxb/.settings/org.maven.ide.eclipse.prefs
A  + trunk/services/authorization/pom.xml
AM + trunk/services/authorization/pstore
A  + trunk/services/authorization/pstore/.classpath
A  + trunk/services/authorization/pstore/.project
A  + trunk/services/authorization/pstore/src
A  + trunk/services/authorization/pstore/src/test
A  + trunk/services/authorization/pstore/src/test/resources
A  + trunk/services/authorization/pstore/src/test/resources/META-INF
A  + trunk/services/authorization/pstore/src/test/resources/META-INF/persistence.xml
A  + trunk/services/authorization/pstore/src/test/resources/hibernate.cfg.xml
A  + trunk/services/authorization/pstore/src/main
A  + trunk/services/authorization/pstore/src/main/resources
A  + trunk/services/authorization/pstore/src/main/resources/db
A  + trunk/services/authorization/pstore/src/main/resources/db/mysql
A  + trunk/services/authorization/pstore/src/main/resources/db/mysql/authorization_index.sql
A  + trunk/services/authorization/pstore/src/main/resources/db/mysql/acl.sql
A  + trunk/services/authorization/pstore/src/main/resources/db/mysql/test_authorization.sql
A  + trunk/services/authorization/pstore/src/main/resources/db/mysql/authorization.sql
A  + trunk/services/authorization/pstore/pom.xml
A  + trunk/services/authorization/pstore/build.xml
A  + trunk/services/authorization/build.xml
M    trunk/services/client/src/test/java/org/collectionspace/services/client/test/ServiceLayerTest.java
_M   trunk/services/client/src/main/java/org/collectionspace/services/client/test/ServiceTest.java
_M   trunk/services/client/src/main/java/org/collectionspace/services/client/AbstractServiceClientImpl.java
_M   trunk/services/client/src/main/java/org/collectionspace/services/client/CollectionSpaceClient.java
_M   trunk/src/site
_M   trunk/docs/allteam-061409-toronto
_M   trunk/docs/allteam-061409-toronto/Toronto_BehindTheScenes.pptx
_M   trunk/HelloWorld
_M   trunk/HelloWorld/HelloWorldJaxb/src/main/resources/hello.xsd
_M   trunk/HelloWorld/HelloWorldNuxeoService
_M   trunk/HelloWorld/HelloWorldNuxeoService/src/main/java/org/collectionspace/hello/services/HelloworldNuxeoApplication.java

81 files changed:
services/JaxRsServiceProvider/nb-configuration.xml
services/JaxRsServiceProvider/pom.xml
services/JaxRsServiceProvider/src/main/java/org/collectionspace/services/jaxrs/CollectionSpaceJaxRsApplication.java
services/JaxRsServiceProvider/src/main/resources/META-INF/persistence.xml
services/JaxRsServiceProvider/src/main/resources/urls.properties [new file with mode: 0644]
services/JaxRsServiceProvider/src/main/webapp/WEB-INF/applicationContext-security.xml
services/JaxRsServiceProvider/src/main/webapp/WEB-INF/web.xml
services/account/service/pom.xml
services/account/service/src/main/java/org/collectionspace/services/account/AccountResource.java
services/authentication/jaxb/src/main/resources/authentication_identity_provider.xsd
services/authentication/jaxb/src/test/resources/META-INF/persistence.xml
services/authentication/pom.xml
services/authentication/pstore/pom.xml
services/authentication/pstore/src/main/resources/db/mysql/authentication.sql
services/authentication/pstore/src/main/resources/db/mysql/authentication_index.sql
services/authentication/pstore/src/main/resources/db/mysql/test_authentication.sql
services/authentication/pstore/src/test/resources/META-INF/persistence.xml
services/authentication/service/pom.xml
services/authentication/service/src/main/java/org/collectionspace/authentication/AuthN.java [new file with mode: 0644]
services/authentication/service/src/main/java/org/collectionspace/authentication/CSpaceTenant.java
services/authentication/service/src/main/java/org/collectionspace/authentication/SecurityContextUtils.java [new file with mode: 0644]
services/authentication/service/src/main/java/org/collectionspace/authentication/spring/CSpaceAuthorityGranter.java
services/authentication/service/src/main/java/org/collectionspace/authentication/spring/CSpaceUserDetailsService.java
services/authentication/service/src/main/java/org/collectionspace/authentication/spring/SpringSecurityContextUtils.java [new file with mode: 0644]
services/authorization/build.xml [new file with mode: 0644]
services/authorization/jaxb/.classpath [new file with mode: 0644]
services/authorization/jaxb/.project [new file with mode: 0644]
services/authorization/jaxb/.settings/org.eclipse.jdt.core.prefs [new file with mode: 0644]
services/authorization/jaxb/.settings/org.maven.ide.eclipse.prefs [new file with mode: 0644]
services/authorization/jaxb/pom.xml [new file with mode: 0644]
services/authorization/jaxb/src/main/resources/authorization_provider.xsd [new file with mode: 0644]
services/authorization/jaxb/src/test/resources/META-INF/persistence.xml [new file with mode: 0644]
services/authorization/jaxb/src/test/resources/hibernate.cfg.xml [new file with mode: 0644]
services/authorization/jaxb/src/test/resources/log4j.properties [moved from services/authentication/jaxb/src/test/resources/log4j.properties with 100% similarity]
services/authorization/pom.xml [new file with mode: 0644]
services/authorization/pstore/.classpath [new file with mode: 0644]
services/authorization/pstore/.project [new file with mode: 0644]
services/authorization/pstore/build.xml [new file with mode: 0644]
services/authorization/pstore/pom.xml [new file with mode: 0644]
services/authorization/pstore/src/main/resources/db/mysql/acl.sql [new file with mode: 0644]
services/authorization/pstore/src/main/resources/db/mysql/authorization.sql [new file with mode: 0644]
services/authorization/pstore/src/main/resources/db/mysql/authorization_index.sql [new file with mode: 0644]
services/authorization/pstore/src/main/resources/db/mysql/test_authorization.sql [new file with mode: 0644]
services/authorization/pstore/src/test/resources/META-INF/persistence.xml [new file with mode: 0644]
services/authorization/pstore/src/test/resources/hibernate.cfg.xml [new file with mode: 0644]
services/authorization/service/build.xml [new file with mode: 0644]
services/authorization/service/pom.xml [new file with mode: 0644]
services/authorization/service/src/main/java/org/collectionspace/services/authorization/AuthZ.java [new file with mode: 0644]
services/authorization/service/src/main/java/org/collectionspace/services/authorization/CSpaceAction.java [new file with mode: 0644]
services/authorization/service/src/main/java/org/collectionspace/services/authorization/CSpaceResource.java [new file with mode: 0644]
services/authorization/service/src/main/java/org/collectionspace/services/authorization/CSpaceResourceImpl.java [new file with mode: 0644]
services/authorization/service/src/main/java/org/collectionspace/services/authorization/URIResourceImpl.java [new file with mode: 0644]
services/authorization/service/src/main/java/org/collectionspace/services/authorization/spi/CSpaceAuthorizationProvider.java [new file with mode: 0644]
services/authorization/service/src/main/java/org/collectionspace/services/authorization/spi/CSpacePermissionEvaluator.java [new file with mode: 0644]
services/authorization/service/src/main/java/org/collectionspace/services/authorization/spi/CSpacePermissionManager.java [new file with mode: 0644]
services/authorization/service/src/main/java/org/collectionspace/services/authorization/spring/CSpaceSecurityMetadataSource.java [new file with mode: 0644]
services/authorization/service/src/main/java/org/collectionspace/services/authorization/spring/SpringAuthorizationProvider.java [new file with mode: 0644]
services/authorization/service/src/main/java/org/collectionspace/services/authorization/spring/SpringPermissionEvaluator.java [new file with mode: 0644]
services/authorization/service/src/main/java/org/collectionspace/services/authorization/spring/SpringPermissionManager.java [new file with mode: 0644]
services/authorization/service/src/main/resources/applicationContext-authorization.xml [new file with mode: 0644]
services/authorization/service/src/test/java/org/collectionspace/services/authorization/test/AuthorizationSeedTest.java [new file with mode: 0644]
services/authorization/service/src/test/resources/applicationContext-authorization-test.xml [new file with mode: 0644]
services/authorization/service/src/test/resources/log4j.properties [moved from services/authentication/pstore/src/test/resources/log4j.properties with 92% similarity]
services/authorization/service/src/test/resources/test-data/test-permissions.xml [new file with mode: 0644]
services/build.xml
services/client/src/test/java/org/collectionspace/services/client/test/ServiceLayerTest.java
services/common/build.xml
services/common/lib/spring/aopalliance-1.0.jar [new file with mode: 0644]
services/common/lib/spring/ehcache-1.6.2.jar [new file with mode: 0644]
services/common/lib/spring/org.springframework.context.support-3.0.0.BUILD-20100208195804.jar [new file with mode: 0644]
services/common/lib/spring/org.springframework.transaction-3.0.0.RELEASE.jar [new file with mode: 0644]
services/common/lib/spring/spring-security-acl-3.0.2.RELEASE.jar [moved from services/common/lib/spring/spring-security-acl-3.0.1.RELEASE.jar with 80% similarity]
services/common/lib/spring/spring-security-config-3.0.2.RELEASE.jar [moved from services/common/lib/spring/spring-security-config-3.0.1.RELEASE.jar with 78% similarity]
services/common/lib/spring/spring-security-core-3.0.2.RELEASE.jar [moved from services/common/lib/spring/spring-security-core-3.0.1.RELEASE.jar with 77% similarity]
services/common/lib/spring/spring-security-web-3.0.2.RELEASE.jar [moved from services/common/lib/spring/spring-security-web-3.0.1.RELEASE.jar with 67% similarity]
services/common/pom.xml
services/common/src/main/config/log/jboss-log4j-release.xml
services/common/src/main/config/log/jboss-log4j.xml
services/common/src/main/java/org/collectionspace/services/common/context/AbstractServiceContextImpl.java
services/common/src/main/java/org/collectionspace/services/common/security/SecurityInterceptor.java [new file with mode: 0644]
services/pom.xml

index 3e5cd988f234c1ff20f9265f65b4ce6007056419..bcf0a33c91561798ce71cb6e92a62993bfe5878d 100644 (file)
@@ -1,21 +1,20 @@
-<?xml version="1.0" encoding="UTF-8"?>\r
-<project-shared-configuration>\r
+<?xml version="1.0" encoding="UTF-8"?>
+<project-shared-configuration>
     <!--
 This file contains additional configuration written by modules in the NetBeans IDE.
 The configuration is intended to be shared among all the users of project and
 therefore it is assumed to be part of version control checkout.
 Without this configuration present, some functionality in the IDE may be limited or fail altogether.
--->\r
-    <properties xmlns="http://www.netbeans.org/ns/maven-properties-data/1">\r
+-->
+    <properties xmlns="http://www.netbeans.org/ns/maven-properties-data/1">
         <!--
 Properties that influence various parts of the IDE, especially code formatting and the like. 
 You can copy and paste the single properties, into the pom.xml file and the IDE will pick them up.
 That way multiple projects can share the same settings (useful for formatting rules for example).
 Any value defined here will override the pom.xml file value but is only applicable to the current project.
--->\r
-        <org-netbeans-modules-editor-indent.CodeStyle.usedProfile>default</org-netbeans-modules-editor-indent.CodeStyle.usedProfile>\r
-        <org-netbeans-modules-editor-indent.CodeStyle.project.tab-size>8</org-netbeans-modules-editor-indent.CodeStyle.project.tab-size>\r
-        <org-netbeans-modules-editor-indent.CodeStyle.project.text-limit-width>80</org-netbeans-modules-editor-indent.CodeStyle.project.text-limit-width>\r
-        <netbeans.hint.useExternalMaven>false</netbeans.hint.useExternalMaven>\r
-    </properties>\r
-</project-shared-configuration>\r
+-->
+        <org-netbeans-modules-editor-indent.CodeStyle.usedProfile>default</org-netbeans-modules-editor-indent.CodeStyle.usedProfile>
+        <org-netbeans-modules-editor-indent.CodeStyle.project.tab-size>8</org-netbeans-modules-editor-indent.CodeStyle.project.tab-size>
+        <org-netbeans-modules-editor-indent.CodeStyle.project.text-limit-width>80</org-netbeans-modules-editor-indent.CodeStyle.project.text-limit-width>
+    </properties>
+</project-shared-configuration>
index 1a8e115ca549d77241e9d32c9babb962b997c354..0225c15cb0a59648023fe7b805d9c384f54884f8 100644 (file)
@@ -16,7 +16,7 @@
     <properties>\r
         <cs.release>0.5</cs.release>\r
         <spring.version>3.0.0.RELEASE</spring.version>\r
-        <spring.security.version>3.0.1.RELEASE</spring.security.version>\r
+        <spring.security.version>3.0.2.RELEASE</spring.security.version>\r
     </properties>\r
     \r
     <dependencies>\r
             <groupId>org.slf4j</groupId>\r
             <artifactId>slf4j-log4j12</artifactId>\r
         </dependency>\r
+        <!-- somewhere dependency is added 1.5.8 unnecessarily -->\r
+        <dependency>\r
+            <groupId>org.slf4j</groupId>\r
+            <artifactId>slf4j-simple</artifactId>\r
+            <version>1.5.8</version>\r
+            <scope>test</scope>\r
+        </dependency>\r
+        <dependency>\r
+            <groupId>org.slf4j</groupId>\r
+            <artifactId>jcl-over-slf4j</artifactId>\r
+            <version>1.5.8</version>\r
+            <scope>test</scope>\r
+        </dependency>\r
+\r
         <dependency>\r
             <groupId>log4j</groupId>\r
             <artifactId>log4j</artifactId>\r
             <scope>provided</scope>\r
         </dependency>\r
 <!-- CollectionSpace dependencies -->\r
+        <dependency>\r
+            <groupId>org.collectionspace.services</groupId>\r
+            <artifactId>org.collectionspace.services.authorization.service</artifactId>\r
+            <version>${project.version}</version>\r
+            <scope>provided</scope>\r
+        </dependency>\r
         <dependency>\r
             <groupId>org.collectionspace.services</groupId>\r
             <artifactId>org.collectionspace.services.common</artifactId>\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
+            <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-context</artifactId>\r
+            <artifactId>spring-context-support</artifactId>\r
             <version>${spring.version}</version>\r
             <scope>provided</scope>\r
         </dependency>\r
             <version>${spring.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-webmvc</artifactId>\r
+            <artifactId>spring-aop</artifactId>\r
             <version>${spring.version}</version>\r
             <scope>provided</scope>\r
         </dependency>\r
+        <dependency>\r
+            <groupId>aopalliance</groupId>\r
+            <artifactId>aopalliance</artifactId>\r
+            <version>1.0</version>\r
+            <scope>provided</scope>\r
+        </dependency>\r
         <dependency>\r
             <groupId>org.springframework</groupId>\r
-            <artifactId>spring-aop</artifactId>\r
+            <artifactId>spring-tx</artifactId>\r
             <version>${spring.version}</version>\r
             <scope>provided</scope>\r
         </dependency>\r
+        <dependency>\r
+            <groupId>net.sf.ehcache</groupId>\r
+            <artifactId>ehcache</artifactId>\r
+            <version>1.6.2</version>\r
+            <optional>true</optional>\r
+        </dependency-->\r
+\r
         <!-- javax -->\r
 \r
         <!-- jboss -->\r
index 0e6aefe926895cea7c1db58fbdbc6c5952bdded6..ba0591be5e065b476632d42109d0ea94b51487bd 100644 (file)
@@ -41,6 +41,7 @@ import org.collectionspace.services.person.PersonAuthorityResource;
 import javax.ws.rs.core.Application;
 import java.util.HashSet;
 import java.util.Set;
+import org.collectionspace.services.common.security.SecurityInterceptor;
 
 /**
  * CollectionSpaceJaxRsApplication, the root application
@@ -57,6 +58,7 @@ public class CollectionSpaceJaxRsApplication extends Application {
     private Set<Class<?>> empty = new HashSet<Class<?>>();
 
     public CollectionSpaceJaxRsApplication() {
+        singletons.add(new SecurityInterceptor());
         singletons.add(new AccountResource());
         singletons.add(new CollectionObjectResource());
         singletons.add(new IDResource());
index 7aa4f4b04bd7b15f77f5eb7c3fc8af984f1fad70..5cc85d50d746e59bc808ce31e032a5b53609775a 100644 (file)
@@ -10,8 +10,8 @@
         <class>org.collectionspace.services.account.AccountTenant</class>
         <class>org.collectionspace.services.account.Status</class>
         <class>org.collectionspace.services.authentication.User</class>
-        <class>org.collectionspace.services.authentication.Role</class>
-        <class>org.collectionspace.services.authentication.UserRole</class>
+        <class>org.collectionspace.services.authorization.Role</class>
+        <class>org.collectionspace.services.authorization.UserRole</class>
 
         <properties>
             <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
diff --git a/services/JaxRsServiceProvider/src/main/resources/urls.properties b/services/JaxRsServiceProvider/src/main/resources/urls.properties
new file mode 100644 (file)
index 0000000..c2353ae
--- /dev/null
@@ -0,0 +1,3 @@
+# To change this template, choose Tools | Templates
+# and open the template in the editor.
+/accounts/**=ROLE_ADMINISTRATOR
\ No newline at end of file
index 71be7d13c3b90181af98f537da07f3a2f274e29a..45d75fbd09bc09e32146de2bcd75b9cee4eb854d 100644 (file)
@@ -7,20 +7,64 @@
         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"
+       xmlns:sec="http://www.springframework.org/schema/security"
+       xmlns:util="http://www.springframework.org/schema/util"
        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" realm="org.collectionspace.services">
-        <s:intercept-url pattern="/**" access="permitAll" />
-        <s:http-basic />
-        <s:logout />
-        <s:anonymous enabled="false"/>
-    </s:http>
-
-    <s:authentication-manager>
-        <s:authentication-provider ref="jaasAuthenticationProvider" user-service-ref="userDetailsService"/>
-    </s:authentication-manager>
+       http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security.xsd
+       http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">
+
+    <!--sec:http use-expressions="true" realm="org.collectionspace.services">
+        <sec:http-basic />
+        <sec:logout />
+        <sec:anonymous enabled="false"/>
+    </sec:http-->
+
+    <sec:global-method-security >
+        <sec:expression-handler ref="expressionHandler"/>
+    </sec:global-method-security>
+
+
+    <bean id="springSecurityFilterChain" class="org.springframework.security.web.FilterChainProxy">
+        <sec:filter-chain-map path-type="ant">
+            <sec:filter-chain pattern="/**"
+                              filters="securityPersistenceFilter,basicAuthenticationFilter,logoutFilter,exTranslationFilter,filterInvocationInterceptor"/>
+        </sec:filter-chain-map>
+    </bean>
+
+    <bean id="securityPersistenceFilter" class="org.springframework.security.web.context.SecurityContextPersistenceFilter"/>
+
+    <bean id="basicAuthenticationFilter"
+          class="org.springframework.security.web.authentication.www.BasicAuthenticationFilter">
+        <property name="authenticationManager" ref="authenticationManager"/>
+        <property name="authenticationEntryPoint" ref="basicAuthenticationEntryPoint"/>
+    </bean>
+
+    <bean id="basicAuthenticationEntryPoint"
+          class="org.springframework.security.web.authentication.www.BasicAuthenticationEntryPoint">
+        <property name="realmName" value="org.collectionspace.services"/>
+    </bean>
+
+    <bean id="logoutFilter" class="org.springframework.security.web.authentication.logout.LogoutFilter">
+        <constructor-arg value="/"/>
+        <constructor-arg>
+            <list>
+                <bean class="org.springframework.security.web.authentication.logout.SecurityContextLogoutHandler"/>
+            </list>
+        </constructor-arg>
+    </bean>
+
+    <bean id="exTranslationFilter" class="org.springframework.security.web.access.ExceptionTranslationFilter">
+        <property name="authenticationEntryPoint" ref="preAuthenticatedProcessingFilterEntryPoint"/>
+    </bean>
+
+    <bean id="preAuthenticatedProcessingFilterEntryPoint"
+          class="org.springframework.security.web.authentication.Http403ForbiddenEntryPoint"/>
+
+
+    <sec:authentication-manager alias="authenticationManager">
+        <sec:authentication-provider ref="jaasAuthenticationProvider" user-service-ref="userDetailsService"/>
+    </sec:authentication-manager>
 
     <bean id="jaasAuthenticationProvider"
           class="org.springframework.security.authentication.jaas.JaasAuthenticationProvider">
 
     <bean id="userDetailsService" class="org.collectionspace.authentication.spring.CSpaceUserDetailsService">
     </bean>
+
+    <bean id="filterInvocationInterceptor" class="org.springframework.security.web.access.intercept.FilterSecurityInterceptor">
+        <property name="authenticationManager" ref="authenticationManager"/>
+        <property name="accessDecisionManager" ref="httpRequestAccessDecisionManager"/>
+        <!--property name="securityMetadataSource" ref="cspaceMetadataSource"/-->
+        <property name="securityMetadataSource">
+            <sec:filter-security-metadata-source>
+                <sec:intercept-url pattern="/**" access="ROLE_USERS"/>
+            </sec:filter-security-metadata-source>
+        </property>
+    </bean>
+
+    <bean id="httpRequestAccessDecisionManager" class="org.springframework.security.access.vote.AffirmativeBased">
+        <property name="allowIfAllAbstainDecisions" value="false"/>
+        <property name="decisionVoters">
+            <list>
+                <ref bean="roleVoter"/>
+            </list>
+        </property>
+    </bean>
+
+    <bean id="roleVoter" class="org.springframework.security.access.vote.RoleVoter"/>
+
+    <!--bean id="cspaceMetadataSource" class="org.collectionspace.services.authorization.spring.CSpaceSecurityMetadataSource">
+        <property name="urlProperties">
+            <util:properties location="classpath:urls.properties" />
+        </property>
+    </bean-->
+
 </beans>
index 65512963bee7c49c331e5454d47ea1bbaafd85cc..3ed461b9a5cfa3bc86e8da7ed457c94e617c6ce4 100644 (file)
         <url-pattern>/*</url-pattern>
     </servlet-mapping>
 
-    <!-- BEGIN-AUTH uncomment the following
-    <security-constraint>
-        <web-resource-collection>
-            <web-resource-name>CollectionSpace Services</web-resource-name>
-            <url-pattern>/*</url-pattern>
-        </web-resource-collection>
-        <auth-constraint>
-            <role-name>*</role-name>
-        </auth-constraint>
-
-        <user-data-constraint>
-            <transport-guarantee>NONE</transport-guarantee>
-        </user-data-constraint>
-    </security-constraint>
-
-    <login-config>
-        <auth-method>BASIC</auth-method>
-        <realm-name>CollectionSpace realm</realm-name>
-    </login-config>
- END AUTH -->
-    <!--resource-ref>
-        <description>DB Connection</description>
-        <res-ref-name>jdbc/cspaceds</res-ref-name>
-        <res-type>javax.sql.DataSource</res-type>
-        <res-auth>Container</res-auth>
-    </resource-ref-->
 </web-app>
index 7fb025b62175dd0c1d9b3dea9a307577bcdd05d7..d5d52de3c12892e5b7c8494836e4aceb5c015755 100644 (file)
@@ -12,6 +12,9 @@
     <name>services.account.service</name>\r
     <packaging>jar</packaging>\r
 \r
+    <properties>\r
+        <spring.security.version>3.0.2.RELEASE</spring.security.version>\r
+    </properties>\r
     <dependencies>\r
         <dependency>\r
             <groupId>org.slf4j</groupId>\r
             <artifactId>org.collectionspace.services.authentication.jaxb</artifactId>\r
             <version>${project.version}</version>\r
         </dependency>\r
+        <dependency>\r
+            <groupId>org.collectionspace.services</groupId>\r
+            <artifactId>org.collectionspace.services.authorization.jaxb</artifactId>\r
+            <version>${project.version}</version>\r
+        </dependency>\r
         <dependency>\r
             <groupId>org.collectionspace.services</groupId>\r
             <artifactId>org.collectionspace.services.account.jaxb</artifactId>\r
             <version>1.1.GA</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
 \r
     </dependencies>\r
 \r
index 3c55b483a52b7cb92e9f0d68735b1fce76fce284..801cded51a422b2f8b4f2506dce68d436e075fed 100644 (file)
@@ -51,6 +51,7 @@ import org.collectionspace.services.common.storage.StorageClient;
 import org.jboss.resteasy.util.HttpResponseCodes;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.security.access.prepost.PreAuthorize;
 
 @Path("/accounts")
 @Consumes("application/xml")
@@ -96,6 +97,7 @@ public class AccountResource
     }
 
     @POST
+    @PreAuthorize("hasPermission('account', 'account', 'create')")
     public Response createAccount(AccountsCommon input) {
         try {
             ServiceContext ctx = createServiceContext(input);
@@ -184,7 +186,7 @@ public class AccountResource
             MultivaluedMap<String, String> queryParams = ui.getQueryParameters();
             DocumentFilter myFilter = handler.createDocumentFilter();
             myFilter.setPagination(queryParams);
-            myFilter.setQueryParams(queryParams);           
+            myFilter.setQueryParams(queryParams);
             handler.setDocumentFilter(myFilter);
             getStorageClient(ctx).getFiltered(ctx, handler);
             accountList = (AccountsCommonList) handler.getCommonPartList();
index 8b668b8f70e9af82c061e59f5c28cedee2ef4912..4743a4c39dfb8d5e7724b3e3c46f400e725485fd 100644 (file)
@@ -3,7 +3,7 @@
 <!--
     CollectionSpace default (security) identity provider schema (XSD)
 
-    Entity(s)  : users, roles, users_roles
+    Entity(s)  : users
     Used for:
 
     $LastChangedRevision: 916 $
         </xs:complexType>
     </xs:element>
 
-    <xs:element name="role">
-        <xs:complexType>
-            <xs:annotation>
-                <xs:appinfo>
-                    <hj:entity>
-                        <orm:table name="roles"/>
-                    </hj:entity>
-                </xs:appinfo>
-            </xs:annotation>
-            <xs:sequence>
-                <xs:element name="rolename" type="xs:string" minOccurs="1" maxOccurs="1">
-                    <xs:annotation>
-                        <xs:appinfo>
-                            <hj:id>
-                                <orm:column name="rolename" length="200" nullable="false"/>
-                            </hj:id>
-                        </xs:appinfo>
-                    </xs:annotation>
-                </xs:element>
-                <xs:element name="rolegroup" type="xs:string" minOccurs="1" maxOccurs="1">
-                    <xs:annotation>
-                        <xs:appinfo>
-                            <hj:basic>
-                                <orm:column name="rolegroup" nullable="false"/>
-                            </hj:basic>
-                        </xs:appinfo>
-                    </xs:annotation>
-                </xs:element>
-                <xs:element name="createdAt" type="xs:dateTime">
-                    <xs:annotation>
-                        <xs:appinfo>
-                            <hj:basic>
-                                <orm:column name="created_at" nullable="false"/>
-                            </hj:basic>
-                        </xs:appinfo>
-                    </xs:annotation>
-                </xs:element>
-                <xs:element name="updatedAt" type="xs:dateTime">
-                    <xs:annotation>
-                        <xs:appinfo>
-                            <hj:basic>
-                                <orm:column name="updated_at" />
-                            </hj:basic>
-                        </xs:appinfo>
-                    </xs:annotation>
-                </xs:element>
-            </xs:sequence>
-        </xs:complexType>
-    </xs:element>
-
-    <xs:element name="user_role">
-        <xs:complexType>
-            <xs:annotation>
-                <xs:appinfo>
-                    <hj:entity>
-                        <orm:table name="users_roles">
-                            <orm:unique-constraint>
-                                <!-- combined length should be < 1000 bytes -->
-                                <orm:column-name>username</orm:column-name>
-                                <orm:column-name>rolename</orm:column-name>
-                            </orm:unique-constraint>
-                        </orm:table>
-                    </hj:entity>
-                </xs:appinfo>
-            </xs:annotation>
-            <xs:sequence>
-                <xs:element name="username" type="xs:string" minOccurs="1" maxOccurs="1">
-                    <xs:annotation>
-                        <xs:appinfo>
-                            <hj:basic>
-                                <orm:column name="username" length="128" nullable="false"/>
-                            </hj:basic>
-                        </xs:appinfo>
-                    </xs:annotation>
-                </xs:element>
-                <xs:element name="rolename" type="xs:string" minOccurs="1" maxOccurs="1">
-                    <xs:annotation>
-                        <xs:appinfo>
-                            <hj:basic>
-                                <orm:column name="rolename" length="200" nullable="false"/>
-                            </hj:basic>
-                        </xs:appinfo>
-                    </xs:annotation>
-                </xs:element>
-                <xs:element name="createdAt" type="xs:dateTime">
-                    <xs:annotation>
-                        <xs:appinfo>
-                            <hj:basic>
-                                <orm:column name="created_at" nullable="false"/>
-                            </hj:basic>
-                        </xs:appinfo>
-                    </xs:annotation>
-                </xs:element>
-                <xs:element name="updatedAt" type="xs:dateTime">
-                    <xs:annotation>
-                        <xs:appinfo>
-                            <hj:basic>
-                                <orm:column name="updated_at" />
-                            </hj:basic>
-                        </xs:appinfo>
-                    </xs:annotation>
-                </xs:element>
-            </xs:sequence>
-        </xs:complexType>
-    </xs:element>
 </xs:schema>
 
index a2eeadba1ed2f180b485aafbfd644607c28ef8b2..c46723c6bf5dd03b2cc6e5b30005f9b80bbee6ee 100644 (file)
@@ -3,8 +3,6 @@
 http://java.sun.com/xml/ns/persistence/orm http://java.sun.com/xml/ns/persistence/orm_1_0.xsd" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:orm="http://java.sun.com/xml/ns/persistence/orm" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
     <persistence-unit name="org.collectionspace.services.authentication">
     <class>org.collectionspace.services.authentication.User</class>
-    <class>org.collectionspace.services.authentication.Role</class>
-    <class>org.collectionspace.services.authentication.UserRole</class>
         <properties>
             <property name="hibernate.ejb.cfgfile" value="hibernate.cfg.xml"/>
 
index 8a68881dcd009ad4af020d066bb428883620e2e4..5937c8fb784ad4df059ca8157d9301b4c995f813 100644 (file)
@@ -11,7 +11,7 @@
     <artifactId>org.collectionspace.services.authentication</artifactId>\r
     <name>services.authentication</name>\r
     <packaging>pom</packaging>\r
-\r
+    <url>http://www.collectionspace.org</url>\r
     <properties>\r
     </properties>\r
 \r
index 5a3d258f2c1311cb0c1141cd69e71337f56adf4f..2453e99005e5f8e253e2c99408cd3e681c08e24f 100644 (file)
@@ -50,7 +50,7 @@
     </dependencies>\r
 \r
     <build>\r
-        <finalName>cspace-services-authentication-client</finalName>\r
+        <finalName>cspace-services-authentication-pstore</finalName>\r
         <plugins>\r
             <plugin>\r
                 <artifactId>maven-antrun-plugin</artifactId>\r
index 2062f9b84dd9a2ad50cbb2b46f786c55ce1e1249..558f1f36e077eddadce2b9e19b6a69213aa2cc75 100644 (file)
@@ -1,6 +1,2 @@
-drop table if exists roles;
 drop table if exists users;
-drop table if exists users_roles;
-create table roles (rolename varchar(200) not null, created_at datetime not null, rolegroup varchar(255) not null, updated_at datetime, primary key (rolename));
 create table users (username varchar(128) not null, created_at datetime not null, passwd varchar(128) not null, updated_at datetime, primary key (username));
-create table users_roles (HJID bigint not null auto_increment, created_at datetime not null, rolename varchar(200) not null, updated_at datetime, username varchar(128) not null, primary key (HJID), unique (username, rolename));
index 4f93e32250768f4a0cdf20e3a39f582c6eb720ed..be7089011b8b7ab135f086a5feb03b9793cdb80e 100644 (file)
@@ -4,6 +4,5 @@
 -- You may not use this file except in compliance with this License.
 --
 use cspace;
-CREATE INDEX index_rolename ON roles (rolegroup);
-CREATE INDEX index_username ON users_roles (username);
-CREATE INDEX index_rolename ON users_roles (rolename);
+
+
index 441a0a4123b32ecd462b58fee06133db13b5ba3a..1a3979bdcdfc6fab8477b6b2e6ec7c1f7eb3292e 100644 (file)
@@ -6,10 +6,3 @@
 use cspace;\r
 \r
 insert into `users` (`username`,`passwd`, `created_at`) VALUES ('test','n4bQgYhMfWWaL+qgxVrQFaO/TxsrC4Is0V1sFbDwCgg=', '2010-02-17 16:31:48');\r
-\r
-insert into `roles` (`rolename`, `rolegroup`, `created_at`) values ('kernel', 'kernel', '2010-02-17 16:31:48');\r
-insert into `roles` (`rolename`, `rolegroup`, `created_at`) values ('collections_manager', 'collections', '2010-02-17 16:31:48');\r
-insert into `roles` (`rolename`, `rolegroup`, `created_at`) values ('collections_registrar', 'collections', '2010-02-17 16:31:48');\r
-\r
-insert into `users_roles`(`username`, `rolename`, `created_at`) values ('test', 'collections_manager', '2010-02-17 16:31:48');\r
-insert into `users_roles`(`username`, `rolename`, `created_at`) values('admin', 'collections_registrar', '2010-02-17 16:31:48');
\ No newline at end of file
index 97d00a01d1d66b7b62f51a9d49362760a5bd5346..05b2b43dfc5e7a8923eac0d2f35707d2b91d6760 100644 (file)
@@ -3,8 +3,6 @@
 http://java.sun.com/xml/ns/persistence/orm http://java.sun.com/xml/ns/persistence/orm_1_0.xsd" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:orm="http://java.sun.com/xml/ns/persistence/orm" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
     <persistence-unit name="org.collectionspace.services.authentication">
         <class>org.collectionspace.services.authentication.User</class>
-        <class>org.collectionspace.services.authentication.Role</class>
-        <class>org.collectionspace.services.authentication.UserRole</class>
         <properties>
             <property name="hibernate.ejb.cfgfile" value="hibernate.cfg.xml"/>
 
index 3b376aeb6cbed4ab1954e5f7165725a192aa2ac7..6893b7069c0ad656d45f7880573143e1a21c3064 100644 (file)
 <!--        <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.1.RELEASE</spring.security.version>
+        <spring.security.version>3.0.2.RELEASE</spring.security.version>
     </properties>
 
     <dependencies>
-        <!-- keep slf4j dependencies on the top -->
+
+        <!-- slf4j not available due to classloading issues running in system classpath  -->
         <dependency>
             <groupId>org.slf4j</groupId>
             <artifactId>slf4j-api</artifactId>
             <artifactId>commons-logging</artifactId>
             <version>1.1.1</version>
         </dependency>
+        <dependency>
+            <groupId>log4j</groupId>
+            <artifactId>log4j</artifactId>
+            <version>1.2.14</version>
+            <scope>provided</scope>
+        </dependency>
+        <!-- utilities -->
         <dependency>
             <groupId>junit</groupId>
             <artifactId>junit</artifactId>
diff --git a/services/authentication/service/src/main/java/org/collectionspace/authentication/AuthN.java b/services/authentication/service/src/main/java/org/collectionspace/authentication/AuthN.java
new file mode 100644 (file)
index 0000000..e259e2f
--- /dev/null
@@ -0,0 +1,100 @@
+/**
+ *  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;
+
+import org.collectionspace.authentication.spring.SpringSecurityContextUtils;
+
+/**
+ * AuthN is a singleton to access various authentication related utilities
+ * accessed by services runtime
+ * @author 
+ */
+public class AuthN {
+    /**
+     * volatile is used here to assume about ordering (post JDK 1.5)
+     */
+    private static volatile AuthN  self = new AuthN();
+    private SecurityContextUtils securityContextUtils;
+    
+    private AuthN() {
+        //hardcoded initialization of a provider
+        //FIXME initialize with the help of configuration meta data
+        securityContextUtils = new SpringSecurityContextUtils();
+    }
+
+    public final static AuthN get() {
+        return self;
+    }
+
+    /**
+     * getAuthn returns authentication utilities
+     * @return
+     */
+    public SecurityContextUtils getSecurityContextUtils() {
+        return securityContextUtils;
+    }
+
+    /**
+     * getUserId returns authenticated user's id (principal name)
+     * @return
+     */
+    public String getUserId() {
+        return securityContextUtils.getUserId();
+    }
+    /**
+     * getTenantIds returns a list of tenant ids the user is associated with
+     * @return
+     */
+    public String[] getTenantIds() {
+        return securityContextUtils.getTenantIds();
+    }
+
+}
index 5b4565e1f3c6b1fc14fd0470a2eafe849da36459..656c615005f74d0fefb2c6e56aacbd8593308ae4 100644 (file)
@@ -42,7 +42,7 @@ public class CSpaceTenant implements Group, Cloneable {
     private static final long serialVersionUID = 1L;
     private String name;
     private String id;
-    private HashMap members = new HashMap(3);
+    private HashMap<Principal, Principal> members = new HashMap<Principal, Principal>();
 
     public CSpaceTenant(String name, String id) {
         if(name == null || id == null) {
diff --git a/services/authentication/service/src/main/java/org/collectionspace/authentication/SecurityContextUtils.java b/services/authentication/service/src/main/java/org/collectionspace/authentication/SecurityContextUtils.java
new file mode 100644 (file)
index 0000000..720fe92
--- /dev/null
@@ -0,0 +1,70 @@
+/**
+ *  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;
+
+/**
+ * Utilities to be used by Services runtime to interface with authentication service
+ * @author 
+ */
+public abstract class SecurityContextUtils {
+
+    /**
+     * getUserId returns authenticated user id
+     * @return
+     */
+    public abstract String getUserId();
+    
+    /**
+     * get tenant ids associated with the security context
+     * @return
+     */
+    public abstract String[] getTenantIds();
+}
index b228d107490b46551bd52f2a31c05febf0e85953..66355bf78edb66aad9ef128e38f270916def32ec 100644 (file)
  * 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.security.acl.Group;
+import java.util.Enumeration;
 import java.util.HashSet;
 import java.util.Set;
 import org.springframework.security.authentication.jaas.AuthorityGranter;
 
 /**
- *
+ * CSpaceAuthorityGranter maps a given prinicpal to role names
  * @author 
  */
 public class CSpaceAuthorityGranter implements AuthorityGranter {
-    public Set<String> grant(Principal principal) {
-        Set<String> rtnSet = new HashSet<String>();
 
-
-        return rtnSet;
+    public Set<String> grant(Principal principal) {
+        Set<String> authorities = new HashSet<String>();
+        if (principal instanceof Group) {
+            Group g = (Group) principal;
+            Enumeration members = g.members();
+            while (members.hasMoreElements()) {
+                Principal p = (Principal) members.nextElement();
+                authorities.add(p.getName());
+            }
+        } else {
+            authorities.add(principal.getName());
+        }
+        return authorities;
     }
 }
index 92bf5c4ad809e51402b7a10522e2dd44b69c7f48..469aed77f7ef7619f89b7afe87dbba50e0fc5761 100644 (file)
@@ -63,6 +63,7 @@ import org.springframework.security.core.userdetails.UsernameNotFoundException;
 
 /**
  * A CollectionSpace UserDetailsService for spring
+ * mockup code to cheat spring config reader...not used by Spring JaasAuthenticationProvider
  */
 //FIXME remove test/mockup code
 public class CSpaceUserDetailsService implements UserDetailsService {
@@ -72,11 +73,6 @@ public class CSpaceUserDetailsService implements UserDetailsService {
 
     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 {
diff --git a/services/authentication/service/src/main/java/org/collectionspace/authentication/spring/SpringSecurityContextUtils.java b/services/authentication/service/src/main/java/org/collectionspace/authentication/spring/SpringSecurityContextUtils.java
new file mode 100644 (file)
index 0000000..a958788
--- /dev/null
@@ -0,0 +1,125 @@
+/**
+ *  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.acl.Group;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.Set;
+import javax.security.auth.Subject;
+import org.collectionspace.authentication.SecurityContextUtils;
+import org.collectionspace.authentication.CSpaceTenant;
+import org.springframework.security.authentication.jaas.JaasAuthenticationToken;
+import org.springframework.security.core.Authentication;
+import org.springframework.security.core.context.SecurityContextHolder;
+
+/**
+ * SpringSecurityContextUtils provides utilities to CSpace services runtime
+ * @author 
+ */
+final public class SpringSecurityContextUtils extends SecurityContextUtils {
+    //private static final String SUBJECT_CONTEXT_KEY = "javax.security.auth.Subject.container";
+
+    public String getUserId() {
+        Authentication authToken = SecurityContextHolder.getContext().getAuthentication();
+        return authToken.getName();
+    }
+
+    /**
+     * retrieve tenant ids from Jaas LoginContext
+     * @return
+     */
+    @Override
+    public String[] getTenantIds() {
+
+        ArrayList<String> tenants = new ArrayList<String>();
+        Subject caller = null;
+        Authentication authToken = SecurityContextHolder.getContext().getAuthentication();
+        JaasAuthenticationToken jaasToken = null;
+        if (authToken instanceof JaasAuthenticationToken) {
+            jaasToken = (JaasAuthenticationToken) authToken;
+            caller = (Subject) jaasToken.getLoginContext().getSubject();
+        }
+        //caller = (Subject) PolicyContext.getContext(SUBJECT_CONTEXT_KEY);
+        if (caller == null) {
+            String msg = "security not enabled!";
+            //TODO: find out why subject is not null
+            //FIXME: if logger is loaded when authn comes up, use it
+            //logger.warn(msg);
+            System.err.println(msg);
+            return tenants.toArray(new String[0]);
+        }
+        Set<Group> groups = null;
+        groups = caller.getPrincipals(Group.class);
+        if (groups != null && groups.size() == 0) {
+            String msg = "no role(s)/tenant(s) found!";
+            //TODO: find out why no roles / tenants found
+            //FIXME: if logger is loaded when authn comes up, use it
+            //logger.warn(msg);
+            System.err.println(msg);
+            return tenants.toArray(new String[0]);
+        }
+        for (Group g : groups) {
+            if ("Tenants".equals(g.getName())) {
+                Enumeration members = g.members();
+                while (members.hasMoreElements()) {
+                    CSpaceTenant tenant = (CSpaceTenant) members.nextElement();
+                    tenants.add(tenant.getId());
+                    //FIXME: if logger is loaded when authn comes up, use it
+//                    if (logger.isDebugEnabled()) {
+//                        logger.debug("found tenant id=" + tenant.getId()
+//                                + " name=" + tenant.getName());
+//                    }
+                }
+            }
+        }
+        return tenants.toArray(new String[0]);
+    }
+}
diff --git a/services/authorization/build.xml b/services/authorization/build.xml
new file mode 100644 (file)
index 0000000..add2af1
--- /dev/null
@@ -0,0 +1,138 @@
+\r
+<project name="authorization" default="package" basedir=".">\r
+    <description>\r
+        authorization service\r
+    </description>\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
+    <property file="${services.trunk}/build.properties" />\r
+    <property name="mvn.opts" value="" />\r
+    <property name="src" location="src"/>\r
+    <property name="build" location="build"/>\r
+\r
+    <condition property="osfamily-unix">\r
+        <os family="unix" />\r
+    </condition>\r
+    <condition property="osfamily-windows">\r
+        <os family="windows" />\r
+    </condition>\r
+\r
+    <target name="package" depends="package-unix,package-windows"\r
+            description="Package CollectionSpace Services" />\r
+\r
+    <target name="package-unix" if="osfamily-unix">\r
+        <exec executable="mvn" failonerror="true">\r
+            <arg value="package" />\r
+            <arg value="-Dmaven.test.skip=true" />\r
+            <arg value="-f" />\r
+            <arg value="${basedir}/pom.xml" />\r
+            <arg value="-N" />\r
+            <arg value="${mvn.opts}" />\r
+        </exec>\r
+    </target>\r
+\r
+    <target name="package-windows" if="osfamily-windows">\r
+        <exec executable="cmd" failonerror="true">\r
+            <arg value="/c" />\r
+            <arg value="mvn.bat" />\r
+            <arg value="package" />\r
+            <arg value="-Dmaven.test.skip=true" />\r
+            <arg value="-f" />\r
+            <arg value="${basedir}/pom.xml" />\r
+            <arg value="-N" />\r
+            <arg value="${mvn.opts}" />\r
+        </exec>\r
+    </target>\r
+\r
+\r
+    <target name="install" depends="install-unix,install-windows"\r
+            description="Install" />\r
+    <target name="install-unix" if="osfamily-unix">\r
+        <exec executable="mvn" failonerror="true">\r
+            <arg value="install" />\r
+            <arg value="-Dmaven.test.skip=true" />\r
+            <arg value="-f" />\r
+            <arg value="${basedir}/pom.xml" />\r
+            <arg value="-N" />\r
+            <arg value="${mvn.opts}" />\r
+        </exec>\r
+    </target>\r
+    <target name="install-windows" if="osfamily-windows">\r
+        <exec executable="cmd" failonerror="true">\r
+            <arg value="/c" />\r
+            <arg value="mvn.bat" />\r
+            <arg value="install" />\r
+            <arg value="-Dmaven.test.skip=true" />\r
+            <arg value="-f" />\r
+            <arg value="${basedir}/pom.xml" />\r
+            <arg value="-N" />\r
+            <arg value="${mvn.opts}" />\r
+        </exec>\r
+    </target>\r
+\r
+    <target name="clean" depends="clean-unix,clean-windows"\r
+            description="Delete target directories" >\r
+        <delete dir="${build}"/>\r
+    </target>\r
+    <target name="clean-unix" if="osfamily-unix">\r
+        <exec executable="mvn" failonerror="true">\r
+            <arg value="clean" />\r
+            <arg value="${mvn.opts}" />\r
+        </exec>\r
+    </target>\r
+    <target name="clean-windows" if="osfamily-windows">\r
+        <exec executable="cmd" failonerror="true">\r
+            <arg value="/c" />\r
+            <arg value="mvn.bat" />\r
+            <arg value="clean" />\r
+            <arg value="${mvn.opts}" />\r
+        </exec>\r
+    </target>\r
+\r
+    <target name="test" depends="test-unix,test-windows" description="Run tests" />\r
+    <target name="test-unix" if="osfamily-unix">\r
+        <exec executable="mvn" failonerror="true">\r
+            <arg value="test" />\r
+            <arg value="${mvn.opts}" />\r
+        </exec>\r
+    </target>\r
+    <target name="test-windows" if="osfamily-windows">\r
+        <exec executable="cmd" failonerror="true">\r
+            <arg value="/c" />\r
+            <arg value="mvn.bat" />\r
+            <arg value="test" />\r
+            <arg value="${mvn.opts}" />\r
+        </exec>\r
+    </target>\r
+\r
+    <target name="gen_ddl"\r
+            description="generate service-specific tables(s), indices, etc.">\r
+        <ant antfile="pstore/build.xml" target="gen_ddl" inheritAll="false"/>\r
+    </target>\r
+\r
+    <target name="create_db"\r
+            description="create tables(s), indices for authorization service">\r
+        <ant antfile="pstore/build.xml" target="create_db" inheritAll="false"/>\r
+    </target>\r
+\r
+    <target name="deploy" depends="install"\r
+            description="deploy authorization service">\r
+        <ant antfile="pstore/build.xml" target="deploy" inheritAll="false"/>\r
+        <ant antfile="service/build.xml" target="deploy" inheritall="false"/>\r
+    </target>\r
+\r
+    <target name="undeploy"\r
+            description="undeploy authorization service">\r
+        <ant antfile="pstore/build.xml" target="undeploy" inheritAll="false"/>\r
+        <ant antfile="service/build.xml" target="undeploy" inheritall="false"/>\r
+    </target>\r
+\r
+    <target name="dist" depends="package"\r
+            description="distribute authorization service}">\r
+        <!--ant antfile="pstore/build.xml" target="dist" inheritall="false"/-->\r
+        <ant antfile="service/build.xml" target="dist" inheritall="false"/>\r
+    </target>\r
+\r
+</project>\r
diff --git a/services/authorization/jaxb/.classpath b/services/authorization/jaxb/.classpath
new file mode 100644 (file)
index 0000000..1707f3e
--- /dev/null
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<classpath>\r
+       <classpathentry kind="src" output="target/classes" path="src/main/java"/>\r
+       <classpathentry kind="src" output="target/classes" path="target/generated-sources/xjc"/>\r
+       <classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/>\r
+       <classpathentry kind="src" output="target/test-classes" path="src/test/java"/>\r
+       <classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources"/>\r
+       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>\r
+       <classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>\r
+       <classpathentry kind="output" path="target/classes"/>\r
+</classpath>\r
diff --git a/services/authorization/jaxb/.project b/services/authorization/jaxb/.project
new file mode 100644 (file)
index 0000000..677b488
--- /dev/null
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<projectDescription>\r
+       <name>org.collectionspace.services.authorization.jaxb</name>\r
+       <comment></comment>\r
+       <projects>\r
+       </projects>\r
+       <buildSpec>\r
+               <buildCommand>\r
+                       <name>org.eclipse.jdt.core.javabuilder</name>\r
+                       <arguments>\r
+                       </arguments>\r
+               </buildCommand>\r
+               <buildCommand>\r
+                       <name>org.maven.ide.eclipse.maven2Builder</name>\r
+                       <arguments>\r
+                       </arguments>\r
+               </buildCommand>\r
+       </buildSpec>\r
+       <natures>\r
+               <nature>org.eclipse.jdt.core.javanature</nature>\r
+               <nature>org.maven.ide.eclipse.maven2Nature</nature>\r
+       </natures>\r
+</projectDescription>\r
diff --git a/services/authorization/jaxb/.settings/org.eclipse.jdt.core.prefs b/services/authorization/jaxb/.settings/org.eclipse.jdt.core.prefs
new file mode 100644 (file)
index 0000000..034764a
--- /dev/null
@@ -0,0 +1,5 @@
+#Mon Nov 23 11:54:01 PST 2009\r
+eclipse.preferences.version=1\r
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6\r
+org.eclipse.jdt.core.compiler.compliance=1.6\r
+org.eclipse.jdt.core.compiler.source=1.6\r
diff --git a/services/authorization/jaxb/.settings/org.maven.ide.eclipse.prefs b/services/authorization/jaxb/.settings/org.maven.ide.eclipse.prefs
new file mode 100644 (file)
index 0000000..10222cb
--- /dev/null
@@ -0,0 +1,9 @@
+#Mon Nov 23 11:53:49 PST 2009\r
+activeProfiles=\r
+eclipse.preferences.version=1\r
+fullBuildGoals=process-test-resources\r
+includeModules=false\r
+resolveWorkspaceProjects=true\r
+resourceFilterGoals=process-resources resources\:testResources\r
+skipCompilerPlugin=true\r
+version=1\r
diff --git a/services/authorization/jaxb/pom.xml b/services/authorization/jaxb/pom.xml
new file mode 100644 (file)
index 0000000..b02da04
--- /dev/null
@@ -0,0 +1,97 @@
+<?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
+    <parent>\r
+        <artifactId>org.collectionspace.services.authorization</artifactId>\r
+        <groupId>org.collectionspace.services</groupId>\r
+        <version>0.6-SNAPSHOT</version>\r
+    </parent>\r
+\r
+    <modelVersion>4.0.0</modelVersion>\r
+    <groupId>org.collectionspace.services</groupId>\r
+    <artifactId>org.collectionspace.services.authorization.jaxb</artifactId>\r
+    <name>services.authorization.jaxb</name>\r
+    <properties>\r
+    </properties>\r
+    <dependencies>\r
+        <!-- keep slf4j dependencies on the top -->\r
+        <dependency>\r
+            <groupId>org.slf4j</groupId>\r
+            <artifactId>slf4j-api</artifactId>\r
+            <scope>test</scope>\r
+        </dependency>\r
+        <dependency>\r
+            <groupId>org.slf4j</groupId>\r
+            <artifactId>slf4j-log4j12</artifactId>\r
+            <scope>test</scope>\r
+        </dependency>\r
+        <dependency>\r
+            <groupId>com.sun.xml.bind</groupId>\r
+            <artifactId>jaxb-impl</artifactId>\r
+        </dependency>\r
+        <dependency>\r
+            <groupId>org.jvnet.jaxb2-commons</groupId>\r
+            <artifactId>property-listener-injector</artifactId>\r
+        </dependency>\r
+        <dependency>\r
+            <groupId>org.jvnet.jaxb2_commons</groupId>\r
+            <artifactId>runtime</artifactId>\r
+        </dependency>\r
+\r
+        <dependency>\r
+            <groupId>mysql</groupId>\r
+            <artifactId>mysql-connector-java</artifactId>\r
+        </dependency>\r
+\r
+        <dependency>\r
+            <groupId>javax.persistence</groupId>\r
+            <artifactId>persistence-api</artifactId>\r
+        </dependency>\r
+        <dependency>\r
+            <groupId>org.hibernate</groupId>\r
+            <artifactId>hibernate-entitymanager</artifactId>\r
+        </dependency>\r
+        <dependency>\r
+            <groupId>org.jvnet.hyperjaxb3</groupId>\r
+            <artifactId>hyperjaxb3-ejb-runtime</artifactId>\r
+        </dependency>\r
+        <dependency>\r
+            <groupId>org.testng</groupId>\r
+            <artifactId>testng</artifactId>\r
+            <version>5.6</version>\r
+        </dependency>\r
+    </dependencies>\r
+\r
+    <build>\r
+        <finalName>collectionspace-services-authorization-jaxb</finalName>\r
+        <defaultGoal>install</defaultGoal>\r
+        <plugins>\r
+            <plugin>\r
+                <!-- maven-hyperjaxb3-plugin generates jaxb + jpa bindings -->\r
+                <groupId>org.jvnet.hyperjaxb3</groupId>\r
+                <artifactId>maven-hyperjaxb3-plugin</artifactId>\r
+                <executions>\r
+                    <execution>\r
+                        <goals>\r
+                            <goal>generate</goal>\r
+                        </goals>\r
+                    </execution>\r
+                </executions>\r
+                <configuration>\r
+                    <extension>true</extension>\r
+                    <jdk5>true</jdk5>\r
+                    <ejb3>false</ejb3>\r
+                </configuration>\r
+            </plugin>\r
+            <plugin>\r
+                <artifactId>maven-compiler-plugin</artifactId>\r
+                <configuration>\r
+                    <source>1.6</source>\r
+                    <target>1.6</target>\r
+                </configuration>\r
+            </plugin>\r
+\r
+        </plugins>\r
+    </build>\r
+\r
+</project>\r
diff --git a/services/authorization/jaxb/src/main/resources/authorization_provider.xsd b/services/authorization/jaxb/src/main/resources/authorization_provider.xsd
new file mode 100644 (file)
index 0000000..8a9b1d6
--- /dev/null
@@ -0,0 +1,206 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+
+<!--
+    CollectionSpace default (security) authorization provider schema (XSD)
+
+    Entity(s)  : roles, users_roles
+    Used for:
+
+    $LastChangedRevision: 916 $
+    $LastChangedDate: 2009-11-05 16:59:20 -0800 (Thu, 05 Nov 2009) $
+-->
+
+<xs:schema 
+    xmlns:xs="http://www.w3.org/2001/XMLSchema"
+    xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
+    xmlns:hj="http://hyperjaxb3.jvnet.org/ejb/schemas/customizations"
+    xmlns:orm="http://java.sun.com/xml/ns/persistence/orm"
+    xmlns:ns="http://collectionspace.org/services/authorization"
+    xmlns="http://collectionspace.org/services/authorization"
+    targetNamespace="http://collectionspace.org/services/authorization"
+    version="0.1"
+    jaxb:extensionBindingPrefixes="hj orm"
+    >
+
+    <!--
+    Avoid XmlRootElement nightmare:
+    See http://weblogs.java.net/blog/kohsuke/archive/2006/03/why_does_jaxb_p.html
+-->
+<!--
+    Notes for MySQL
+    MySQL puts key length limit of 1000 bytes
+    username - rolename constraint should be within 1000 bytes
+    hbm2ddl makes column length >= 256 as long text, such as column cannot be used
+    in defining a key (pk, fk or constraint)
+-->
+    <xs:element name="role">
+        <xs:complexType>
+            <xs:annotation>
+                <xs:documentation>Role definition in CollectionSpace</xs:documentation>
+                <xs:appinfo>
+                    <hj:entity>
+                        <orm:table name="roles"/>
+                    </hj:entity>
+                </xs:appinfo>
+            </xs:annotation>
+            <xs:sequence>
+                <xs:element name="rolename" type="xs:string" minOccurs="1" maxOccurs="1">
+                    <xs:annotation>
+                        <xs:appinfo>
+                            <hj:id>
+                                <orm:column name="rolename" length="200" nullable="false"/>
+                            </hj:id>
+                        </xs:appinfo>
+                    </xs:annotation>
+                </xs:element>
+                <xs:element name="rolegroup" type="xs:string" minOccurs="1" maxOccurs="1">
+                    <xs:annotation>
+                        <xs:appinfo>
+                            <hj:basic>
+                                <orm:column name="rolegroup" nullable="false"/>
+                            </hj:basic>
+                        </xs:appinfo>
+                    </xs:annotation>
+                </xs:element>
+                <xs:element name="createdAt" type="xs:dateTime">
+                    <xs:annotation>
+                        <xs:appinfo>
+                            <hj:basic>
+                                <orm:column name="created_at" nullable="false"/>
+                            </hj:basic>
+                        </xs:appinfo>
+                    </xs:annotation>
+                </xs:element>
+                <xs:element name="updatedAt" type="xs:dateTime">
+                    <xs:annotation>
+                        <xs:appinfo>
+                            <hj:basic>
+                                <orm:column name="updated_at" />
+                            </hj:basic>
+                        </xs:appinfo>
+                    </xs:annotation>
+                </xs:element>
+            </xs:sequence>
+        </xs:complexType>
+    </xs:element>
+
+    <xs:element name="user_role">
+        <xs:complexType>
+            <xs:annotation>
+                <xs:documentation>UserRole defines association between user and role in CollectionSpace</xs:documentation>
+                <xs:appinfo>
+                    <hj:entity>
+                        <orm:table name="users_roles">
+                            <orm:unique-constraint>
+                                <!-- combined length should be < 1000 bytes -->
+                                <orm:column-name>username</orm:column-name>
+                                <orm:column-name>rolename</orm:column-name>
+                            </orm:unique-constraint>
+                        </orm:table>
+                    </hj:entity>
+                </xs:appinfo>
+            </xs:annotation>
+            <xs:sequence>
+                <xs:element name="username" type="xs:string" minOccurs="1" maxOccurs="1">
+                    <xs:annotation>
+                        <xs:appinfo>
+                            <hj:basic>
+                                <orm:column name="username" length="128" nullable="false"/>
+                            </hj:basic>
+                        </xs:appinfo>
+                    </xs:annotation>
+                </xs:element>
+                <xs:element name="rolename" type="xs:string" minOccurs="1" maxOccurs="1">
+                    <xs:annotation>
+                        <xs:appinfo>
+                            <hj:basic>
+                                <orm:column name="rolename" length="200" nullable="false"/>
+                            </hj:basic>
+                        </xs:appinfo>
+                    </xs:annotation>
+                </xs:element>
+                <xs:element name="createdAt" type="xs:dateTime">
+                    <xs:annotation>
+                        <xs:appinfo>
+                            <hj:basic>
+                                <orm:column name="created_at" nullable="false"/>
+                            </hj:basic>
+                        </xs:appinfo>
+                    </xs:annotation>
+                </xs:element>
+                <xs:element name="updatedAt" type="xs:dateTime">
+                    <xs:annotation>
+                        <xs:appinfo>
+                            <hj:basic>
+                                <orm:column name="updated_at" />
+                            </hj:basic>
+                        </xs:appinfo>
+                    </xs:annotation>
+                </xs:element>
+            </xs:sequence>
+        </xs:complexType>
+    </xs:element>
+
+    <xs:element name="permission_config_list">
+        <xs:complexType>
+            <xs:sequence>
+                <xs:annotation>
+                    <xs:documentation>permission configuration list</xs:documentation>
+                </xs:annotation>
+                <xs:element name="permission" type="permission_config" minOccurs="1" maxOccurs="unbounded"/>
+            </xs:sequence>
+        </xs:complexType>
+    </xs:element>
+
+
+    <xs:complexType name="permission_config">
+        <xs:annotation>
+            <xs:documentation>CspacePermissionConfig describes permission in CollectionSpace</xs:documentation>
+            <xs:appinfo>
+                <hj:ignored/>
+            </xs:appinfo>
+        </xs:annotation>
+        <xs:sequence>
+            <xs:annotation>
+                <xs:documentation>
+                    resourceName could be a servicename or a servicename#attribute
+                </xs:documentation>
+            </xs:annotation>
+            <xs:element name="resourceName" type="xs:string" minOccurs="1" maxOccurs="1"/>
+            <xs:element name="action" type="ActionType" minOccurs="1" maxOccurs="unbounded"/>
+            <xs:element name="role" type="xs:string" minOccurs="1" maxOccurs="unbounded"/>
+            <xs:element name="user" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
+            <xs:element name="effect" type="EffectType" minOccurs="1" maxOccurs="1"/>
+        </xs:sequence>
+    </xs:complexType>
+
+
+    <xs:simpleType name = "ActionType">
+        <xs:annotation>
+            <xs:documentation>Action describes the actions that coudl be taken</xs:documentation>
+        </xs:annotation>
+        <xs:restriction base = "xs:string">
+            <xs:enumeration value = "CREATE"/>
+            <xs:enumeration value = "READ"/>
+            <xs:enumeration value = "UPDATE"/>
+            <xs:enumeration value = "DELETE"/>
+            <xs:enumeration value = "SEARCH"/>
+            <xs:enumeration value = "START"/>
+            <xs:enumeration value = "STOP"/>
+            <xs:enumeration value = "RUN"/>
+            <xs:enumeration value = "ADMIN"/>
+        </xs:restriction>
+    </xs:simpleType>
+
+    <xs:simpleType name = "EffectType">
+        <xs:annotation>
+            <xs:documentation>EffectType describes the effect of access control</xs:documentation>
+        </xs:annotation>
+        <xs:restriction base = "xs:string">
+            <xs:enumeration value = "PERMIT"/>
+            <xs:enumeration value = "DENY"/>
+        </xs:restriction>
+    </xs:simpleType>
+
+</xs:schema>
+
diff --git a/services/authorization/jaxb/src/test/resources/META-INF/persistence.xml b/services/authorization/jaxb/src/test/resources/META-INF/persistence.xml
new file mode 100644 (file)
index 0000000..a922bf9
--- /dev/null
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<persistence version="1.0" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd
+http://java.sun.com/xml/ns/persistence/orm http://java.sun.com/xml/ns/persistence/orm_1_0.xsd" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:orm="http://java.sun.com/xml/ns/persistence/orm" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+    <persistence-unit name="org.collectionspace.services.authorization">
+    <class>org.collectionspace.services.authorization.Role</class>
+    <class>org.collectionspace.services.authorization.UserRole</class>
+        <properties>
+            <property name="hibernate.ejb.cfgfile" value="hibernate.cfg.xml"/>
+
+            <!--property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
+            <property name="hibernate.max_fetch_depth" value="3"/>
+            <property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/>
+            <property name="hibernate.connection.username" value="test"/>
+            <property name="hibernate.connection.password" value="test"/>
+            <property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/cspace"/-->
+        </properties>
+    </persistence-unit>
+</persistence>
diff --git a/services/authorization/jaxb/src/test/resources/hibernate.cfg.xml b/services/authorization/jaxb/src/test/resources/hibernate.cfg.xml
new file mode 100644 (file)
index 0000000..c7c6009
--- /dev/null
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+    Document   : hibernate.cfg.xml.xml
+    Created on : November 12, 2009, 12:02 PM
+    Author     : sanjaydalal
+    Description:
+        Purpose of the document follows.
+-->
+<!DOCTYPE hibernate-configuration PUBLIC
+          "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
+          "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
+<hibernate-configuration>
+    <session-factory>
+        <property name="connection.url">jdbc:mysql://localhost:3306/cspace</property>
+        <property name="connection.driver_class">com.mysql.jdbc.Driver</property>
+        <property name="connection.username">test</property>
+        <property name="connection.password">test</property>
+        <property name="dialect">org.hibernate.dialect.MySQLDialect</property>
+        <property name="transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property>
+        <property name="current_session_context_class">thread</property>
+        <property name="hibernate.show_sql">true</property>
+    </session-factory>
+</hibernate-configuration>
diff --git a/services/authorization/pom.xml b/services/authorization/pom.xml
new file mode 100644 (file)
index 0000000..c0dbf20
--- /dev/null
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project>
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <artifactId>org.collectionspace.services.main</artifactId>
+        <groupId>org.collectionspace.services</groupId>
+        <version>0.6-SNAPSHOT</version>
+    </parent>
+    <groupId>org.collectionspace.services</groupId>
+    <artifactId>org.collectionspace.services.authorization</artifactId>
+    <name>services.authorization</name>
+    <packaging>pom</packaging>
+    <url>http://www.collectionspace.org</url>
+    <properties>
+    </properties>
+
+
+    <modules>
+        <module>jaxb</module>
+        <module>pstore</module>
+        <module>service</module>
+    </modules>
+</project>
diff --git a/services/authorization/pstore/.classpath b/services/authorization/pstore/.classpath
new file mode 100644 (file)
index 0000000..c9485d7
--- /dev/null
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<classpath>\r
+       <classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/>\r
+       <classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources"/>\r
+       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>\r
+       <classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>\r
+</classpath>\r
diff --git a/services/authorization/pstore/.project b/services/authorization/pstore/.project
new file mode 100644 (file)
index 0000000..6f4ff86
--- /dev/null
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<projectDescription>\r
+       <name>org.collectionspace.services.authorization.pstore</name>\r
+       <comment></comment>\r
+       <projects>\r
+       </projects>\r
+       <buildSpec>\r
+               <buildCommand>\r
+                       <name>org.eclipse.jdt.core.javabuilder</name>\r
+                       <arguments>\r
+                       </arguments>\r
+               </buildCommand>\r
+               <buildCommand>\r
+                       <name>org.maven.ide.eclipse.maven2Builder</name>\r
+                       <arguments>\r
+                       </arguments>\r
+               </buildCommand>\r
+       </buildSpec>\r
+       <natures>\r
+               <nature>org.eclipse.jdt.core.javanature</nature>\r
+               <nature>org.maven.ide.eclipse.maven2Nature</nature>\r
+       </natures>\r
+</projectDescription>\r
diff --git a/services/authorization/pstore/build.xml b/services/authorization/pstore/build.xml
new file mode 100644 (file)
index 0000000..be9641b
--- /dev/null
@@ -0,0 +1,221 @@
+\r
+<project name="authorization.pstore" default="package" basedir=".">\r
+    <description>\r
+        collectionspace authorization service\r
+    </description>\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
+    <property file="${services.trunk}/build.properties" />\r
+    <property name="mvn.opts" value="" />\r
+    <property name="src" location="src"/>\r
+\r
+    <condition property="osfamily-unix">\r
+        <os family="unix" />\r
+    </condition>\r
+    <condition property="osfamily-windows">\r
+        <os family="windows" />\r
+    </condition>\r
+\r
+    <target name="init">\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
+    <target name="package-unix" if="osfamily-unix">\r
+        <exec executable="mvn" failonerror="true">\r
+            <arg value="package" />\r
+            <arg value="-Dmaven.test.skip=true" />\r
+            <arg value="-f" />\r
+            <arg value="${basedir}/pom.xml" />\r
+            <arg value="-N" />\r
+            <arg value="${mvn.opts}" />\r
+        </exec>\r
+    </target>\r
+    <target name="package-windows" if="osfamily-windows">\r
+        <exec executable="cmd" failonerror="true">\r
+            <arg value="/c" />\r
+            <arg value="mvn.bat" />\r
+            <arg value="package" />\r
+            <arg value="-Dmaven.test.skip=true" />\r
+            <arg value="-f" />\r
+            <arg value="${basedir}/pom.xml" />\r
+            <arg value="-N" />\r
+            <arg value="${mvn.opts}" />\r
+        </exec>\r
+    </target>\r
+\r
+    <target name="install" depends="install-unix,install-windows"\r
+            description="Install" />\r
+    <target name="install-unix" if="osfamily-unix">\r
+        <exec executable="mvn" failonerror="true">\r
+            <arg value="install" />\r
+            <arg value="-Dmaven.test.skip=true" />\r
+            <arg value="-f" />\r
+            <arg value="${basedir}/pom.xml" />\r
+            <arg value="-N" />\r
+            <arg value="${mvn.opts}" />\r
+        </exec>\r
+    </target>\r
+    <target name="install-windows" if="osfamily-windows">\r
+        <exec executable="cmd" failonerror="true">\r
+            <arg value="/c" />\r
+            <arg value="mvn.bat" />\r
+            <arg value="install" />\r
+            <arg value="-Dmaven.test.skip=true" />\r
+            <arg value="-f" />\r
+            <arg value="${basedir}/pom.xml" />\r
+            <arg value="-N" />\r
+            <arg value="${mvn.opts}" />\r
+        </exec>\r
+    </target>\r
+\r
+    <target name="clean" depends="clean-unix,clean-windows"\r
+            description="Delete target directories" >\r
+        <delete dir="${build}"/>\r
+    </target>\r
+    <target name="clean-unix" if="osfamily-unix">\r
+        <exec executable="mvn" failonerror="true">\r
+            <arg value="clean" />\r
+            <arg value="${mvn.opts}" />\r
+        </exec>\r
+    </target>\r
+    <target name="clean-windows" if="osfamily-windows">\r
+        <exec executable="cmd" failonerror="true">\r
+            <arg value="/c" />\r
+            <arg value="mvn.bat" />\r
+            <arg value="clean" />\r
+            <arg value="${mvn.opts}" />\r
+        </exec>\r
+    </target>\r
+\r
+    <target name="test" depends="test-unix,test-windows" description="Run tests" />\r
+    <target name="test-unix" if="osfamily-unix">\r
+        <exec executable="mvn" failonerror="true">\r
+            <arg value="test" />\r
+            <arg value="${mvn.opts}" />\r
+        </exec>\r
+    </target>\r
+    <target name="test-windows" if="osfamily-windows">\r
+        <exec executable="cmd" failonerror="true">\r
+            <arg value="/c" />\r
+            <arg value="mvn.bat" />\r
+            <arg value="test" />\r
+            <arg value="${mvn.opts}" />\r
+        </exec>\r
+    </target>\r
+\r
+    <target name="setup_hibernate.cfg" description="replace property keywords in hibernate.cfg.xml">\r
+        <property name="src.hibernate.cfg" value="${basedir}/src/test/resources/hibernate.cfg.xml"/>\r
+        <property name="dest.hibernate.cfg" value="${basedir}/target/test-classes/hibernate.cfg.xml"/>\r
+        <delete file="${dest.hibernate.cfg}" verbose="true" />\r
+        <filter token="DB_URL" value="${db.jdbc.url}" />\r
+        <filter token="DB_DRIVER_CLASS" value="${db.jdbc.driver.class}" />\r
+        <filter token="DB_USER" value="${env.DB_USER}" /> <!-- double-sub from ${db.user} fails -->\r
+        <filter token="DB_PASSWORD" value="${env.DB_PASSWORD}" /> <!-- double-sub from ${db.user.password} fails -->\r
+        <filter token="DB_DIALECT" value="${db.dialect}" />\r
+        <copy todir="${basedir}/target/test-classes" filtering="true">\r
+            <fileset dir="${basedir}/src/test/resources">\r
+                <include name="hibernate.cfg.xml" />\r
+            </fileset>\r
+        </copy>\r
+    </target>\r
+\r
+\r
+    <target name="gen_ddl" depends="gen_ddl-unix,gen_ddl-windows"\r
+            description="geneate ddl" />\r
+    <target name="gen_ddl-unix" if="osfamily-unix" depends="setup_hibernate.cfg">\r
+        <exec executable="mvn" failonerror="true">\r
+            <arg value="-Pddl" />\r
+            <arg value="process-test-resources" />\r
+            <arg value="-f" />\r
+            <arg value="${basedir}/pom.xml" />\r
+            <arg value="-N" />\r
+            <arg value="${mvn.opts}" />\r
+        </exec>\r
+    </target>\r
+    <target name="gen_ddl-windows" if="osfamily-windows" depends="setup_hibernate.cfg">\r
+        <exec executable="cmd" failonerror="true">\r
+            <arg value="/c" />\r
+            <arg value="mvn.bat" />\r
+            <arg value="-Pddl" />\r
+            <arg value="process-test-resources" />\r
+            <arg value="-f" />\r
+            <arg value="${basedir}/pom.xml" />\r
+            <arg value="-N" />\r
+            <arg value="${mvn.opts}" />\r
+        </exec>\r
+    </target>\r
+\r
+    <target name="create_db"\r
+            description="create tables(s), indices for authorization service">\r
+        <sql driver="com.mysql.jdbc.Driver"\r
+             url="jdbc:mysql://${db.host}:${db.port}/cspace"\r
+             userid="${db.user}"\r
+             password="${db.user.password}"\r
+             src="${db.script.dir}/authorization.sql"\r
+             >\r
+            <classpath>\r
+                <pathelement path="${db.driver.jar}"/>\r
+            </classpath>\r
+        </sql>\r
+        <sql driver="com.mysql.jdbc.Driver"\r
+             url="jdbc:mysql://${db.host}:${db.port}/cspace"\r
+             userid="${db.user}"\r
+             password="${db.user.password}"\r
+             src="${db.script.dir}/authorization_index.sql"\r
+             >\r
+            <classpath>\r
+                <pathelement path="${db.driver.jar}"/>\r
+            </classpath>\r
+        </sql>\r
+        <sql driver="com.mysql.jdbc.Driver"\r
+             url="jdbc:mysql://${db.host}:${db.port}/cspace"\r
+             userid="${db.user}"\r
+             password="${db.user.password}"\r
+             src="${db.script.dir}/acl.sql"\r
+             >\r
+            <classpath>\r
+                <pathelement path="${db.driver.jar}"/>\r
+            </classpath>\r
+        </sql>\r
+        <sql driver="com.mysql.jdbc.Driver"\r
+             url="jdbc:mysql://${db.host}:${db.port}/cspace"\r
+             userid="${db.user}"\r
+             password="${db.user.password}"\r
+             src="${db.script.dir}/test_authorization.sql"\r
+             >\r
+            <classpath>\r
+                <pathelement path="${db.driver.jar}"/>\r
+            </classpath>\r
+        </sql>\r
+    </target>\r
+\r
+    <target name="deploy" depends="install"\r
+            description="deploy authorization service in ${jboss.server.cspace}">\r
+        <copy todir="${jboss.server.cspace}/cspace/services">\r
+            <fileset dir="${src}/main/resources/"/>\r
+        </copy>\r
+    </target>\r
+\r
+    <target name="undeploy"\r
+            description="undeploy authorization service from ${jboss.server.cspace}">\r
+        <delete>\r
+            <fileset dir="${jboss.server.cspace}/cspace/services/db/${db}"\r
+                     includes="**authorization**.sql"/>\r
+        </delete>\r
+    </target>\r
+\r
+    <target name="dist"\r
+            description="generate distribution for authorization service" depends="package">\r
+        <!-- copy db scripts, etc. -->\r
+        <copy todir="${services.trunk}/${dist.server.cspace}/cspace/services">\r
+            <fileset dir="${src}/main/resources/"/>\r
+        </copy>\r
+    </target>\r
+\r
+</project>\r
diff --git a/services/authorization/pstore/pom.xml b/services/authorization/pstore/pom.xml
new file mode 100644 (file)
index 0000000..195998c
--- /dev/null
@@ -0,0 +1,153 @@
+<?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
+    <parent>\r
+        <artifactId>org.collectionspace.services.authorization</artifactId>\r
+        <groupId>org.collectionspace.services</groupId>\r
+        <version>0.6-SNAPSHOT</version>\r
+    </parent>\r
+\r
+    <modelVersion>4.0.0</modelVersion>\r
+    <groupId>org.collectionspace.services</groupId>\r
+    <artifactId>org.collectionspace.services.authorization.pstore</artifactId>\r
+    <name>services.authorization.pstore</name>\r
+    <properties>\r
+        <sql.file>authorization.sql</sql.file>\r
+        <sql.dir>${basedir}/src/main/resources/db/mysql</sql.dir>\r
+    </properties>\r
+    <dependencies>\r
+        <!-- keep slf4j dependencies on the top -->\r
+        <dependency>\r
+            <groupId>org.slf4j</groupId>\r
+            <artifactId>slf4j-api</artifactId>\r
+            <scope>test</scope>\r
+        </dependency>\r
+        <dependency>\r
+            <groupId>org.slf4j</groupId>\r
+            <artifactId>slf4j-log4j12</artifactId>\r
+            <scope>test</scope>\r
+        </dependency>\r
+        <dependency>\r
+            <groupId>org.collectionspace.services</groupId>\r
+            <artifactId>org.collectionspace.services.authorization.jaxb</artifactId>\r
+            <version>${project.version}</version>\r
+        </dependency>\r
+        <dependency>\r
+            <groupId>org.testng</groupId>\r
+            <artifactId>testng</artifactId>\r
+            <version>5.6</version>\r
+        </dependency>\r
+        <dependency>\r
+            <groupId>mysql</groupId>\r
+            <artifactId>mysql-connector-java</artifactId>\r
+        </dependency>\r
+    </dependencies>\r
+\r
+    <build>\r
+        <finalName>cspace-services-authorization-pstore</finalName>\r
+        <plugins>\r
+            <plugin>\r
+                <artifactId>maven-antrun-plugin</artifactId>\r
+                <executions>\r
+                    <execution>\r
+                        <id>subs-hibernate-config</id>\r
+                        <phase>generate-test-resources</phase>\r
+                        <goals>\r
+                            <goal>run</goal>\r
+                        </goals>\r
+                        <configuration>\r
+                            <tasks>\r
+                                <property name="runtime-classpath" refid="maven.runtime.classpath" />\r
+                                <ant target="setup_hibernate.cfg" inheritRefs="true" />\r
+                            </tasks>\r
+                        </configuration>\r
+                    </execution>\r
+                </executions>\r
+            </plugin>\r
+            <plugin>\r
+                <groupId>org.apache.maven.plugins</groupId>\r
+                <artifactId>maven-surefire-plugin</artifactId>\r
+                <configuration>\r
+                    <systemProperties>\r
+                        <property>\r
+                            <name>log4j.configuration</name>\r
+                            <value>file:target/test-classes/log4j.properties</value>\r
+                        </property>\r
+                    </systemProperties>\r
+                </configuration>\r
+            </plugin>\r
+            <plugin>\r
+                <artifactId>maven-compiler-plugin</artifactId>\r
+                <version>2.0.2</version>\r
+                <configuration>\r
+                    <source>1.6</source>\r
+                    <target>1.6</target>\r
+                </configuration>\r
+            </plugin>\r
+        </plugins>\r
+    </build>\r
+    <profiles>\r
+        <profile>\r
+            <!-- use profile as this task is not needed for every build and test -->\r
+            <id>ddl</id>\r
+            <build>\r
+                <plugins>\r
+                    <plugin>\r
+                        <groupId>org.codehaus.mojo</groupId>\r
+                        <artifactId>hibernate3-maven-plugin</artifactId>\r
+                        <version>2.2</version>\r
+                        <executions>\r
+                            <execution>\r
+                                <phase>process-test-resources</phase>\r
+                                <goals>\r
+                                    <goal>hbm2ddl</goal>\r
+                                </goals>\r
+                            </execution>\r
+                        </executions>\r
+                        <configuration>\r
+                            <components>\r
+                                <component>\r
+                                    <name>hbm2ddl</name>\r
+                                </component>\r
+                            </components>\r
+                            <componentProperties>\r
+                                <outputfilename>${sql.file}</outputfilename>\r
+                                <implementation>jpaconfiguration</implementation>\r
+                                <drop>true</drop>\r
+                                <create>true</create>\r
+                                <export>true</export>\r
+                                <jdk5>true</jdk5>\r
+                                <ejb3>false</ejb3>\r
+                                <persistenceunit>org.collectionspace.services.authorization</persistenceunit>\r
+                            </componentProperties>\r
+                        </configuration>\r
+                        <dependencies>\r
+                            <dependency>\r
+                                <groupId>mysql</groupId>\r
+                                <artifactId>mysql-connector-java</artifactId>\r
+                                <version>5.1.5</version>\r
+                            </dependency>\r
+                        </dependencies>\r
+                    </plugin>\r
+                    <plugin>\r
+                        <artifactId>maven-antrun-plugin</artifactId>\r
+                        <executions>\r
+                            <execution>\r
+                                <phase>process-test-resources</phase>\r
+                                <configuration>\r
+                                    <tasks>\r
+                                        <copy file="${basedir}/target/hibernate3/sql/${sql.file}" tofile="${sql.dir}/${sql.file}" />\r
+                                    </tasks>\r
+                                </configuration>\r
+                                <goals>\r
+                                    <goal>run</goal>\r
+                                </goals>\r
+                            </execution>\r
+                        </executions>\r
+                    </plugin>\r
+\r
+                </plugins>\r
+            </build>\r
+        </profile>\r
+    </profiles>\r
+</project>\r
diff --git a/services/authorization/pstore/src/main/resources/db/mysql/acl.sql b/services/authorization/pstore/src/main/resources/db/mysql/acl.sql
new file mode 100644 (file)
index 0000000..a3a07cd
--- /dev/null
@@ -0,0 +1,106 @@
+--
+-- Copyright 2010 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.
+--
+
+use cspace;
+drop table if exists `acl_entry`;
+drop table if exists `acl_object_identity`;
+drop table if exists `acl_sid`;
+drop table if exists `acl_class`;
+
+--
+-- Table structure for table `acl_class`
+--
+
+CREATE TABLE IF NOT EXISTS `acl_class` (
+  `id` bigint(20) NOT NULL auto_increment,
+  `class` varchar(100) NOT NULL,
+  PRIMARY KEY  (`id`),
+  UNIQUE KEY `unique_uk_2` (`class`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
+
+--
+-- Dumping data for table `acl_class`
+--
+
+
+--
+-- Table structure for table `acl_sid`
+--
+
+CREATE TABLE IF NOT EXISTS `acl_sid` (
+  `id` bigint(20) NOT NULL auto_increment,
+  `principal` tinyint(1) NOT NULL,
+  `sid` varchar(100) NOT NULL,
+  PRIMARY KEY  (`id`),
+  UNIQUE KEY `unique_uk_1` (`principal`,`sid`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+--
+-- Dumping data for table `acl_sid`
+--
+
+--
+-- Table structure for table `acl_entry`
+--
+
+CREATE TABLE IF NOT EXISTS `acl_entry` (
+  `id` bigint(20) NOT NULL auto_increment,
+  `acl_object_identity` bigint(20) NOT NULL,
+  `ace_order` int(11) NOT NULL,
+  `sid` bigint(20) NOT NULL,
+  `mask` int(11) NOT NULL,
+  `granting` tinyint(1) NOT NULL,
+  `audit_success` tinyint(1) NOT NULL,
+  `audit_failure` tinyint(1) NOT NULL,
+  PRIMARY KEY  (`id`),
+  UNIQUE KEY `unique_uk_4` (`acl_object_identity`,`ace_order`),
+  KEY `sid` (`sid`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
+
+
+
+--
+-- Dumping data for table `acl_entry`
+--
+
+
+--
+-- Table structure for table `acl_object_identity`
+--
+
+CREATE TABLE IF NOT EXISTS `acl_object_identity` (
+  `id` bigint(20) NOT NULL auto_increment,
+  `object_id_class` bigint(20) NOT NULL,
+  `object_id_identity` bigint(20) NOT NULL,
+  `parent_object` bigint(20) default NULL,
+  `owner_sid` bigint(20) default NULL,
+  `entries_inheriting` tinyint(1) NOT NULL,
+  PRIMARY KEY  (`id`),
+  UNIQUE KEY `unique_uk_3` (`object_id_class`,`object_id_identity`),
+  KEY `owner_sid` (`owner_sid`),
+  KEY `parent_object` (`parent_object`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
+
+
+--
+-- Dumping data for table `acl_object_identity`
+--
+
+--
+-- Constraints for table `acl_entry`
+--
+ALTER TABLE `acl_entry`
+  ADD CONSTRAINT `acl_entry_ibfk_1` FOREIGN KEY (`sid`) REFERENCES `acl_sid` (`id`),
+  ADD CONSTRAINT `acl_entry_ibfk_2` FOREIGN KEY (`acl_object_identity`) REFERENCES `acl_object_identity` (`id`);
+
+
+--
+-- Constraints for table `acl_object_identity`
+--
+ALTER TABLE `acl_object_identity`
+  ADD CONSTRAINT `acl_object_identity_ibfk_1` FOREIGN KEY (`owner_sid`) REFERENCES `acl_sid` (`id`),
+  ADD CONSTRAINT `acl_object_identity_ibfk_2` FOREIGN KEY (`object_id_class`) REFERENCES `acl_class` (`id`),
+  ADD CONSTRAINT `acl_object_identity_ibfk_3` FOREIGN KEY (`parent_object`) REFERENCES `acl_object_identity` (`id`);
diff --git a/services/authorization/pstore/src/main/resources/db/mysql/authorization.sql b/services/authorization/pstore/src/main/resources/db/mysql/authorization.sql
new file mode 100644 (file)
index 0000000..3a5b1e5
--- /dev/null
@@ -0,0 +1,4 @@
+drop table if exists roles;
+drop table if exists users_roles;
+create table roles (rolename varchar(200) not null, created_at datetime not null, rolegroup varchar(255) not null, updated_at datetime, primary key (rolename));
+create table users_roles (HJID bigint not null auto_increment, created_at datetime not null, rolename varchar(200) not null, updated_at datetime, username varchar(128) not null, primary key (HJID), unique (username, rolename));
diff --git a/services/authorization/pstore/src/main/resources/db/mysql/authorization_index.sql b/services/authorization/pstore/src/main/resources/db/mysql/authorization_index.sql
new file mode 100644 (file)
index 0000000..4f93e32
--- /dev/null
@@ -0,0 +1,9 @@
+--
+-- Copyright 20010 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.
+--
+use cspace;
+CREATE INDEX index_rolename ON roles (rolegroup);
+CREATE INDEX index_username ON users_roles (username);
+CREATE INDEX index_rolename ON users_roles (rolename);
diff --git a/services/authorization/pstore/src/main/resources/db/mysql/test_authorization.sql b/services/authorization/pstore/src/main/resources/db/mysql/test_authorization.sql
new file mode 100644 (file)
index 0000000..dfd0524
--- /dev/null
@@ -0,0 +1,18 @@
+--\r
+-- Copyright 2009 University of California at Berkeley\r
+-- Licensed under the Educational Community License (ECL), Version 2.0.\r
+-- You may not use this file except in compliance with this License.\r
+--\r
+use cspace;\r
+\r
+insert into `roles` (`rolename`, `rolegroup`, `created_at`) values ('ROLE_KERNEL', 'kernel', '2010-02-17 16:31:48');\r
+insert into `roles` (`rolename`, `rolegroup`, `created_at`) values ('ROLE_USERS', 'collections', '2010-02-17 16:31:48');\r
+insert into `roles` (`rolename`, `rolegroup`, `created_at`) values ('ROLE_COLLECTIONS_MANAGER', 'collections', '2010-02-17 16:31:48');\r
+insert into `roles` (`rolename`, `rolegroup`, `created_at`) values ('ROLE_COLLECTIONS_REGISTRAR', 'collections', '2010-02-17 16:31:48');\r
+\r
+insert into `users_roles`(`username`, `rolename`, `created_at`) values ('test', 'ROLE_ADMINISTRATOR', '2010-02-17 16:31:48');\r
+insert into `users_roles`(`username`, `rolename`, `created_at`) values ('test', 'ROLE_USERS', '2010-02-17 16:31:48');\r
+insert into `users_roles`(`username`, `rolename`, `created_at`) values ('test', 'ROLE_COLLECTIONS_MANAGER', '2010-02-17 16:31:48');\r
+\r
+insert into `users_roles`(`username`, `rolename`, `created_at`) values ('barney', 'ROLE_USERS', '2010-02-17 16:31:48');\r
+insert into `users_roles`(`username`, `rolename`, `created_at`) values ('barney', 'ROLE_COLLECTIONS_MANAGER', '2010-02-17 16:31:48');\r
diff --git a/services/authorization/pstore/src/test/resources/META-INF/persistence.xml b/services/authorization/pstore/src/test/resources/META-INF/persistence.xml
new file mode 100644 (file)
index 0000000..4039596
--- /dev/null
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<persistence version="1.0" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd
+http://java.sun.com/xml/ns/persistence/orm http://java.sun.com/xml/ns/persistence/orm_1_0.xsd" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:orm="http://java.sun.com/xml/ns/persistence/orm" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+    <persistence-unit name="org.collectionspace.services.authorization">
+        <class>org.collectionspace.services.authorization.Role</class>
+        <class>org.collectionspace.services.authorization.UserRole</class>
+        <properties>
+            <property name="hibernate.ejb.cfgfile" value="hibernate.cfg.xml"/>
+
+            <!--property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
+            <property name="hibernate.max_fetch_depth" value="3"/>
+            <property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/>
+            <property name="hibernate.connection.username" value="test"/>
+            <property name="hibernate.connection.password" value="test"/>
+            <property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/cspace"/-->
+        </properties>
+    </persistence-unit>
+</persistence>
diff --git a/services/authorization/pstore/src/test/resources/hibernate.cfg.xml b/services/authorization/pstore/src/test/resources/hibernate.cfg.xml
new file mode 100644 (file)
index 0000000..8296399
--- /dev/null
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+    Document   : hibernate.cfg.xml
+    Created on : 
+    Author     : 
+    Description:
+        Hibernate configuration file for testing and tools
+-->
+<!DOCTYPE hibernate-configuration PUBLIC
+          "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
+          "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
+<hibernate-configuration>
+    <session-factory>
+        <property name="connection.url">@DB_URL@</property>
+        <property name="connection.driver_class">@DB_DRIVER_CLASS@</property>
+        <property name="connection.username">@DB_USER@</property>
+        <property name="connection.password">@DB_PASSWORD@</property>
+        <property name="dialect">@DB_DIALECT@</property>
+        <property name="transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property>
+        <property name="current_session_context_class">thread</property>
+        <property name="hibernate.show_sql">true</property>
+    </session-factory>
+</hibernate-configuration>
diff --git a/services/authorization/service/build.xml b/services/authorization/service/build.xml
new file mode 100644 (file)
index 0000000..834a97f
--- /dev/null
@@ -0,0 +1,132 @@
+\r
+<project name="authorization.service" default="package" basedir=".">\r
+    <description>\r
+        collectionspace authorization service\r
+    </description>\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
+    <property file="${services.trunk}/build.properties" />\r
+    <property name="mvn.opts" value="" />\r
+    <property name="src" location="src"/>\r
+    <property name="authorization.jar" value="cspace-services-authz.jar"/>\r
+    <condition property="osfamily-unix">\r
+        <os family="unix" />\r
+    </condition>\r
+    <condition property="osfamily-windows">\r
+        <os family="windows" />\r
+    </condition>\r
+\r
+    <target name="init">\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
+    <target name="package-unix" if="osfamily-unix">\r
+        <exec executable="mvn" failonerror="true">\r
+            <arg value="package" />\r
+            <arg value="-Dmaven.test.skip=true" />\r
+            <arg value="-f" />\r
+            <arg value="${basedir}/pom.xml" />\r
+            <arg value="-N" />\r
+            <arg value="${mvn.opts}" />\r
+        </exec>\r
+    </target>\r
+    <target name="package-windows" if="osfamily-windows">\r
+        <exec executable="cmd" failonerror="true">\r
+            <arg value="/c" />\r
+            <arg value="mvn.bat" />\r
+            <arg value="package" />\r
+            <arg value="-Dmaven.test.skip=true" />\r
+            <arg value="-f" />\r
+            <arg value="${basedir}/pom.xml" />\r
+            <arg value="-N" />\r
+            <arg value="${mvn.opts}" />\r
+        </exec>\r
+    </target>\r
+\r
+    <target name="install" depends="install-unix,install-windows"\r
+            description="Install" />\r
+    <target name="install-unix" if="osfamily-unix">\r
+        <exec executable="mvn" failonerror="true">\r
+            <arg value="install" />\r
+            <arg value="-Dmaven.test.skip=true" />\r
+            <arg value="-f" />\r
+            <arg value="${basedir}/pom.xml" />\r
+            <arg value="-N" />\r
+            <arg value="${mvn.opts}" />\r
+        </exec>\r
+    </target>\r
+    <target name="install-windows" if="osfamily-windows">\r
+        <exec executable="cmd" failonerror="true">\r
+            <arg value="/c" />\r
+            <arg value="mvn.bat" />\r
+            <arg value="install" />\r
+            <arg value="-Dmaven.test.skip=true" />\r
+            <arg value="-f" />\r
+            <arg value="${basedir}/pom.xml" />\r
+            <arg value="-N" />\r
+            <arg value="${mvn.opts}" />\r
+        </exec>\r
+    </target>\r
+\r
+    <target name="clean" depends="clean-unix,clean-windows"\r
+            description="Delete target directories" >\r
+        <delete dir="${build}"/>\r
+    </target>\r
+    <target name="clean-unix" if="osfamily-unix">\r
+        <exec executable="mvn" failonerror="true">\r
+            <arg value="clean" />\r
+            <arg value="${mvn.opts}" />\r
+        </exec>\r
+    </target>\r
+    <target name="clean-windows" if="osfamily-windows">\r
+        <exec executable="cmd" failonerror="true">\r
+            <arg value="/c" />\r
+            <arg value="mvn.bat" />\r
+            <arg value="clean" />\r
+            <arg value="${mvn.opts}" />\r
+        </exec>\r
+    </target>\r
+\r
+    <target name="test" depends="test-unix,test-windows" description="Run tests" />\r
+    <target name="test-unix" if="osfamily-unix">\r
+        <exec executable="mvn" failonerror="true">\r
+            <arg value="test" />\r
+            <arg value="${mvn.opts}" />\r
+        </exec>\r
+    </target>\r
+    <target name="test-windows" if="osfamily-windows">\r
+        <exec executable="cmd" failonerror="true">\r
+            <arg value="/c" />\r
+            <arg value="mvn.bat" />\r
+            <arg value="test" />\r
+            <arg value="${mvn.opts}" />\r
+        </exec>\r
+    </target>\r
+\r
+    <target name="deploy" depends="install"\r
+            description="deploy authorization service in ${jboss.server.cspace}">\r
+        <copy file="${basedir}/target/${authorization.jar}" todir="${jboss.server.cspace}/lib"/>\r
+        <echo message="Check out authorization Service Configuration Guide on wiki.collectionspace.org for more details" />\r
+    </target>\r
+\r
+    <target name="undeploy"\r
+            description="undeploy authorization service from ${jboss.server.cspace}">\r
+        <delete file="${jboss.server.cspace}/lib/${authorization.jar}"/>\r
+        <echo message="Check out authorization Service Configuration Guide on wiki.collectionspace.org for more details"/>\r
+    </target>\r
+\r
+    <target name="dist"\r
+            description="generate distribution for authorization service" depends="package">\r
+        <!-- copy db scripts, etc. -->\r
+        <copy todir="${services.trunk}/${dist.server.cspace}/cspace/services">\r
+            <fileset dir="${src}/main/resources/"/>\r
+        </copy>\r
+    </target>\r
+\r
+</project>\r
diff --git a/services/authorization/service/pom.xml b/services/authorization/service/pom.xml
new file mode 100644 (file)
index 0000000..e1a8957
--- /dev/null
@@ -0,0 +1,186 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project>
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <artifactId>org.collectionspace.services.authorization</artifactId>
+        <groupId>org.collectionspace.services</groupId>
+        <version>0.6-SNAPSHOT</version>
+    </parent>
+    <groupId>org.collectionspace.services</groupId>
+    <artifactId>org.collectionspace.services.authorization.service</artifactId>
+    <packaging>jar</packaging>
+    <name>services.authorization.service</name>
+    <url>http://www.collectionspace.org</url>
+
+    <properties>
+        <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.version>3.0.0.RELEASE</spring.version>
+        <spring.security.version>3.0.2.RELEASE</spring.security.version>
+    </properties>
+
+    <dependencies>
+
+        <!-- utilities -->
+
+        <!-- slf4j not available due to classloading issues running in system classpath -->
+        <dependency>
+            <groupId>commons-logging</groupId>
+            <artifactId>commons-logging</artifactId>
+            <version>1.1.1</version>
+        </dependency>
+        <dependency>
+            <groupId>log4j</groupId>
+            <artifactId>log4j</artifactId>
+            <version>1.2.14</version>
+            <scope>provided</scope>
+        </dependency>
+
+        <!-- slf4j used for testing only -->
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-api</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-log4j12</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>4.1</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.testng</groupId>
+            <artifactId>testng</artifactId>
+            <version>5.6</version>
+            <scope>test</scope>
+        </dependency>
+        <!-- javax -->
+        <dependency>
+            <groupId>javax.security</groupId>
+            <artifactId>jaas</artifactId>
+            <version>1.0.01</version>
+            <scope>provided</scope>
+        </dependency>
+
+        <!-- jboss -->
+        <dependency>
+            <groupId>org.jboss.logging</groupId>
+            <artifactId>jboss-logging-log4j</artifactId>
+            <version>2.1.0.GA</version>
+        </dependency>
+        <dependency>
+            <groupId>jboss</groupId>
+            <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>
+        <dependency>
+            <groupId>org.springframework.security</groupId>
+            <artifactId>spring-security-config</artifactId>
+            <version>${spring.security.version}</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.security</groupId>
+            <artifactId>spring-security-acl</artifactId>
+            <version>${spring.security.version}</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.security</groupId>
+            <artifactId>spring-security-web</artifactId>
+            <version>${spring.security.version}</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-context</artifactId>
+            <version>${spring.version}</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-context-support</artifactId>
+            <version>${spring.version}</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-aop</artifactId>
+            <version>${spring.version}</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>aopalliance</groupId>
+            <artifactId>aopalliance</artifactId>
+            <version>1.0</version>
+            <scope>provided</scope>
+        </dependency>
+        <!--dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-tx</artifactId>
+            <version>${spring.version}</version>
+            <scope>provided</scope>
+        </dependency-->
+        <dependency>
+            <groupId>net.sf.ehcache</groupId>
+            <artifactId>ehcache</artifactId>
+            <version>1.6.2</version>
+            <optional>true</optional>
+        </dependency>
+        <dependency>
+            <groupId>mysql</groupId>
+            <artifactId>mysql-connector-java</artifactId>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.collectionspace.services</groupId>
+            <artifactId>org.collectionspace.services.authorization.jaxb</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+
+    </dependencies>
+
+    <build>
+        <finalName>cspace-services-authz</finalName>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-surefire-plugin</artifactId>
+                <configuration>
+                    <systemProperties>
+                        <property>
+                            <name>log4j.configuration</name>
+                            <value>file:target/test-classes/log4j.properties</value>
+                        </property>
+                        <property>
+                            <name>spring-beans-config</name>
+                            <value>applicationContext-authorization-test.xml</value>
+                        </property>
+                    </systemProperties>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <configuration>
+                    <source>1.6</source>
+                    <target>1.6</target>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+</project>
diff --git a/services/authorization/service/src/main/java/org/collectionspace/services/authorization/AuthZ.java b/services/authorization/service/src/main/java/org/collectionspace/services/authorization/AuthZ.java
new file mode 100644 (file)
index 0000000..ebea99f
--- /dev/null
@@ -0,0 +1,186 @@
+/**
+ *  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.services.authorization;
+
+import java.util.List;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.collectionspace.services.authorization.spi.CSpaceAuthorizationProvider;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+/**
+ * AuthZ is the authorization service singleton used by the services runtime
+ * @author 
+ */
+public class AuthZ {
+
+    /**
+     * volatile is used here to assume about ordering (post JDK 1.5)
+     */
+    private static volatile AuthZ self = new AuthZ();
+    private CSpaceAuthorizationProvider provider;
+    final Log log = LogFactory.getLog(AuthZ.class);
+
+    private AuthZ() {
+        setupProvider();
+    }
+
+    /**
+     *
+     * @return
+     */
+    public final static AuthZ get() {
+        return self;
+    }
+
+    private void setupProvider() {
+        String beanConfig = "applicationContext-authorization.xml";
+        //system property is only set in test environment
+        String beanConfigProp = System.getProperty("spring-beans-config");
+        if (beanConfigProp != null && !beanConfigProp.isEmpty()) {
+            beanConfig = beanConfigProp;
+        }
+        if (log.isDebugEnabled()) {
+            log.debug("reading beanConfig=" + beanConfig);
+        }
+        ClassPathXmlApplicationContext appContext = new ClassPathXmlApplicationContext(
+                new String[]{beanConfig});
+        provider = (CSpaceAuthorizationProvider) appContext.getBean("cspaceAuthorizationProvider");
+        if (log.isDebugEnabled()) {
+            log.debug("initialized the authz provider");
+        }
+    }
+
+    /**
+     * addPermissions add permissions from given permission configuration
+     * @param permission configuration
+     */
+    public void addPermissions(PermissionConfig pConfig) {
+        List<String> principals = pConfig.getRole();
+        List<String> users = pConfig.getUser();
+        principals.addAll(users);
+        List<ActionType> actions = pConfig.getAction();
+        for (ActionType action : actions) {
+            URIResourceImpl uriRes = new URIResourceImpl(pConfig.getResourceName(),
+                    action);
+            addPermission(uriRes, principals.toArray(new String[0]));
+        }
+    }
+
+    /**
+     * addPermission for given principals to access given resource
+     * -permission is retrieved from the resource
+     * @param res
+     * @param principals
+     */
+    public void addPermission(CSpaceResource res, String[] principals) {
+        CSpaceAction action = res.getAction();
+        addPermission(res, principals, action);
+    }
+
+    /**
+     * addPermission add given permission for given principals to access given resource
+     * @param res
+     * @param principals
+     * @param perm
+     */
+    public void addPermission(CSpaceResource res, String[] principals, CSpaceAction action) {
+        provider.getPermissionManager().addPermission(res, principals, action);
+        if (log.isDebugEnabled()) {
+            log.debug("added permission resource=" + res.getId() + " action=" + action.name());
+        }
+    }
+
+    /**
+     * deletePermission for given principals for given resource
+     * permission is retrieve from the resource
+     * @param res
+     * @param principals
+     */
+    public void deletePermission(CSpaceResource res, String[] principals) {
+        CSpaceAction action = res.getAction();
+        deletePermission(res, principals, action);
+    }
+
+    /**
+     * deletePermission given permission for given principals for given resource
+     * @param res
+     * @param principals
+     * @param perm
+     */
+    public void deletePermission(CSpaceResource res, String[] principals, CSpaceAction action) {
+        provider.getPermissionManager().deletePermission(res, principals, action);
+        if (log.isDebugEnabled()) {
+            log.debug("removed permission resource=" + res.getId() + " action=" + action.name());
+        }
+    }
+
+    /**
+     * isAccessAllowed check if authenticated principal is allowed to access
+     * given resource, permission is retrieved from the resource
+     * @param res
+     * @return
+     */
+    public boolean isAccessAllowed(CSpaceResource res) {
+        CSpaceAction action = res.getAction();
+        return isAccessAllowed(res, action);
+    }
+
+    /**
+     * isAccessAllowed check if authenticated principal is allowed to access
+     * given resource per given permission
+     * @param res
+     * @param perm
+     * @return
+     */
+    public boolean isAccessAllowed(CSpaceResource res, CSpaceAction action) {
+        return provider.getPermissionEvaluator().hasPermission(res, action);
+    }
+}
diff --git a/services/authorization/service/src/main/java/org/collectionspace/services/authorization/CSpaceAction.java b/services/authorization/service/src/main/java/org/collectionspace/services/authorization/CSpaceAction.java
new file mode 100644 (file)
index 0000000..5e800c4
--- /dev/null
@@ -0,0 +1,96 @@
+/**
+ *  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.services.authorization;
+
+/**
+ * CollectionSpace permission for a resource. A resource could be an entity, a
+ * procedure/activity, an attribute or an action
+ * @author 
+ */
+public enum CSpaceAction {
+
+    /**
+     * permission to create a collectionspace resource
+     */
+    CREATE,
+    /**
+     * permission to retrieve a collectionspace resource
+     */
+    READ,
+    /**
+     * permission to update a collectionspace resource
+     */
+    UPDATE,
+    /**
+     * to delete a collectionspace resource
+     */
+    DELETE,
+    /**
+     * permission to search a collectionspace service resource
+     */
+    SEARCH,
+    /**
+     * permission to execute/run a collectionspace service resource
+     */
+    RUN,
+    /**
+     * permission to start a collectionspace service activity/procedure
+     */
+    START,
+    /**
+     * permission to stop a collectionspace service activity/procedure
+     */
+    STOP,
+    /**
+     * permission to administer any collectionspace service resource, involves 
+     * all the permissions described above
+     */
+    ADMIN
+}
diff --git a/services/authorization/service/src/main/java/org/collectionspace/services/authorization/CSpaceResource.java b/services/authorization/service/src/main/java/org/collectionspace/services/authorization/CSpaceResource.java
new file mode 100644 (file)
index 0000000..ab06c7c
--- /dev/null
@@ -0,0 +1,72 @@
+/**
+ *  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.
+ */
+
+
+package org.collectionspace.services.authorization;
+
+/**
+ * CSpaceResource represents the resource to secure
+ * @author 
+ */
+public interface CSpaceResource {
+
+    public enum TYPE {
+        URI,
+        CLASS,
+        OBJECT,
+        ATTRIBUTE
+    }
+    public String getId();
+
+    public TYPE getType();
+
+    /**
+     * getAction is a conveneniece method to get corresponding action to be invoked
+     * on the resource for which permission is sought
+     * @return
+     */
+    public CSpaceAction getAction();
+}
diff --git a/services/authorization/service/src/main/java/org/collectionspace/services/authorization/CSpaceResourceImpl.java b/services/authorization/service/src/main/java/org/collectionspace/services/authorization/CSpaceResourceImpl.java
new file mode 100644 (file)
index 0000000..0058a98
--- /dev/null
@@ -0,0 +1,84 @@
+/**
+ *  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.services.authorization;
+
+/**
+ * CSpaceResourceImpl abstract resource implementation
+ * @author 
+ */
+public abstract class CSpaceResourceImpl implements CSpaceResource {
+
+    private String id;
+    private TYPE type;
+
+    public CSpaceResourceImpl() {
+    }
+
+    public CSpaceResourceImpl(String id, TYPE type) {
+        if (id == null || id.isEmpty() || type == null) {
+            throw new IllegalArgumentException("id and/or type cannot be null or empty");
+        }
+        this.id = id;
+        this.type = type;
+    }
+
+    @Override
+    public String getId() {
+        return id;
+    }
+
+    @Override
+    public TYPE getType() {
+        return type;
+    }
+
+    @Override
+    public abstract CSpaceAction getAction();
+}
diff --git a/services/authorization/service/src/main/java/org/collectionspace/services/authorization/URIResourceImpl.java b/services/authorization/service/src/main/java/org/collectionspace/services/authorization/URIResourceImpl.java
new file mode 100644 (file)
index 0000000..cc4c126
--- /dev/null
@@ -0,0 +1,171 @@
+/**
+ *  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.
+ */
+package org.collectionspace.services.authorization;
+
+import java.util.StringTokenizer;
+
+/**
+ * A security resource that represents URI and method invoked on it
+ * @author 
+ */
+public class URIResourceImpl extends CSpaceResourceImpl {
+
+    private String uri;
+    private String method;
+    private CSpaceAction action;
+
+    /**
+     * constructor that is usually called from service runtime
+     * @param uri
+     * @param method an http method
+     */
+    public URIResourceImpl(String uri, String method) {
+        super(getParent(uri) + "#" + getAction(method).toString(), TYPE.URI);
+        action = getAction(method);
+        this.uri = uri;
+        this.method = method;
+    }
+
+    /**
+     * constructor that is usually called from administrative interface
+     * @param resourceName
+     * @param actionType
+     */
+    public URIResourceImpl(String resourceName, ActionType actionType) {
+        //FIXME more validation might be needed
+        super(resourceName + "#" + getAction(actionType).toString(), TYPE.URI);
+        action = getAction(actionType);
+    }
+
+    /**
+     * @return the uri
+     */
+    public String getUri() {
+        return uri;
+    }
+
+    /**
+     * @param uri the uri to set
+     */
+    public void setUri(String uri) {
+        this.uri = uri;
+    }
+
+    /**
+     * @return the method
+     */
+    public String getMethod() {
+        return method;
+    }
+
+    /**
+     * @param method the method to set
+     */
+    public void setMethod(String method) {
+        this.method = method;
+    }
+
+    /**
+     * getAction a convenience method to get action invoked on the resource
+     */
+    @Override
+    public CSpaceAction getAction() {
+        return action;
+    }
+
+    private static String getParent(String uri) {
+        StringTokenizer stz = new StringTokenizer(uri, "/");
+        //FIXME the following ignores sub resources as well as object instances
+        return stz.nextToken();
+    }
+
+    /**
+     * getAction is a conveneniece method to get action
+     * for given HTTP method invoked on the resource
+     * @param method http method
+     * @return
+     */
+    public static CSpaceAction getAction(String method) {
+
+        if ("POST".equalsIgnoreCase(method)) {
+            return CSpaceAction.CREATE;
+        } else if ("GET".equalsIgnoreCase(method)) {
+            return CSpaceAction.READ;
+        } else if ("PUT".equalsIgnoreCase(method)) {
+            return CSpaceAction.UPDATE;
+        } else if ("DELETE".equalsIgnoreCase(method)) {
+            return CSpaceAction.DELETE;
+        }
+        throw new IllegalStateException("no method found!");
+    }
+
+    /**
+     * getAction is a convenience method to get corresponding action for
+     * given ActionType
+     * @param action
+     * @return
+     */
+    public static CSpaceAction getAction(ActionType action) {
+        if (ActionType.CREATE.equals(action)) {
+            return CSpaceAction.CREATE;
+        } else if (ActionType.READ.equals(action)) {
+            return CSpaceAction.READ;
+        } else if (ActionType.UPDATE.equals(action)) {
+            return CSpaceAction.UPDATE;
+        } else if (ActionType.DELETE.equals(action)) {
+            return CSpaceAction.DELETE;
+        } else if (ActionType.SEARCH.equals(action)) {
+            return CSpaceAction.SEARCH;
+        } else if (ActionType.ADMIN.equals(action)) {
+            return CSpaceAction.ADMIN;
+        } else if (ActionType.START.equals(action)) {
+            return CSpaceAction.START;
+        } else if (ActionType.STOP.equals(action)) {
+            return CSpaceAction.STOP;
+        }
+        throw new IllegalArgumentException("action = " + action.toString());
+    }
+}
diff --git a/services/authorization/service/src/main/java/org/collectionspace/services/authorization/spi/CSpaceAuthorizationProvider.java b/services/authorization/service/src/main/java/org/collectionspace/services/authorization/spi/CSpaceAuthorizationProvider.java
new file mode 100644 (file)
index 0000000..9ea216e
--- /dev/null
@@ -0,0 +1,45 @@
+/**
+ *  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.services.authorization.spi;
+
+/**
+ * CSpaceAuthorizationProvider acts as a main interface to access the provider
+ * specific information
+ * @author 
+ */
+public interface CSpaceAuthorizationProvider {
+
+    public String getName();
+
+    public String getVersion();
+    
+    public CSpacePermissionEvaluator getPermissionEvaluator();
+
+    public CSpacePermissionManager getPermissionManager();
+}
diff --git a/services/authorization/service/src/main/java/org/collectionspace/services/authorization/spi/CSpacePermissionEvaluator.java b/services/authorization/service/src/main/java/org/collectionspace/services/authorization/spi/CSpacePermissionEvaluator.java
new file mode 100644 (file)
index 0000000..dc483c8
--- /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.
+ *//**
+ *  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.
+ */
+
+
+package org.collectionspace.services.authorization.spi;
+
+import org.collectionspace.services.authorization.CSpaceResource;
+import org.collectionspace.services.authorization.CSpaceAction;
+
+/**
+ * Permission evaluation interface for CSpace services
+ * @author 
+ */
+public interface CSpacePermissionEvaluator {
+
+    public boolean hasPermission(CSpaceResource res, CSpaceAction perm);
+}
diff --git a/services/authorization/service/src/main/java/org/collectionspace/services/authorization/spi/CSpacePermissionManager.java b/services/authorization/service/src/main/java/org/collectionspace/services/authorization/spi/CSpacePermissionManager.java
new file mode 100644 (file)
index 0000000..2487b94
--- /dev/null
@@ -0,0 +1,40 @@
+/**
+ *  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.
+ */
+
+
+package org.collectionspace.services.authorization.spi;
+
+import org.collectionspace.services.authorization.CSpaceResource;
+import org.collectionspace.services.authorization.CSpaceAction;
+
+/**
+ * Permission management interface for CSpace services
+ * @author 
+ */
+public interface CSpacePermissionManager {
+
+    public void addPermission(CSpaceResource res, String[] principals, CSpaceAction perm);
+
+    public void deletePermission(CSpaceResource res, String[] principals, CSpaceAction perm);
+}
diff --git a/services/authorization/service/src/main/java/org/collectionspace/services/authorization/spring/CSpaceSecurityMetadataSource.java b/services/authorization/service/src/main/java/org/collectionspace/services/authorization/spring/CSpaceSecurityMetadataSource.java
new file mode 100644 (file)
index 0000000..3812e53
--- /dev/null
@@ -0,0 +1,127 @@
+/**
+ *  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.services.authorization.spring;
+
+import java.util.Collection;
+import java.util.Properties;
+import org.springframework.security.access.ConfigAttribute;
+import org.springframework.security.access.SecurityConfig;
+import org.springframework.security.web.FilterInvocation;
+import org.springframework.security.web.access.intercept.FilterInvocationSecurityMetadataSource;
+
+/**
+ *
+ * @author 
+ */
+public class CSpaceSecurityMetadataSource implements FilterInvocationSecurityMetadataSource {
+
+    private Properties urlProperties;
+
+    public Collection<ConfigAttribute> getAllConfigAttributes() {
+        return null;
+    }
+
+    public Collection<ConfigAttribute> getAttributes(Object filter)
+            throws IllegalArgumentException {
+        FilterInvocation filterInvocation = (FilterInvocation) filter;
+        String url = filterInvocation.getRequestUrl();
+
+        //get the roles for requested page from the property file
+        String urlPropsValue = urlProperties.getProperty(url);
+        StringBuilder rolesStringBuilder = new StringBuilder();
+        if (urlPropsValue != null) {
+            rolesStringBuilder.append(urlPropsValue).append(",");
+        }
+
+        if (!url.endsWith("/")) {
+            int lastSlashIndex = url.lastIndexOf("/");
+            url = url.substring(0, lastSlashIndex + 1);
+        }
+
+
+        String[] urlParts = url.split("/");
+
+        StringBuilder urlBuilder = new StringBuilder();
+        for (String urlPart : urlParts) {
+            if (urlPart.trim().length() == 0) {
+                continue;
+            }
+            urlBuilder.append("/").append(urlPart);
+            urlPropsValue = urlProperties.getProperty(urlBuilder.toString() + "/**");
+
+            if (urlPropsValue != null) {
+                rolesStringBuilder.append(urlPropsValue).append(",");
+            }
+        }
+
+        if (rolesStringBuilder.toString().endsWith(",")) {
+            rolesStringBuilder.deleteCharAt(rolesStringBuilder.length() - 1);
+        }
+
+
+        if (rolesStringBuilder.length() == 0) {
+            return null;
+        }
+
+        return SecurityConfig.createListFromCommaDelimitedString(rolesStringBuilder.toString());
+    }
+
+    public boolean supports(Class<?> arg0) {
+        return true;
+    }
+
+    public void setUrlProperties(Properties urlProperties) {
+        this.urlProperties = urlProperties;
+    }
+
+    public Properties getUrlProperties() {
+        return urlProperties;
+    }
+}
diff --git a/services/authorization/service/src/main/java/org/collectionspace/services/authorization/spring/SpringAuthorizationProvider.java b/services/authorization/service/src/main/java/org/collectionspace/services/authorization/spring/SpringAuthorizationProvider.java
new file mode 100644 (file)
index 0000000..b986bd6
--- /dev/null
@@ -0,0 +1,159 @@
+/**
+ *  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.services.authorization.spring;
+
+import java.util.ArrayList;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.collectionspace.services.authorization.CSpaceAction;
+import org.collectionspace.services.authorization.CSpaceResource;
+import org.collectionspace.services.authorization.spi.CSpaceAuthorizationProvider;
+import org.collectionspace.services.authorization.spi.CSpacePermissionEvaluator;
+import org.collectionspace.services.authorization.spi.CSpacePermissionManager;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.PermissionEvaluator;
+import org.springframework.security.acls.domain.BasePermission;
+import org.springframework.security.acls.domain.GrantedAuthoritySid;
+import org.springframework.security.acls.domain.ObjectIdentityImpl;
+import org.springframework.security.acls.model.MutableAclService;
+import org.springframework.security.acls.model.ObjectIdentity;
+import org.springframework.security.acls.model.Permission;
+import org.springframework.security.acls.model.Sid;
+
+/**
+ * SpringAuthorizationProvider Spring Security provider
+ * @author 
+ */
+public class SpringAuthorizationProvider implements CSpaceAuthorizationProvider {
+
+    final Log log = LogFactory.getLog(SpringPermissionEvaluator.class);
+    @Autowired
+    private MutableAclService providerAclService;
+    @Autowired
+    private PermissionEvaluator providerPermissionEvaluator;
+    private SpringPermissionEvaluator permissionEvaluator;
+    private SpringPermissionManager permissionManager;
+    private String version = "1.0";
+
+    public SpringAuthorizationProvider() {
+        permissionManager = new SpringPermissionManager(this);
+        permissionEvaluator = new SpringPermissionEvaluator(this);
+    }
+
+    MutableAclService getProviderAclService() {
+        return providerAclService;
+    }
+
+    public void setProviderAclService(MutableAclService mutableAclService) {
+         this.providerAclService = mutableAclService;
+        if (log.isDebugEnabled()) {
+            log.debug("mutableAclService set");
+        }
+    }
+
+    @Override
+    public String getName() {
+        return this.getClass().getSimpleName();
+    }
+
+    @Override
+    public String getVersion() {
+        return version;
+    }
+
+    PermissionEvaluator getProviderPermissionEvaluator() {
+        return providerPermissionEvaluator;
+    }
+
+    public void setProviderPermissionEvaluator(PermissionEvaluator permEval) {
+        this.providerPermissionEvaluator = permEval;
+        if (log.isDebugEnabled()) {
+            log.debug("permission evaluator set");
+        }
+    }
+
+    @Override
+    public CSpacePermissionEvaluator getPermissionEvaluator() {
+        return permissionEvaluator;
+    }
+
+    @Override
+    public CSpacePermissionManager getPermissionManager() {
+        return permissionManager;
+    }
+
+    static ObjectIdentity mapResource(CSpaceResource res) {
+        return new ObjectIdentityImpl(res.getType().toString(), Long.valueOf(res.getId().hashCode()));
+    }
+
+    static Sid[] mapPrincipal(String[] principals) {
+        ArrayList<Sid> sids = new ArrayList<Sid>();
+        for (String principal : principals) {
+            sids.add(new GrantedAuthoritySid(principal));
+        }
+        return sids.toArray(new Sid[0]);
+    }
+
+    static Permission mapPermssion(CSpaceAction perm) {
+        switch (perm) {
+            case ADMIN:
+                return BasePermission.ADMINISTRATION;
+            case CREATE:
+                return BasePermission.CREATE;
+            case READ:
+                return BasePermission.READ;
+            case UPDATE:
+                return BasePermission.WRITE;
+            case DELETE:
+                return BasePermission.DELETE;
+        }
+        return null;
+    }
+}
diff --git a/services/authorization/service/src/main/java/org/collectionspace/services/authorization/spring/SpringPermissionEvaluator.java b/services/authorization/service/src/main/java/org/collectionspace/services/authorization/spring/SpringPermissionEvaluator.java
new file mode 100644 (file)
index 0000000..2f5b6d0
--- /dev/null
@@ -0,0 +1,57 @@
+/**
+ *  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.
+ */
+package org.collectionspace.services.authorization.spring;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.collectionspace.services.authorization.CSpaceAction;
+import org.collectionspace.services.authorization.spi.CSpacePermissionEvaluator;
+
+import org.collectionspace.services.authorization.CSpaceResource;
+import org.springframework.security.access.PermissionEvaluator;
+import org.springframework.security.acls.model.Permission;
+import org.springframework.security.core.Authentication;
+import org.springframework.security.core.context.SecurityContextHolder;
+
+/**
+ * SpringPermissionEvaluator evaluates permissions in Spring Security
+ * @author 
+ */
+public class SpringPermissionEvaluator implements CSpacePermissionEvaluator {
+
+    final Log log = LogFactory.getLog(SpringPermissionEvaluator.class);
+    private SpringAuthorizationProvider provider;
+
+    SpringPermissionEvaluator(SpringAuthorizationProvider provider) {
+        this.provider = provider;
+    }
+
+    @Override
+    public boolean hasPermission(CSpaceResource res, CSpaceAction perm) {
+        PermissionEvaluator eval = provider.getProviderPermissionEvaluator();
+        Permission p = SpringAuthorizationProvider.mapPermssion(perm);
+        Authentication authToken = SecurityContextHolder.getContext().getAuthentication();
+        return eval.hasPermission(authToken, Long.valueOf(res.getId().hashCode()), res.getType().toString(), p);
+    }
+}
diff --git a/services/authorization/service/src/main/java/org/collectionspace/services/authorization/spring/SpringPermissionManager.java b/services/authorization/service/src/main/java/org/collectionspace/services/authorization/spring/SpringPermissionManager.java
new file mode 100644 (file)
index 0000000..b6ed849
--- /dev/null
@@ -0,0 +1,104 @@
+/**
+ *  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.
+ */
+
+package org.collectionspace.services.authorization.spring;
+
+import java.util.List;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.collectionspace.services.authorization.CSpaceAction;
+import org.collectionspace.services.authorization.spi.CSpacePermissionManager;
+import org.collectionspace.services.authorization.CSpaceResource;
+import org.springframework.security.acls.model.AccessControlEntry;
+import org.springframework.security.acls.model.MutableAcl;
+import org.springframework.security.acls.model.MutableAclService;
+import org.springframework.security.acls.model.NotFoundException;
+import org.springframework.security.acls.model.ObjectIdentity;
+import org.springframework.security.acls.model.Permission;
+import org.springframework.security.acls.model.Sid;
+
+/**
+ * Manages permissions in Spring Security
+ * @author 
+ */
+public class SpringPermissionManager implements CSpacePermissionManager {
+
+    final Log log = LogFactory.getLog(SpringPermissionEvaluator.class);
+    private SpringAuthorizationProvider provider;
+
+    SpringPermissionManager(SpringAuthorizationProvider provider) {
+        this.provider = provider;
+    }
+
+    @Override
+    public void addPermission(CSpaceResource res, String[] principals, CSpaceAction perm) {
+        ObjectIdentity oid = SpringAuthorizationProvider.mapResource(res);
+        Sid[] sids = SpringAuthorizationProvider.mapPrincipal(principals);
+        Permission p = SpringAuthorizationProvider.mapPermssion(perm);
+        for (Sid sid : sids) {
+            addPermission(oid, sid, p);
+        }
+    }
+
+    private void addPermission(ObjectIdentity oid, Sid recipient, Permission permission) {
+        MutableAcl acl;
+        MutableAclService mutableAclService = provider.getProviderAclService();
+        try {
+            acl = (MutableAcl) mutableAclService.readAclById(oid);
+        } catch (NotFoundException nfe) {
+            acl = mutableAclService.createAcl(oid);
+        }
+
+        acl.insertAce(acl.getEntries().size(), permission, recipient, true);
+        mutableAclService.updateAcl(acl);
+
+    }
+
+    @Override
+    public void deletePermission(CSpaceResource res, String[] principals, CSpaceAction perm) {
+        ObjectIdentity oid = SpringAuthorizationProvider.mapResource(res);
+        Sid[] sids = SpringAuthorizationProvider.mapPrincipal(principals);
+        Permission p = SpringAuthorizationProvider.mapPermssion(perm);
+        for (Sid sid : sids) {
+            deletePermission(oid, sid, p);
+        }
+    }
+
+    private void deletePermission(ObjectIdentity oid, Sid recipient, Permission permission) {
+
+        MutableAclService mutableAclService = provider.getProviderAclService();
+        MutableAcl acl = (MutableAcl) mutableAclService.readAclById(oid);
+
+        // Remove all permissions associated with this particular recipient (string equality to KISS)
+        List<AccessControlEntry> entries = acl.getEntries();
+
+        for (int i = 0; i < entries.size(); i++) {
+            if (entries.get(i).getSid().equals(recipient)
+                    && entries.get(i).getPermission().equals(permission)) {
+                acl.deleteAce(i);
+            }
+        }
+        mutableAclService.updateAcl(acl);
+    }
+}
diff --git a/services/authorization/service/src/main/resources/applicationContext-authorization.xml b/services/authorization/service/src/main/resources/applicationContext-authorization.xml
new file mode 100644 (file)
index 0000000..cd22bcd
--- /dev/null
@@ -0,0 +1,88 @@
+<!--
+    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:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:sec="http://www.springframework.org/schema/security"
+       xmlns:tx="http://www.springframework.org/schema/tx"
+       xmlns:util="http://www.springframework.org/schema/util"
+       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.xsd
+       http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
+       http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">
+
+    <!-- application context containing the ACL beans. -->
+
+    <bean id="expressionHandler" class="org.springframework.security.access.expression.method.DefaultMethodSecurityExpressionHandler">
+        <property name="permissionEvaluator" ref="permissionEvaluator"/>
+    </bean>
+
+    <bean id="permissionEvaluator" class="org.springframework.security.acls.AclPermissionEvaluator">
+        <constructor-arg ref="aclService"/>
+    </bean>
+
+    <bean id="aclService" class="org.springframework.security.acls.jdbc.JdbcMutableAclService">
+        <constructor-arg ref="dataSource"/>
+        <constructor-arg ref="lookupStrategy"/>
+        <constructor-arg ref="aclCache"/>
+        <property name="classIdentityQuery" value="SELECT @@IDENTITY"/>
+        <property name="sidIdentityQuery" value="SELECT @@IDENTITY"/>
+    </bean>
+
+    <bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
+        <property name="jndiName" value="CspaceDS"/>
+    </bean>
+
+    <bean id="lookupStrategy" class="org.springframework.security.acls.jdbc.BasicLookupStrategy">
+        <constructor-arg ref="dataSource"/>
+        <constructor-arg ref="aclCache"/>
+        <constructor-arg>
+            <bean class="org.springframework.security.acls.domain.AclAuthorizationStrategyImpl">
+                <constructor-arg>
+                    <list>
+                        <bean class="org.springframework.security.core.authority.GrantedAuthorityImpl">
+                            <constructor-arg value="ROLE_ADMINISTRATOR"/>
+                        </bean>
+                        <bean class="org.springframework.security.core.authority.GrantedAuthorityImpl">
+                            <constructor-arg value="ROLE_ADMINISTRATOR"/>
+                        </bean>
+                        <bean class="org.springframework.security.core.authority.GrantedAuthorityImpl">
+                            <constructor-arg value="ROLE_ADMINISTRATOR"/>
+                        </bean>
+                    </list>
+                </constructor-arg>
+            </bean>
+        </constructor-arg>
+        <constructor-arg>
+            <bean class="org.springframework.security.acls.domain.ConsoleAuditLogger"/>
+        </constructor-arg>
+    </bean>
+
+    <bean id="aclCache" class="org.springframework.security.acls.domain.EhCacheBasedAclCache">
+        <constructor-arg>
+            <bean class="org.springframework.cache.ehcache.EhCacheFactoryBean">
+                <property name="cacheManager">
+                    <bean class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean"/>
+                </property>
+                <property name="cacheName" value="aclCache"/>
+            </bean>
+        </constructor-arg>
+    </bean>
+
+
+    <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
+        <property name="dataSource" ref="dataSource"/>
+    </bean>
+
+    <tx:annotation-driven transaction-manager="transactionManager" />
+
+    <bean id="cspaceAuthorizationProvider" class="org.collectionspace.services.authorization.spring.SpringAuthorizationProvider">
+        <property name="providerAclService" ref="aclService"/>
+        <property name="providerPermissionEvaluator" ref="permissionEvaluator"/>
+    </bean>
+</beans>
diff --git a/services/authorization/service/src/test/java/org/collectionspace/services/authorization/test/AuthorizationSeedTest.java b/services/authorization/service/src/test/java/org/collectionspace/services/authorization/test/AuthorizationSeedTest.java
new file mode 100644 (file)
index 0000000..06e9be7
--- /dev/null
@@ -0,0 +1,205 @@
+/**
+ *  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.services.authorization.test;
+
+import java.io.File;
+import java.io.InputStream;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.HashSet;
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.Marshaller;
+import javax.xml.bind.Unmarshaller;
+import org.collectionspace.services.authorization.ActionType;
+import org.collectionspace.services.authorization.AuthZ;
+import org.collectionspace.services.authorization.PermissionConfig;
+import org.collectionspace.services.authorization.EffectType;
+import org.collectionspace.services.authorization.PermissionConfigList;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
+import org.springframework.security.core.Authentication;
+import org.springframework.security.core.GrantedAuthority;
+import org.springframework.security.core.authority.GrantedAuthorityImpl;
+import org.springframework.security.core.context.SecurityContextHolder;
+import org.springframework.transaction.TransactionDefinition;
+import org.springframework.transaction.TransactionStatus;
+import org.springframework.transaction.support.DefaultTransactionDefinition;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+
+/**
+ *
+ * @author 
+ */
+public class AuthorizationSeedTest {
+
+    final Logger logger = LoggerFactory.getLogger(AuthorizationSeedTest.class);
+
+    /**
+     * Returns the name of the currently running test.
+     *
+     * Note: although the return type is listed as Object[][],
+     * this method instead returns a String.
+     *
+     * @param   m  The currently running test method.
+     *
+     * @return  The name of the currently running test method.
+     */
+    @DataProvider(name = "testName")
+    public static Object[][] testName(Method m) {
+        return new Object[][]{
+                    new Object[]{m.getName()}
+                };
+    }
+
+    @BeforeClass(alwaysRun = true)
+    public void seedData() {
+        ClassPathXmlApplicationContext appContext = new ClassPathXmlApplicationContext(
+                new String[]{"applicationContext-authorization-test.xml"});
+        GrantedAuthority gauth = new GrantedAuthorityImpl("ROLE_ADMINISTRATOR");
+        HashSet<GrantedAuthority> gauths = new HashSet<GrantedAuthority>();
+        gauths.add(gauth);
+        Authentication authRequest = new UsernamePasswordAuthenticationToken("test", "test", gauths);
+
+        SecurityContextHolder.getContext().setAuthentication(authRequest);
+        AuthZ authZ = AuthZ.get();
+
+        org.springframework.jdbc.datasource.DataSourceTransactionManager txManager =
+                (org.springframework.jdbc.datasource.DataSourceTransactionManager) appContext.getBean("transactionManager");
+        DefaultTransactionDefinition def = new DefaultTransactionDefinition();
+        // explicitly setting the transaction name is something that can only be done programmatically
+        def.setName("seedData");
+        def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
+
+        TransactionStatus status = txManager.getTransaction(def);
+        try {
+            seedRoles();
+            seedPermissions();
+        } catch (Exception ex) {
+            txManager.rollback(status);
+            ex.printStackTrace();
+            throw new RuntimeException(ex);
+        }
+        txManager.commit(status);
+
+    }
+
+    public void seedRoles() throws Exception {
+    }
+
+    public void seedPermissions() throws Exception {
+
+        PermissionConfigList pcList =
+                (PermissionConfigList) fromFile(PermissionConfigList.class,
+                "./test-data/test-permissions.xml");
+        AuthZ authZ = AuthZ.get();
+        for (PermissionConfig pc : pcList.getPermission()) {
+            if(logger.isDebugEnabled()) {
+                logger.debug("adding permission for res=" + pc.getResourceName());
+            }
+            authZ.addPermissions(pc);
+        }
+    }
+
+    private void genPermissions() {
+        PermissionConfigList pcList = new PermissionConfigList();
+        ArrayList<PermissionConfig> apcList = new ArrayList<PermissionConfig>();
+        pcList.setPermission(apcList);
+        PermissionConfig pc = new PermissionConfig();
+        pc.setResourceName("accounts");
+        pc.setEffect(EffectType.PERMIT);
+        ArrayList<String> roles = new ArrayList<String>();
+        roles.add("ROLE_USERS");
+        roles.add("ROLE_ADMINISTRATOR");
+        pc.setRole(roles);
+        ArrayList<ActionType> actions = new ArrayList<ActionType>();
+        actions.add(ActionType.CREATE);
+        actions.add(ActionType.READ);
+        actions.add(ActionType.UPDATE);
+        actions.add(ActionType.DELETE);
+        pc.setAction(actions);
+        apcList.add(pc);
+        toFile(pcList, PermissionConfigList.class, "./target/test-permissions.xml");
+
+    }
+
+    private void toFile(Object o, Class jaxbClass, String fileName) {
+        File f = new File(fileName);
+        try {
+            JAXBContext jc = JAXBContext.newInstance(jaxbClass);
+            Marshaller m = jc.createMarshaller();
+            m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT,
+                    Boolean.TRUE);
+            m.marshal(o, f);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    private Object fromFile(Class jaxbClass, String fileName) throws Exception {
+        ClassLoader tccl = Thread.currentThread().getContextClassLoader();
+        InputStream is = tccl.getResourceAsStream(fileName);
+        JAXBContext context = JAXBContext.newInstance(jaxbClass);
+        Unmarshaller unmarshaller = context.createUnmarshaller();
+        //note: setting schema to null will turn validator off
+        unmarshaller.setSchema(null);
+        return jaxbClass.cast(unmarshaller.unmarshal(is));
+    }
+
+    @Test(dataProvider = "testName", dataProviderClass = AuthorizationSeedTest.class)
+    public void test(String testName) {
+        if (logger.isDebugEnabled()) {
+            logger.debug(testName);
+        }
+    }
+}
diff --git a/services/authorization/service/src/test/resources/applicationContext-authorization-test.xml b/services/authorization/service/src/test/resources/applicationContext-authorization-test.xml
new file mode 100644 (file)
index 0000000..d9f03ee
--- /dev/null
@@ -0,0 +1,92 @@
+<!--
+    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:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:sec="http://www.springframework.org/schema/security"
+       xmlns:tx="http://www.springframework.org/schema/tx"
+       xmlns:util="http://www.springframework.org/schema/util"
+       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.xsd
+       http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
+       http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">
+
+
+    <!-- application context containing the ACL beans. -->
+
+    <bean id="expressionHandler" class="org.springframework.security.access.expression.method.DefaultMethodSecurityExpressionHandler">
+        <property name="permissionEvaluator" ref="permissionEvaluator"/>
+    </bean>
+
+    <bean id="permissionEvaluator" class="org.springframework.security.acls.AclPermissionEvaluator">
+        <constructor-arg ref="aclService"/>
+    </bean>
+
+    <bean id="aclService" class="org.springframework.security.acls.jdbc.JdbcMutableAclService">
+        <constructor-arg ref="dataSource"/>
+        <constructor-arg ref="lookupStrategy"/>
+        <constructor-arg ref="aclCache"/>
+        <property name="classIdentityQuery" value="SELECT @@IDENTITY"/>
+        <property name="sidIdentityQuery" value="SELECT @@IDENTITY"/>
+    </bean>
+
+    <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
+        <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
+        <property name="url" value="jdbc:mysql://localhost:3306/cspace"/>
+        <property name="username" value="test"/>
+        <property name="password" value="test"/>
+    </bean>
+
+    <bean id="lookupStrategy" class="org.springframework.security.acls.jdbc.BasicLookupStrategy">
+        <constructor-arg ref="dataSource"/>
+        <constructor-arg ref="aclCache"/>
+        <constructor-arg>
+            <bean class="org.springframework.security.acls.domain.AclAuthorizationStrategyImpl">
+                <constructor-arg>
+                    <list>
+                        <bean class="org.springframework.security.core.authority.GrantedAuthorityImpl">
+                            <constructor-arg value="ROLE_ADMINISTRATOR"/>
+                        </bean>
+                        <bean class="org.springframework.security.core.authority.GrantedAuthorityImpl">
+                            <constructor-arg value="ROLE_ADMINISTRATOR"/>
+                        </bean>
+                        <bean class="org.springframework.security.core.authority.GrantedAuthorityImpl">
+                            <constructor-arg value="ROLE_ADMINISTRATOR"/>
+                        </bean>
+                    </list>
+                </constructor-arg>
+            </bean>
+        </constructor-arg>
+        <constructor-arg>
+            <bean class="org.springframework.security.acls.domain.ConsoleAuditLogger"/>
+        </constructor-arg>
+    </bean>
+
+    <bean id="aclCache" class="org.springframework.security.acls.domain.EhCacheBasedAclCache">
+        <constructor-arg>
+            <bean class="org.springframework.cache.ehcache.EhCacheFactoryBean">
+                <property name="cacheManager">
+                    <bean class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean"/>
+                </property>
+                <property name="cacheName" value="aclCache"/>
+            </bean>
+        </constructor-arg>
+    </bean>
+
+
+    <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
+        <property name="dataSource" ref="dataSource"/>
+    </bean>
+
+    <tx:annotation-driven transaction-manager="transactionManager" />
+
+    <bean id="cspaceAuthorizationProvider" class="org.collectionspace.services.authorization.spring.SpringAuthorizationProvider">
+        <property name="providerAclService" ref="aclService"/>
+        <property name="providerPermissionEvaluator" ref="permissionEvaluator"/>
+    </bean>
+</beans>
similarity index 92%
rename from services/authentication/pstore/src/test/resources/log4j.properties
rename to services/authorization/service/src/test/resources/log4j.properties
index 5d288d87d8e3024d3b87bf197cb5fab920725791..18c510350fd16aa0b59d63d387ee5634a4d3fea1 100644 (file)
@@ -20,4 +20,4 @@ log4j.appender.R.layout.ConversionPattern=%d %-5p [%t] [%c:%L] %m%n
 log4j.logger.org.collectionspace=DEBUG\r
 log4j.logger.org.apache=INFO\r
 log4j.logger.httpclient=INFO\r
-log4j.logger.org.jboss.resteasy=WARN\r
+log4j.logger.org.jboss.resteasy=INFO\r
diff --git a/services/authorization/service/src/test/resources/test-data/test-permissions.xml b/services/authorization/service/src/test/resources/test-data/test-permissions.xml
new file mode 100644 (file)
index 0000000..3ff219a
--- /dev/null
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<ns2:permission_config_list xmlns:ns2="http://collectionspace.org/services/authorization">
+    <permission>
+        <resourceName>accounts</resourceName>
+        <action>CREATE</action>
+        <action>READ</action>
+        <action>UPDATE</action>
+        <action>DELETE</action>
+        <role>ROLE_ADMINISTRATOR</role>
+        <effect>PERMIT</effect>
+    </permission>
+    <permission>
+        <resourceName>collectionobjects</resourceName>
+        <action>CREATE</action>
+        <action>READ</action>
+        <action>UPDATE</action>
+        <action>DELETE</action>
+        <role>ROLE_USERS</role>
+        <role>ROLE_ADMINISTRATOR</role>
+        <effect>PERMIT</effect>
+    </permission>
+</ns2:permission_config_list>
index a5d3717d2f31665c9e5b72bdbc00567487e6805d..4b2377044cbf122de88048f12e8a8af064d40096 100644 (file)
     <target name="gen_ddl"\r
             description="generate service-specific tables(s), indices, etc.">\r
         <ant antfile="authentication/build.xml" target="gen_ddl" inheritAll="false"/>\r
+        <ant antfile="authorization/build.xml" target="gen_ddl" inheritAll="false"/>\r
         <ant antfile="account/build.xml" target="gen_ddl" inheritAll="false"/>\r
     </target>\r
 \r
     <target name="create_db"\r
             description="create service-specific tables(s), indices, etc.">\r
         <ant antfile="authentication/build.xml" target="create_db" inheritAll="false"/>\r
+        <ant antfile="authorization/build.xml" target="create_db" inheritAll="false"/>\r
         <ant antfile="account/build.xml" target="create_db" inheritAll="false"/>\r
         <ant antfile="id/build.xml" target="create_db" inheritAll="false"/>\r
     </target>\r
     <target name="deploy" depends="install"\r
             description="deploy services in ${jboss.server.cspace}">\r
         <ant antfile="authentication/build.xml" target="deploy" inheritAll="false"/>\r
+        <ant antfile="authorization/build.xml" target="deploy" inheritAll="false"/>\r
         <ant antfile="common/build.xml" target="deploy" inheritAll="false"/>\r
         <ant antfile="account/build.xml" target="deploy" inheritAll="false"/>\r
         <ant antfile="relation/build.xml" target="deploy" inheritAll="false"/>\r
         <ant antfile="relation/build.xml" target="undeploy" inheritAll="false"/>\r
         <ant antfile="account/build.xml" target="undeploy" inheritAll="false"/>\r
         <ant antfile="common/build.xml" target="undeploy" inheritAll="false"/>\r
+        <ant antfile="authorization/build.xml" target="undeploy" inheritAll="false"/>\r
         <ant antfile="authentication/build.xml" target="undeploy" inheritAll="false"/>\r
     </target>\r
 \r
     <target name="dist" depends="doc"\r
             description="create distribution for services">\r
         <ant antfile="authentication/build.xml" target="dist" inheritAll="false"/>\r
+        <ant antfile="authorization/build.xml" target="dist" inheritAll="false"/>\r
+        <ant antfile="account/build.xml" target="dist" inheritAll="false"/>\r
         <ant antfile="common/build.xml" target="dist" inheritAll="false"/>\r
         <ant antfile="relation/build.xml" target="dist" inheritAll="false"/>\r
         <ant antfile="id/build.xml" target="dist" inheritAll="false"/>\r
         <ant antfile="organization/build.xml" target="dist_installer" inheritAll="false"/>\r
         <ant antfile="person/build.xml" target="dist_installer" inheritAll="false"/>\r
         <!--\r
+        <ant antfile="account/build.xml" target="dist_installer" inheritAll="false"/>\r
         <ant antfile="common/build.xml" target="dist_installer" inheritAll="false"/>\r
+        <ant antfile="authorization/build.xml" target="dist_installer" inheritAll="false"/>\r
         <ant antfile="authentication/build.xml" target="dist_installer" inheritAll="false"/>\r
         <ant antfile="relation/build.xml" target="dist_installer" inheritAll="false"/>\r
         <ant antfile="intake/build.xml" target="dist_installer" inheritAll="false"/>\r
index 162e7875fc65256d7b79ab00b111d4960e835d00..ba70241114a586887d3918800ae59e7c3f88c691 100644 (file)
@@ -143,7 +143,7 @@ public class ServiceLayerTest {
         }
     }
 
-    @Test
+//    @Test
     public void serviceSecure() {
         String url = serviceClient.getBaseURL() + "collectionobjects";
         GetMethod method = new GetMethod(url);
index db5b9669d6fc11f9b498b726fede6030d18ff0dc..d08e4b2bdc9868f09ec056dc0b0751353a36e6f4 100644 (file)
 
     <target name="undeploy"
             description="undeploy common elements from ${jboss.server.cspace}">
+        <antcall target="undeploy_spring" />
         <copy tofile="${jboss.server.cspace}/conf/jboss-log4j.xml"
               file="${jboss.server.cspace}/conf/jboss-log4j.xml.org"
               overwrite="true" failonerror="false" />
         <delete failonerror="false" dir="${jboss.server.cspace}/cspace/config/services"/>
     </target>
 
+
+    <target name="undeploy_spring"
+            description="undeploy spring binaries from ${jboss.server.cspace}">
+        <delete>
+            <fileset dir="${jboss.server.cspace}/lib" includes="org.springframework.*.jar"/>
+            <fileset dir="${jboss.server.cspace}/lib" includes="spring-security*.jar"/>
+        </delete>
+    </target>
+
     <target name="dist_jpa"
             description="dist jpa binaries in ${dist.server.cspace}">
         <copy todir="${services.trunk}/${dist.server.cspace}/lib">
diff --git a/services/common/lib/spring/aopalliance-1.0.jar b/services/common/lib/spring/aopalliance-1.0.jar
new file mode 100644 (file)
index 0000000..578b1a0
Binary files /dev/null and b/services/common/lib/spring/aopalliance-1.0.jar differ
diff --git a/services/common/lib/spring/ehcache-1.6.2.jar b/services/common/lib/spring/ehcache-1.6.2.jar
new file mode 100644 (file)
index 0000000..85a0ab4
Binary files /dev/null and b/services/common/lib/spring/ehcache-1.6.2.jar differ
diff --git a/services/common/lib/spring/org.springframework.context.support-3.0.0.BUILD-20100208195804.jar b/services/common/lib/spring/org.springframework.context.support-3.0.0.BUILD-20100208195804.jar
new file mode 100644 (file)
index 0000000..9c05c05
Binary files /dev/null and b/services/common/lib/spring/org.springframework.context.support-3.0.0.BUILD-20100208195804.jar differ
diff --git a/services/common/lib/spring/org.springframework.transaction-3.0.0.RELEASE.jar b/services/common/lib/spring/org.springframework.transaction-3.0.0.RELEASE.jar
new file mode 100644 (file)
index 0000000..c044810
Binary files /dev/null and b/services/common/lib/spring/org.springframework.transaction-3.0.0.RELEASE.jar differ
similarity index 80%
rename from services/common/lib/spring/spring-security-acl-3.0.1.RELEASE.jar
rename to services/common/lib/spring/spring-security-acl-3.0.2.RELEASE.jar
index 9f04e1ee4970e915ddbd524c4dc9ea9eb4760148..59d5c540590a90be5d999e245708cc4868513267 100644 (file)
Binary files a/services/common/lib/spring/spring-security-acl-3.0.1.RELEASE.jar and b/services/common/lib/spring/spring-security-acl-3.0.2.RELEASE.jar differ
similarity index 78%
rename from services/common/lib/spring/spring-security-config-3.0.1.RELEASE.jar
rename to services/common/lib/spring/spring-security-config-3.0.2.RELEASE.jar
index 9a004f291776195a1b35774e1162e8f737342749..7e52d4b74f08a90e31208cd4fe0fc0f1eb3200a2 100644 (file)
Binary files a/services/common/lib/spring/spring-security-config-3.0.1.RELEASE.jar and b/services/common/lib/spring/spring-security-config-3.0.2.RELEASE.jar differ
similarity index 77%
rename from services/common/lib/spring/spring-security-core-3.0.1.RELEASE.jar
rename to services/common/lib/spring/spring-security-core-3.0.2.RELEASE.jar
index f35b66cf8d5bc9f271a9d929c41722fe4115ab02..2ae9c525abc48950dd9709fbf2241dbccf92a267 100644 (file)
Binary files a/services/common/lib/spring/spring-security-core-3.0.1.RELEASE.jar and b/services/common/lib/spring/spring-security-core-3.0.2.RELEASE.jar differ
similarity index 67%
rename from services/common/lib/spring/spring-security-web-3.0.1.RELEASE.jar
rename to services/common/lib/spring/spring-security-web-3.0.2.RELEASE.jar
index b6edf0c1cc167ab3bc0178049f7816bcbd7dc25b..a2d7389259d46b0ad9d1b84ca86f7d112fe786fa 100644 (file)
Binary files a/services/common/lib/spring/spring-security-web-3.0.1.RELEASE.jar and b/services/common/lib/spring/spring-security-web-3.0.2.RELEASE.jar differ
index c306b51ba73978629f6b41b0e37c869b1cc93934..3b32cf3ae871cd074b0ef0ce5567398a8a61db40 100644 (file)
@@ -13,6 +13,7 @@
     <packaging>jar</packaging>\r
 \r
     <dependencies>\r
+\r
         <!-- CollectionSpace dependencies -->\r
         <dependency>\r
             <groupId>org.collectionspace.services</groupId>\r
             <version>${project.version}</version>\r
             <scope>provided</scope>\r
         </dependency>        \r
+        <dependency>\r
+            <groupId>org.collectionspace.services</groupId>\r
+            <artifactId>org.collectionspace.services.authorization.service</artifactId>\r
+            <version>${project.version}</version>\r
+            <scope>provided</scope>\r
+        </dependency>\r
+\r
         <!-- Utilities -->\r
+\r
         <dependency>\r
             <groupId>junit</groupId>\r
             <artifactId>junit</artifactId>\r
             <groupId>org.slf4j</groupId>\r
             <artifactId>slf4j-log4j12</artifactId>\r
         </dependency>\r
+        <dependency>\r
+            <groupId>log4j</groupId>\r
+            <artifactId>log4j</artifactId>\r
+            <version>1.2.14</version>\r
+            <scope>provided</scope>\r
+        </dependency>\r
+        <dependency>\r
+            <groupId>junit</groupId>\r
+            <artifactId>junit</artifactId>\r
+            <version>4.1</version>\r
+            <scope>test</scope>\r
+        </dependency>\r
+\r
         <!-- javax -->\r
         <dependency>\r
             <groupId>javax.servlet</groupId>\r
index 8fb037eb19d6e90459b5679c2dec85976bd8c4c6..ee2fea60d7461bef7b7ede918bafdc9ed5a80e4a 100644 (file)
@@ -1,28 +1,28 @@
 <?xml version="1.0" encoding="UTF-8"?><!-- ===================================================================== --><!--                                                                       --><!--  Log4j Configuration                                                  --><!--                                                                       --><!-- ===================================================================== --><!-- $Id: jboss-log4j.xml 75507 2008-07-08 20:15:07Z stan.silvert@jboss.com $ --><!--
    | For more configuration infromation and examples see the Jakarta Log4j
    | owebsite: http://jakarta.apache.org/log4j
- --><!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+--><!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
 <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false" threshold="null">
 
-   <!-- ================================= -->
+    <!-- ================================= -->
    <!-- Preserve messages in a local file -->
    <!-- ================================= -->
 
    <!-- A time/date based rolling appender -->
-   <appender name="FILE"
-   class="org.jboss.logging.appender.DailyRollingFileAppender">
-     <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
-     <param name="File" value="${jboss.server.log.dir}/server.log"/>
-     <param name="Append" value="false"/>
-     <param name="DatePattern" value="'.'yyyy-MM-dd"/>
-     <param name="Threshold" value="INFO"/>
-     <layout class="org.apache.log4j.PatternLayout">
-       <param name="ConversionPattern" value="%d %-5p [%c] %m%n"/>
-     </layout>
-   </appender>
-
-
-   <!-- A size based file rolling appender
+    <appender name="FILE"
+              class="org.jboss.logging.appender.DailyRollingFileAppender">
+        <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
+        <param name="File" value="${jboss.server.log.dir}/server.log"/>
+        <param name="Append" value="false"/>
+        <param name="DatePattern" value="'.'yyyy-MM-dd"/>
+        <param name="Threshold" value="INFO"/>
+        <layout class="org.apache.log4j.PatternLayout">
+            <param name="ConversionPattern" value="%d %-5p [%c] %m%n"/>
+        </layout>
+    </appender>
+
+
+    <!-- A size based file rolling appender
    <appender name="FILE" class="org.jboss.logging.appender.RollingFileAppender">
      <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
      <param name="File" value="${jboss.server.log.dir}/server.log"/>
@@ -32,7 +32,7 @@
 
      <layout class="org.apache.log4j.PatternLayout">
        <param name="ConversionPattern" value="%d %-5p [%c] %m%n"/>
-     </layout>     
+     </layout>
    </appender>
    -->
 
    <!-- Append messages to the console -->
    <!-- ============================== -->
 
-   <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
-      <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
-      <param name="Target" value="System.out"/>
-      <param name="Threshold" value="INFO"/>
+    <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
+        <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
+        <param name="Target" value="System.out"/>
+        <param name="Threshold" value="INFO"/>
 
-      <layout class="org.apache.log4j.PatternLayout">
-         <!-- The default pattern: Date Priority [Category] Message\n -->
-         <param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{1}] %m%n"/>
-      </layout>
-   </appender>
-  
-   <!-- ====================== -->
+        <layout class="org.apache.log4j.PatternLayout">
+            <!-- The default pattern: Date Priority [Category] Message\n -->
+            <param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{1}] %m%n"/>
+        </layout>
+    </appender>
+
+    <!-- ====================== -->
    <!-- More Appender examples -->
    <!-- ====================== -->
 
    <!--  Emit events as JMX notifications
    <appender name="JMX" class="org.jboss.monitor.services.JMXNotificationAppender">
       <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
-      
+
       <param name="Threshold" value="WARN"/>
       <param name="ObjectName" value="jboss.system:service=Logging,type=JMXNotificationAppender"/>
-      
+
       <layout class="org.apache.log4j.PatternLayout">
          <param name="ConversionPattern" value="%d %-5p [%c] %m"/>
       </layout>
    -->
 
    <!-- collectionspace appender -->
-   <appender name="CSLOG" class="org.jboss.logging.appender.FileAppender">
-      <errorHandler  class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
-     <param name="Append" value="false"/>
-     <param name="DatePattern" value="'.'yyyy-MM-dd"/>
-      <param name="File" value="${jboss.server.log.dir}/collectionspace.log"/>
-      <layout class="org.apache.log4j.PatternLayout">
-         <param name="ConversionPattern" value="%d %-5p [%t] [%c:%L] %m%n"/>
-      </layout>
-            <!--filter class="org.jboss.logging.filter.TCLFilter">
+    <appender name="CSLOG" class="org.jboss.logging.appender.DailyRollingFileAppender">
+        <errorHandler  class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
+        <param name="Append" value="false"/>
+        <param name="DatePattern" value="'.'yyyy-MM-dd"/>
+        <param name="File" value="${jboss.server.log.dir}/collectionspace.log"/>
+        <layout class="org.apache.log4j.PatternLayout">
+            <param name="ConversionPattern" value="%d %-5p [%t] [%c:%L] %m%n"/>
+        </layout>
+        <!--filter class="org.jboss.logging.filter.TCLFilter">
          <param name="AcceptOnMatch" value="true"/>
          <param name="DeployURL" value="cspace-services.war"/>
-      </filter> 
+      </filter>
       <filter class="org.apache.log4j.varia.DenyAllFilter"></filter-->
-   </appender>
 
+    </appender>
 
-   
-   <!-- ================ -->
+
+
+    <!-- ================ -->
    <!-- Limit categories -->
    <!-- ================ -->
-   
+
    <!-- Limit the org.apache category to INFO as its DEBUG is verbose -->
     <category name="org.apache" additivity="true">
-      <priority value="INFO"/>
-   </category>
-   
-      <!-- Limit JBoss categories
+        <priority value="INFO"/>
+    </category>
+
+    <!-- enable catalina.core to debug spring bean configuration -->
+    <category name="org.apache.catalina.core" additivity="true">
+        <priority value="INFO"/>
+    </category>
+    
+    <!-- Limit JBoss categories
    <category name="org.jboss">
       <priority value="INFO"/>
    </category>
    -->
     <category name="org.jboss.security.auth">
-    <priority value="INFO"/>
+        <priority value="INFO"/>
     </category>
     <category name="com.arjuna"><priority value="INFO"/></category>
     <category name="org.jboss.ejb3"><priority value="INFO"/></category>
     <category name="org.jboss.ejb3.cache.simple.StatefulSessionFilePersistenceManager"><priority value="INFO"/></category>
     <category name="org.jboss.seam">
-    <priority value="INFO"/>
+        <priority value="INFO"/>
     </category>
     <category name="org.jboss.seam.contexts.Contexts"><priority value="WARN"/></category>
     <category name="org.jboss.seam.contexts.Lifecycle"><priority value="WARN"/></category>
     <category name="javax.enterprise.resource.webcontainer.jsf.renderkit"><priority value="INFO"/></category>
     <category name="javax.enterprise.resource.webcontainer.jsf.application"><priority value="INFO"/></category>
     <category name="javax.enterprise.resource.webcontainer.jsf.lifecycle"><priority value="INFO"/></category>
-    
-   <!-- Limit the jacorb category to WARN as its INFO is verbose -->
-   <category name="jacorb" additivity="true">
-      <priority value="WARN"/>
-   </category>
-   
-   <!-- Limit the org.jgroups category to WARN as its INFO is verbose -->
-   <category name="org.jgroups" additivity="true">
-      <priority value="WARN"/>
-   </category>
-   
-   <!-- Limit the org.quartz category to INFO as its DEBUG is verbose -->
-   <category name="org.quartz" additivity="true">
-      <priority value="INFO"/>
-   </category>
 
-   <!-- Limit JSF logging to DEBUG.  FINER and FINEST will not be logged -->
-   <category name="javax.enterprise.resource.webcontainer.jsf" additivity="true">
-      <priority value="INFO"/>
-   </category>
-                
+    <!-- Limit the jacorb category to WARN as its INFO is verbose -->
+    <category name="jacorb" additivity="true">
+        <priority value="WARN"/>
+    </category>
+
+    <!-- Limit the org.jgroups category to WARN as its INFO is verbose -->
+    <category name="org.jgroups" additivity="true">
+        <priority value="WARN"/>
+    </category>
+
+    <!-- Limit the org.quartz category to INFO as its DEBUG is verbose -->
+    <category name="org.quartz" additivity="true">
+        <priority value="INFO"/>
+    </category>
+
+    <!-- Limit JSF logging to DEBUG.  FINER and FINEST will not be logged -->
+    <category name="javax.enterprise.resource.webcontainer.jsf" additivity="true">
+        <priority value="INFO"/>
+    </category>
 
 
-   <!-- Limit the JSR77 categories -->
-   <category name="org.jboss.management" additivity="true">
-      <priority value="INFO"/>
-   </category>
 
-   <!-- Show the evolution of the DataSource pool in the logs [inUse/Available/Max]
+    <!-- Limit the JSR77 categories -->
+    <category name="org.jboss.management" additivity="true">
+        <priority value="INFO"/>
+    </category>
+
+    <!-- Show the evolution of the DataSource pool in the logs [inUse/Available/Max]
    <category name="org.jboss.resource.connectionmanager.JBossManagedConnectionPool">
      <priority value="TRACE"/>
    </category>
    -->
-   
+
    <!-- Limit the org.jboss.serial (jboss-serialization) to INFO as its DEBUG is verbose -->
-   <category name="org.jboss.serial" additivity="true">
-      <priority value="INFO"/>
-   </category>
-   
-   <!-- Decrease the priority threshold for the org.jboss.varia category
+    <category name="org.jboss.serial" additivity="true">
+        <priority value="INFO"/>
+    </category>
+
+    <!-- Decrease the priority threshold for the org.jboss.varia category
    <category name="org.jboss.varia">
      <priority value="DEBUG"/>
    </category>
      <priority value="TRACE"/>
    </category>
    -->
-  
+
    <!--
        | Logs these events to SNMP:
            - server starts/stops
            - cluster evolution (node death/startup)
            - When an EJB archive is deployed (and associated verified messages)
            - When an EAR archive is deployed
-        
+
    <category name="org.jboss.system.server.Server">
      <priority value="INFO" />
      <appender-ref ref="TRAP_LOG"/>
    </category>
-  
+
    <category name="org.jboss.ha.framework.interfaces.HAPartition.lifecycle">
      <priority value="INFO" />
      <appender-ref ref="TRAP_LOG"/>
      <priority value="ERROR" />
      <appender-ref ref="TRAP_LOG"/>
    </category>
-   
+
    <category name="org.jboss.ejb.EJBDeployer">
      <priority value="INFO" />
      <appender-ref ref="TRAP_LOG"/>
    </category>
-   
+
    <category name="org.jboss.deployment.EARDeployer">
      <priority value="INFO" />
      <appender-ref ref="TRAP_LOG"/>
 
 
 
-   <category name="org.springframework">
-     <priority value="INFO" />
-     <appender-ref ref="CSLOG"/>
-   </category>
+    <category name="org.springframework">
+        <priority value="INFO" />
+        <appender-ref ref="CSLOG"/>
+    </category>
 
-   <category name="org.springframework.security">
-     <priority value="INFO" />
-     <appender-ref ref="CSLOG"/>
-   </category>
+    <category name="org.springframework.security">
+        <priority value="INFO" />
+        <appender-ref ref="CSLOG"/>
+    </category>
 
-   <category name="org.nuxeo">
-     <priority value="INFO" />
-     <appender-ref ref="CSLOG"/>
-   </category>
+    <category name="org.nuxeo">
+        <priority value="INFO" />
+        <appender-ref ref="CSLOG"/>
+    </category>
 
-   <category name="nuxeo">
-     <priority value="INFO" />
-     <appender-ref ref="CSLOG"/>
-   </category>
+    <category name="nuxeo">
+        <priority value="INFO" />
+        <appender-ref ref="CSLOG"/>
+    </category>
 
-   <category name="org.collectionspace">
-     <priority value="INFO" />
-     <appender-ref ref="CSLOG"/>
-   </category>
+    <category name="org.collectionspace">
+        <priority value="INFO" />
+        <appender-ref ref="CSLOG"/>
+    </category>
 
-   
-   <!-- ======================= -->
+
+    <!-- ======================= -->
    <!-- Setup the Root category -->
    <!-- ======================= -->
 
-   <root>
-      <appender-ref ref="CONSOLE"/>
-      <appender-ref ref="FILE"/>
-      <appender-ref ref="CSLOG"/>
-   </root>
+    <root>
+        <appender-ref ref="CONSOLE"/>
+        <appender-ref ref="FILE"/>
+        <appender-ref ref="CSLOG"/>
+    </root>
 
 </log4j:configuration>
index bac4f2224858e83f02ff0fbaf6fd22c2fa729cfe..bbad4e8833dde339d9f2c781c894c5569386e4b8 100644 (file)
@@ -1,14 +1,14 @@
 <?xml version="1.0" encoding="UTF-8"?><!-- ===================================================================== --><!--                                                                       --><!--  Log4j Configuration                                                  --><!--                                                                       --><!-- ===================================================================== --><!-- $Id: jboss-log4j.xml 75507 2008-07-08 20:15:07Z stan.silvert@jboss.com $ --><!--
    | For more configuration infromation and examples see the Jakarta Log4j
    | owebsite: http://jakarta.apache.org/log4j
- --><!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">\r
-<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false" threshold="null">\r
-\r
-   <!-- ================================= -->\r
-   <!-- Preserve messages in a local file -->\r
-   <!-- ================================= -->\r
-\r
-   <!-- A time/date based rolling appender -->\r
+ --><!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false" threshold="null">
+
+   <!-- ================================= -->
+   <!-- Preserve messages in a local file -->
+   <!-- ================================= -->
+
+   <!-- A time/date based rolling appender -->
    <appender name="FILE"
    class="org.jboss.logging.appender.DailyRollingFileAppender">
      <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
@@ -19,9 +19,9 @@
      <layout class="org.apache.log4j.PatternLayout">
        <param name="ConversionPattern" value="%d %-5p [%c] %m%n"/>
      </layout>
-   </appender>\r
+   </appender>
+
 
-\r
    <!-- A size based file rolling appender
    <appender name="FILE" class="org.jboss.logging.appender.RollingFileAppender">
      <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
        <param name="ConversionPattern" value="%d %-5p [%c] %m%n"/>
      </layout>     
    </appender>
-   -->\r
-\r
-   <!-- ============================== -->\r
-   <!-- Append messages to the console -->\r
-   <!-- ============================== -->\r
-\r
-   <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">\r
-      <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>\r
-      <param name="Target" value="System.out"/>\r
-      <param name="Threshold" value="INFO"/>\r
-\r
-      <layout class="org.apache.log4j.PatternLayout">\r
-         <!-- The default pattern: Date Priority [Category] Message\n -->\r
-         <param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{1}] %m%n"/>\r
-      </layout>\r
-   </appender>\r
-  \r
-   <!-- ====================== -->\r
-   <!-- More Appender examples -->\r
-   <!-- ====================== -->\r
-\r
+   -->
+
+   <!-- ============================== -->
+   <!-- Append messages to the console -->
+   <!-- ============================== -->
+
+   <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
+      <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
+      <param name="Target" value="System.out"/>
+      <param name="Threshold" value="INFO"/>
+
+      <layout class="org.apache.log4j.PatternLayout">
+         <!-- The default pattern: Date Priority [Category] Message\n -->
+         <param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{1}] %m%n"/>
+      </layout>
+   </appender>
+  
+   <!-- ====================== -->
+   <!-- More Appender examples -->
+   <!-- ====================== -->
+
    <!-- Buffer events and log them asynchronously
    <appender name="ASYNC" class="org.apache.log4j.AsyncAppender">
      <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
@@ -62,8 +62,8 @@
      <appender-ref ref="CONSOLE"/>
      <appender-ref ref="SMTP"/>
    </appender>
-   -->\r
-\r
+   -->
+
    <!-- EMail events to an administrator
    <appender name="SMTP" class="org.apache.log4j.net.SMTPAppender">
      <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
@@ -77,8 +77,8 @@
        <param name="ConversionPattern" value="[%d{ABSOLUTE},%c{1}] %m%n"/>
      </layout>
    </appender>
-   -->\r
-\r
+   -->
+
    <!-- Syslog events
    <appender name="SYSLOG" class="org.apache.log4j.net.SyslogAppender">
      <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
@@ -89,8 +89,8 @@
        <param name="ConversionPattern" value="[%d{ABSOLUTE},%c{1}] %m%n"/>
      </layout>
    </appender>
-   -->\r
-\r
+   -->
+
    <!-- Log events to JMS (requires a topic to be created)
    <appender name="JMS" class="org.apache.log4j.net.JMSAppender">
      <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
@@ -98,8 +98,8 @@
      <param name="TopicConnectionFactoryBindingName" value="java:/ConnectionFactory"/>
      <param name="TopicBindingName" value="topic/MyErrorsTopic"/>
    </appender>
-   -->\r
-\r
+   -->
+
    <!-- Log events through SNMP
    <appender name="TRAP_LOG" class="org.apache.log4j.ext.SNMPTrapAppender">
      <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
             <param name="ConversionPattern" value="%d,%p,[%t],[%c],%m%n"/>
      </layout>
    </appender>
-   -->\r
-\r
+   -->
+
    <!--  Emit events as JMX notifications
    <appender name="JMX" class="org.jboss.monitor.services.JMXNotificationAppender">
       <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
          <param name="ConversionPattern" value="%d %-5p [%c] %m"/>
       </layout>
    </appender>
-   -->\r
+   -->
 
    <!-- collectionspace appender -->
-   <appender name="CSLOG" class="org.jboss.logging.appender.FileAppender">
+   <appender name="CSLOG" class="org.jboss.logging.appender.DailyRollingFileAppender">
       <errorHandler  class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
      <param name="Append" value="false"/>
      <param name="DatePattern" value="'.'yyyy-MM-dd"/>
    </appender>
 
 
-   \r
-   <!-- ================ -->\r
-   <!-- Limit categories -->\r
-   <!-- ================ -->\r
    
-   <!-- Limit the org.apache category to INFO as its DEBUG is verbose -->\r
-    <category name="org.apache" additivity="true">\r
-      <priority value="INFO"/>\r
-   </category>
+   <!-- ================ -->
+   <!-- Limit categories -->
+   <!-- ================ -->
    
+   <!-- Limit the org.apache category to INFO as its DEBUG is verbose -->
+    <category name="org.apache" additivity="true">
+      <priority value="INFO"/>
+   </category>
+
+   <!-- enable catalina.core to debug spring bean configuration -->
+   <category name="org.apache.catalina.core" additivity="true">
+      <priority value="INFO"/>
+   </category>
+
       <!-- Limit JBoss categories
    <category name="org.jboss">
       <priority value="INFO"/>
    </category>
-   -->\r
+   -->
     <category name="org.jboss.security.auth">
     <priority value="INFO"/>
-    </category>\r
-    <category name="com.arjuna"><priority value="INFO"/></category>\r
-    <category name="org.jboss.ejb3"><priority value="INFO"/></category>\r
-    <category name="org.jboss.ejb3.cache.simple.StatefulSessionFilePersistenceManager"><priority value="INFO"/></category>\r
+    </category>
+    <category name="com.arjuna"><priority value="INFO"/></category>
+    <category name="org.jboss.ejb3"><priority value="INFO"/></category>
+    <category name="org.jboss.ejb3.cache.simple.StatefulSessionFilePersistenceManager"><priority value="INFO"/></category>
     <category name="org.jboss.seam">
     <priority value="INFO"/>
-    </category>\r
-    <category name="org.jboss.seam.contexts.Contexts"><priority value="WARN"/></category>\r
-    <category name="org.jboss.seam.contexts.Lifecycle"><priority value="WARN"/></category>\r
-    <category name="org.jboss.mx.loading"><priority value="INFO"/></category>\r
-    <category name="org.jboss.remoting"><priority value="INFO"/></category>\r
-    <category name="org.jboss.resteasy"><priority value="INFO"/></category>\r
-    <category name="org.ajax4jsf"><priority value="INFO"/></category>\r
-    <category name="org.hibernate"><priority value="WARN"/></category>\r
-    <category name="org.hibernate.engine.StatefulPersistenceContext.ProxyWarnLog"><priority value="ERROR"/></category>\r
-    <category name="org.hibernate.impl.SessionFactoryObjectFactory"><priority value="ERROR"/></category>\r
-    <category name="org.hibernate.cache.EhCacheProvider"><priority value="ERROR"/></category>\r
-    <category name="org.hibernate.hql.ast.tree.FromElementType"><priority value="ERROR"/></category>\r
-    <category name="org.jbpm"><priority value="INFO"/></category>\r
-    <category name="org.jbpm.jpdl.xml.JpdlXmlReader"><priority value="ERROR"/></category>\r
-    <category name="org.compass.core.transaction"><priority value="INFO"/></category>\r
-    <category name="org.compass.core.lucene.engine.optimizer.ScheduledLuceneSearchEngineOptimizer"><priority value="INFO"/></category>\r
-    <category name="org.apache.jackrabbit.core.query.lucene.IndexMerger"><priority value="WARN"/></category>\r
-
-    <category name="org.nuxeo.ecm.platform.ui.web.auth"><priority value="INFO"/></category>\r
-    <category name="org.nuxeo.runtime.osgi.OSGiRuntimeService"><priority value="INFO"/></category>\r
-
-    <category name="org.apache.myfaces.renderkit.html.util.DefaultAddResource"><priority value="ERROR"/></category>\r
-    <category name="javax.enterprise.resource.webcontainer.jsf.renderkit"><priority value="INFO"/></category>\r
-    <category name="javax.enterprise.resource.webcontainer.jsf.application"><priority value="INFO"/></category>\r
+    </category>
+    <category name="org.jboss.seam.contexts.Contexts"><priority value="WARN"/></category>
+    <category name="org.jboss.seam.contexts.Lifecycle"><priority value="WARN"/></category>
+    <category name="org.jboss.mx.loading"><priority value="INFO"/></category>
+    <category name="org.jboss.remoting"><priority value="INFO"/></category>
+    <category name="org.jboss.resteasy"><priority value="INFO"/></category>
+    <category name="org.ajax4jsf"><priority value="INFO"/></category>
+    <category name="org.hibernate"><priority value="WARN"/></category>
+    <category name="org.hibernate.engine.StatefulPersistenceContext.ProxyWarnLog"><priority value="ERROR"/></category>
+    <category name="org.hibernate.impl.SessionFactoryObjectFactory"><priority value="ERROR"/></category>
+    <category name="org.hibernate.cache.EhCacheProvider"><priority value="ERROR"/></category>
+    <category name="org.hibernate.hql.ast.tree.FromElementType"><priority value="ERROR"/></category>
+    <category name="org.jbpm"><priority value="INFO"/></category>
+    <category name="org.jbpm.jpdl.xml.JpdlXmlReader"><priority value="ERROR"/></category>
+    <category name="org.compass.core.transaction"><priority value="INFO"/></category>
+    <category name="org.compass.core.lucene.engine.optimizer.ScheduledLuceneSearchEngineOptimizer"><priority value="INFO"/></category>
+    <category name="org.apache.jackrabbit.core.query.lucene.IndexMerger"><priority value="WARN"/></category>
+
+    <category name="org.nuxeo.ecm.platform.ui.web.auth"><priority value="INFO"/></category>
+    <category name="org.nuxeo.runtime.osgi.OSGiRuntimeService"><priority value="INFO"/></category>
+
+    <category name="org.apache.myfaces.renderkit.html.util.DefaultAddResource"><priority value="ERROR"/></category>
+    <category name="javax.enterprise.resource.webcontainer.jsf.renderkit"><priority value="INFO"/></category>
+    <category name="javax.enterprise.resource.webcontainer.jsf.application"><priority value="INFO"/></category>
     <category name="javax.enterprise.resource.webcontainer.jsf.lifecycle"><priority value="INFO"/></category>
-    \r
-   <!-- Limit the jacorb category to WARN as its INFO is verbose -->\r
-   <category name="jacorb" additivity="true">\r
-      <priority value="WARN"/>\r
-   </category>\r
-   \r
-   <!-- Limit the org.jgroups category to WARN as its INFO is verbose -->\r
-   <category name="org.jgroups" additivity="true">\r
-      <priority value="WARN"/>\r
-   </category>\r
-   \r
-   <!-- Limit the org.quartz category to INFO as its DEBUG is verbose -->\r
-   <category name="org.quartz" additivity="true">\r
-      <priority value="INFO"/>\r
-   </category>\r
-\r
-   <!-- Limit JSF logging to DEBUG.  FINER and FINEST will not be logged -->\r
-   <category name="javax.enterprise.resource.webcontainer.jsf" additivity="true">\r
-      <priority value="INFO"/>\r
-   </category>\r
-                \r
-\r
-\r
-   <!-- Limit the JSR77 categories -->\r
-   <category name="org.jboss.management" additivity="true">\r
-      <priority value="INFO"/>\r
-   </category>\r
-\r
+    
+   <!-- Limit the jacorb category to WARN as its INFO is verbose -->
+   <category name="jacorb" additivity="true">
+      <priority value="WARN"/>
+   </category>
+   
+   <!-- Limit the org.jgroups category to WARN as its INFO is verbose -->
+   <category name="org.jgroups" additivity="true">
+      <priority value="WARN"/>
+   </category>
+   
+   <!-- Limit the org.quartz category to INFO as its DEBUG is verbose -->
+   <category name="org.quartz" additivity="true">
+      <priority value="INFO"/>
+   </category>
+
+   <!-- Limit JSF logging to DEBUG.  FINER and FINEST will not be logged -->
+   <category name="javax.enterprise.resource.webcontainer.jsf" additivity="true">
+      <priority value="INFO"/>
+   </category>
+                
+
+
+   <!-- Limit the JSR77 categories -->
+   <category name="org.jboss.management" additivity="true">
+      <priority value="INFO"/>
+   </category>
+
    <!-- Show the evolution of the DataSource pool in the logs [inUse/Available/Max]
    <category name="org.jboss.resource.connectionmanager.JBossManagedConnectionPool">
      <priority value="TRACE"/>
    </category>
-   -->\r
-   \r
-   <!-- Limit the org.jboss.serial (jboss-serialization) to INFO as its DEBUG is verbose -->\r
-   <category name="org.jboss.serial" additivity="true">\r
-      <priority value="INFO"/>\r
-   </category>\r
-   \r
+   -->
+   
+   <!-- Limit the org.jboss.serial (jboss-serialization) to INFO as its DEBUG is verbose -->
+   <category name="org.jboss.serial" additivity="true">
+      <priority value="INFO"/>
+   </category>
+   
    <!-- Decrease the priority threshold for the org.jboss.varia category
    <category name="org.jboss.varia">
      <priority value="DEBUG"/>
    </category>
-   -->\r
-\r
+   -->
+
    <!-- Enable JBossWS message tracing
    <category name="org.jboss.ws.core.MessageTrace">
     <priority value="TRACE"/>
    </category>
-   -->\r
-\r
+   -->
+
    <!--
       | An example of enabling the custom TRACE level priority that is used
       | by the JBoss internals to diagnose low level details. This example
    <category name="org.jboss.ejb.plugins">
      <priority value="TRACE"/>
    </category>
-   -->\r
-  \r
+   -->
+  
    <!--
        | Logs these events to SNMP:
            - server starts/stops
      <priority value="INFO" />
      <appender-ref ref="TRAP_LOG"/>
    </category>
-   -->\r
-\r
-   <!-- Clustering logging -->\r
+   -->
+
+   <!-- Clustering logging -->
    <!-- Uncomment the following to redirect the org.jgroups and
       org.jboss.ha categories to a cluster.log file.
 
      <priority value="DEBUG" />
      <appender-ref ref="CLUSTER"/>
    </category>
-   -->\r
+   -->
 
 
 
      <appender-ref ref="CSLOG"/>
    </category>
 
-   \r
-   <!-- ======================= -->\r
-   <!-- Setup the Root category -->\r
-   <!-- ======================= -->\r
-\r
-   <root>\r
-      <appender-ref ref="CONSOLE"/>\r
-      <appender-ref ref="FILE"/>\r
-      <appender-ref ref="CSLOG"/>\r
-   </root>\r
-\r
+   
+   <!-- ======================= -->
+   <!-- Setup the Root category -->
+   <!-- ======================= -->
+
+   <root>
+      <appender-ref ref="CONSOLE"/>
+      <appender-ref ref="FILE"/>
+      <appender-ref ref="CSLOG"/>
+   </root>
+
 </log4j:configuration>
index 448a0cf19fddb69db32b03ba09ce2d50995d93f6..9542d9012c593a32df4941e72660388ba251acf3 100644 (file)
@@ -33,6 +33,7 @@ import java.util.Set;
 import javax.security.auth.Subject;
 import javax.security.jacc.PolicyContext;
 import javax.security.jacc.PolicyContextException;
+import org.collectionspace.authentication.AuthN;
 import org.collectionspace.authentication.CSpaceTenant;
 
 import org.collectionspace.services.common.ClientType;
@@ -124,14 +125,14 @@ public abstract class AbstractServiceContextImpl<IT, OT>
         ServiceBindingUtils.getPartsMetadata(getServiceBinding(), objectPartMap);
         return objectPartMap;
     }
-    
+
     public List<PropertyType> getPropertiesForPart(String partLabel) {
-       Map<String, ObjectPartType> partMap = getPartsMetadata();
-       ObjectPartType part = partMap.get(partLabel);
-       if(part==null) {
-               throw new RuntimeException("No such part found: "+partLabel);
-       }
-       return part.getProperties();
+        Map<String, ObjectPartType> partMap = getPartsMetadata();
+        ObjectPartType part = partMap.get(partLabel);
+        if (part == null) {
+            throw new RuntimeException("No such part found: " + partLabel);
+        }
+        return part.getProperties();
     }
 
     public List<String> getPropertyValuesForPart(String partLabel, String propName) {
@@ -144,11 +145,11 @@ public abstract class AbstractServiceContextImpl<IT, OT>
     }
     
     public List<PropertyType> getCommonPartProperties() {
-       return getPropertiesForPart(getCommonPartLabel());
+        return getPropertiesForPart(getCommonPartLabel());
     }
 
     public List<String> getCommonPartPropertyValues(String propName) {
-       return getPropertyValuesForPart(getCommonPartLabel(), propName);
+        return getPropertyValuesForPart(getCommonPartLabel(), propName);
     }
 
     @Override
@@ -248,53 +249,19 @@ public abstract class AbstractServiceContextImpl<IT, OT>
     public void setProperty(String name, Object o) {
         properties.put(name, o);
     }
-    private static final String SUBJECT_CONTEXT_KEY = "javax.security.auth.Subject.container";
+
 
     private String retrieveTenantId() throws UnauthorizedException {
 
-        String tenantId = null;
-        Subject caller = null;
-        Set<Group> groups = null;
-        try {
-            caller = (Subject) PolicyContext.getContext(SUBJECT_CONTEXT_KEY);
-            if (caller == null) {
-                //logger.warn("security not enabled...");
-                return tenantId;
-            }
-            groups = caller.getPrincipals(Group.class);
-            if (groups != null && groups.size() == 0) {
-                //TODO: find out why subject is not null
-                if (logger.isDebugEnabled()) {
-                    logger.debug("no tenant(s) found!");
-                }
-                return tenantId;
-            }
-        } catch (PolicyContextException pce) {
-            String msg = "Could not retrieve principal information";
-            logger.error(msg, pce);
-            throw new UnauthorizedException(msg);
-        }
-        for (Group g : groups) {
-            if ("Tenants".equals(g.getName())) {
-                Enumeration members = g.members();
-                while (members.hasMoreElements()) {
-                    CSpaceTenant tenant = (CSpaceTenant) members.nextElement();
-                    tenantId = tenant.getId();
-                    if (logger.isDebugEnabled()) {
-                        logger.debug("found tenant id=" + tenant.getId()
-                                + " name=" + tenant.getName());
-                    }
-                }
-            }
-        }
-        //TODO: if a user is associated with more than one tenants, the tenant
-        //id should be matched with sent over the wire
-        if (tenantId == null) {
+        String[] tenantIds = AuthN.get().getTenantIds();
+        if (tenantIds.length == 0) {
             String msg = "Could not find tenant context";
             logger.error(msg);
             throw new UnauthorizedException(msg);
         }
-        return tenantId;
+        //TODO: if a user is associated with more than one tenants, the tenant
+        //id should be matched with the one sent over the wire
+        return tenantIds[0];
     }
 
     @Override
@@ -307,8 +274,8 @@ public abstract class AbstractServiceContextImpl<IT, OT>
         if (DocumentHandler.class.isAssignableFrom(c)) {
             docHandler = (DocumentHandler) c.newInstance();
         } else {
-            throw new IllegalArgumentException("Not of type " +
-                    DocumentHandler.class.getCanonicalName());
+            throw new IllegalArgumentException("Not of type "
+                    DocumentHandler.class.getCanonicalName());
         }
         docHandler.setServiceContext(this);
         return docHandler;
diff --git a/services/common/src/main/java/org/collectionspace/services/common/security/SecurityInterceptor.java b/services/common/src/main/java/org/collectionspace/services/common/security/SecurityInterceptor.java
new file mode 100644 (file)
index 0000000..2cd6428
--- /dev/null
@@ -0,0 +1,102 @@
+/**
+ *  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.services.common.security;
+
+import org.jboss.resteasy.core.ResourceMethod;
+import org.jboss.resteasy.core.ServerResponse;
+import org.jboss.resteasy.spi.interception.PreProcessInterceptor;
+import org.jboss.resteasy.annotations.interception.SecurityPrecedence;
+import org.jboss.resteasy.annotations.interception.ServerInterceptor;
+import org.jboss.resteasy.spi.Failure;
+import org.jboss.resteasy.spi.HttpRequest;
+
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.Response;
+import org.collectionspace.authentication.AuthN;
+import org.collectionspace.services.authorization.AuthZ;
+import org.collectionspace.services.authorization.CSpaceResource;
+import org.collectionspace.services.authorization.URIResourceImpl;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * RESTeasy interceptor for access control
+ * @version $Revision: 1 $
+ */
+@SecurityPrecedence
+@ServerInterceptor
+public class SecurityInterceptor implements PreProcessInterceptor {
+
+    private static final Logger logger = LoggerFactory.getLogger(SecurityInterceptor.class);
+
+    @Override
+    public ServerResponse preProcess(HttpRequest request, ResourceMethod method)
+            throws Failure, WebApplicationException {
+        String httpMethod = request.getHttpMethod();
+        String uriPath = request.getUri().getPath();
+        if (logger.isDebugEnabled()) {
+            logger.debug("received " + httpMethod + " on " + uriPath);
+        }
+        AuthZ authZ = AuthZ.get();
+        CSpaceResource res = new URIResourceImpl(uriPath, httpMethod);
+//        if (!authZ.isAccessAllowed(res)) {
+//            logger.error("Access to " + res.getId() + " is NOT allowed to " +
+//                    " user=" + AuthN.get().getUserId());
+//            Response response = Response.status(
+//                    Response.Status.FORBIDDEN).entity(uriPath + " " + httpMethod).type("text/plain").build();
+//            throw new WebApplicationException(response);
+//        }
+        if(logger.isDebugEnabled()) {
+            logger.debug("Access to " + res.getId() + " is allowed to " +
+                    " user=" + AuthN.get().getUserId());
+        }
+        return null;
+    }
+}
index 9ef82fb6771462e4d1f540521e806c0ec2f6782a..cefff9c0f92eff24190818343ac63cc8d46980a6 100644 (file)
@@ -15,6 +15,7 @@
     <modules>
         <module>jaxb</module>
         <module>authentication</module>
+        <module>authorization</module>
         <module>common</module>
         <module>client</module>
         <module>account</module>
@@ -30,7 +31,7 @@
         <module>dimension</module>
         <module>contact</module>
         <module>JaxRsServiceProvider</module>
-        <module>sdk</module>
+        <!--module>sdk</module-->
         <module>IntegrationTests</module>
         <module>PerformanceTests</module>
         <module>security</module>
                         <jbossHome>${jboss.dir}</jbossHome>
                     </configuration>
                 </plugin>
-                
+
                 <plugin>
                     <groupId>org.jvnet.hyperjaxb3</groupId>
                     <artifactId>maven-hyperjaxb3-plugin</artifactId>
                     <version>0.5.4</version>
                 </plugin>
-                
+
                 <plugin>
                     <groupId>org.jvnet.jaxb2.maven2</groupId>
                     <artifactId>maven-jaxb2-plugin</artifactId>
                     <version>0.7.2</version>
                 </plugin>
-                
+
                 <plugin>
                     <groupId>org.apache.maven.plugins</groupId>
                     <artifactId>maven-compiler-plugin</artifactId>
             </dependency>
         </dependencies>
     </dependencyManagement>
-</project>
+</project>
\ No newline at end of file