diff --git a/.gitignore b/.gitignore index 19f72f531d..e56d60133e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,18 +1,21 @@ target/ -.classpath -.project -.settings/ */src/*/java/META-INF -bin/ -build/ +*/src/META-INF/ +*/src/*/java/META-INF/ +.classpath +.springBeans +.project +.DS_Store +.settings/ +.idea/ out/ +bin/ intellij/ +build/ +*.log +*.log.* +*.iml *.ipr *.iws -*.log -*.log.1 -.DS_Store -*.iml .gradle/ -gradle.properties atlassian-ide-plugin.xml diff --git a/acl/pom.xml b/acl/pom.xml index 4ca4662779..3181e4c0c4 100644 --- a/acl/pom.xml +++ b/acl/pom.xml @@ -3,7 +3,7 @@ spring-security-parent org.springframework.security - 3.0.8.CI-SNAPSHOT + @pomVersion@ 4.0.0 org.springframework.security diff --git a/acl/template.mf b/acl/template.mf index 7abb563aca..d92dd43b47 100644 --- a/acl/template.mf +++ b/acl/template.mf @@ -9,14 +9,15 @@ Ignored-Existing-Headers: Import-Package, Export-Package Import-Template: - org.apache.commons.logging.*;version="[1.0.4, 2.0.0)", - org.springframework.security.core.*;version="[${version}, 3.1.0)", - org.springframework.security.access.*;version="[${version}, 3.1.0)", - org.springframework.security.util.*;version="[${version}, 3.1.0)", - org.springframework.context.*;version="[${spring.version}, 3.1.0)";resolution:=optional, - org.springframework.dao.*;version="[${spring.version}, 3.1.0)";resolution:=optional, - org.springframework.jdbc.core.*;version="[${spring.version}, 3.1.0)";resolution:=optional, - org.springframework.transaction.support.*;version="[${spring.version}, 3.1.0)";resolution:=optional, - org.springframework.util.*;version="[${spring.version}, 3.1.0)";resolution:=optional, - net.sf.ehcache.*;version="[1.4.1, 2.0.0)";resolution:=optional, + org.aopalliance.*;version="${aopAllianceRange}", + org.apache.commons.logging.*;version="${cloggingRange}", + org.springframework.security.core.*;version="${secRange}", + org.springframework.security.access.*;version="${secRange}", + org.springframework.security.util.*;version="${secRange}", + org.springframework.context.*;version="${springRange}";resolution:=optional, + org.springframework.dao.*;version="${springRange}";resolution:=optional, + org.springframework.jdbc.core.*;version="${springRange}";resolution:=optional, + org.springframework.transaction.support.*;version="${springRange}";resolution:=optional, + org.springframework.util.*;version="${springRange}";resolution:=optional, + net.sf.ehcache.*;version="${ehcacheRange}";resolution:=optional, javax.sql.*;version="0";resolution:=optional diff --git a/aspects/pom.xml b/aspects/pom.xml index d328d0ae18..1ddc2555af 100644 --- a/aspects/pom.xml +++ b/aspects/pom.xml @@ -5,7 +5,7 @@ org.springframework.security spring-security-parent - 3.0.8.CI-SNAPSHOT + @pomVersion@ jar spring-security-aspects @@ -18,7 +18,7 @@ org.springframework.security spring-security-core - 3.0.8.CI-SNAPSHOT + @pomVersion@ diff --git a/aspects/template.mf b/aspects/template.mf new file mode 100644 index 0000000000..5f43a718e0 --- /dev/null +++ b/aspects/template.mf @@ -0,0 +1,16 @@ +Implementation-Title: org.springframework.security.aspects +Implementation-Version: ${version} +Bundle-SymbolicName: org.springframework.security.aspects +Bundle-Name: Spring Security Aspects +Bundle-Vendor: SpringSource +Bundle-ManifestVersion: 2 +Bundle-Version: ${version} +Ignored-Existing-Headers: + Import-Package, + Export-Package +Import-Template: + org.aspectj.*;version="${aspectjRange}";resolution:=optional, + org.apache.commons.logging.*;version="${cloggingRange}", + org.springframework.security.core.*;version="${secRange}", + org.springframework.security.access.intercept.aspectj;version="${secRange}", + org.springframework.beans.factory;version="${springRange}" diff --git a/build.gradle b/build.gradle index fba90870d3..efddbb1e0f 100644 --- a/build.gradle +++ b/build.gradle @@ -1,120 +1,58 @@ apply plugin: 'base' +description = 'Spring Security' allprojects { - version = '3.0.8.CI-SNAPSHOT' - releaseBuild = version.endsWith('RELEASE') - snapshotBuild = version.endsWith('SNAPSHOT') + ext.releaseBuild = version.endsWith('RELEASE') + ext.snapshotBuild = version.endsWith('SNAPSHOT') group = 'org.springframework.security' repositories { - mavenRepo name:'Local', urls: "file://" + System.properties['user.home'] + "/.m2/repository" mavenCentral() - mavenRepo name: 'SpringSource Milestone Repo', urls: 'http://repository.springsource.com/maven/bundles/milestone' - mavenRepo name: 'SpringSource Maven Snapshot Repo', urls: 'http://maven.springframework.org/snapshot/' - mavenRepo name: 'SpringSource Enterprise Release', urls: 'http://repository.springsource.com/maven/bundles/release' - mavenRepo name: 'SpringSource Enterprise External', urls: 'http://repository.springsource.com/maven/bundles/external' } } +// Set up different subproject lists for individual configuration +ext.javaProjects = subprojects.findAll { project -> project.name != 'docs' && project.name != 'faq' && project.name != 'manual' } +ext.sampleProjects = subprojects.findAll { project -> project.name.startsWith('spring-security-samples') } +ext.itestProjects = subprojects.findAll { project -> project.name.startsWith('itest') } +ext.coreModuleProjects = javaProjects - sampleProjects - itestProjects +ext.aspectjProjects = [project(':spring-security-aspects'), project(':spring-security-samples-aspectj')] configure(javaProjects) { apply from: "$rootDir/gradle/javaprojects.gradle" - apply from: "$rootDir/gradle/maven.gradle" } configure(coreModuleProjects) { - apply from: "$rootDir/gradle/bundlor.gradle" // Gives better names in structure101 jar diagram - sourceSets.main.classesDir = new File(buildDir, "classes/" + project.name.substring("spring-security".length() + 1)) + sourceSets.main.output.classesDir = new File(buildDir, "classes/" + project.name.substring("spring-security".length() + 1)) + apply plugin: 'bundlor' + bundlor.expansions = bundlorProperties + apply from: "$rootDir/gradle/maven-deployment.gradle" + apply plugin: 'emma' +} + +task coreBuild { + dependsOn coreModuleProjects*.tasks*.matching { task -> task.name == 'build' } } configure (aspectjProjects) { - apply from: "$rootDir/gradle/aspectj.gradle" + apply plugin: 'aspectj' } -configurations { - antlibs -} - -dependencies { - antlibs "org.springframework.build:org.springframework.build.aws.ant:3.0.3.RELEASE", - "net.java.dev.jets3t:jets3t:0.6.1" -} - -task apidocs(type: Javadoc) { - destinationDir = new File(buildDir, 'apidocs') - title = "Spring Security $version API" - optionsFile = file("$buildDir/tmp/javadoc.options") - - source coreModuleProjects.collect {project -> - project.sourceSets.main.allJava - } - - classpath = files(coreModuleProjects.collect {project -> - project.sourceSets.main.compileClasspath - }) -} - -task docSiteLogin(type: Login) { - if (project.hasProperty('sshHost')) { - host = project.property('sshHost') - } -} - -// Define remoteSiteDir and sshHost in gradle.properties -def remoteDocsDir = null - -if (hasProperty('remoteSiteDir')) { - remoteDocsDir="$remoteSiteDir/docs/3.0.x" -} - -task uploadApidocs(type: TarUpload) { - dependsOn apidocs - classifier = 'apidocs' - remoteDir = remoteDocsDir - login = docSiteLogin - - into('apidocs') { - from apidocs.destinationDir - } -} - -def docsDir = new File(project(':manual').buildDir, 'docs') - -task uploadDoc(type: TarUpload) { - dependsOn ':manual:doc' - classifier = 'doc' - remoteDir = remoteDocsDir - login = docSiteLogin - - into('reference') { - from docsDir - } -} - -task uploadFaq(type: TarUpload) { - dependsOn ':faq:docbookHtmlSingle' - classifier = 'faq' - if (project.hasProperty('remoteSiteDir')) { - remoteDir = project.property('remoteSiteDir') - } - login = docSiteLogin - - def faqDir = new File(project(':faq').buildDir, 'docs') - - into('faq') { - from faqDir - } -} +// Task for creating the distro zip task dist(type: Zip) { + dependsOn subprojects*.tasks*.matching { task -> task.name == 'assemble' || task.name.endsWith('Zip') } + classifier = 'dist' + evaluationDependsOn(':docs') def zipRootDir = "${project.name}-$version" into(zipRootDir) { - into('docs/apidocs') { - from apidocs.destinationDir + from(rootDir) { + include '*.txt' } - into('docs/reference') { - from docsDir + into('docs') { + with(project(':docs').apiSpec) + with(project(':docs:manual').spec) } into('dist') { from coreModuleProjects.collect {project -> project.libsDir } @@ -124,83 +62,14 @@ task dist(type: Zip) { } } -dist { - dependsOn apidocs, ':manual:doc', subprojects.collect { "$it.path:assemble" } - doLast { - ant.checksum(file: archivePath, algorithm: 'SHA1', fileext: '.sha1') - } +artifacts { + archives dist + archives project(':docs').docsZip + archives project(':docs').schemaZip } -task uploadDist(type: UploadDist) { - archiveFile = dist.archivePath - shaFile = "${dist.archivePath}.sha1" as File - archiveName = dist.archiveName - classpath = configurations.antlibs +apply from: "$rootDir/gradle/ide-integration.gradle" + +task wrapper(type: Wrapper) { + gradleVersion = '1.1' } - -def getJavaProjects() { - subprojects.findAll {project -> project.name != 'faq' && project.name != 'manual' } -} - -def getSampleProjects() { - subprojects.findAll {project -> project.name.startsWith('spring-security-samples') } -} - -def getItestProjects() { - subprojects.findAll {project -> project.name.startsWith('itest') } -} - -def getCoreModuleProjects() { - javaProjects - sampleProjects - itestProjects - aspectjProjects -} - -def getAspectjProjects() { - subprojects.findAll {project -> project.name == 'spring-security-aspects' || project.name == 'spring-security-samples-aspectj'} -} - -class UploadDist extends DefaultTask { - @InputFile - File shaFile - - @InputFile - File archiveFile - - @Input - String archiveName - - @InputFiles - def classpath - - @TaskAction - def upload() { - def accessKey = project.s3AccessKey - def secretKey = project.s3SecretAccessKey - def version = project.version - - project.ant { - taskdef(resource: 'org/springframework/build/aws/ant/antlib.xml', classpath: classpath.asPath) - s3(accessKey: accessKey, secretKey: secretKey) { - upload(bucketName: 'dist.springframework.org', file: archiveFile, - toFile: releaseType() + "/SEC/${archiveName}", publicRead: 'true') { - metadata(name: 'project.name', value: 'Spring Security') - metadata(name: 'release.type', value: releaseType()) - metadata(name: 'bundle.version', value: version) - metadata(name: 'package.file.name', value: archiveName) - } - upload(bucketName: 'dist.springframework.org', file: shaFile, - toFile: releaseType() + "/SEC/${archiveName}.sha1", publicRead: 'true') - } - } - } - - def releaseType() { - if (project.releaseBuild) { - 'release' - } else if (project.snapshotBuild) { - 'snapshot' - } else { - 'milestone' - } - } -} - diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle index c0cdf8c470..97d8b139a8 100644 --- a/buildSrc/build.gradle +++ b/buildSrc/build.gradle @@ -1,11 +1,18 @@ apply plugin: 'groovy' repositories { - mavenRepo name:'localRepo', urls: "file://" + System.properties['user.home'] + "/.m2/repository" mavenCentral() - mavenRepo name:'Shibboleth Repo', urls:'http://shibboleth.internet2.edu/downloads/maven2' + maven { + name = 'SpringSource Enterprise Release' + url = 'http://repository.springsource.com/maven/bundles/release' + } + maven { + name = 'SpringSource Enterprise External' + url = 'http://repository.springsource.com/maven/bundles/external' + } } +// Docbook Plugin dependencies { def fopDeps = [ 'org.apache.xmlgraphics:fop:0.95-1@jar', 'org.apache.xmlgraphics:xmlgraphics-commons:1.3', @@ -17,15 +24,31 @@ dependencies { 'org.apache.avalon.framework:avalon-framework-api:4.3.1'] groovy localGroovy() compile gradleApi(), - 'org.apache.xerces:resolver:2.9.1', + 'xml-resolver:xml-resolver:1.2', + 'xerces:xercesImpl:2.9.1', 'saxon:saxon:6.5.3', - 'org.apache.xerces:xercesImpl:2.9.1', + 'net.java.dev.jets3t:jets3t:0.6.1', fopDeps runtime 'net.sf.xslthl:xslthl:2.0.1', 'net.sf.docbook:docbook-xsl:1.75.2:ns-resources@zip' } +// GAE +dependencies { + compile 'com.google.appengine:appengine-tools-sdk:1.4.2' +} + +dependencies{ + compile "emma:emma:2.0.5312" +} + +// Bundlor +dependencies { + compile 'com.springsource.bundlor:com.springsource.bundlor:1.0.0.RELEASE', + 'com.springsource.bundlor:com.springsource.bundlor.blint:1.0.0.RELEASE' +} + task ide(type: Copy) { from configurations.runtime into 'ide' diff --git a/buildSrc/src/main/groovy/TarUpload.groovy b/buildSrc/src/main/groovy/TarUpload.groovy deleted file mode 100644 index ab0234865e..0000000000 --- a/buildSrc/src/main/groovy/TarUpload.groovy +++ /dev/null @@ -1,75 +0,0 @@ -import org.gradle.api.DefaultTask; -import org.gradle.api.tasks.*; -import org.gradle.api.tasks.bundling.Tar; -import org.gradle.api.tasks.bundling.Compression; - -/** - * Extends the Tar task, uploading the created archive to a remote directory, unpacking and deleting it. - * Requires Ant ssh (jsch) support. - */ -class TarUpload extends Tar { - @Input - String remoteDir - Login login - @Input - String host - - TarUpload() { - compression = Compression.BZIP2 - if (project.configurations.findByName('antjsch') == null) { - project.configurations.add('antjsch') - project.dependencies { - antjsch 'org.apache.ant:ant-jsch:1.8.1' - } - def classpath = project.configurations.antjsch.asPath - project.ant { - taskdef(name: 'scp', classname: 'org.apache.tools.ant.taskdefs.optional.ssh.Scp', classpath: classpath) - taskdef(name: 'sshexec', classname: 'org.apache.tools.ant.taskdefs.optional.ssh.SSHExec', classpath: classpath) - } - } - } - - @TaskAction - void copy() { - super.copy(); - upload(); - } - - def upload() { - String username = login.username - String password = login.password - String host = login.host - project.ant { - scp(file: archivePath, todir: "$username@$host:$remoteDir", password: password) - sshexec(host: host, username: username, password: password, command: "cd $remoteDir && tar -xjf $archiveName") - sshexec(host: host, username: username, password: password, command: "rm $remoteDir/$archiveName") - } - } - - void setLogin(Login login) { - dependsOn(login) - this.login = login - this.host = login.host - } -} - -/** - * Stores login information for a remote host. - */ -class Login extends DefaultTask { - @Input - String host - String username - String password - - @TaskAction - login() { - def console = System.console() - if (console) { - username = console.readLine("\nPlease enter the ssh username for host '$host': ") - password = new String(console.readPassword("Please enter the ssh password for '$host': ")) - } else { - logger.error "Unable to access System.console()." - } - } -} diff --git a/buildSrc/src/main/groovy/aspectj/AspectJPlugin.groovy b/buildSrc/src/main/groovy/aspectj/AspectJPlugin.groovy new file mode 100644 index 0000000000..2e0751545a --- /dev/null +++ b/buildSrc/src/main/groovy/aspectj/AspectJPlugin.groovy @@ -0,0 +1,108 @@ +package aspectj + +import org.gradle.api.Project +import org.gradle.api.Plugin +import org.gradle.api.tasks.TaskAction +import org.gradle.api.logging.LogLevel +import org.gradle.api.file.FileCollection +import org.gradle.api.tasks.SourceSet +import org.gradle.api.DefaultTask +import org.gradle.api.GradleException + +import org.gradle.plugins.ide.eclipse.GenerateEclipseProject +import org.gradle.plugins.ide.eclipse.GenerateEclipseClasspath +import org.gradle.plugins.ide.eclipse.EclipsePlugin +import org.gradle.plugins.ide.eclipse.model.BuildCommand +import org.gradle.plugins.ide.eclipse.model.ProjectDependency + +/** + * + * @author Luke Taylor + */ +class AspectJPlugin implements Plugin { + + void apply(Project project) { + if (!project.hasProperty('aspectjVersion')) { + throw new GradleException("You must set the property 'aspectjVersion' before applying the aspectj plugin") + } + + if (project.configurations.findByName('ajtools') == null) { + project.configurations.add('ajtools') + project.dependencies { + ajtools "org.aspectj:aspectjtools:${project.aspectjVersion}" + compile "org.aspectj:aspectjrt:${project.aspectjVersion}" + } + } + + if (project.configurations.findByName('aspectpath') == null) { + project.configurations.add('aspectpath') + } + + project.tasks.add(name: 'compileJava', overwrite: true, description: 'Compiles AspectJ Source', type: Ajc) { + dependsOn project.processResources + sourceSet = project.sourceSets.main + inputs.files(sourceSet.java.srcDirs) + outputs.dir(sourceSet.output.classesDir) + aspectPath = project.configurations.aspectpath + } + + project.tasks.add(name: 'compileTestJava', overwrite: true, description: 'Compiles AspectJ Test Source', type: Ajc) { + dependsOn project.processTestResources, project.compileJava, project.jar + sourceSet = project.sourceSets.test + inputs.files(sourceSet.java.srcDirs) + outputs.dir(sourceSet.output.classesDir) + aspectPath = project.files(project.configurations.aspectpath, project.jar.archivePath) + } + + project.tasks.withType(GenerateEclipseProject) { + project.eclipse.project.file.whenMerged { p -> + p.natures.add(0, 'org.eclipse.ajdt.ui.ajnature') + p.buildCommands = [new BuildCommand('org.eclipse.ajdt.core.ajbuilder')] + } + } + + project.tasks.withType(GenerateEclipseClasspath) { + project.eclipse.classpath.file.whenMerged { classpath -> + def entries = classpath.entries.findAll { it instanceof ProjectDependency}.findAll { entry -> + def projectPath = entry.path.replaceAll('/',':') +println projectPath + project.rootProject.allprojects.find{ p-> + if(p.plugins.findPlugin(EclipsePlugin)) { + println " checking " + p.eclipse.project.name + return p.eclipse.project.name == projectPath && p.plugins.findPlugin(AspectJPlugin) + } + false + } + } + entries.each { entry-> + entry.entryAttributes.put('org.eclipse.ajdt.aspectpath','org.eclipse.ajdt.aspectpath') + } + } + } + } +} + +class Ajc extends DefaultTask { + SourceSet sourceSet + FileCollection aspectPath + + Ajc() { + logging.captureStandardOutput(LogLevel.INFO) + } + + @TaskAction + def compile() { + logger.info("Running ajc ...") + ant.taskdef(resource: "org/aspectj/tools/ant/taskdefs/aspectjTaskdefs.properties", classpath: project.configurations.ajtools.asPath) + ant.iajc(classpath: sourceSet.compileClasspath.asPath, fork: 'true', destDir: sourceSet.output.classesDir.absolutePath, + source: project.convention.plugins.java.sourceCompatibility, + target: project.convention.plugins.java.targetCompatibility, + aspectPath: aspectPath.asPath, sourceRootCopyFilter: '**/*.java', showWeaveInfo: 'true') { + sourceroots { + sourceSet.java.srcDirs.each { + pathelement(location: it.absolutePath) + } + } + } + } +} diff --git a/buildSrc/src/main/groovy/bundlor/BundlorPlugin.groovy b/buildSrc/src/main/groovy/bundlor/BundlorPlugin.groovy new file mode 100644 index 0000000000..a48e1248e9 --- /dev/null +++ b/buildSrc/src/main/groovy/bundlor/BundlorPlugin.groovy @@ -0,0 +1,150 @@ +package bundlor + +import com.springsource.bundlor.ClassPath +import com.springsource.bundlor.ManifestGenerator +import com.springsource.bundlor.ManifestWriter +import com.springsource.bundlor.blint.ManifestValidator +import com.springsource.bundlor.blint.support.DefaultManifestValidatorContributorsFactory +import com.springsource.bundlor.blint.support.StandardManifestValidator +import com.springsource.bundlor.support.DefaultManifestGeneratorContributorsFactory +import com.springsource.bundlor.support.StandardManifestGenerator +import com.springsource.bundlor.support.classpath.FileSystemClassPath +import com.springsource.bundlor.support.manifestwriter.FileSystemManifestWriter +import com.springsource.bundlor.support.properties.EmptyPropertiesSource +import com.springsource.bundlor.support.properties.FileSystemPropertiesSource +import com.springsource.bundlor.support.properties.PropertiesPropertiesSource +import com.springsource.bundlor.support.properties.PropertiesSource +import com.springsource.bundlor.util.BundleManifestUtils +import com.springsource.util.parser.manifest.ManifestContents +import org.gradle.api.DefaultTask +import org.gradle.api.GradleException +import org.gradle.api.Plugin +import org.gradle.api.Project +import org.gradle.api.Task +import org.gradle.api.file.FileCollection +import org.gradle.api.logging.LogLevel +import org.gradle.api.tasks.Input +import org.gradle.api.tasks.InputFile +import org.gradle.api.tasks.InputFiles +import org.gradle.api.tasks.Optional +import org.gradle.api.tasks.OutputDirectory +import org.gradle.api.tasks.OutputFile +import org.gradle.api.tasks.TaskAction + +/** + * @author Luke Taylor + */ +class BundlorPlugin implements Plugin { + void apply(Project project) { + Task bundlor = project.tasks.add('bundlor', Bundlor.class) + bundlor.setDescription('Generates OSGi manifest using bundlor tool') + bundlor.dependsOn(project.classes) + project.jar.dependsOn bundlor + } +} + +public class Bundlor extends DefaultTask { + @InputFile + @Optional + File manifestTemplate + + @OutputDirectory + File bundlorDir = new File("${project.buildDir}/bundlor") + + @OutputFile + File manifest = project.file("${bundlorDir}/META-INF/MANIFEST.MF") + + @Input + Map expansions = [:] + + @InputFile + @Optional + File osgiProfile + + @InputFiles + @Optional + FileCollection inputPaths + + @Input + boolean failOnWarnings = false + + Bundlor() { + manifestTemplate = new File(project.projectDir, 'template.mf') + + if (!manifestTemplate.exists()) { + logger.info("No bundlor template for project " + project.name) + manifestTemplate = null + } + + inputPaths = project.files(project.sourceSets.main.output.classesDir) + + if (manifestTemplate != null) { + project.jar.manifest.from manifest + project.jar.inputs.files manifest + } + } + + @TaskAction + void createManifest() { + if (manifestTemplate == null) { + return; + } + + logging.captureStandardOutput(LogLevel.INFO) + + project.mkdir(bundlorDir) + + //String inputPath = project.sourceSets.main.classesDir + + List inputClassPath = [] as List; + + ManifestWriter manifestWriter = new FileSystemManifestWriter(project.file(bundlorDir.absolutePath)); + ManifestContents mfTemplate = BundleManifestUtils.getManifest(manifestTemplate); + + inputPaths.each {f -> + inputClassPath.add(new FileSystemClassPath(f)) + } + + // Must be a better way of doing this... + Properties p = new Properties() + expansions.each {entry -> + p.setProperty(entry.key, entry.value as String) + } + + PropertiesSource expansionProps = new PropertiesPropertiesSource(p) + PropertiesSource osgiProfileProps = osgiProfile == null ? new EmptyPropertiesSource() : + new FileSystemPropertiesSource(osgiProfile); + + ManifestGenerator manifestGenerator = new StandardManifestGenerator( + DefaultManifestGeneratorContributorsFactory.create(expansionProps, osgiProfileProps)); + + ManifestContents mf = manifestGenerator.generate(mfTemplate, inputClassPath.toArray(new ClassPath[inputClassPath.size()])); + + try { + manifestWriter.write(mf); + } finally { + manifestWriter.close(); + } + + ManifestValidator manifestValidator = new StandardManifestValidator(DefaultManifestValidatorContributorsFactory.create()); + + List warnings = manifestValidator.validate(mf); + + if (warnings.isEmpty()) { + return + } + + logger.warn("Bundlor Warnings:"); + for (String warning : warnings) { + logger.warn(" " + warning); + } + + if (failOnWarnings) { + throw new GradleException("Bundlor returned warnings. Please fix manifest template at " + manifestTemplate.absolutePath + " and try again.") + } + } + + def inputPath(FileCollection paths) { + inputPaths = project.files(inputPaths, paths) + } +} diff --git a/buildSrc/src/main/groovy/docbook/DocbookPlugin.groovy b/buildSrc/src/main/groovy/docbook/DocbookPlugin.groovy index 24e84de9ad..d9c699c061 100644 --- a/buildSrc/src/main/groovy/docbook/DocbookPlugin.groovy +++ b/buildSrc/src/main/groovy/docbook/DocbookPlugin.groovy @@ -48,6 +48,9 @@ class DocbookPlugin implements Plugin { Task docbookFoPdf = project.tasks.add("docbookFoPdf", DocbookFoPdf.class); docbookFoPdf.setDescription('Generates PDF output'); docbookFoPdf.extension = 'fo' + + Task docbook = project.tasks.add("docbook", DefaultTask.class); + docbook.dependsOn (docbookHtml, docbookHtmlSingle, docbookFoPdf) } } @@ -69,6 +72,8 @@ public class Docbook extends DefaultTask { String admonGraphicsPath; + String imgSrcPath; + @InputDirectory File sourceDirectory = new File(project.getProjectDir(), "src/docbook"); @@ -87,7 +92,7 @@ public class Docbook extends DefaultTask { factory.setXIncludeAware(XIncludeAware); docsDir.mkdirs(); - File srcFile = new File(sourceDirectory, sourceFileName); + File srcFile = new File(filterDocbookSources(sourceDirectory), sourceFileName); String outputFilename = srcFile.getName().substring(0, srcFile.getName().length() - 4) + suffix + '.' + extension; File outputFile = new File(getDocsDir(), outputFilename); @@ -112,11 +117,15 @@ public class Docbook extends DefaultTask { } transformer.setParameter("highlight.xslthl.config", new File(highlightingDir, "xslthl-config.xml").toURI().toURL()); + } - if (admonGraphicsPath != null) { - transformer.setParameter("admon.graphics", "1"); - transformer.setParameter("admon.graphics.path", admonGraphicsPath); - } + if (admonGraphicsPath != null) { + transformer.setParameter("admon.graphics", "1"); + transformer.setParameter("admon.graphics.path", admonGraphicsPath); + } + + if (imgSrcPath != null) { + transformer.setParameter("img.src.path", imgSrcPath); } preTransform(transformer, srcFile, outputFile); @@ -126,6 +135,32 @@ public class Docbook extends DefaultTask { postTransform(outputFile); } + /** + * @param sourceDir directory of unfiltered sources + * @return directory of filtered sources + * @author Chris Beams + */ + private File filterDocbookSources(File sourceDir) { + def docbookWorkDir = new File("${project.buildDir}/reference-work") + + docbookWorkDir.mkdirs() + + // copy everything but springsecurity.xml + project.copy { + into(docbookWorkDir) + from(sourceDir) { exclude '**/springsecurity.xml' } + } + // copy index.xml and expand ${...} variables along the way + // e.g.: ${version} needs to be replaced in the header + project.copy { + into(docbookWorkDir) + from(sourceDir) { include '**/springsecurity.xml' } + expand(version: "${project.version}") + } + + return docbookWorkDir + } + private void extractHighlightFiles(File toDir) { URLClassLoader cl = (URLClassLoader) getClass().getClassLoader(); URL[] urls = cl.getURLs(); @@ -254,9 +289,9 @@ class DocbookFoPdf extends Docbook { } } - if (!foFile.delete()) { +/* if (!foFile.delete()) { logger.warn("Failed to delete 'fo' file " + foFile); - } + }*/ } private File getPdfOutputFile(File foFile) { diff --git a/buildSrc/src/main/groovy/emma/EmmaPlugin.groovy b/buildSrc/src/main/groovy/emma/EmmaPlugin.groovy new file mode 100644 index 0000000000..f325019468 --- /dev/null +++ b/buildSrc/src/main/groovy/emma/EmmaPlugin.groovy @@ -0,0 +1,114 @@ +package emma; + +import org.gradle.api.* +import org.gradle.api.tasks.testing.Test +import org.gradle.api.tasks.TaskAction +import org.gradle.api.tasks.Input +import com.vladium.emma.instr.InstrProcessor +import com.vladium.emma.report.ReportProcessor +import org.gradle.api.tasks.InputFiles +import com.vladium.util.XProperties; + +/** + * + * @author Luke Taylor + */ +class EmmaPlugin implements Plugin { + + void apply(Project project) { + Project rootProject = project.rootProject + def emmaMetaDataFile = "${rootProject.buildDir}/emma/emma.em" + def emmaCoverageFile = "${rootProject.buildDir}/emma/emma.ec" + + if (project.configurations.findByName('emma_rt') == null) { + project.configurations.add('emma_rt') + project.dependencies { + emma_rt 'emma:emma:2.0.5312' + } + } + + project.task('emmaInstrument') { + dependsOn project.classes + + doFirst { + InstrProcessor processor = InstrProcessor.create (); + String[] classesDirPath = [project.sourceSets.main.output.classesDir.absolutePath] + + processor.setInstrPath(classesDirPath, false); + processor.setOutMode(InstrProcessor.OutMode.OUT_MODE_COPY); + processor.setInstrOutDir("${project.buildDir}/emma/classes"); + processor.setMetaOutFile(emmaMetaDataFile); + processor.setMetaOutMerge(true); + //processor.setInclExclFilter (null); + processor.run(); + } + } + + // Modify test tasks in the project to generate coverage data + project.afterEvaluate { + if (project.hasProperty('coverage') && ['on','true'].contains(project.properties.coverage)) { + project.tasks.withType(Test.class).each { task -> + task.dependsOn project.emmaInstrument + task.configure() { + jvmArgs '-Dsec.log.level=DEBUG', "-Demma.coverage.out.file=$emmaCoverageFile" + jvmArgs '-Demma.verbosity.level=quiet' + } + task.doFirst { + classpath = project.files("${project.buildDir}/emma/classes") + project.configurations.emma_rt + classpath + } + } + } + } + + List reportTasks = rootProject.getTasksByName('coverageReport', false) as List; + CoverageReport task; + + if (reportTasks.isEmpty()) { + task = rootProject.tasks.add('coverageReport', CoverageReport.class); + task.dataPath = [emmaMetaDataFile, emmaCoverageFile]; + } else { + task = reportTasks[0]; + } + + task.modules.add(project); + } +} + +class CoverageReport extends DefaultTask { + @Input + List modules = []; + + @Input + String[] dataPath; + + @TaskAction + void generateReport() { + def buildDir = project.rootProject.buildDir + + if (!buildDir.exists()) { + throw new GradleException("No coverage data. Run gradle with -Pcoverage=on if using coverageReport"); + } + + ReportProcessor processor = ReportProcessor.create (); + processor.setDataPath(dataPath) + + def srcPath = [] + modules.each {module-> + module.sourceSets.main.java.srcDirs.each { + srcPath.add(it.absolutePath) + } + } + + processor.setSourcePath(srcPath as String[]); + + + def types = ['txt', 'html'] + processor.setReportTypes(types as String[]); + XProperties properties = new XProperties(); + properties.setProperty('report.html.out.file', "$buildDir/emma/coverage.html"); + properties.setProperty('report.txt.out.file', "$buildDir/emma/coverage.txt"); + processor.setPropertyOverrides(properties) + + processor.run() + } +} diff --git a/buildSrc/src/main/groovy/gae/GaePlugin.groovy b/buildSrc/src/main/groovy/gae/GaePlugin.groovy new file mode 100644 index 0000000000..b131c8c316 --- /dev/null +++ b/buildSrc/src/main/groovy/gae/GaePlugin.groovy @@ -0,0 +1,26 @@ +package gae; + +import com.google.appengine.tools.admin.AppCfg +import org.gradle.api.*; + +class GaePlugin implements Plugin { + public void apply(Project project) { + if (!project.hasProperty('appEngineSdkRoot')) { + println "'appEngineSdkRoot' must be set in gradle.properties" + } else { + System.setProperty('appengine.sdk.root', project.property('appEngineSdkRoot')) + } + + File explodedWar = new File(project.buildDir, "gae-exploded") + + project.task('gaeDeploy') << { + AppCfg.main("update", explodedWar.toString()) + } + + project.gaeDeploy.dependsOn project.war + + project.war.doLast { + ant.unzip(src: project.war.archivePath, dest: explodedWar) + } + } +} diff --git a/buildSrc/src/main/resources/META-INF/gradle-plugins/aspectj.properties b/buildSrc/src/main/resources/META-INF/gradle-plugins/aspectj.properties new file mode 100644 index 0000000000..3e8a23c083 --- /dev/null +++ b/buildSrc/src/main/resources/META-INF/gradle-plugins/aspectj.properties @@ -0,0 +1 @@ +implementation-class=aspectj.AspectJPlugin diff --git a/buildSrc/src/main/resources/META-INF/gradle-plugins/bundlor.properties b/buildSrc/src/main/resources/META-INF/gradle-plugins/bundlor.properties new file mode 100644 index 0000000000..483572f837 --- /dev/null +++ b/buildSrc/src/main/resources/META-INF/gradle-plugins/bundlor.properties @@ -0,0 +1 @@ +implementation-class=bundlor.BundlorPlugin diff --git a/buildSrc/src/main/resources/META-INF/gradle-plugins/emma.properties b/buildSrc/src/main/resources/META-INF/gradle-plugins/emma.properties new file mode 100644 index 0000000000..29a6d56444 --- /dev/null +++ b/buildSrc/src/main/resources/META-INF/gradle-plugins/emma.properties @@ -0,0 +1 @@ +implementation-class=emma.EmmaPlugin diff --git a/buildSrc/src/main/resources/META-INF/gradle-plugins/gae.properties b/buildSrc/src/main/resources/META-INF/gradle-plugins/gae.properties new file mode 100644 index 0000000000..d6c44963b6 --- /dev/null +++ b/buildSrc/src/main/resources/META-INF/gradle-plugins/gae.properties @@ -0,0 +1 @@ +implementation-class=gae.GaePlugin \ No newline at end of file diff --git a/cas/cas.gradle b/cas/cas.gradle index 7b4945de3e..291c09d2ba 100644 --- a/cas/cas.gradle +++ b/cas/cas.gradle @@ -10,4 +10,4 @@ dependencies { "net.sf.ehcache:ehcache:$ehcacheVersion" provided 'javax.servlet:servlet-api:2.5' -} \ No newline at end of file +} \ No newline at end of file diff --git a/cas/pom.xml b/cas/pom.xml index 9334bf1b62..dc0b373ef9 100644 --- a/cas/pom.xml +++ b/cas/pom.xml @@ -3,7 +3,7 @@ org.springframework.security spring-security-parent - 3.0.8.CI-SNAPSHOT + @pomVersion@ spring-security-cas-client Spring Security - CAS support diff --git a/cas/template.mf b/cas/template.mf index 06da716830..b508b16119 100644 --- a/cas/template.mf +++ b/cas/template.mf @@ -5,18 +5,18 @@ Bundle-Name: Spring Security CAS Bundle-Vendor: SpringSource Bundle-Version: ${version} Bundle-ManifestVersion: 2 -Ignored-Existing-Headers: +Ignored-Existing-Headers: Import-Package, Export-Package -Import-Template: - org.apache.commons.logging.*;version="[1.0.4, 2.0.0)", - org.jasig.cas.client.*;version="[3.1.1,3.2)", - org.springframework.security.core.*;version="[${version}, 3.1.0)", - org.springframework.security.authentication.*;version="[${version}, 3.1.0)", - org.springframework.security.web.*;version="[${version}, 3.1.0)", - org.springframework.beans.factory;version="[${spring.version}, 3.1.0)", - org.springframework.context.*;version="[${spring.version}, 3.1.0)", - org.springframework.dao;version="[${spring.version}, 3.1.0)", - org.springframework.util;version="[${spring.version}, 3.1.0)", - net.sf.ehcache.*;version="[1.4.1, 2.0.0)";resolution:=optional, +Import-Template: + org.apache.commons.logging.*;version="${cloggingRange}", + org.jasig.cas.client.*;version="${casRange}", + org.springframework.security.core.*;version="${secRange}", + org.springframework.security.authentication.*;version="${secRange}", + org.springframework.security.web.*;version="${secRange}", + org.springframework.beans.factory;version="${springRange}", + org.springframework.context.*;version="${springRange}", + org.springframework.dao;version="${springRange}", + org.springframework.util;version="${springRange}", + net.sf.ehcache.*;version="${ehcacheRange}";resolution:=optional, javax.servlet.*;version="0" diff --git a/config/config.gradle b/config/config.gradle index 87661e85a1..7e7275cfba 100644 --- a/config/config.gradle +++ b/config/config.gradle @@ -17,8 +17,23 @@ dependencies { testCompile project(':spring-security-ldap'), project(':spring-security-openid'), - files(this.project(':spring-security-core').sourceSets.test.classesDir), + project(':spring-security-core').sourceSets.test.output, 'javax.annotation:jsr250-api:1.0', "org.springframework.ldap:spring-ldap-core:$springLdapVersion", - "org.springframework:spring-jdbc:$springVersion" + "org.springframework:spring-expression:$springVersion", + "org.springframework:spring-jdbc:$springVersion", + "org.springframework:spring-tx:$springVersion", + 'org.spockframework:spock-core:0.6-groovy-1.8', + "org.slf4j:jcl-over-slf4j:$slf4jVersion" + testCompile('org.openid4java:openid4java-nodeps:0.9.6') { + exclude group: 'com.google.code.guice', module: 'guice' + } + + + testRuntime "hsqldb:hsqldb:$hsqlVersion", + "cglib:cglib-nodep:2.2" +} + +integrationTest { + systemProperties['apacheDSWorkDir'] = "${buildDir}/apacheDSWork" } diff --git a/config/pom.xml b/config/pom.xml index 120ac463e2..0fc76059bd 100644 --- a/config/pom.xml +++ b/config/pom.xml @@ -3,7 +3,7 @@ org.springframework.security spring-security-parent - 3.0.8.CI-SNAPSHOT + @pomVersion@ jar spring-security-config diff --git a/config/src/test/java/org/springframework/security/config/ldap/LdapProviderBeanDefinitionParserTests.java b/config/src/integration-test/java/org/springframework/security/config/ldap/LdapProviderBeanDefinitionParserTests.java similarity index 100% rename from config/src/test/java/org/springframework/security/config/ldap/LdapProviderBeanDefinitionParserTests.java rename to config/src/integration-test/java/org/springframework/security/config/ldap/LdapProviderBeanDefinitionParserTests.java diff --git a/config/src/test/java/org/springframework/security/config/ldap/LdapServerBeanDefinitionParserTests.java b/config/src/integration-test/java/org/springframework/security/config/ldap/LdapServerBeanDefinitionParserTests.java similarity index 61% rename from config/src/test/java/org/springframework/security/config/ldap/LdapServerBeanDefinitionParserTests.java rename to config/src/integration-test/java/org/springframework/security/config/ldap/LdapServerBeanDefinitionParserTests.java index 72f44f9f13..ed6bf73ec9 100644 --- a/config/src/test/java/org/springframework/security/config/ldap/LdapServerBeanDefinitionParserTests.java +++ b/config/src/integration-test/java/org/springframework/security/config/ldap/LdapServerBeanDefinitionParserTests.java @@ -1,14 +1,31 @@ +/* + * Copyright 2002-2012 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * 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.springframework.security.config.ldap; +import static org.junit.Assert.*; + import org.junit.After; import org.junit.Test; import org.springframework.ldap.core.LdapTemplate; import org.springframework.security.config.BeanIds; import org.springframework.security.config.util.InMemoryXmlApplicationContext; import org.springframework.security.ldap.DefaultSpringSecurityContextSource; +import org.springframework.security.ldap.server.ApacheDSContainer; +import org.springframework.test.util.ReflectionTestUtils; /** * @author Luke Taylor + * @author Rob Winch */ public class LdapServerBeanDefinitionParserTests { InMemoryXmlApplicationContext appCtx; @@ -23,7 +40,7 @@ public class LdapServerBeanDefinitionParserTests { @Test public void embeddedServerCreationContainsExpectedContextSourceAndData() { - appCtx = new InMemoryXmlApplicationContext(""); + appCtx = new InMemoryXmlApplicationContext(""); DefaultSpringSecurityContextSource contextSource = (DefaultSpringSecurityContextSource) appCtx.getBean(BeanIds.CONTEXT_SOURCE); @@ -35,8 +52,8 @@ public class LdapServerBeanDefinitionParserTests { @Test public void useOfUrlAttributeCreatesCorrectContextSource() { // Create second "server" with a url pointing at embedded one - appCtx = new InMemoryXmlApplicationContext("" + - ""); + appCtx = new InMemoryXmlApplicationContext("" + + ""); // Check the default context source is still there. appCtx.getBean(BeanIds.CONTEXT_SOURCE); @@ -58,6 +75,12 @@ public class LdapServerBeanDefinitionParserTests { template.lookup("uid=pg,ou=gorillas"); } + @Test + public void defaultLdifFileIsSuccessful() { + appCtx = new InMemoryXmlApplicationContext( + ""); + ApacheDSContainer dsContainer = appCtx.getBean(ApacheDSContainer.class); - + assertEquals("classpath*:*.ldif", ReflectionTestUtils.getField(dsContainer, "ldifResources")); + } } diff --git a/config/src/test/java/org/springframework/security/config/ldap/LdapUserServiceBeanDefinitionParserTests.java b/config/src/integration-test/java/org/springframework/security/config/ldap/LdapUserServiceBeanDefinitionParserTests.java similarity index 82% rename from config/src/test/java/org/springframework/security/config/ldap/LdapUserServiceBeanDefinitionParserTests.java rename to config/src/integration-test/java/org/springframework/security/config/ldap/LdapUserServiceBeanDefinitionParserTests.java index 2f1d44fe1d..d862ca4e9d 100644 --- a/config/src/test/java/org/springframework/security/config/ldap/LdapUserServiceBeanDefinitionParserTests.java +++ b/config/src/integration-test/java/org/springframework/security/config/ldap/LdapUserServiceBeanDefinitionParserTests.java @@ -1,17 +1,24 @@ +/* + * Copyright 2002-2012 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * 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.springframework.security.config.ldap; import static org.junit.Assert.*; -import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.*; import static org.springframework.security.config.ldap.LdapUserServiceBeanDefinitionParser.*; -import java.util.Set; - -import org.junit.After; -import org.junit.Test; -import org.springframework.security.config.ldap.LdapUserServiceBeanDefinitionParser; +import org.junit.*; import org.springframework.security.config.util.InMemoryXmlApplicationContext; import org.springframework.security.core.authority.AuthorityUtils; -import org.springframework.security.core.authority.GrantedAuthorityImpl; import org.springframework.security.core.userdetails.UserDetails; import org.springframework.security.core.userdetails.UserDetailsService; import org.springframework.security.ldap.search.FilterBasedLdapUserSearch; @@ -24,8 +31,11 @@ import org.springframework.security.ldap.userdetails.Person; import org.springframework.security.ldap.userdetails.PersonContextMapper; import org.w3c.dom.Element; +import java.util.*; + /** * @author Luke Taylor + * @author Rob Winch */ public class LdapUserServiceBeanDefinitionParserTests { private InMemoryXmlApplicationContext appCtx; @@ -50,12 +60,12 @@ public class LdapUserServiceBeanDefinitionParserTests { @Test public void minimalConfigurationIsParsedOk() throws Exception { - setContext(""); + setContext(""); } @Test public void userServiceReturnsExpectedData() throws Exception { - setContext(""); + setContext(""); UserDetailsService uds = (UserDetailsService) appCtx.getBean("ldapUDS"); UserDetails ben = uds.loadUserByUsername("ben"); @@ -70,7 +80,7 @@ public class LdapUserServiceBeanDefinitionParserTests { setContext(""); + " group-search-filter='member={0}' />"); UserDetailsService uds = (UserDetailsService) appCtx.getBean("ldapUDS"); UserDetails joe = uds.loadUserByUsername("Joe Smeth"); @@ -86,7 +96,7 @@ public class LdapUserServiceBeanDefinitionParserTests { " group-search-filter='member={0}' role-prefix='PREFIX_'/>" + ""); + " group-search-filter='member={0}' role-prefix='none'/>"); UserDetailsService uds = (UserDetailsService) appCtx.getBean("ldapUDS"); UserDetails ben = uds.loadUserByUsername("ben"); @@ -101,21 +111,21 @@ public class LdapUserServiceBeanDefinitionParserTests { @Test public void differentGroupRoleAttributeWorksAsExpected() throws Exception { - setContext(""); + setContext(""); UserDetailsService uds = (UserDetailsService) appCtx.getBean("ldapUDS"); UserDetails ben = uds.loadUserByUsername("ben"); Set authorities = AuthorityUtils.authorityListToSet(ben.getAuthorities()); assertEquals(3, authorities.size()); - assertTrue(authorities.contains(new GrantedAuthorityImpl("ROLE_DEVELOPER"))); + assertTrue(authorities.contains("ROLE_DEVELOPER")); } @Test public void isSupportedByAuthenticationProviderElement() { setContext( - "" + + "" + "" + " " + " " + @@ -126,7 +136,7 @@ public class LdapUserServiceBeanDefinitionParserTests { @Test public void personContextMapperIsSupported() { setContext( - "" + + "" + ""); UserDetailsService uds = (UserDetailsService) appCtx.getBean("ldapUDS"); UserDetails ben = uds.loadUserByUsername("ben"); @@ -136,7 +146,7 @@ public class LdapUserServiceBeanDefinitionParserTests { @Test public void inetOrgContextMapperIsSupported() { setContext( - "" + + "" + ""); UserDetailsService uds = (UserDetailsService) appCtx.getBean("ldapUDS"); UserDetails ben = uds.loadUserByUsername("ben"); @@ -146,7 +156,7 @@ public class LdapUserServiceBeanDefinitionParserTests { @Test public void externalContextMapperIsSupported() { setContext( - "" + + "" + "" + ""); diff --git a/config/template.mf b/config/template.mf index 251edc81d8..cc76467216 100644 --- a/config/template.mf +++ b/config/template.mf @@ -5,22 +5,24 @@ Bundle-Name: Spring Security Namespace Configuration Bundle-Vendor: SpringSource Bundle-Version: ${version} Bundle-ManifestVersion: 2 -Ignored-Existing-Headers: +Ignored-Existing-Headers: Import-Package, Export-Package -Import-Template: - org.apache.commons.logging.*;version="[1.0.4, 2.0.0)", - org.aspectj.*;version="[1.6.0, 1.7.0)";resolution:=optional, - org.springframework.security.access.*;version="[${version}, 3.1.0)", - org.springframework.security.authentication.*;version="[${version}, 3.1.0)", - org.springframework.security.core.*;version="[${version}, 3.1.0)", - org.springframework.security.util;version="[${version}, 3.1.0)", - org.springframework.security.web.*;version="[${version}, 3.1.0)";resolution:=optional, - org.springframework.aop.*;version="[${spring.version}, 3.1.0)";resolution:=optional, - org.springframework.beans.*;version="[${spring.version}, 3.1.0)", - org.springframework.context.*;version="[${spring.version}, 3.1.0)", - org.springframework.core.*;version="[${spring.version}, 3.1.0)", - org.springframework.util.*;version="[${spring.version}, 3.1.0)", - javax.servlet;version="0";resolution:=optional, +Import-Template: + org.apache.commons.logging.*;version="${cloggingRange}", + org.aspectj.*;version="${aspectjRange}";resolution:=optional, + org.springframework.security.access.*;version="${secRange}", + org.springframework.security.authentication.*;version="${secRange}", + org.springframework.security.core.*;version="${secRange}", + org.springframework.security.util;version="${secRange}", + org.springframework.security.provisioning;version="${secRange}", + org.springframework.security.web.*;version="${secRange}";resolution:=optional, + org.springframework.aop.*;version="${springRange}";resolution:=optional, + org.springframework.beans.*;version="${springRange}", + org.springframework.context.*;version="${springRange}", + org.springframework.core.*;version="${springRange}", + org.springframework.web.*;version="${springRange}", + org.springframework.util.*;version="${springRange}", + javax.servlet.*;version="0";resolution:=optional, javax.naming.directory;version="0";resolution:=optional, org.w3c.dom;version="0";resolution:=optional diff --git a/core/core.gradle b/core/core.gradle index 4e7fc54aa6..27036e68c0 100644 --- a/core/core.gradle +++ b/core/core.gradle @@ -17,5 +17,9 @@ dependencies { runtime 'hsqldb:hsqldb:1.8.0.10' testCompile 'commons-collections:commons-collections:3.2', - "org.springframework:spring-test:$springVersion" + "org.springframework:spring-test:$springVersion", + "org.slf4j:jcl-over-slf4j:$slf4jVersion" + + testRuntime "hsqldb:hsqldb:$hsqlVersion", + "cglib:cglib-nodep:$cglibVersion" } diff --git a/core/pom.xml b/core/pom.xml index 9aafc0e420..badb511fb9 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -3,7 +3,7 @@ org.springframework.security spring-security-parent - 3.0.8.CI-SNAPSHOT + @pomVersion@ jar spring-security-core diff --git a/core/template.mf b/core/template.mf index 81918e516b..4560dd006c 100644 --- a/core/template.mf +++ b/core/template.mf @@ -9,20 +9,20 @@ Ignored-Existing-Headers: Import-Package, Export-Package Import-Template: - org.aopalliance.*;version="[1.0.0, 2.0.0)", - org.aspectj.*;version="[1.6.0, 1.7.0)";resolution:=optional, - org.apache.commons.logging.*;version="[1.0.4, 2.0.0)", - org.springframework.aop.*;version="[${spring.version}, 3.1.0)";resolution:=optional, - org.springframework.beans.*;version="[${spring.version}, 3.1.0)", - org.springframework.context.*;version="[${spring.version}, 3.1.0)", - org.springframework.core.*;version="[${spring.version}, 3.1.0)", - org.springframework.expression.*;version="[${spring.version}, 3.1.0)";resolution:=optional, - org.springframework.remoting.*;version="[${spring.version}, 3.1.0)";resolution:=optional, - org.springframework.dao.*;version="[${spring.version}, 3.1.0)";resolution:=optional, - org.springframework.jdbc.*;version="[${spring.version}, 3.1.0)";resolution:=optional, - org.springframework.transaction.*;version="[${spring.version}, 3.1.0)";resolution:=optional, - org.springframework.util;version="[${spring.version}, 3.1.0)", - net.sf.ehcache.*;version="[1.4.1, 2.0.0)";resolution:=optional, + org.aopalliance.*;version="${aopAllianceRange}", + org.aspectj.*;version="${aspectjRange}";resolution:=optional, + org.apache.commons.logging.*;version="${cloggingRange}", + org.springframework.aop.*;version="${springRange}";resolution:=optional, + org.springframework.beans.*;version="${springRange}", + org.springframework.context.*;version="${springRange}", + org.springframework.core.*;version="${springRange}", + org.springframework.expression.*;version="${springRange}";resolution:=optional, + org.springframework.remoting.*;version="${springRange}";resolution:=optional, + org.springframework.dao.*;version="${springRange}";resolution:=optional, + org.springframework.jdbc.*;version="${springRange}";resolution:=optional, + org.springframework.transaction.*;version="${springRange}";resolution:=optional, + org.springframework.util;version="${springRange}", + net.sf.ehcache.*;version="${ehcacheRange}";resolution:=optional, javax.annotation.security.*;version="0";resolution:=optional, javax.crypto.*;version="0";resolution:=optional, javax.security.auth.*;version="0";resolution:=optional, diff --git a/docs/docs.gradle b/docs/docs.gradle new file mode 100644 index 0000000000..685ac7dbd6 --- /dev/null +++ b/docs/docs.gradle @@ -0,0 +1,143 @@ + // Docbook and Javadoc building and uploading tasks +apply plugin: 'base' + +task docs { + dependsOn 'manual:docbook', 'faq:docbookHtmlSingle', 'apidocs' +} + +subprojects { + apply plugin: 'base' + apply plugin: 'docbook' + + docbookHtmlSingle.stylesheet = new File(projectDir, 'src/xsl/html-single-custom.xsl') +} + +project('faq') { + defaultTasks 'docbookHtmlSingle' + [docbookHtml, docbookFoPdf, docbookHtmlSingle]*.sourceFileName = 'faq.xml' + docbookHtmlSingle.suffix = '' + + ext.spec = copySpec { + into ('faq') { + from("$buildDir/docs") + from("$projectDir/src/resources") + } + } +} + +project('manual') { + defaultTasks 'docbookHtml', 'docbookHtmlSingle', 'docbookFoPdf' + [docbookHtml, docbookFoPdf, docbookHtmlSingle]*.sourceFileName = 'springsecurity.xml' + + docbookHtml.stylesheet = new File(projectDir, 'src/xsl/html-custom.xsl') + docbookHtmlSingle.stylesheet = new File(projectDir, 'src/xsl/html-single-custom.xsl') + docbookFoPdf.stylesheet = new File(projectDir, 'src/xsl/pdf-custom.xsl') + def imagesDir = new File(projectDir, 'src/docbook/images'); +// docbookFoPdf.admonGraphicsPath = "${imagesDir}/" + docbookFoPdf.imgSrcPath = "${projectDir}/src/docbook/" + + ext.spec = copySpec { + into ('reference') { + from("$buildDir/docs") + from("$projectDir/src/resources") + } + into ('reference/images') { + from (imagesDir) + } + } +} + +task reference (type: Copy) { + dependsOn 'manual:docbook' + destinationDir = buildDir + with(project('manual').spec) +} + +task apidocs(type: Javadoc) { + destinationDir = new File(buildDir, 'apidocs') + title = "Spring Security $version API" + + source coreModuleProjects.collect { project -> + project.sourceSets.main.allJava + } + + classpath = files(coreModuleProjects.collect { project -> + project.sourceSets.main.compileClasspath + }) +} + +apidocs.options.outputLevel = org.gradle.external.javadoc.JavadocOutputLevel.QUIET + +apidocs.options.links = [ + "http://static.springframework.org/spring/docs/3.0.x/javadoc-api", + "http://static.springsource.org/spring-ldap/docs/1.3.x/apidocs/", + "http://download.oracle.com/javase/6/docs/api/" +] + +apidocs.options.groups = [ + 'Spring Security Core':[ + 'org.springframework.security.core*', + 'org.springframework.security.authentication*', + 'org.springframework.security.access*', + 'org.springframework.security.remoting*', + 'org.springframework.security.provisioning*', + 'org.springframework.security.util*'], + 'Spring Security Web':['org.springframework.security.web*'], + 'Spring Security LDAP':['org.springframework.security.ldap*'], + 'Spring Security Crypto':['org.springframework.security.crypto*'], + 'Spring Security OpenID':['org.springframework.security.openid*'], + 'Spring Security CAS':['org.springframework.security.cas*'], + 'Spring Security ACL':['org.springframework.security.acls*'], + 'Spring Security Config':['org.springframework.security.config*'], + 'Spring Security Taglibs':['org.springframework.security.taglibs*'], + +] + +ext.apiSpec = copySpec { + into('apidocs') { + from(apidocs.destinationDir) + } +} + +assemble.dependsOn = [apidocs, 'manual:docbook'] + +task docsZip(type: Zip) { + dependsOn docs + group = 'Distribution' + baseName = rootProject.name + classifier = 'docs' + description = "Builds -${classifier} archive containing api and reference " + + "for deployment at static.springframework.org/spring-security/site/docs." + + with(project(':docs').apiSpec) + with(project(':docs:manual').spec) + with(project(':docs:faq').spec) +} + +task schemaZip(type: Zip) { + group = 'Distribution' + baseName = rootProject.name + classifier = 'schema' + description = "Builds -${classifier} archive containing all " + + "XSDs for deployment at static.springframework.org/schema." + + coreModuleProjects.each { module -> + def Properties schemas = new Properties(); + + module.sourceSets.main.resources.find { + it.path.endsWith('META-INF/spring.schemas') + }?.withInputStream { schemas.load(it) } + + for (def key : schemas.keySet()) { + def shortName = key.replaceAll(/http.*schema.(.*).spring-.*/, '$1') + assert shortName != key + File xsdFile = module.sourceSets.main.resources.find { + it.path.endsWith(schemas.get(key)) + } + assert xsdFile != null + into (shortName) { + from xsdFile.path + } + } + } +} diff --git a/docs/faq/faq.gradle b/docs/faq/faq.gradle deleted file mode 100644 index 2680a455e3..0000000000 --- a/docs/faq/faq.gradle +++ /dev/null @@ -1,17 +0,0 @@ -apply plugin: 'base' -apply plugin: 'docbook' - -defaultTasks 'docbookHtmlSingle' - -[docbookHtml, docbookFoPdf, docbookHtmlSingle]*.sourceFileName = 'faq.xml' - -docbookHtmlSingle.stylesheet = new File(projectDir, 'src/xsl/html-single-custom.xsl') -docbookHtmlSingle.suffix = '' - -docbookHtmlSingle.doLast { - resourcesDir = new File(projectDir, 'src/resources') - ant { - docsDir = new File(buildDir, 'docs') - copy(toDir: docsDir) {fileset(dir: resourcesDir)} - } -} diff --git a/docs/manual/manual.gradle b/docs/manual/manual.gradle deleted file mode 100644 index a1f7b6f28a..0000000000 --- a/docs/manual/manual.gradle +++ /dev/null @@ -1,19 +0,0 @@ -apply plugin: 'base' -apply plugin: 'docbook' - -[docbookHtml, docbookFoPdf, docbookHtmlSingle]*.sourceFileName = 'springsecurity.xml'; - -docbookHtml.stylesheet = new File(projectDir, 'src/xsl/html-custom.xsl') -docbookHtmlSingle.stylesheet = new File(projectDir, 'src/xsl/html-single-custom.xsl') -docbookFoPdf.stylesheet = new File(projectDir, 'src/xsl/pdf-custom.xsl') -def imagesDir = new File(projectDir, 'src/docbook/images'); -docbookFoPdf.admonGraphicsPath = "${imagesDir}/" - -task doc (dependsOn: [docbookHtml, docbookHtmlSingle, docbookFoPdf]) << { - resourcesDir = new File(projectDir, 'src/resources') - ant { - docsDir = new File(buildDir, 'docs') - copy(toDir: docsDir) {fileset(dir: resourcesDir)} - copy(toDir: new File(docsDir, 'images')) {fileset(dir: imagesDir)} - } -} diff --git a/docs/manual/src/docbook/springsecurity.xml b/docs/manual/src/docbook/springsecurity.xml index 3028a3bc1b..82c77c0ebb 100644 --- a/docs/manual/src/docbook/springsecurity.xml +++ b/docs/manual/src/docbook/springsecurity.xml @@ -10,7 +10,7 @@ Spring Security - 3.0.7.RELEASE + ${version} diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000000..d8b19fe0ce --- /dev/null +++ b/gradle.properties @@ -0,0 +1 @@ +version=3.0.8.CI-SNAPSHOT \ No newline at end of file diff --git a/gradle/aspectj.gradle b/gradle/aspectj.gradle deleted file mode 100644 index 0d7cab37e4..0000000000 --- a/gradle/aspectj.gradle +++ /dev/null @@ -1,47 +0,0 @@ -apply plugin: 'java' - -configurations { - ajtools - aspectpath -} - -dependencies { - ajtools "org.aspectj:aspectjtools:$aspectjVersion" - compile "org.aspectj:aspectjrt:$aspectjVersion" -} - -task compileJava(overwrite: true, description: 'Compiles AspectJ Source', type: Ajc) { - dependsOn processResources - sourceSet = sourceSets.main - aspectPath = configurations.aspectpath -} - -task compileTestJava(overwrite: true, description: 'Compiles AspectJ Test Source', type: Ajc) { - dependsOn processTestResources, compileJava, jar - sourceSet = sourceSets.test - aspectPath = files(configurations.aspectpath, jar.archivePath) -} - -class Ajc extends DefaultTask { - @Input - SourceSet sourceSet - - @Input - FileCollection aspectPath - - @TaskAction - def compile() { - println "Running ajc ..." - ant.taskdef(resource: "org/aspectj/tools/ant/taskdefs/aspectjTaskdefs.properties", classpath: project.configurations.ajtools.asPath) - ant.iajc(classpath: sourceSet.compileClasspath.asPath, fork: 'true', destDir: sourceSet.classesDir.absolutePath, - source: project.convention.plugins.java.sourceCompatibility, - target: project.convention.plugins.java.targetCompatibility, - aspectPath: aspectPath.asPath, sourceRootCopyFilter: '**/*.java', showWeaveInfo: 'true') { - sourceroots { - sourceSet.java.srcDirs.each { - pathelement(location: it.absolutePath) - } - } - } - } -} \ No newline at end of file diff --git a/gradle/bundlor.gradle b/gradle/bundlor.gradle deleted file mode 100644 index b081c9e1d4..0000000000 --- a/gradle/bundlor.gradle +++ /dev/null @@ -1,31 +0,0 @@ -apply plugin: 'java' - -configurations { - bundlor -} - -dependencies { - bundlor 'com.springsource.bundlor:com.springsource.bundlor.ant:1.0.0.RELEASE', - 'com.springsource.bundlor:com.springsource.bundlor:1.0.0.RELEASE', - 'com.springsource.bundlor:com.springsource.bundlor.blint:1.0.0.RELEASE' -} - -task bundlor(dependsOn: compileJava) { - onlyIf { - dependsOnTaskDidWork() - } - doFirst { - ant.taskdef(resource: 'com/springsource/bundlor/ant/antlib.xml', classpath: configurations.bundlor.asPath) - File template = new File(projectDir, 'template.mf') - mkdir("$buildDir/bundlor") - if (template.exists()) { - ant.bundlor(inputPath: sourceSets.main.classesDir, outputPath: "$buildDir/bundlor", manifestTemplatePath: template) { - property(name: 'version', value: "$version") - property(name: 'spring.version', value: "$springVersion") - } - jar.manifest.from("$buildDir/bundlor/META-INF/MANIFEST.MF") - } - } -} - -jar.dependsOn bundlor diff --git a/gradle/ide-integration.gradle b/gradle/ide-integration.gradle new file mode 100644 index 0000000000..aa1821b535 --- /dev/null +++ b/gradle/ide-integration.gradle @@ -0,0 +1,63 @@ +apply plugin: 'idea' + +configure(javaProjects) { + apply plugin: 'eclipse-wtp' + + eclipse.classpath.downloadSources = true + + // GRADLE-1116 + project.eclipse.classpath.file.whenMerged { classpath -> + classpath.entries.removeAll { entry -> entry.path.endsWith('/build/classes/test') } + } + + // GRADLE-1422 + project.eclipseClasspath.doFirst { + // delay adding whenMerged till the entryAttributes are added (must be the last whenMerged) + project.eclipse.classpath.file.whenMerged { classpath -> + def includeDeps = project.configurations.getByName('runtime').collect {f -> f.absolutePath } as Set + classpath.entries.each { cp -> + if(cp instanceof org.gradle.plugins.ide.eclipse.model.Library) { + def include = includeDeps.contains(cp.path) + def attr = 'org.eclipse.jst.component.dependency' + if(!include) { + cp.entryAttributes.remove(attr) + } + } + } + } + } + + tasks.withType(org.gradle.plugins.ide.eclipse.GenerateEclipseWtpComponent) { + project.eclipse.classpath.file.whenMerged { classpath-> + project.eclipse.wtp.component.file.whenMerged { wtpComponent -> + wtpComponent.contextPath = project.tasks.findByName('jettyRun')?.contextPath?.replaceFirst('/','') + } + } + } +} + +// STS-2723 +project(':spring-security-samples-aspectj') { + task afterEclipseImport { + ext.srcFile = file('.classpath') + inputs.file srcFile + outputs.dir srcFile + + onlyIf { srcFile.exists() } + + doLast { + def classpath = new XmlParser().parse(srcFile) + + classpath.classpathentry.findAll{ it.@path == '/spring-security-aspects' }.each { node -> + if(node.children().size() == 0) { + def attrs = new Node(node,'attributes') + def adjtAttr = new Node(attrs,'attributes',[name: 'org.eclipse.ajdt.aspectpath', value: 'org.eclipse.ajdt.aspectpath']) + node.appendNode(adjtAttr) + } + } + + def writer = new FileWriter(srcFile) + new XmlNodePrinter(new PrintWriter(writer)).print(classpath) + } + } +} diff --git a/gradle/javaprojects.gradle b/gradle/javaprojects.gradle index 7fd31440dd..a255bb526d 100644 --- a/gradle/javaprojects.gradle +++ b/gradle/javaprojects.gradle @@ -1,24 +1,73 @@ apply plugin: 'java' apply plugin: 'eclipse' -springVersion = '3.0.3.RELEASE' -springLdapVersion = '1.3.0.RELEASE' -ehcacheVersion = '1.6.2' -aspectjVersion = '1.6.8' -apacheDsVersion = '1.5.5' -jstlVersion = '1.1.2' -jettyVersion = '6.1.22' -hsqlVersion = '1.8.0.10' -slf4jVersion = '1.6.1' -logbackVersion = '0.9.29' +sourceCompatibility = 1.5 +targetCompatibility = 1.5 +ext.springVersion = '3.0.7.RELEASE' +ext.springLdapVersion = '1.3.1.RELEASE' +ext.ehcacheVersion = '1.6.2' +ext.aspectjVersion = '1.6.10' +ext.apacheDsVersion = '1.5.5' +ext.jstlVersion = '1.2' +ext.jettyVersion = '6.1.26' +ext.hsqlVersion = '1.8.0.10' +ext.slf4jVersion = '1.6.1' +ext.logbackVersion = '0.9.29' +ext.cglibVersion = '2.2' +ext.powerMockVersion = '1.4.12' +ext.bundlorProperties = [ + version: version, + secRange: "[$version, 3.1.0)", + springRange: "[$springVersion, 3.1.0)", + aspectjRange: '[1.6.0, 1.7.0)', + casRange: '[3.1.1, 3.2.0)', + cloggingRange: '[1.0.4, 2.0.0)', + ehcacheRange: '[1.4.1, 2.5.0)', + openid4javaRange: '[0.9.5, 1.0.0)', + springLdapRange: '[1.3.0,1.4.0)', + apacheDSRange: '[1.5.5, 1.6)', + apacheDSSharedRange: '[0.9.15, 1.0)', + ldapSdkRange: '[4.1, 5.0)', + aopAllianceRange: '[1.0.0, 2.0.0)' +] configurations { + // Configuration which is ONLY used for compileJava and will not be inherited by any others + // Revisit post Gradle 1.0 + compileOnly + // Used to identify deps which should be marked as "provided" in maven poms provided - compile.extendsFrom provided + testCompile.extendsFrom provided + compile.transitive = false + testCompile.transitive = false } +// Integration test setup +configurations { + integrationTestCompile { + extendsFrom testCompile + } + integrationTestRuntime { + extendsFrom integrationTestCompile, testRuntime + } +} +sourceSets { + integrationTest { + java.srcDir file('src/integration-test/java') + resources.srcDir file('src/integration-test/resources') + compileClasspath = sourceSets.main.output + sourceSets.test.output + configurations.integrationTestCompile + runtimeClasspath = output + compileClasspath + configurations.integrationTestRuntime + } +} +task integrationTest(type: Test, dependsOn: jar) { + testClassesDir = sourceSets.integrationTest.output.classesDir + logging.captureStandardOutput(LogLevel.INFO) + classpath = sourceSets.integrationTest.runtimeClasspath + maxParallelForks = 1 +// testReport = false +} dependencies { - compile 'commons-logging:commons-logging:1.1.1' + compileOnly 'commons-logging:commons-logging:1.1.1' compile ("org.springframework:spring-core:$springVersion") { exclude(group: 'commons-logging', module: 'commons-logging') @@ -31,12 +80,60 @@ dependencies { 'org.hamcrest:hamcrest-core:1.1', 'org.hamcrest:hamcrest-library:1.1', "org.springframework:spring-test:$springVersion" + // Use slf4j/logback for logging + testRuntime "org.slf4j:jcl-over-slf4j:$slf4jVersion", + "ch.qos.logback:logback-classic:$logbackVersion" } +[configurations.runtime, configurations.default]*.exclude(module: 'commons-logging') +sourceSets.main.compileClasspath += configurations.compileOnly +sourceSets.main.compileClasspath += configurations.provided +[compileJava, compileTestJava]*.options*.encoding = 'UTF-8' test { - onlyIf { - !project.hasProperty('skipTests') + jvmArgs = ['-ea', '-Xmx500m'] + maxParallelForks = guessMaxForks() + logging.captureStandardOutput(LogLevel.INFO) + testReport = false +} +def guessMaxForks() { + int processors = Runtime.runtime.availableProcessors() + return Math.max(2, (int) (processors / 2)) +} +javadoc { + title = "Spring Security $version API" + source = sourceSets.main.allJava + classpath += configurations.compileOnly + configurations.provided + options { + memberLevel = org.gradle.external.javadoc.JavadocMemberLevel.PROTECTED + author = true + header = project.name + outputLevel = org.gradle.external.javadoc.JavadocOutputLevel.QUIET + links = [ + "http://static.springframework.org/spring/docs/3.0.x/javadoc-api", + "http://static.springsource.org/spring-ldap/docs/1.3.x/apidocs/", + "http://download.oracle.com/javase/6/docs/api/" + ] + groups = [ + 'Spring Security Core':[ + 'org.springframework.security.core*', + 'org.springframework.security.authentication*', + 'org.springframework.security.access*', + 'org.springframework.security.remoting*', + 'org.springframework.security.provisioning*', + 'org.springframework.security.util*'], + 'Spring Security Web':['org.springframework.security.web*'], + 'Spring Security LDAP':['org.springframework.security.ldap*'], + 'Spring Security Crypto':['org.springframework.security.crypto*'], + 'Spring Security OpenID':['org.springframework.security.openid*'], + 'Spring Security CAS':['org.springframework.security.cas*'], + 'Spring Security ACL':['org.springframework.security.acls*'], + 'Spring Security Config':['org.springframework.security.config*'], + 'Spring Security Taglibs':['org.springframework.security.taglibs*'], + ] } - jvmArgs = ['-ea', '-Xms128m', '-Xmx500m', '-XX:MaxPermSize=128m'] } +task javadocJar(type: Jar) { + classifier = 'javadoc' + from javadoc +} diff --git a/gradle/maven-deployment.gradle b/gradle/maven-deployment.gradle new file mode 100644 index 0000000000..bf68c10679 --- /dev/null +++ b/gradle/maven-deployment.gradle @@ -0,0 +1,51 @@ +import org.apache.tools.ant.filters.ReplaceTokens + +apply plugin: 'maven' + +// Create a source jar for uploading +task sourceJar(type: Jar) { + classifier = 'sources' + from sourceSets.main.java.srcDirs + include '**/*.java', '**/*.aj' +} + +// Configuration for SpringSource s3 maven deployer +configurations { + deployerJars +} +dependencies { + deployerJars "org.springframework.build.aws:org.springframework.build.aws.maven:3.0.0.RELEASE" +} + +// Remove the archive configuration from the runtime configuration, so that anything added to archives +// (such as the source jar) is no longer included in the runtime classpath +configurations.default.extendsFrom = [configurations.runtime] as Set +// Add the main jar into the default configuration +artifacts { 'default' jar } + +install { + customizePom(repositories.mavenInstaller.pom, project) +} + +if(project != project(":spring-security-parent")) { + install.dependsOn ':spring-security-parent:install' + artifacts { + archives sourceJar + archives javadocJar + } +} + +task generatePom(type: Copy) { + from 'pom.xml' + into 'build/' + filter(ReplaceTokens, tokens: [pomVersion : project.properties.version]) +} +install.dependsOn generatePom + +def customizePom(pom, gradleProject) { + pom.withXml { provider -> + def builder = provider.asString() + builder.length = 0 // delete existing content + builder.append(file("build/pom.xml").text) + } +} \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000000..7b359d719b Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000000..9b3cdd7c3e --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Tue Oct 02 08:45:52 CDT 2012 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=http\://services.gradle.org/distributions/gradle-1.1-bin.zip diff --git a/gradlew b/gradlew new file mode 100755 index 0000000000..e7a5be4ba1 --- /dev/null +++ b/gradlew @@ -0,0 +1,164 @@ +#!/usr/bin/env bash + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="-Xmx1024M -XX:MaxPermSize=256M" + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn ( ) { + echo "$*" +} + +die ( ) { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; +esac + +# For Cygwin, ensure paths are in UNIX format before anything is touched. +if $cygwin ; then + [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` +fi + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" +APP_HOME="`pwd -P`" +cd "$SAVED" + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin, switch paths to Windows format before running java +if $cygwin ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules +function splitJvmOpts() { + JVM_OPTS=("$@") +} +eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS +JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" + +exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 0000000000..bbc4099e94 --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,90 @@ +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS=-Xmx1024M -XX:MaxPermSize=256M + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windowz variants + +if not "%OS%" == "Windows_NT" goto win9xME_args +if "%@eval[2+2]" == "4" goto 4NT_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* +goto execute + +:4NT_args +@rem Get arguments from the 4NT Shell from JP Software +set CMD_LINE_ARGS=%$ + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/itest/context/itest-context.gradle b/itest/context/itest-context.gradle new file mode 100644 index 0000000000..9a35296564 --- /dev/null +++ b/itest/context/itest-context.gradle @@ -0,0 +1,17 @@ +System.setProperty('python.cachedir.skip', 'true') + +dependencies { + compile project(':spring-security-core'), + 'aopalliance:aopalliance:1.0', + 'org.python:jython:2.5.0', + "org.springframework:spring-context:$springVersion", + "org.springframework:spring-aop:$springVersion", + "org.springframework:spring-tx:$springVersion", + "org.springframework:spring-beans:$springVersion" + + testCompile project(':spring-security-web'), + 'javax.servlet:servlet-api:2.5', + "org.springframework:spring-web:$springVersion" + testRuntime project(':spring-security-config') + +} diff --git a/itest/context/pom.xml b/itest/context/pom.xml index c91c93f4b4..701d05d93c 100644 --- a/itest/context/pom.xml +++ b/itest/context/pom.xml @@ -4,7 +4,7 @@ org.springframework.security spring-security-itest - 3.0.8.CI-SNAPSHOT + @pomVersion@ spring-security-itest-context Spring Security - Miscellaneous Application Context Integration Tests diff --git a/itest/context/src/test/java/org/springframework/security/integration/HttpNamespaceWithMultipleInterceptorsTests.java b/itest/context/src/integration-test/java/org/springframework/security/integration/HttpNamespaceWithMultipleInterceptorsTests.java similarity index 100% rename from itest/context/src/test/java/org/springframework/security/integration/HttpNamespaceWithMultipleInterceptorsTests.java rename to itest/context/src/integration-test/java/org/springframework/security/integration/HttpNamespaceWithMultipleInterceptorsTests.java diff --git a/itest/context/src/test/java/org/springframework/security/integration/HttpPathParameterStrippingTests.java b/itest/context/src/integration-test/java/org/springframework/security/integration/HttpPathParameterStrippingTests.java similarity index 100% rename from itest/context/src/test/java/org/springframework/security/integration/HttpPathParameterStrippingTests.java rename to itest/context/src/integration-test/java/org/springframework/security/integration/HttpPathParameterStrippingTests.java diff --git a/itest/context/src/test/java/org/springframework/security/integration/MultiAnnotationTests.java b/itest/context/src/integration-test/java/org/springframework/security/integration/MultiAnnotationTests.java similarity index 100% rename from itest/context/src/test/java/org/springframework/security/integration/MultiAnnotationTests.java rename to itest/context/src/integration-test/java/org/springframework/security/integration/MultiAnnotationTests.java diff --git a/itest/context/src/test/java/org/springframework/security/integration/SEC933ApplicationContextTests.java b/itest/context/src/integration-test/java/org/springframework/security/integration/SEC933ApplicationContextTests.java similarity index 100% rename from itest/context/src/test/java/org/springframework/security/integration/SEC933ApplicationContextTests.java rename to itest/context/src/integration-test/java/org/springframework/security/integration/SEC933ApplicationContextTests.java diff --git a/itest/context/src/test/java/org/springframework/security/integration/SEC936ApplicationContextTests.java b/itest/context/src/integration-test/java/org/springframework/security/integration/SEC936ApplicationContextTests.java similarity index 100% rename from itest/context/src/test/java/org/springframework/security/integration/SEC936ApplicationContextTests.java rename to itest/context/src/integration-test/java/org/springframework/security/integration/SEC936ApplicationContextTests.java diff --git a/itest/context/src/test/java/org/springframework/security/integration/StubUserRepository.java b/itest/context/src/integration-test/java/org/springframework/security/integration/StubUserRepository.java similarity index 100% rename from itest/context/src/test/java/org/springframework/security/integration/StubUserRepository.java rename to itest/context/src/integration-test/java/org/springframework/security/integration/StubUserRepository.java diff --git a/itest/context/src/test/java/org/springframework/security/integration/python/PythonInterpreterBasedSecurityTests.java b/itest/context/src/integration-test/java/org/springframework/security/integration/python/PythonInterpreterBasedSecurityTests.java similarity index 100% rename from itest/context/src/test/java/org/springframework/security/integration/python/PythonInterpreterBasedSecurityTests.java rename to itest/context/src/integration-test/java/org/springframework/security/integration/python/PythonInterpreterBasedSecurityTests.java diff --git a/itest/context/src/test/java/org/springframework/security/performance/FilterChainPerformanceTests.java b/itest/context/src/integration-test/java/org/springframework/security/performance/FilterChainPerformanceTests.java similarity index 94% rename from itest/context/src/test/java/org/springframework/security/performance/FilterChainPerformanceTests.java rename to itest/context/src/integration-test/java/org/springframework/security/performance/FilterChainPerformanceTests.java index 9a3c32201e..a3be2ec8ef 100644 --- a/itest/context/src/test/java/org/springframework/security/performance/FilterChainPerformanceTests.java +++ b/itest/context/src/integration-test/java/org/springframework/security/performance/FilterChainPerformanceTests.java @@ -1,14 +1,6 @@ package org.springframework.security.performance; -import java.util.Arrays; -import java.util.List; - -import javax.servlet.http.HttpSession; - -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.Test; +import org.junit.*; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; @@ -26,6 +18,9 @@ import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.util.StopWatch; +import javax.servlet.http.HttpSession; +import java.util.*; + /** * * @author Luke Taylor @@ -34,8 +29,9 @@ import org.springframework.util.StopWatch; @ContextConfiguration(locations={"/filter-chain-performance-app-context.xml"}) @RunWith(SpringJUnit4ClassRunner.class) public class FilterChainPerformanceTests { - private static final int N_INVOCATIONS = 1000; - private static final int N_AUTHORITIES = 200; + // Adjust as required + private static final int N_INVOCATIONS = 1; // 1000 + private static final int N_AUTHORITIES = 2; // 200 private static StopWatch sw = new StopWatch("Filter Chain Performance Tests"); private final UsernamePasswordAuthenticationToken user = new UsernamePasswordAuthenticationToken("bob", "bobspassword", createRoles(N_AUTHORITIES)); diff --git a/itest/context/src/test/java/org/springframework/security/performance/ProtectPointcutPerformanceTests.java b/itest/context/src/integration-test/java/org/springframework/security/performance/ProtectPointcutPerformanceTests.java similarity index 100% rename from itest/context/src/test/java/org/springframework/security/performance/ProtectPointcutPerformanceTests.java rename to itest/context/src/integration-test/java/org/springframework/security/performance/ProtectPointcutPerformanceTests.java diff --git a/itest/context/src/test/resources/filter-chain-performance-app-context.xml b/itest/context/src/integration-test/resources/filter-chain-performance-app-context.xml similarity index 100% rename from itest/context/src/test/resources/filter-chain-performance-app-context.xml rename to itest/context/src/integration-test/resources/filter-chain-performance-app-context.xml diff --git a/itest/context/src/test/resources/http-extra-fsi-app-context.xml b/itest/context/src/integration-test/resources/http-extra-fsi-app-context.xml similarity index 100% rename from itest/context/src/test/resources/http-extra-fsi-app-context.xml rename to itest/context/src/integration-test/resources/http-extra-fsi-app-context.xml diff --git a/itest/context/src/test/resources/http-path-param-stripping-app-context.xml b/itest/context/src/integration-test/resources/http-path-param-stripping-app-context.xml similarity index 100% rename from itest/context/src/test/resources/http-path-param-stripping-app-context.xml rename to itest/context/src/integration-test/resources/http-path-param-stripping-app-context.xml diff --git a/itest/context/src/test/resources/log4j.properties b/itest/context/src/integration-test/resources/log4j.properties similarity index 100% rename from itest/context/src/test/resources/log4j.properties rename to itest/context/src/integration-test/resources/log4j.properties diff --git a/itest/context/src/test/resources/multi-sec-annotation-app-context.xml b/itest/context/src/integration-test/resources/multi-sec-annotation-app-context.xml similarity index 100% rename from itest/context/src/test/resources/multi-sec-annotation-app-context.xml rename to itest/context/src/integration-test/resources/multi-sec-annotation-app-context.xml diff --git a/itest/context/src/test/resources/protect-pointcut-performance-app-context.xml b/itest/context/src/integration-test/resources/protect-pointcut-performance-app-context.xml similarity index 100% rename from itest/context/src/test/resources/protect-pointcut-performance-app-context.xml rename to itest/context/src/integration-test/resources/protect-pointcut-performance-app-context.xml diff --git a/itest/context/src/test/resources/python-method-access-app-context.xml b/itest/context/src/integration-test/resources/python-method-access-app-context.xml similarity index 100% rename from itest/context/src/test/resources/python-method-access-app-context.xml rename to itest/context/src/integration-test/resources/python-method-access-app-context.xml diff --git a/itest/context/src/test/resources/sec-933-app-context.xml b/itest/context/src/integration-test/resources/sec-933-app-context.xml similarity index 100% rename from itest/context/src/test/resources/sec-933-app-context.xml rename to itest/context/src/integration-test/resources/sec-933-app-context.xml diff --git a/itest/context/src/test/resources/sec-936-app-context.xml b/itest/context/src/integration-test/resources/sec-936-app-context.xml similarity index 100% rename from itest/context/src/test/resources/sec-936-app-context.xml rename to itest/context/src/integration-test/resources/sec-936-app-context.xml diff --git a/itest/context/src/test/resources/someMethod.py b/itest/context/src/integration-test/resources/someMethod.py similarity index 100% rename from itest/context/src/test/resources/someMethod.py rename to itest/context/src/integration-test/resources/someMethod.py diff --git a/itest/misc/pom.xml b/itest/misc/pom.xml index 22493e7530..e1e580fd96 100644 --- a/itest/misc/pom.xml +++ b/itest/misc/pom.xml @@ -5,7 +5,7 @@ org.springframework.security spring-security-itest - 3.0.8.CI-SNAPSHOT + @pomVersion@ spring-security-itest-misc Spring Security - Miscellaneous Integration Tests diff --git a/itest/pom.xml b/itest/pom.xml index d79029124c..c2c1cddfd6 100644 --- a/itest/pom.xml +++ b/itest/pom.xml @@ -3,12 +3,12 @@ org.springframework.security spring-security-parent - 3.0.8.CI-SNAPSHOT + @pomVersion@ spring-security-itest Spring Security - Integration Tests pom - 3.0.8.CI-SNAPSHOT + @pomVersion@ web diff --git a/itest/web/itest-web.gradle b/itest/web/itest-web.gradle index 6ba082f47d..4849b58bfc 100644 --- a/itest/web/itest-web.gradle +++ b/itest/web/itest-web.gradle @@ -21,10 +21,11 @@ dependencies { 'net.sourceforge.jwebunit:jwebunit-htmlunit-plugin:2.2' } -test { +integrationTest { useTestNG(); options { jvmArgs = ["-ea", '-Xms128m', '-Xmx500m'] systemProperties = ['webapp.dir': "$projectDir/src/main/webapp"] } -} \ No newline at end of file + maxParallelForks = 1 +} diff --git a/itest/web/pom.xml b/itest/web/pom.xml index 6679c138a5..6e746c93d3 100644 --- a/itest/web/pom.xml +++ b/itest/web/pom.xml @@ -4,7 +4,7 @@ org.springframework.security spring-security-itest - 3.0.8.CI-SNAPSHOT + @pomVersion@ spring-security-itest-web Spring Security - Web Integration Tests diff --git a/ldap/ldap.gradle b/ldap/ldap.gradle index 4bd8091054..4c9920d27a 100644 --- a/ldap/ldap.gradle +++ b/ldap/ldap.gradle @@ -1,25 +1,42 @@ // Ldap build file -test.exclude('**/OpenLDAPIntegrationTestSuite.class') -dependencies { - compile project(':spring-security-core'), - "org.springframework:spring-beans:$springVersion", - "org.springframework:spring-context:$springVersion", - "org.springframework:spring-tx:$springVersion", +def apacheds_libs = [ "org.apache.directory.server:apacheds-core:$apacheDsVersion", "org.apache.directory.server:apacheds-core-entry:$apacheDsVersion", "org.apache.directory.server:apacheds-protocol-shared:$apacheDsVersion", "org.apache.directory.server:apacheds-protocol-ldap:$apacheDsVersion", "org.apache.directory.server:apacheds-server-jndi:$apacheDsVersion", - 'org.apache.directory.shared:shared-ldap:0.9.15', + 'org.apache.directory.shared:shared-ldap:0.9.15' +] +dependencies { + compile project(':spring-security-core'), + "org.springframework:spring-beans:$springVersion", + "org.springframework:spring-context:$springVersion", + "org.springframework:spring-tx:$springVersion", 'ldapsdk:ldapsdk:4.1' + apacheds_libs.collect { + compile (it) { + exclude group: 'org.slf4j' + } + } compile ("org.springframework.ldap:spring-ldap-core:$springLdapVersion") { exclude(group: 'commons-logging', module: 'commons-logging') exclude(group: 'org.springframework', module: 'spring-core') exclude(group: 'org.springframework', module: 'spring-tx') exclude(group: 'org.springframework', module: 'spring-beans') } +} - runtime 'org.slf4j:slf4j-log4j12:1.4.3' -} \ No newline at end of file +integrationTest { + include('**/ApacheDSServerIntegrationTests.class') +// exclude('**/OpenLDAPIntegrationTestSuite.class') + maxParallelForks = 1 + systemProperties['apacheDSWorkDir'] = "${buildDir}/apacheDSWork" +} +// Runs a server for running the integration tests against (from an IDE, for example) +task(ldapServer, dependsOn: 'integrationTestClasses', type: JavaExec) { + classpath = sourceSets.integrationTest.runtimeClasspath + main = 'org.springframework.security.ldap.ApacheDSServerIntegrationTests' + systemProperties['apacheDSWorkDir'] = "${buildDir}/apacheDSWork" +} diff --git a/ldap/pom.xml b/ldap/pom.xml index ef2c592fac..2921a658e2 100644 --- a/ldap/pom.xml +++ b/ldap/pom.xml @@ -3,7 +3,7 @@ org.springframework.security spring-security-parent - 3.0.8.CI-SNAPSHOT + @pomVersion@ jar spring-security-ldap diff --git a/ldap/src/integration-test/java/org/springframework/security/ldap/AbstractLdapIntegrationTests.java b/ldap/src/integration-test/java/org/springframework/security/ldap/AbstractLdapIntegrationTests.java new file mode 100644 index 0000000000..4091295b41 --- /dev/null +++ b/ldap/src/integration-test/java/org/springframework/security/ldap/AbstractLdapIntegrationTests.java @@ -0,0 +1,49 @@ +/* Copyright 2004, 2005, 2006 Acegi Technology Pty Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * 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.springframework.security.ldap; + +import org.junit.Before; +import org.junit.BeforeClass; +import org.springframework.ldap.core.support.BaseLdapPathContextSource; + +/** + * Based on class borrowed from Spring Ldap project. + * + * @author Luke Taylor + */ +public abstract class AbstractLdapIntegrationTests { + private static DefaultSpringSecurityContextSource contextSource; + + protected AbstractLdapIntegrationTests() { + } + + @BeforeClass + public static void startServer() throws Exception { + contextSource = new DefaultSpringSecurityContextSource("ldap://127.0.0.1:53389/dc=springframework,dc=org"); + // OpenLDAP configuration +// contextSource = new DefaultSpringSecurityContextSource("ldap://127.0.0.1:22389/dc=springsource,dc=com"); +// contextSource.setUserDn("cn=admin,dc=springsource,dc=com"); +// contextSource.setPassword("password"); + contextSource.afterPropertiesSet(); + } + + @Before + public void onSetUp() throws Exception { + } + + public BaseLdapPathContextSource getContextSource() { + return contextSource; + } +} diff --git a/ldap/src/test/java/org/springframework/security/ldap/AbstractLdapIntegrationTests.java b/ldap/src/integration-test/java/org/springframework/security/ldap/ApacheDSServerIntegrationTests.java similarity index 58% rename from ldap/src/test/java/org/springframework/security/ldap/AbstractLdapIntegrationTests.java rename to ldap/src/integration-test/java/org/springframework/security/ldap/ApacheDSServerIntegrationTests.java index 29732d99d8..55c8b642cf 100644 --- a/ldap/src/test/java/org/springframework/security/ldap/AbstractLdapIntegrationTests.java +++ b/ldap/src/integration-test/java/org/springframework/security/ldap/ApacheDSServerIntegrationTests.java @@ -1,59 +1,40 @@ -/* Copyright 2004, 2005, 2006 Acegi Technology Pty Limited - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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.springframework.security.ldap; -import javax.naming.Binding; -import javax.naming.ContextNotEmptyException; -import javax.naming.Name; -import javax.naming.NameNotFoundException; -import javax.naming.NamingEnumeration; -import javax.naming.NamingException; -import javax.naming.directory.DirContext; - -import org.apache.directory.server.protocol.shared.store.LdifFileLoader; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.springframework.core.io.ClassPathResource; -import org.springframework.ldap.core.DistinguishedName; -import org.springframework.ldap.core.support.BaseLdapPathContextSource; +import org.junit.*; +import org.junit.runner.RunWith; +import org.junit.runners.Suite; +import org.springframework.security.ldap.authentication.BindAuthenticatorTests; +import org.springframework.security.ldap.authentication.PasswordComparisonAuthenticatorTests; +import org.springframework.security.ldap.search.FilterBasedLdapUserSearchTests; import org.springframework.security.ldap.server.ApacheDSContainer; +import org.springframework.security.ldap.userdetails.DefaultLdapAuthoritiesPopulatorTests; +import org.springframework.security.ldap.userdetails.LdapUserDetailsManagerTests; /** - * Based on class borrowed from Spring Ldap project. - * * @author Luke Taylor */ -public abstract class AbstractLdapIntegrationTests { -// private static InMemoryXmlApplicationContext appContext; +@RunWith(Suite.class) +@Suite.SuiteClasses( { + BindAuthenticatorTests.class, + PasswordComparisonAuthenticatorTests.class, + FilterBasedLdapUserSearchTests.class, + DefaultLdapAuthoritiesPopulatorTests.class, + LdapUserDetailsManagerTests.class, + DefaultSpringSecurityContextSourceTests.class, + SpringSecurityLdapTemplateTests.class +} +) +public final class ApacheDSServerIntegrationTests { private static ApacheDSContainer server; - private static DefaultSpringSecurityContextSource contextSource; - - protected AbstractLdapIntegrationTests() { - } @BeforeClass public static void startServer() throws Exception { - contextSource = new DefaultSpringSecurityContextSource("ldap://127.0.0.1:53389/dc=springframework,dc=org"); // OpenLDAP configuration // contextSource = new DefaultSpringSecurityContextSource("ldap://127.0.0.1:22389/dc=springsource,dc=com"); // contextSource.setUserDn("cn=admin,dc=springsource,dc=com"); // contextSource.setPassword("password"); - contextSource.afterPropertiesSet(); server = new ApacheDSContainer("dc=springframework,dc=org", "classpath:test-server.ldif"); + server.setPort(53389); server.afterPropertiesSet(); } @@ -64,11 +45,15 @@ public abstract class AbstractLdapIntegrationTests { } } - @Before - public void onSetUp() throws Exception { + /** + * Main class to allow server to be started from gradle script + */ + public static void main(String[] args) throws Exception { + ApacheDSContainer server = new ApacheDSContainer("dc=springframework,dc=org", "classpath:test-server.ldif"); + server.afterPropertiesSet(); } - +/* @After public final void reloadServerDataIfDirty() throws Exception { ClassPathResource ldifs = new ClassPathResource("test-server.ldif"); @@ -91,11 +76,6 @@ public abstract class AbstractLdapIntegrationTests { } } - public BaseLdapPathContextSource getContextSource() { - return contextSource; - } - - private void clearSubContexts(DirContext ctx, Name name) throws NamingException { NamingEnumeration enumeration = null; @@ -124,4 +104,5 @@ public abstract class AbstractLdapIntegrationTests { } } } + */ } diff --git a/ldap/src/test/java/org/springframework/security/ldap/DefaultSpringSecurityContextSourceTests.java b/ldap/src/integration-test/java/org/springframework/security/ldap/DefaultSpringSecurityContextSourceTests.java similarity index 100% rename from ldap/src/test/java/org/springframework/security/ldap/DefaultSpringSecurityContextSourceTests.java rename to ldap/src/integration-test/java/org/springframework/security/ldap/DefaultSpringSecurityContextSourceTests.java diff --git a/ldap/src/test/java/org/springframework/security/ldap/SpringSecurityLdapTemplateTests.java b/ldap/src/integration-test/java/org/springframework/security/ldap/SpringSecurityLdapTemplateTests.java similarity index 100% rename from ldap/src/test/java/org/springframework/security/ldap/SpringSecurityLdapTemplateTests.java rename to ldap/src/integration-test/java/org/springframework/security/ldap/SpringSecurityLdapTemplateTests.java diff --git a/ldap/src/test/java/org/springframework/security/ldap/authentication/BindAuthenticatorTests.java b/ldap/src/integration-test/java/org/springframework/security/ldap/authentication/BindAuthenticatorTests.java similarity index 100% rename from ldap/src/test/java/org/springframework/security/ldap/authentication/BindAuthenticatorTests.java rename to ldap/src/integration-test/java/org/springframework/security/ldap/authentication/BindAuthenticatorTests.java diff --git a/ldap/src/test/java/org/springframework/security/ldap/authentication/PasswordComparisonAuthenticatorTests.java b/ldap/src/integration-test/java/org/springframework/security/ldap/authentication/PasswordComparisonAuthenticatorTests.java similarity index 100% rename from ldap/src/test/java/org/springframework/security/ldap/authentication/PasswordComparisonAuthenticatorTests.java rename to ldap/src/integration-test/java/org/springframework/security/ldap/authentication/PasswordComparisonAuthenticatorTests.java diff --git a/ldap/src/test/java/org/springframework/security/ldap/populator/DefaultLdapAuthoritiesPopulatorTests.java b/ldap/src/integration-test/java/org/springframework/security/ldap/populator/DefaultLdapAuthoritiesPopulatorTests.java similarity index 100% rename from ldap/src/test/java/org/springframework/security/ldap/populator/DefaultLdapAuthoritiesPopulatorTests.java rename to ldap/src/integration-test/java/org/springframework/security/ldap/populator/DefaultLdapAuthoritiesPopulatorTests.java diff --git a/ldap/src/test/java/org/springframework/security/ldap/ppolicy/OpenLDAPIntegrationTestSuite.java b/ldap/src/integration-test/java/org/springframework/security/ldap/ppolicy/OpenLDAPIntegrationTestSuite.java similarity index 100% rename from ldap/src/test/java/org/springframework/security/ldap/ppolicy/OpenLDAPIntegrationTestSuite.java rename to ldap/src/integration-test/java/org/springframework/security/ldap/ppolicy/OpenLDAPIntegrationTestSuite.java diff --git a/ldap/src/test/java/org/springframework/security/ldap/search/FilterBasedLdapUserSearchTests.java b/ldap/src/integration-test/java/org/springframework/security/ldap/search/FilterBasedLdapUserSearchTests.java similarity index 100% rename from ldap/src/test/java/org/springframework/security/ldap/search/FilterBasedLdapUserSearchTests.java rename to ldap/src/integration-test/java/org/springframework/security/ldap/search/FilterBasedLdapUserSearchTests.java diff --git a/ldap/src/test/java/org/springframework/security/ldap/server/ApacheDSContainerTests.java b/ldap/src/integration-test/java/org/springframework/security/ldap/server/ApacheDSContainerTests.java similarity index 100% rename from ldap/src/test/java/org/springframework/security/ldap/server/ApacheDSContainerTests.java rename to ldap/src/integration-test/java/org/springframework/security/ldap/server/ApacheDSContainerTests.java diff --git a/ldap/src/integration-test/java/org/springframework/security/ldap/userdetails/DefaultLdapAuthoritiesPopulatorTests.java b/ldap/src/integration-test/java/org/springframework/security/ldap/userdetails/DefaultLdapAuthoritiesPopulatorTests.java new file mode 100644 index 0000000000..3c1c085b75 --- /dev/null +++ b/ldap/src/integration-test/java/org/springframework/security/ldap/userdetails/DefaultLdapAuthoritiesPopulatorTests.java @@ -0,0 +1,161 @@ +/* Copyright 2004, 2005, 2006 Acegi Technology Pty Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * 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.springframework.security.ldap.userdetails; + + +import static org.junit.Assert.*; + +import org.junit.*; +import org.springframework.ldap.core.DirContextAdapter; +import org.springframework.ldap.core.DirContextOperations; +import org.springframework.ldap.core.DistinguishedName; +import org.springframework.security.core.GrantedAuthority; +import org.springframework.security.core.authority.AuthorityUtils; +import org.springframework.security.ldap.AbstractLdapIntegrationTests; + +import java.util.*; + + +/** + * + * @author Luke Taylor + */ +@SuppressWarnings({"deprecation"}) +public class DefaultLdapAuthoritiesPopulatorTests extends AbstractLdapIntegrationTests { + private DefaultLdapAuthoritiesPopulator populator; + //~ Methods ======================================================================================================== + + @Before + public void setUp() throws Exception { + populator = new DefaultLdapAuthoritiesPopulator(getContextSource(), "ou=groups"); + populator.setIgnorePartialResultException(false); + } + + @Test + public void defaultRoleIsAssignedWhenSet() { + populator.setDefaultRole("ROLE_USER"); + assertSame(getContextSource(), populator.getContextSource()); + + DirContextAdapter ctx = new DirContextAdapter(new DistinguishedName("cn=notfound")); + + Collection authorities = populator.getGrantedAuthorities(ctx, "notfound"); + assertEquals(1, authorities.size()); + assertTrue(AuthorityUtils.authorityListToSet(authorities).contains("ROLE_USER")); + } + + @Test + public void nullSearchBaseIsAccepted() throws Exception { + populator = new DefaultLdapAuthoritiesPopulator(getContextSource(), null); + populator.setDefaultRole("ROLE_USER"); + + Collection authorities = populator.getGrantedAuthorities( + new DirContextAdapter(new DistinguishedName("cn=notused")), "notused"); + assertEquals(1, authorities.size()); + assertTrue(AuthorityUtils.authorityListToSet(authorities).contains("ROLE_USER")); + } + + @Test + public void groupSearchReturnsExpectedRoles() { + populator.setRolePrefix("ROLE_"); + populator.setGroupRoleAttribute("ou"); + populator.setSearchSubtree(true); + populator.setSearchSubtree(false); + populator.setConvertToUpperCase(true); + populator.setGroupSearchFilter("(member={0})"); + + DirContextAdapter ctx = new DirContextAdapter(new DistinguishedName("uid=ben,ou=people,dc=springframework,dc=org")); + + Set authorities = AuthorityUtils.authorityListToSet(populator.getGrantedAuthorities(ctx, "ben")); + + assertEquals("Should have 2 roles", 2, authorities.size()); + + assertTrue(authorities.contains("ROLE_DEVELOPER")); + assertTrue(authorities.contains("ROLE_MANAGER")); + } + + @Test + public void useOfUsernameParameterReturnsExpectedRoles() { + populator.setGroupRoleAttribute("ou"); + populator.setConvertToUpperCase(true); + populator.setGroupSearchFilter("(ou={1})"); + + DirContextAdapter ctx = new DirContextAdapter(new DistinguishedName("uid=ben,ou=people,dc=springframework,dc=org")); + + Set authorities = AuthorityUtils.authorityListToSet(populator.getGrantedAuthorities(ctx, "manager")); + + assertEquals("Should have 1 role", 1, authorities.size()); + assertTrue(authorities.contains("ROLE_MANAGER")); + } + + @Test + public void subGroupRolesAreNotFoundByDefault() { + populator.setGroupRoleAttribute("ou"); + populator.setConvertToUpperCase(true); + + DirContextAdapter ctx = new DirContextAdapter(new DistinguishedName("uid=ben,ou=people,dc=springframework,dc=org")); + + Set authorities = AuthorityUtils.authorityListToSet(populator.getGrantedAuthorities(ctx, "manager")); + + assertEquals("Should have 2 roles", 2, authorities.size()); + assertTrue(authorities.contains("ROLE_MANAGER")); + assertTrue(authorities.contains("ROLE_DEVELOPER")); + } + + @Test + public void subGroupRolesAreFoundWhenSubtreeSearchIsEnabled() { + populator.setGroupRoleAttribute("ou"); + populator.setConvertToUpperCase(true); + populator.setSearchSubtree(true); + + DirContextAdapter ctx = new DirContextAdapter(new DistinguishedName("uid=ben,ou=people,dc=springframework,dc=org")); + + Set authorities = AuthorityUtils.authorityListToSet(populator.getGrantedAuthorities(ctx, "manager")); + + assertEquals("Should have 3 roles", 3, authorities.size()); + assertTrue(authorities.contains("ROLE_MANAGER")); + assertTrue(authorities.contains("ROLE_SUBMANAGER")); + assertTrue(authorities.contains("ROLE_DEVELOPER")); + } + + @Test + public void extraRolesAreAdded() throws Exception { + populator = new DefaultLdapAuthoritiesPopulator(getContextSource(), null) { + @Override + protected Set getAdditionalRoles(DirContextOperations user, String username) { + return new HashSet(AuthorityUtils.createAuthorityList("ROLE_EXTRA")); + } + }; + + Collection authorities = populator.getGrantedAuthorities( + new DirContextAdapter(new DistinguishedName("cn=notused")), "notused"); + assertEquals(1, authorities.size()); + assertTrue(AuthorityUtils.authorityListToSet(authorities).contains("ROLE_EXTRA")); + } + + @Test + public void userDnWithEscapedCharacterParameterReturnsExpectedRoles() { + populator.setGroupRoleAttribute("ou"); + populator.setConvertToUpperCase(true); + populator.setGroupSearchFilter("(member={0})"); + + DirContextAdapter ctx = new DirContextAdapter(new DistinguishedName("cn=mouse\\, jerry,ou=people,dc=springframework,dc=org")); + + Set authorities = AuthorityUtils.authorityListToSet(populator.getGrantedAuthorities(ctx, "notused")); + + assertEquals("Should have 1 role", 1, authorities.size()); + assertTrue(authorities.contains("ROLE_MANAGER")); + } +} diff --git a/ldap/src/test/java/org/springframework/security/ldap/userdetails/LdapUserDetailsManagerTests.java b/ldap/src/integration-test/java/org/springframework/security/ldap/userdetails/LdapUserDetailsManagerTests.java similarity index 100% rename from ldap/src/test/java/org/springframework/security/ldap/userdetails/LdapUserDetailsManagerTests.java rename to ldap/src/integration-test/java/org/springframework/security/ldap/userdetails/LdapUserDetailsManagerTests.java diff --git a/ldap/src/integration-test/resources/logback-test.xml b/ldap/src/integration-test/resources/logback-test.xml new file mode 100644 index 0000000000..60cd6fd4ee --- /dev/null +++ b/ldap/src/integration-test/resources/logback-test.xml @@ -0,0 +1,18 @@ + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + + + + + + + + + + + diff --git a/ldap/src/test/resources/test-server.ldif b/ldap/src/integration-test/resources/test-server.ldif similarity index 100% rename from ldap/src/test/resources/test-server.ldif rename to ldap/src/integration-test/resources/test-server.ldif diff --git a/ldap/template.mf b/ldap/template.mf index cfc3058d6e..971eb1aa3e 100644 --- a/ldap/template.mf +++ b/ldap/template.mf @@ -9,18 +9,18 @@ Ignored-Existing-Headers: Import-Package, Export-Package Import-Template: - org.apache.commons.logging.*;version="[1.0.4, 2.0.0)", - org.apache.directory.server.*;version="[1.5.5, 1.6)";resolution:=optional, - org.apache.directory.shared.ldap.*;version="[0.9.15, 1.0)";resolution:=optional, - org.springframework.ldap.*;version="[1.3.0,1.4.0)", - org.springframework.security.core.*;version="[${version}, 3.1.0)", - org.springframework.security.authentication.*;version="[${version}, 3.1.0)", - org.springframework.security.provisioning.*;version="[${version}, 3.1.0)", - org.springframework.security.util;version="[${version}, 3.1.0)", - org.springframework.beans.*;version="[${spring.version}, 3.1.0)", - org.springframework.context.*;version="[${spring.version}, 3.1.0)", - org.springframework.core.io.*;version="[${spring.version}, 3.1.0)", - org.springframework.dao.*;version="[${spring.version}, 3.1.0)";resolution:=optional, - org.springframework.util.*;version="[${spring.version}, 3.1.0)", + org.apache.commons.logging.*;version="${cloggingRange}", + org.apache.directory.server.*;version="${apacheDSRange}";resolution:=optional, + org.apache.directory.shared.ldap.*;version="${apacheDSSharedRange}";resolution:=optional, + org.springframework.ldap.*;version="${springLdapRange}", + org.springframework.security.core.*;version="${secRange}", + org.springframework.security.authentication.*;version="${secRange}", + org.springframework.security.provisioning.*;version="${secRange}", + org.springframework.security.util;version="${secRange}", + org.springframework.beans.*;version="${springRange}", + org.springframework.context.*;version="${springRange}", + org.springframework.core.io.*;version="${springRange}", + org.springframework.dao.*;version="${springRange}";resolution:=optional, + org.springframework.util.*;version="${springRange}", javax.naming.*;version="0";resolution:=optional, - netscape.ldap.ber.stream;version="[4.1, 5.0)";resolution:=optional + netscape.ldap.ber.stream;version="${ldapSdkRange}";resolution:=optional diff --git a/openid/openid.gradle b/openid/openid.gradle index 814d480259..5de412a291 100644 --- a/openid/openid.gradle +++ b/openid/openid.gradle @@ -3,14 +3,20 @@ dependencies { compile project(':spring-security-core'), project(':spring-security-web'), - 'org.openid4java:openid4java-nodeps:0.9.5', "org.springframework:spring-aop:$springVersion", + "org.springframework:spring-tx:$springVersion", "org.springframework:spring-context:$springVersion", "org.springframework:spring-beans:$springVersion", - "org.springframework:spring-tx:$springVersion", "org.springframework:spring-web:$springVersion" + // openid4java has a compile time dep on guice with a group + // name which is different from the maven central one. + // We use the maven central version here instead. + compile('org.openid4java:openid4java-nodeps:0.9.6') { + exclude group: 'com.google.code.guice', module: 'guice' + } + compile 'com.google.inject:guice:2.0' provided 'javax.servlet:servlet-api:2.5' - runtime 'commons-httpclient:commons-httpclient:3.1' + runtime 'org.apache.httpcomponents:httpclient:4.1.1' } \ No newline at end of file diff --git a/openid/pom.xml b/openid/pom.xml index 4f731d1062..d22edf7fd8 100644 --- a/openid/pom.xml +++ b/openid/pom.xml @@ -3,7 +3,7 @@ org.springframework.security spring-security-parent - 3.0.8.CI-SNAPSHOT + @pomVersion@ spring-security-openid Spring Security - OpenID support diff --git a/openid/template.mf b/openid/template.mf index f49295a006..030a9802f5 100644 --- a/openid/template.mf +++ b/openid/template.mf @@ -9,11 +9,11 @@ Ignored-Existing-Headers: Import-Package, Export-Package Import-Template: - org.apache.commons.logging.*;version="[1.0.4, 2.0.0)", - org.springframework.security.core.*;version="[${version}, 3.1.0)", - org.springframework.security.authentication.*;version="[${version}, 3.1.0)", - org.springframework.security.web.*;version="[${version}, 3.1.0)", - org.springframework.beans.factory;version="[${spring.version}, 3.1.0)", - org.springframework.util;version="[${spring.version}, 3.1.0)", - org.openid4java.*;version="[0.9.5, 1.0.0)", + org.apache.commons.logging.*;version="${cloggingRange}", + org.springframework.security.core.*;version="${secRange}", + org.springframework.security.authentication.*;version="${secRange}", + org.springframework.security.web.*;version="${secRange}", + org.springframework.beans.factory;version="${springRange}", + org.springframework.util;version="${springRange}", + org.openid4java.*;version="${openid4javaRange}", javax.servlet.*;version="0" diff --git a/parent/parent.gradle b/parent/parent.gradle new file mode 100644 index 0000000000..fa0bf62e5e --- /dev/null +++ b/parent/parent.gradle @@ -0,0 +1 @@ +[sourceJar,javadoc,javadocJar]*.enabled = false diff --git a/pom.xml b/parent/pom.xml similarity index 99% rename from pom.xml rename to parent/pom.xml index e6920d9623..b67abca411 100644 --- a/pom.xml +++ b/parent/pom.xml @@ -3,7 +3,7 @@ 4.0.0 org.springframework.security spring-security-parent - 3.0.8.CI-SNAPSHOT + @pomVersion@ Spring Security pom diff --git a/readme.txt b/readme.txt index eb79d9f553..e5f34379c6 100644 --- a/readme.txt +++ b/readme.txt @@ -6,19 +6,22 @@ OVERVIEW ------------------------------------------------------------------------------- -Spring Security provides security services for -The Spring Framework (http://www.springframework.org). +Spring Security provides security services for the Spring Framework +(http://www.springframework.org). Spring Security 3.1 requires Spring 3.0.3 as +a minimum and also requires Java 5. For a detailed list of features and access to the latest release, please visit http://www.springframework.org/projects/. +Spring Security is released under an Apache 2.0 license. See the accompanying +license.txt file. ------------------------------------------------------------------------------- BUILDING ------------------------------------------------------------------------------- -Spring Security is built using Maven. Please read the "Building from Source" page -at http://static.springframework.org/spring-security/site/. +Please read the "Building from Source" page at +http://static.springframework.org/spring-security/site/. ------------------------------------------------------------------------------- DOCUMENTATION @@ -33,7 +36,7 @@ QUICK START ------------------------------------------------------------------------------- We recommend you visit http://static.springframework.org/spring-security/site and -read the "Suggested Steps" page. +read the "Getting Started" page. ------------------------------------------------------------------------------- MAVEN REPOSITORY DOWNLOADS @@ -44,11 +47,11 @@ Release jars for the project are available from the central maven repository http://repo1.maven.org/maven2/org/springframework/security/ Note that milestone releases and snapshots are not uploaded to the central -repository, but can be obtained from te Spring milestone repository. -This blog article has full details on how to download milestone or snapshot -jars or use them in a Maven-based project build: - -http://blog.springsource.com/main/2007/09/18/maven-artifacts-2/ +repository, but can be obtained from the Spring milestone repository, using the +maven repository http://maven.springframework.org/snapshot/. You can't browse this +URL directly, but there is a separate browser interface. Check the downloads page +for more information +http://static.springsource.org/spring-security/site/downloads.html ------------------------------------------------------------------------------- @@ -69,4 +72,9 @@ located at the Spring Community's forum site: Links to the forums, and other useful resources are available from the web site. +------------------------------------------------------------------------------- +CONTRIBUTING +------------------------------------------------------------------------------- +Contributions are welcome. Please refer to the Contributor Guidelines for details + https://github.com/SpringSource/spring-security/wiki/Contributor-Guidelines \ No newline at end of file diff --git a/samples/aspectj/pom.xml b/samples/aspectj/pom.xml deleted file mode 100644 index ebf2aa976f..0000000000 --- a/samples/aspectj/pom.xml +++ /dev/null @@ -1,80 +0,0 @@ - - - 4.0.0 - - org.springframework.security - spring-security-parent - 3.0.8.CI-SNAPSHOT - - spring-security-samples-aspectj - jar - Spring Security Sample AspectJ - - - - junit - junit - 4.6 - test - - - org.springframework.security - spring-security-config - ${project.version} - - - org.springframework.security - spring-security-aspects - ${project.version} - - - org.springframework - spring-test - test - - - - - - org.codehaus.mojo - aspectj-maven-plugin - 1.2 - - - - org.aspectj - aspectjrt - 1.6.8 - - - org.aspectj - aspectjtools - 1.6.8 - - - - - - compile - test-compile - - - - - - - org.springframework.security - spring-security-aspects - - - 1.5 - 1.5 - - - - - diff --git a/samples/cas/Readme.txt b/samples/cas/Readme.txt index 4df65e67ec..cfa67e6ad7 100644 --- a/samples/cas/Readme.txt +++ b/samples/cas/Readme.txt @@ -1,53 +1,12 @@ -There are two subdirectories in this project; +To run a CAS server and client application, just execute the command -server - this is not a real maven sub-project in the sense that it builds anything. It is just here to allow you to - conveniently run the CAS server using the maven Jetty plugin with our preconfigured SSL certificates. - -client - this contains the actual sample web application which uses the cas server for authentication. It uses the same - certificates. In practice, the CAS server would likely be running on a different machine and both client and - server would have different certificates issued to the server hostname. - -Running the CAS Server ------------------------ - -You first need to download the CAS server 3.3.5 distribution from - -http://www.ja-sig.org/products/cas/downloads/index.html - -You only need the modules/cas-server-webapp-3.3.5.war web application file from the distribution. Copy this to the -"server" directory inside the one that contains this readme file (i.e. copy it to samples/cas/server). - -You can then run the CAS server (from the same) by executing the maven command - -mvn jetty:run-war - -This will start the server on - -https://localhost:9443/cas - -If you point your browser at this URL, you should see the CAS login screen. - - -Running the Client Application -------------------------------- - -Leave the server running and start up a separate command window to run the sample application. Change to the directory -samples/cas/client and execute the command - -mvn jetty:run - - -This should start the sample application on - -http://localhost:8080/cas-sample/ - -Try to access the secure page (as with the other samples) and you should be redirected to the CAS server to log in. Note -that the sample authentication module that comes with the CAS server webapp will authenticate any user whose password -matches the username. So you have to log in here as rod/rod, dianne/dianne etc. Obviously the usernames must still match -those listed in the application's user-service. - - -$Id$ +./gradlew cas +from the project root directory. You should then be able to point your browser at +https://localhost:8443/cas-sample/ +to view the sample application. On attempting to access a secure page, +you'll be redirected to the CAS server where you can log in with one of +the usernames from the sample application context (enter the username in the +password field too, to authenticate to CAS in testing mode). diff --git a/samples/cas/cas.gradle b/samples/cas/cas.gradle deleted file mode 100644 index ebd59e42aa..0000000000 --- a/samples/cas/cas.gradle +++ /dev/null @@ -1,9 +0,0 @@ -apply plugin: 'war' -apply plugin: 'jetty' - -dependencies { - runtime project(':spring-security-core'), - project(':spring-security-web'), - project(':spring-security-config'), - 'log4j:log4j:1.2.15@jar' -} \ No newline at end of file diff --git a/samples/cas/pom.xml b/samples/cas/pom.xml deleted file mode 100644 index 5627683141..0000000000 --- a/samples/cas/pom.xml +++ /dev/null @@ -1,16 +0,0 @@ - - 4.0.0 - - org.springframework.security - spring-security-samples - 3.0.8.CI-SNAPSHOT - - org.springframework.security - spring-security-samples-cas - Spring Security - CAS Sample Parent - pom - - client - server - - diff --git a/samples/cas/sample/cassample.gradle b/samples/cas/sample/cassample.gradle new file mode 100644 index 0000000000..5dc4fa27c8 --- /dev/null +++ b/samples/cas/sample/cassample.gradle @@ -0,0 +1,125 @@ +// CAS sample build file + +apply plugin: 'war' +apply plugin: 'jetty' +apply plugin: 'groovy' + +def excludeModules = ['spring-security-acl', 'jsr250-api', 'spring-jdbc', 'spring-tx'] +def jettyVersion = '7.1.6.v20100715' +def keystore = "$rootDir/samples/certificates/server.jks" +def password = 'password' + +configurations { + casServer + excludeModules.each {name -> + runtime.exclude module: name + } + + runtime.exclude group: 'org.aspectj' + + integrationTestCompile.extendsFrom groovy +} + +sourceSets { + test.resources.exclude 'GebConfig.groovy' + integrationTest.groovy.srcDir file('src/integration-test/groovy') +} + +eclipse.classpath.plusConfigurations += configurations.integrationTestRuntime + +dependencies { + groovy 'org.codehaus.groovy:groovy:1.8.7' + + providedCompile 'javax.servlet:servlet-api:2.5@jar' + + compile project(':spring-security-core'), + project(':spring-security-cas-client'), + "org.jasig.cas.client:cas-client-core:3.1.12" + + runtime project(':spring-security-web'), + project(':spring-security-config'), + "org.slf4j:jcl-over-slf4j:$slf4jVersion", + "ch.qos.logback:logback-classic:$logbackVersion" + + integrationTestCompile project(':spring-security-cas-client'), + 'org.seleniumhq.selenium:selenium-htmlunit-driver:2.25.0', + 'org.spockframework:spock-core:0.6-groovy-1.8', + 'org.codehaus.geb:geb-spock:0.7.2', + 'commons-httpclient:commons-httpclient:3.1', + "org.eclipse.jetty:jetty-server:$jettyVersion", + "org.eclipse.jetty:jetty-servlet:$jettyVersion" +} + +[jettyRun, jettyRunWar]*.configure { + contextPath = "/cas-sample" + def httpConnector = jettyRunWar.class.classLoader.loadClass('org.mortbay.jetty.nio.SelectChannelConnector').newInstance() + httpConnector.port = 8080 + httpConnector.confidentialPort = 8443 + def httpsConnector = jettyRunWar.class.classLoader.loadClass('org.mortbay.jetty.security.SslSocketConnector').newInstance() + httpsConnector.port = 8443 + httpsConnector.keystore = httpsConnector.truststore = keystore + httpsConnector.keyPassword = httpsConnector.trustPassword = password + + connectors = [httpConnector, httpsConnector] + doFirst() { + System.setProperty('cas.server.host', casServer().httpsHost) + System.setProperty('cas.service.host', jettyRunWar.httpsHost) + } +} + +task cas (dependsOn: [jettyRunWar]) { + jettyRunWar.dependsOn(':spring-security-samples-casserver:casServer') +} + +task casServer(dependsOn: ':spring-security-samples-casserver:casServer') { +} + +integrationTest.dependsOn cas +integrationTest.doFirst { + def casServiceHost = jettyRunWar.httpsHost + systemProperties['cas.server.host'] = casServer().httpsHost + systemProperties['cas.service.host'] = casServiceHost + systemProperties['geb.build.baseUrl'] = 'https://'+casServiceHost+'/cas-sample/' + systemProperties['geb.build.reportsDir'] = 'build/geb-reports' + systemProperties['jar.path'] = jar.archivePath + systemProperties['javax.net.ssl.trustStore'] = keystore + systemProperties['javax.net.ssl.trustStorePassword'] = password +} + +gradle.taskGraph.whenReady {graph -> + def casServer = casServer() + [casServer,jettyRunWar]*.metaClass*.getHttpsConnector {-> + def sslSocketConnClass = jettyRunWar.class.classLoader.loadClass('org.mortbay.jetty.security.SslSocketConnector') + delegate.connectors.find { it in sslSocketConnClass } + } + [casServer,jettyRunWar]*.metaClass*.getHttpsHost {-> + "localhost:"+delegate.httpsConnector.port + } + jettyRunWar.metaClass.getHttpConnector {-> + def channelConnClass = jettyRunWar.class.classLoader.loadClass('org.mortbay.jetty.nio.SelectChannelConnector') + delegate.connectors.find { it in channelConnClass } + } + if (graph.hasTask(cas)) { + casServer.daemon = true + } + if(graph.hasTask(integrationTest)) { + tasks.getByPath(':spring-security-samples-casserver:casServerOverlay').logLevel = 'ERROR' + jettyRunWar.additionalRuntimeJars += file("src/integration-test/resources") + + jettyRunWar.daemon = true + jettyRunWar.httpConnector.port = availablePort() + jettyRunWar.httpsConnector.port = jettyRunWar.httpConnector.confidentialPort = availablePort() + casServer.httpsConnector.port = availablePort() + } +} + +def casServer() { + tasks.getByPath(':spring-security-samples-casserver:casServer') +} + +def availablePort() { + ServerSocket server = new ServerSocket(0) + int port = server.localPort + server.close() + port +} diff --git a/samples/cas/client/pom.xml b/samples/cas/sample/pom.xml similarity index 99% rename from samples/cas/client/pom.xml rename to samples/cas/sample/pom.xml index e398a5ce05..e28a6bd391 100644 --- a/samples/cas/client/pom.xml +++ b/samples/cas/sample/pom.xml @@ -3,7 +3,7 @@ org.springframework.security spring-security-samples-cas - 3.0.8.CI-SNAPSHOT + @pomVersion@ org.springframework.security spring-security-samples-cas-client diff --git a/samples/cas/client/src/main/java/Dummy.java b/samples/cas/sample/src/main/java/Dummy.java similarity index 100% rename from samples/cas/client/src/main/java/Dummy.java rename to samples/cas/sample/src/main/java/Dummy.java diff --git a/samples/cas/client/src/main/webapp/WEB-INF/applicationContext-security.xml b/samples/cas/sample/src/main/webapp/WEB-INF/applicationContext-security.xml similarity index 100% rename from samples/cas/client/src/main/webapp/WEB-INF/applicationContext-security.xml rename to samples/cas/sample/src/main/webapp/WEB-INF/applicationContext-security.xml diff --git a/samples/cas/client/src/main/webapp/WEB-INF/classes/log4j.properties b/samples/cas/sample/src/main/webapp/WEB-INF/classes/log4j.properties similarity index 100% rename from samples/cas/client/src/main/webapp/WEB-INF/classes/log4j.properties rename to samples/cas/sample/src/main/webapp/WEB-INF/classes/log4j.properties diff --git a/samples/cas/client/src/main/webapp/WEB-INF/web.xml b/samples/cas/sample/src/main/webapp/WEB-INF/web.xml similarity index 100% rename from samples/cas/client/src/main/webapp/WEB-INF/web.xml rename to samples/cas/sample/src/main/webapp/WEB-INF/web.xml diff --git a/samples/cas/client/src/main/webapp/cas-logout.jsp b/samples/cas/sample/src/main/webapp/cas-logout.jsp similarity index 100% rename from samples/cas/client/src/main/webapp/cas-logout.jsp rename to samples/cas/sample/src/main/webapp/cas-logout.jsp diff --git a/samples/cas/client/src/main/webapp/casfailed.jsp b/samples/cas/sample/src/main/webapp/casfailed.jsp similarity index 100% rename from samples/cas/client/src/main/webapp/casfailed.jsp rename to samples/cas/sample/src/main/webapp/casfailed.jsp diff --git a/samples/cas/client/src/main/webapp/index.jsp b/samples/cas/sample/src/main/webapp/index.jsp similarity index 100% rename from samples/cas/client/src/main/webapp/index.jsp rename to samples/cas/sample/src/main/webapp/index.jsp diff --git a/samples/cas/client/src/main/webapp/secure/extreme/index.jsp b/samples/cas/sample/src/main/webapp/secure/extreme/index.jsp similarity index 100% rename from samples/cas/client/src/main/webapp/secure/extreme/index.jsp rename to samples/cas/sample/src/main/webapp/secure/extreme/index.jsp diff --git a/samples/cas/client/src/main/webapp/secure/index.jsp b/samples/cas/sample/src/main/webapp/secure/index.jsp similarity index 100% rename from samples/cas/client/src/main/webapp/secure/index.jsp rename to samples/cas/sample/src/main/webapp/secure/index.jsp diff --git a/samples/cas/server/casserver.gradle b/samples/cas/server/casserver.gradle new file mode 100644 index 0000000000..d3d98dc825 --- /dev/null +++ b/samples/cas/server/casserver.gradle @@ -0,0 +1,61 @@ +import org.apache.tools.ant.filters.ReplaceTokens + +apply plugin: 'jetty' + +def keystore = "$rootDir/samples/certificates/server.jks" +def password = 'password' + +configurations { + casServer +} +dependencies { + casServer "org.jasig.cas:cas-server-webapp:3.4.3.1@war" +} + +task casServerOverlay(type: Sync) { + def war = configurations.casServer.resolve().toArray()[0] + def warName = war.name.replace('.war','-custom') + def overlayDir = file('src/main/webapp') + def explodedWar = file("$buildDir/tmp/${warName}") + ext.customWar = file("$buildDir/tmp/${warName}.war") + ext.tokens = [logLevel: 'INFO'] + + inputs.files(war, overlayDir) + inputs.property('tokens',{tokens}) + outputs.files (customWar,explodedWar,file("$buildDir/tmp/expandedArchives")) + + from zipTree(war) + from (overlayDir) { + filter(ReplaceTokens,tokens: tokens) + } + into explodedWar + + doLast { + if(customWar.exists()) { + customWar.delete() + } + ant.zip(destfile: customWar, baseDir: explodedWar) + } +} + +casServerOverlay.metaClass.setLogLevel { level -> + tokens['logLevel'] = level +} + +task casServer (type: org.gradle.api.plugins.jetty.JettyRunWar, dependsOn: 'casServerOverlay') { + contextPath = "/cas" + connectors = [casServer.class.classLoader.loadClass('org.mortbay.jetty.security.SslSocketConnector').newInstance()] + connectors[0].port = 9443 + connectors[0].keystore = connectors[0].truststore = keystore + connectors[0].keyPassword = connectors[0].trustPassword = password + connectors[0].wantClientAuth = true + connectors[0].needClientAuth = false + webApp = casServerOverlay.customWar + + inputs.file casServerOverlay.customWar + + doFirst() { + System.setProperty('javax.net.ssl.trustStore', keystore) + System.setProperty('javax.net.ssl.trustStorePassword', password) + } +} diff --git a/samples/cas/server/pom.xml b/samples/cas/server/pom.xml deleted file mode 100644 index 5291172600..0000000000 --- a/samples/cas/server/pom.xml +++ /dev/null @@ -1,47 +0,0 @@ - - 4.0.0 - - org.springframework.security - spring-security-samples-cas - 3.0.8.CI-SNAPSHOT - - org.springframework.security - spring-security-samples-cas-server - Spring Security - CAS Server for CAS Sample Application - pom - - - - org.mortbay.jetty - maven-jetty-plugin - ${jetty.version} - - /cas - ${basedir}/cas-server-webapp-3.3.5.war - - - 9443 - ../../certificates/server.jks - password - password - ../../certificates/server.jks - password - true - false - - - - - javax.net.ssl.trustStore - ../../certificates/server.jks - - - javax.net.ssl.trustStorePassword - password - - - - - - - \ No newline at end of file diff --git a/samples/cas/server/src/main/webapp/WEB-INF/classes/log4j.xml b/samples/cas/server/src/main/webapp/WEB-INF/classes/log4j.xml new file mode 100644 index 0000000000..c1ce7fa6fd --- /dev/null +++ b/samples/cas/server/src/main/webapp/WEB-INF/classes/log4j.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/samples/cas/server/src/main/webapp/WEB-INF/spring-configuration/zzzhttpClientCustomization.xml b/samples/cas/server/src/main/webapp/WEB-INF/spring-configuration/zzzhttpClientCustomization.xml new file mode 100644 index 0000000000..5ba031b6e4 --- /dev/null +++ b/samples/cas/server/src/main/webapp/WEB-INF/spring-configuration/zzzhttpClientCustomization.xml @@ -0,0 +1,22 @@ + + + + Customizations to the CAS Server. The name starts with zzz to ensure it is the last file loaded to override other bean definitions. + + + + + + + + + + + + + \ No newline at end of file diff --git a/samples/certificates/server.jks b/samples/certificates/server.jks index f56cf2e837..aaa1119fff 100755 Binary files a/samples/certificates/server.jks and b/samples/certificates/server.jks differ diff --git a/samples/contacts/contacts.gradle b/samples/contacts/contacts.gradle index 6515413f35..bd4b8974c8 100644 --- a/samples/contacts/contacts.gradle +++ b/samples/contacts/contacts.gradle @@ -3,6 +3,11 @@ apply plugin: 'war' apply plugin: 'jetty' +configurations { + runtime.exclude module: 'jsr250-api' + runtime.exclude group: 'org.aspectj' +} + dependencies { providedCompile 'javax.servlet:servlet-api:2.5@jar' @@ -14,13 +19,19 @@ dependencies { "org.springframework:spring-jdbc:$springVersion", "org.springframework:spring-tx:$springVersion", "org.springframework:spring-web:$springVersion", - "org.springframework:spring-webmvc:$springVersion", - "org.aspectj:aspectjrt:$aspectjVersion" + "org.springframework:spring-webmvc:$springVersion" runtime project(':spring-security-web'), project(':spring-security-config'), project(':spring-security-taglibs'), "org.springframework:spring-context-support:$springVersion", + "javax.servlet:jstl:$jstlVersion", "net.sf.ehcache:ehcache:$ehcacheVersion", - 'log4j:log4j:1.2.15@jar' -} \ No newline at end of file + "hsqldb:hsqldb:$hsqlVersion", + "org.slf4j:jcl-over-slf4j:$slf4jVersion", + "ch.qos.logback:logback-classic:$logbackVersion" +} + +jettyRun { + contextPath = "/contacts" +} diff --git a/samples/contacts/pom.xml b/samples/contacts/pom.xml deleted file mode 100644 index ad195e75da..0000000000 --- a/samples/contacts/pom.xml +++ /dev/null @@ -1,144 +0,0 @@ - - 4.0.0 - - org.springframework.security - spring-security-samples - 3.0.8.CI-SNAPSHOT - - spring-security-samples-contacts - Spring Security - Contacts sample - war - - - - org.springframework.security - spring-security-core - ${project.version} - - - org.springframework.security - spring-security-config - ${project.version} - - - org.springframework.security - spring-security-acl - ${project.version} - - - org.springframework.security - spring-security-taglibs - ${project.version} - - - org.springframework - spring-core - - - commons-logging - commons-logging - - - - - org.springframework - spring-webmvc - compile - - - org.springframework - spring-jdbc - compile - - - org.springframework - spring-aop - - - org.springframework - spring-test - test - - - javax.servlet - servlet-api - - - javax.servlet - jstl - - - taglibs - standard - - - net.sf.ehcache - ehcache - - - hessian - hessian - 3.0.1 - - - hsqldb - hsqldb - runtime - - - org.slf4j - slf4j-api - 1.6.0 - runtime - - - org.slf4j - jcl-over-slf4j - 1.6.0 - - - org.slf4j - slf4j-log4j12 - 1.6.0 - runtime - - - log4j - log4j - runtime - - - - - - - org.apache.maven.plugins - maven-war-plugin - - - org.mortbay.jetty - maven-jetty-plugin - ${jetty.version} - - /contacts - - 5 - - - - - - - - diff --git a/samples/dms/dms.gradle b/samples/dms/dms.gradle new file mode 100644 index 0000000000..a1c1363436 --- /dev/null +++ b/samples/dms/dms.gradle @@ -0,0 +1,16 @@ + +dependencies { + compile project(':spring-security-core'), + project(':spring-security-acl'), + "org.springframework:spring-beans:$springVersion", + "org.springframework:spring-tx:$springVersion", + "org.springframework:spring-jdbc:$springVersion" + + testCompile "org.springframework:spring-context:$springVersion" + + runtime project(':spring-security-config'), + "hsqldb:hsqldb:$hsqlVersion", + "net.sf.ehcache:ehcache:$ehcacheVersion", + "org.springframework:spring-context-support:$springVersion" + +} diff --git a/samples/dms/pom.xml b/samples/dms/pom.xml deleted file mode 100644 index 6311c39e27..0000000000 --- a/samples/dms/pom.xml +++ /dev/null @@ -1,54 +0,0 @@ - - 4.0.0 - - org.springframework.security - spring-security-samples - 3.0.8.CI-SNAPSHOT - - spring-security-samples-dms - Spring Security - DMS sample - - - org.springframework.security - spring-security-core - ${project.version} - - - org.springframework.security - spring-security-acl - ${project.version} - - - org.springframework.security - spring-security-config - ${project.version} - - - org.springframework - spring-jdbc - - - javax.servlet - servlet-api - - - org.springframework - spring-aop - runtime - - - org.springframework - spring-test - ${spring.version} - - - hsqldb - hsqldb - - - net.sf.ehcache - ehcache - runtime - - - diff --git a/samples/ldap/ldap.gradle b/samples/ldap/ldap.gradle new file mode 100644 index 0000000000..befbeb78a7 --- /dev/null +++ b/samples/ldap/ldap.gradle @@ -0,0 +1,27 @@ +// LDAP sample build file + +apply plugin: 'war' +apply plugin: 'jetty' + +def excludeModules = ['spring-security-acl', 'jsr250-api', 'ehcache', 'spring-jdbc', 'ldapsdk'] + +configurations { + excludeModules.each {name -> + runtime.exclude module: name + } + + runtime.exclude group: 'org.aspectj' +} + +dependencies { + + runtime project(':spring-security-web'), + project(':spring-security-config'), + project(':spring-security-ldap'), + "org.slf4j:jcl-over-slf4j:$slf4jVersion", + "ch.qos.logback:logback-classic:$logbackVersion" +} + +jettyRun { + contextPath = "/ldap" +} diff --git a/samples/ldap/pom.xml b/samples/ldap/pom.xml deleted file mode 100644 index 6b2b7de040..0000000000 --- a/samples/ldap/pom.xml +++ /dev/null @@ -1,106 +0,0 @@ - - 4.0.0 - - org.springframework.security - spring-security-samples - 3.0.8.CI-SNAPSHOT - - org.springframework.security - spring-security-samples-ldap - Spring Security - Ldap Sample - war - - - org.springframework.security - spring-security-ldap - ${project.version} - - - org.springframework.security - spring-security-config - ${project.version} - - - org.springframework.security - spring-security-web - ${project.version} - - - org.springframework - spring-core - - - commons-logging - commons-logging - - - - - org.springframework - spring-webmvc - ${spring.version} - - - org.springframework - spring-aop - runtime - - - org.apache.directory.server - apacheds-core - 1.5.5 - compile - - - org.apache.directory.server - apacheds-server-jndi - 1.5.5 - compile - - - org.slf4j - slf4j-api - 1.6.0 - runtime - - - org.slf4j - jcl-over-slf4j - 1.6.0 - runtime - - - org.slf4j - slf4j-log4j12 - 1.6.0 - runtime - - - log4j - log4j - runtime - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - - 1.5 - 1.5 - - - - org.mortbay.jetty - maven-jetty-plugin - ${jetty.version} - - /ldap - - - - - - diff --git a/samples/openid/openid.gradle b/samples/openid/openid.gradle index b5e017cf76..47e3ebd112 100644 --- a/samples/openid/openid.gradle +++ b/samples/openid/openid.gradle @@ -4,6 +4,8 @@ apply plugin: 'war' apply plugin: 'jetty' dependencies { + compile project(':spring-security-core'), + project(':spring-security-openid') providedCompile 'javax.servlet:servlet-api:2.5@jar' runtime project(':spring-security-config'), diff --git a/samples/openid/pom.xml b/samples/openid/pom.xml deleted file mode 100644 index 21d5df8c68..0000000000 --- a/samples/openid/pom.xml +++ /dev/null @@ -1,103 +0,0 @@ - - 4.0.0 - - org.springframework.security - spring-security-samples - 3.0.8.CI-SNAPSHOT - - org.springframework.security - spring-security-samples-openid - Spring Security - OpenID sample - war - - - org.springframework.security - spring-security-core - ${project.version} - - - org.springframework.security - spring-security-config - ${project.version} - - - org.springframework.security - spring-security-web - ${project.version} - - - org.springframework.security - spring-security-openid - ${project.version} - - - org.springframework - spring-core - - - commons-logging - commons-logging - - - - org.springframework - spring-webmvc - runtime - - - org.springframework - spring-jdbc - runtime - - - org.springframework - spring-aop - runtime - - - javax.servlet - jstl - - - taglibs - standard - - - org.slf4j - slf4j-api - 1.6.0 - runtime - - - org.slf4j - jcl-over-slf4j - 1.6.0 - runtime - - - org.slf4j - slf4j-log4j12 - 1.6.0 - runtime - - - log4j - log4j - runtime - - - - - - - org.mortbay.jetty - maven-jetty-plugin - ${jetty.version} - - /openid - - - - - - diff --git a/samples/pom.xml b/samples/pom.xml deleted file mode 100644 index 9a8fd4d322..0000000000 --- a/samples/pom.xml +++ /dev/null @@ -1,38 +0,0 @@ - - 4.0.0 - - org.springframework.security - spring-security-parent - 3.0.8.CI-SNAPSHOT - - org.springframework.security - spring-security-samples - Spring Security - Samples - pom - - contacts - tutorial - dms - preauth - openid - ldap - cas - aspectj - - - - javax.servlet - servlet-api - - - javax.servlet - jstl - runtime - - - taglibs - standard - runtime - - - diff --git a/samples/preauth/pom.xml b/samples/preauth/pom.xml deleted file mode 100644 index 9ee13dc39f..0000000000 --- a/samples/preauth/pom.xml +++ /dev/null @@ -1,89 +0,0 @@ - - 4.0.0 - - org.springframework.security - spring-security-samples - 3.0.8.CI-SNAPSHOT - - org.springframework.security - spring-security-samples-preauth - Spring Security - Preauthentication sample - war - - - org.springframework.security - spring-security-core - ${project.version} - runtime - - - org.springframework - spring-core - - - commons-logging - commons-logging - - - - - org.springframework.security - spring-security-web - ${project.version} - runtime - - - org.springframework.security - spring-security-config - ${project.version} - runtime - - - org.springframework - spring-jdbc - runtime - - - org.slf4j - slf4j-api - 1.6.0 - runtime - - - org.slf4j - jcl-over-slf4j - 1.6.0 - runtime - - - org.slf4j - slf4j-log4j12 - 1.6.0 - runtime - - - log4j - log4j - runtime - - - - - - - org.mortbay.jetty - maven-jetty-plugin - ${jetty.version} - - /preauth - - - Preauth Realm - realm.properties - - - - - - - diff --git a/samples/preauth/preauth.gradle b/samples/preauth/preauth.gradle new file mode 100644 index 0000000000..e7218d8ef9 --- /dev/null +++ b/samples/preauth/preauth.gradle @@ -0,0 +1,27 @@ +// Preauth sample build file + +apply plugin: 'war' +apply plugin: 'jetty' + +def excludeModules = ['jsr250-api', 'ehcache', 'spring-jdbc', 'spring-tx'] + +configurations { + excludeModules.each {name -> + runtime.exclude module: name + } + + runtime.exclude group: 'org.aspectj' +} + +dependencies { + + runtime project(':spring-security-web'), + project(':spring-security-config'), + "org.slf4j:jcl-over-slf4j:$slf4jVersion", + "ch.qos.logback:logback-classic:$logbackVersion" +} + +jettyRun { + contextPath = "/preauth" + userRealms = [jettyRun.class.classLoader.loadClass('org.mortbay.jetty.security.HashUserRealm').newInstance('Preauth Realm', "$projectDir/realm.properties")] +} diff --git a/samples/runall.sh b/samples/runall.sh index 784734b98d..eb931a76a9 100755 --- a/samples/runall.sh +++ b/samples/runall.sh @@ -19,7 +19,7 @@ cleanup() { start_jetty() { - mvn -o jetty:run > runall.log & + gradle -d jettyRun > runall.log & until (grep "Started Jetty Server" runall.log) do echo "- Waiting for server to start... -" diff --git a/samples/tutorial/pom.xml b/samples/tutorial/pom.xml index 32e493487d..7f6a4f472b 100644 --- a/samples/tutorial/pom.xml +++ b/samples/tutorial/pom.xml @@ -3,7 +3,7 @@ org.springframework.security spring-security-samples - 3.0.8.CI-SNAPSHOT + @pomVersion@ org.springframework.security spring-security-samples-tutorial diff --git a/samples/tutorial/readme.txt b/samples/tutorial/readme.txt index f14e775c8c..bfa6a48f5d 100644 --- a/samples/tutorial/readme.txt +++ b/samples/tutorial/readme.txt @@ -1,6 +1,10 @@ -Run the application directly from the checked out source tree, using the command +This is the most basic sample web application for Spring Security. -mvn jetty:run +If you have gradle installed, you can run the application directly from the checked out source tree, using the command + +gradle jettyRun This will start jetty on port 8080, with SSL support on port 8443. +The 'scripts' directory contains simple Unix command-line scripts for exercising the application and displaying the results. + diff --git a/samples/tutorial/tutorial.gradle b/samples/tutorial/tutorial.gradle index ec2a90d014..a98a54098f 100644 --- a/samples/tutorial/tutorial.gradle +++ b/samples/tutorial/tutorial.gradle @@ -3,6 +3,15 @@ apply plugin: 'war' apply plugin: 'jetty' +def excludeModules = ['spring-security-acl', 'jsr250-api', 'ehcache', 'spring-jdbc', 'spring-tx'] + +configurations { + excludeModules.each {name -> + runtime.exclude module: name + } + +} + dependencies { providedCompile 'javax.servlet:servlet-api:2.5@jar' @@ -10,10 +19,28 @@ dependencies { "org.springframework:spring-beans:$springVersion", "org.springframework:spring-web:$springVersion", "org.springframework:spring-webmvc:$springVersion", - "org.aspectj:aspectjrt:$aspectjVersion" + "org.aspectj:aspectjrt:$aspectjVersion", + "org.slf4j:slf4j-api:$slf4jVersion" runtime project(':spring-security-web'), project(':spring-security-config'), project(':spring-security-taglibs'), - 'log4j:log4j:1.2.15@jar' -} \ No newline at end of file + "javax.servlet:jstl:$jstlVersion", + "org.slf4j:jcl-over-slf4j:$slf4jVersion", + "ch.qos.logback:logback-core:$logbackVersion", + "ch.qos.logback:logback-classic:$logbackVersion" +} + +jettyRun { + contextPath = "/tutorial" + + def httpConnector = jettyRunWar.class.classLoader.loadClass('org.mortbay.jetty.nio.SelectChannelConnector').newInstance() + httpConnector.port = 8080 + httpConnector.confidentialPort = 8443 + def httpsConnector = jettyRunWar.class.classLoader.loadClass('org.mortbay.jetty.security.SslSocketConnector').newInstance() + httpsConnector.port = 8443 + httpsConnector.keystore = "$rootDir/samples/certificates/server.jks" + httpsConnector.keyPassword = 'password' + + connectors = [httpConnector, httpsConnector] +} diff --git a/sandbox/heavyduty/pom.xml b/sandbox/heavyduty/pom.xml deleted file mode 100755 index bb7a20b95d..0000000000 --- a/sandbox/heavyduty/pom.xml +++ /dev/null @@ -1,194 +0,0 @@ - - 4.0.0 - org.springframework.security - spring-security-heavyduty - Spring Security - Heavy Duty Sample - war - 3.0.8.CI-SNAPSHOT - - - org.springframework.security - spring-security-web - ${spring.security.version} - - - org.springframework.security - spring-security-ldap - ${spring.security.version} - - - org.springframework.security - spring-security-config - ${spring.security.version} - - - org.springframework.security - spring-security-taglibs - ${spring.security.version} - - - org.springframework - spring-context-support - ${spring.version} - - - org.springframework - spring-web - ${spring.version} - - - org.springframework - spring-webmvc - ${spring.version} - - - org.springframework - spring-jdbc - runtime - ${spring.version} - - - org.springframework - spring-orm - ${spring.version} - - - org.freemarker - freemarker - runtime - 2.3.16 - - - hsqldb - hsqldb - 1.8.0.10 - compile - - - org.hibernate - hibernate-entitymanager - 3.4.0.GA - compile - - - commons-logging - commons-logging - - - - - net.sf.ehcache - ehcache - 1.6.2 - compile - - - javax.servlet - servlet-api - provided - 2.4 - - - javax.servlet - jstl - runtime - 1.1.2 - - - taglibs - standard - runtime - 1.1.2 - - - org.apache.directory.server - apacheds-core - 1.5.5 - compile - true - - - org.apache.directory.server - apacheds-server-jndi - 1.5.5 - compile - true - - - commons-collections - commons-collections - 3.2.1 - runtime - - - org.slf4j - slf4j-api - 1.6.0 - runtime - - - org.slf4j - slf4j-log4j12 - 1.6.0 - runtime - - - log4j - log4j - runtime - 1.2.14 - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - - 1.5 - 1.5 - - - - org.apache.maven.plugins - maven-eclipse-plugin - 2.5.1 - - true - 2.0 - - - - org.mortbay.jetty - maven-jetty-plugin - 6.1.22 - - /heavyduty - - - - 8080 - 8443 - - - 8443 - certificates/server.jks - password - password - certificates/server.jks - password - true - false - - - - - - - - 3.0.3.RELEASE - 3.0.6.RELEASE - - - diff --git a/sandbox/webflow/pom.xml b/sandbox/webflow/pom.xml deleted file mode 100644 index 9d72da6066..0000000000 --- a/sandbox/webflow/pom.xml +++ /dev/null @@ -1,96 +0,0 @@ - - 4.0.0 - org.springframework.security - spring-security-samples-webflow - Spring Security - Webflow sample - 3.0.8.CI-SNAPSHOT - war - - - org.springframework.security - spring-security-core - ${project.version} - - - org.springframework.security - spring-security-taglibs - ${project.version} - - - org.springframework.webflow - spring-webflow - 2.0.8.RELEASE - - - ognl - ognl - 2.7.3 - - - org.springframework - spring-web - 3.0.0.RELEASE - - - org.springframework - spring-core - 3.0.0.RELEASE - - - org.springframework - spring-context - 3.0.0.RELEASE - - - org.springframework - spring-webmvc - 3.0.0.RELEASE - - - javax.servlet - servlet-api - provided - 2.5 - - - org.freemarker - freemarker - runtime - 2.3.16 - - - log4j - log4j - runtime - 1.2.14 - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - - 1.5 - 1.5 - - - - org.mortbay.jetty - maven-jetty-plugin - 6.1.22 - - /webflow - - - 8080 - 8443 - - - - - - - - diff --git a/settings.gradle b/settings.gradle index 4151bf051a..e8b7c57205 100644 --- a/settings.gradle +++ b/settings.gradle @@ -7,60 +7,65 @@ def String[] modules = [ 'cas', 'openid', 'taglibs', - 'aspects' + 'aspects', + 'parent' ] def String[] samples = [ 'tutorial', 'contacts', 'openid', - 'aspectj' -] - -def String[] docs = [ - 'faq', - 'manual' + 'aspectj', + 'dms', + 'preauth', + 'cas/server', + 'cas/sample', + 'ldap' ] def String[] itest = [ - 'web' + 'web', + 'context' ] include modules modules.each {name -> - p = findProject(":${name}") + def p = findProject(":${name}") p.name = "spring-security-${name}" p.buildFileName = "${name}.gradle" } +def casClient = findProject(":spring-security-cas") +casClient.name = 'spring-security-cas-client' + include samples samples.each {name -> - p = findProject(":${name}") - p.name = "spring-security-samples-${name}" - p.buildFileName = "${name}.gradle" + def p = findProject(":${name}") + def fullName = name.replaceAll('/','') + p.name = "spring-security-samples-${fullName}" + p.buildFileName = "${fullName}.gradle" p.projectDir = new File(settingsDir, "samples/${name}"); } include itest itest.each { name -> - p = findProject(":${name}") + def p = findProject(":${name}") p.name = "itest-${name}" p.buildFileName = "itest-${name}.gradle" p.projectDir = new File(settingsDir, "itest/${name}"); } -include docs +include 'docs', 'docs:faq', 'docs:manual' -docs.each { name -> - p = findProject(":${name}") - p.buildFileName = "${name}.gradle" - p.projectDir = new File(settingsDir, "docs/${name}"); -} +def docs = findProject(':docs') +docs.buildFileName = 'docs.gradle' + +rootProject.name = 'spring-security' rootProject.children.each {project -> assert project.projectDir.isDirectory() assert project.buildFile.isFile() -} \ No newline at end of file +} diff --git a/taglibs/pom.xml b/taglibs/pom.xml index ec9b5db899..2fd889e07f 100644 --- a/taglibs/pom.xml +++ b/taglibs/pom.xml @@ -3,13 +3,13 @@ spring-security-parent org.springframework.security - 3.0.8.CI-SNAPSHOT + @pomVersion@ 4.0.0 org.springframework.security spring-security-taglibs Spring Security - JSP taglibs - 3.0.8.CI-SNAPSHOT + @pomVersion@ jar diff --git a/taglibs/taglibs.gradle b/taglibs/taglibs.gradle index 7765bf5f15..d631a4550f 100644 --- a/taglibs/taglibs.gradle +++ b/taglibs/taglibs.gradle @@ -5,11 +5,12 @@ dependencies { project(':spring-security-web'), project(':spring-security-acl'), "org.springframework:spring-beans:$springVersion", + "org.springframework:spring-aop:$springVersion", "org.springframework:spring-context:$springVersion", "org.springframework:spring-expression:$springVersion", "org.springframework:spring-web:$springVersion" provided 'javax.servlet:jsp-api:2.0', 'javax.servlet:servlet-api:2.5' - testRuntime "taglibs:standard:$jstlVersion" + testRuntime "javax.servlet:jstl:$jstlVersion" } \ No newline at end of file diff --git a/taglibs/template.mf b/taglibs/template.mf index 72d401ce61..bce2d3fbac 100644 --- a/taglibs/template.mf +++ b/taglibs/template.mf @@ -9,15 +9,17 @@ Ignored-Existing-Headers: Import-Package, Export-Package Import-Template: - org.apache.commons.logging.*;version="[1.0.4, 2.0.0)", - org.springframework.security.core.*;version="[${version}, 3.1.0)", - org.springframework.security.web.*;version="[${version}, 3.1.0)", - org.springframework.security.access.*;version="[${version}, 3.1.0)", - org.springframework.security.util;version="[${version}, 3.1.0)", - org.springframework.security.acls.*;version="[${version}, 3.1.0)";resolution:=optional, - org.springframework.beans.*;version="[${spring.version}, 3.1.0)", - org.springframework.context.*;version="[${spring.version}, 3.1.0)", - org.springframework.expression;version="[${spring.version}, 3.1.0)";resolution:=optional, - org.springframework.web.context.*;version="[${spring.version}, 3.1.0)";resolution:=optional, - org.springframework.web.util.*;version="[${spring.version}, 3.1.0)", + org.apache.commons.logging.*;version="${cloggingRange}", + org.springframework.security.core.*;version="${secRange}", + org.springframework.security.web.*;version="${secRange}", + org.springframework.security.access.*;version="${secRange}", + org.springframework.security.util;version="${secRange}", + org.springframework.security.acls.*;version="${secRange}";resolution:=optional, + org.springframework.core.*;version="${springRange}", + org.springframework.util;version="${springRange}", + org.springframework.beans.*;version="${springRange}", + org.springframework.context.*;version="${springRange}", + org.springframework.expression;version="${springRange}";resolution:=optional, + org.springframework.web.context.*;version="${springRange}";resolution:=optional, + org.springframework.web.util.*;version="${springRange}", javax.servlet.*;version="0" diff --git a/web/pom.xml b/web/pom.xml index 222360f9b0..780219467d 100644 --- a/web/pom.xml +++ b/web/pom.xml @@ -3,7 +3,7 @@ org.springframework.security spring-security-parent - 3.0.8.CI-SNAPSHOT + @pomVersion@ jar spring-security-web diff --git a/web/template.mf b/web/template.mf index 07655c62b8..3cec203cea 100644 --- a/web/template.mf +++ b/web/template.mf @@ -17,23 +17,25 @@ Ignored-Existing-Headers: Import-Package, Export-Package Import-Template: - org.apache.commons.logging.*;version="[1.0.4, 2.0.0)", - org.springframework.security.core.*;version="[${version}, 3.1.0)", - org.springframework.security.authentication.*;version="[${version}, 3.1.0)", - org.springframework.security.access.*;version="[${version}, 3.1.0)", - org.springframework.security.util;version="[${version}, 3.1.0)", - org.springframework.beans.*;version="[${spring.version}, 3.1.0)", - org.springframework.context.*;version="[${spring.version}, 3.1.0)", - org.springframework.core;version="[${spring.version}, 3.1.0)", - org.springframework.core.io;version="[${spring.version}, 3.1.0)", - org.springframework.dao;version="[${spring.version}, 3.1.0)";resolution:=optional, - org.springframework.expression;version="[${spring.version}, 3.1.0)";resolution:=optional, - org.springframework.expression.spel.*;version="[${spring.version}, 3.1.0)";resolution:=optional, - org.springframework.jdbc.*;version="[${spring.version}, 3.1.0)";resolution:=optional, - org.springframework.mock.web;version="[${spring.version}, 3.1.0)";resolution:=optional, - org.springframework.web.context.*;version="[${spring.version}, 3.1.0)";resolution:=optional, - org.springframework.web.filter.*;version="[${spring.version}, 3.1.0)", - org.springframework.util;version="[${spring.version}, 3.1.0)";resolution:=optional, + org.apache.commons.logging.*;version="${cloggingRange}", + org.springframework.security.core.*;version="${secRange}", + org.springframework.security.crypto.*;version="${secRange}", + org.springframework.security.authentication.*;version="${secRange}", + org.springframework.security.access.*;version="${secRange}", + org.springframework.security.util;version="${secRange}", + org.springframework.beans.*;version="${springRange}", + org.springframework.context.*;version="${springRange}", + org.springframework.core;version="${springRange}", + org.springframework.core.io;version="${springRange}", + org.springframework.dao;version="${springRange}";resolution:=optional, + org.springframework.expression;version="${springRange}";resolution:=optional, + org.springframework.expression.spel.*;version="${springRange}";resolution:=optional, + org.springframework.http.*;version="${springRange}", + org.springframework.jdbc.*;version="${springRange}";resolution:=optional, + org.springframework.mock.web;version="${springRange}";resolution:=optional, + org.springframework.web.context.*;version="${springRange}";resolution:=optional, + org.springframework.web.filter.*;version="${springRange}", + org.springframework.util;version="${springRange}";resolution:=optional, org.w3c.dom;version="0";resolution:=optional, org.xml.sax;version="0";resolution:=optional, javax.servlet.*;version="0", diff --git a/web/web.gradle b/web/web.gradle index a47e5531d7..edb246db02 100644 --- a/web/web.gradle +++ b/web/web.gradle @@ -1,20 +1,26 @@ -// Web module build file - dependencies { compile project(':spring-security-core'), 'aopalliance:aopalliance:1.0', - "org.aspectj:aspectjweaver:$aspectjVersion", "org.springframework:spring-aop:$springVersion", "org.springframework:spring-beans:$springVersion", "org.springframework:spring-context:$springVersion", "org.springframework:spring-expression:$springVersion", "org.springframework:spring-jdbc:$springVersion", "org.springframework:spring-tx:$springVersion", - "org.springframework:spring-web:$springVersion", - "org.springframework:spring-test:$springVersion" + "org.springframework:spring-web:$springVersion" provided 'javax.servlet:servlet-api:2.5' - testCompile 'commons-codec:commons-codec:1.3' + testCompile project(':spring-security-core').sourceSets.test.output, + 'commons-codec:commons-codec:1.3', + "org.slf4j:jcl-over-slf4j:$slf4jVersion", + "org.springframework:spring-test:$springVersion", + "org.powermock:powermock-core:$powerMockVersion", + "org.powermock:powermock-api-support:$powerMockVersion", + "org.powermock:powermock-module-junit4-common:$powerMockVersion", + "org.powermock:powermock-module-junit4:$powerMockVersion", + "org.powermock:powermock-api-mockito:$powerMockVersion", + "org.powermock:powermock-reflect:$powerMockVersion" + testRuntime "hsqldb:hsqldb:$hsqlVersion" }