Use xml / javaconfig folders for samples
Fixes gh-3752
This commit is contained in:
12
samples/xml/cas/Readme.txt
Normal file
12
samples/xml/cas/Readme.txt
Normal file
@@ -0,0 +1,12 @@
|
||||
To run a CAS server and client application, just execute the command
|
||||
|
||||
./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).
|
||||
129
samples/xml/cas/cassample/cassample.gradle
Normal file
129
samples/xml/cas/cassample/cassample.gradle
Normal file
@@ -0,0 +1,129 @@
|
||||
// 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 = '8.1.9.v20130131'
|
||||
def keystore = "$rootDir/samples/certificates/server.jks"
|
||||
def password = 'password'
|
||||
|
||||
configurations {
|
||||
casServer
|
||||
excludeModules.each {name ->
|
||||
runtime.exclude module: name
|
||||
}
|
||||
|
||||
runtime.exclude group: 'org.aspectj'
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
test.resources.exclude 'GebConfig.groovy'
|
||||
integrationTest.groovy.srcDir file('src/integration-test/groovy')
|
||||
}
|
||||
|
||||
eclipse.classpath.plusConfigurations += [configurations.integrationTestRuntime]
|
||||
|
||||
dependencies {
|
||||
providedCompile "javax.servlet:javax.servlet-api:$servletApiVersion"
|
||||
|
||||
compile project(':spring-security-core'),
|
||||
project(':spring-security-cas'),
|
||||
"org.jasig.cas.client:cas-client-core:$casClientVersion"
|
||||
|
||||
runtime project(':spring-security-web'),
|
||||
project(':spring-security-config'),
|
||||
"org.springframework:spring-context-support:$springVersion",
|
||||
"org.slf4j:jcl-over-slf4j:$slf4jVersion",
|
||||
"ch.qos.logback:logback-classic:$logbackVersion",
|
||||
"net.sf.ehcache:ehcache:$ehcacheVersion"
|
||||
|
||||
integrationTestCompile project(':spring-security-cas'),
|
||||
"org.seleniumhq.selenium:selenium-htmlunit-driver:$seleniumVersion",
|
||||
"org.gebish:geb-spock:$gebVersion",
|
||||
'commons-httpclient:commons-httpclient:3.1',
|
||||
"org.eclipse.jetty:jetty-server:$jettyVersion",
|
||||
"org.eclipse.jetty:jetty-servlet:$jettyVersion",
|
||||
"org.codehaus.groovy:groovy:$groovyVersion",
|
||||
"org.slf4j:jcl-over-slf4j:$slf4jVersion",
|
||||
spockDependencies
|
||||
}
|
||||
|
||||
[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-xml-casserver:casServer')
|
||||
}
|
||||
|
||||
task casServer(dependsOn: ':spring-security-samples-xml-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-xml-casserver:casServerOverlay').logLevel = 'ERROR'
|
||||
jettyRunWar {
|
||||
additionalRuntimeJars += file("src/integration-test/resources")
|
||||
daemon = true
|
||||
}
|
||||
|
||||
[jettyRunWar.httpConnector,jettyRunWar.httpsConnector,casServer.httpsConnector]*.metaClass*.reservePort { taskToCloseSocket ->
|
||||
def serverSocket = new ServerSocket(0)
|
||||
delegate.metaClass.serverSocket = serverSocket
|
||||
delegate.port = serverSocket.localPort
|
||||
taskToCloseSocket.doFirst {
|
||||
serverSocket.close()
|
||||
}
|
||||
}
|
||||
|
||||
[jettyRunWar.httpConnector,jettyRunWar.httpsConnector]*.reservePort(jettyRunWar)
|
||||
jettyRunWar.httpConnector.confidentialPort = jettyRunWar.httpsConnector.port
|
||||
casServer.httpsConnector.reservePort(casServer)
|
||||
}
|
||||
}
|
||||
|
||||
def casServer() {
|
||||
tasks.getByPath(':spring-security-samples-xml-casserver:casServer')
|
||||
}
|
||||
223
samples/xml/cas/cassample/pom.xml
Normal file
223
samples/xml/cas/cassample/pom.xml
Normal file
@@ -0,0 +1,223 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.springframework.security</groupId>
|
||||
<artifactId>spring-security-samples-xml-cassample</artifactId>
|
||||
<version>4.1.0.BUILD-SNAPSHOT</version>
|
||||
<packaging>war</packaging>
|
||||
<name>spring-security-samples-xml-cassample</name>
|
||||
<description>spring-security-samples-xml-cassample</description>
|
||||
<url>http://spring.io/spring-security</url>
|
||||
<organization>
|
||||
<name>spring.io</name>
|
||||
<url>http://spring.io/</url>
|
||||
</organization>
|
||||
<licenses>
|
||||
<license>
|
||||
<name>The Apache Software License, Version 2.0</name>
|
||||
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
|
||||
<distribution>repo</distribution>
|
||||
</license>
|
||||
</licenses>
|
||||
<developers>
|
||||
<developer>
|
||||
<id>rwinch</id>
|
||||
<name>Rob Winch</name>
|
||||
<email>rwinch@gopivotal.com</email>
|
||||
</developer>
|
||||
</developers>
|
||||
<scm>
|
||||
<connection>scm:git:git://github.com/spring-projects/spring-security</connection>
|
||||
<developerConnection>scm:git:git://github.com/spring-projects/spring-security</developerConnection>
|
||||
<url>https://github.com/spring-projects/spring-security</url>
|
||||
</scm>
|
||||
<properties>
|
||||
<m2eclipse.wtp.contextRoot>/spring-security-samples-xml-cassample</m2eclipse.wtp.contextRoot>
|
||||
</properties>
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-framework-bom</artifactId>
|
||||
<version>4.2.5.RELEASE</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.jasig.cas.client</groupId>
|
||||
<artifactId>cas-client-core</artifactId>
|
||||
<version>3.4.1</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.security</groupId>
|
||||
<artifactId>spring-security-cas</artifactId>
|
||||
<version>4.1.0.BUILD-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.security</groupId>
|
||||
<artifactId>spring-security-core</artifactId>
|
||||
<version>4.1.0.BUILD-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-logging</groupId>
|
||||
<artifactId>commons-logging</artifactId>
|
||||
<version>1.2</version>
|
||||
<scope>compile</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>javax.servlet-api</artifactId>
|
||||
<version>3.0.1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
<artifactId>logback-classic</artifactId>
|
||||
<version>1.1.2</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.sf.ehcache</groupId>
|
||||
<artifactId>ehcache</artifactId>
|
||||
<version>2.9.0</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>jcl-over-slf4j</artifactId>
|
||||
<version>1.7.7</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.security</groupId>
|
||||
<artifactId>spring-security-config</artifactId>
|
||||
<version>4.1.0.BUILD-SNAPSHOT</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.security</groupId>
|
||||
<artifactId>spring-security-web</artifactId>
|
||||
<version>4.1.0.BUILD-SNAPSHOT</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-context-support</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-httpclient</groupId>
|
||||
<artifactId>commons-httpclient</artifactId>
|
||||
<version>3.1</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.12</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.assertj</groupId>
|
||||
<artifactId>assertj-core</artifactId>
|
||||
<version>2.2.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.codehaus.groovy</groupId>
|
||||
<artifactId>groovy</artifactId>
|
||||
<version>2.4.4</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-server</artifactId>
|
||||
<version>8.1.9.v20130131</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-servlet</artifactId>
|
||||
<version>8.1.9.v20130131</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gebish</groupId>
|
||||
<artifactId>geb-spock</artifactId>
|
||||
<version>0.10.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<version>1.10.19</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.seleniumhq.selenium</groupId>
|
||||
<artifactId>selenium-htmlunit-driver</artifactId>
|
||||
<version>2.44.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.spockframework</groupId>
|
||||
<artifactId>spock-core</artifactId>
|
||||
<version>0.7-groovy-2.0</version>
|
||||
<scope>test</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>junit-dep</artifactId>
|
||||
<groupId>junit</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.spockframework</groupId>
|
||||
<artifactId>spock-spring</artifactId>
|
||||
<version>0.7-groovy-2.0</version>
|
||||
<scope>test</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>junit-dep</artifactId>
|
||||
<groupId>junit</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spring-snapshot</id>
|
||||
<url>https://repo.spring.io/snapshot</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>1.7</source>
|
||||
<target>1.7</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-war-plugin</artifactId>
|
||||
<version>2.3</version>
|
||||
<configuration>
|
||||
<failOnMissingWebXml>false</failOnMissingWebXml>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright 2011 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.samples.cas;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import geb.spock.*
|
||||
|
||||
|
||||
/**
|
||||
* Base test for Geb testing.
|
||||
*
|
||||
* @author Rob Winch
|
||||
*/
|
||||
class AbstractCasTests extends GebReportingSpec {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
/*
|
||||
* Copyright 2011 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.samples.cas
|
||||
|
||||
import org.apache.commons.httpclient.HttpClient
|
||||
import org.apache.commons.httpclient.methods.GetMethod
|
||||
import org.jasig.cas.client.jaas.CasLoginModule;
|
||||
import org.jasig.cas.client.proxy.Cas20ProxyRetriever
|
||||
import org.springframework.security.samples.cas.pages.*
|
||||
|
||||
import spock.lang.*
|
||||
|
||||
|
||||
/**
|
||||
* Tests authenticating to the CAS Sample application using Proxy Tickets. Geb is used to authenticate the {@link JettyCasService}
|
||||
* to the CAS Server in order to obtain the Ticket Granting Ticket. Afterwards HttpClient is used for accessing the CAS Sample application
|
||||
* using Proxy Tickets obtained using the Proxy Granting Ticket.
|
||||
*
|
||||
* @author Rob Winch
|
||||
*/
|
||||
@Stepwise
|
||||
class CasSampleProxyTests extends AbstractCasTests {
|
||||
HttpClient client = new HttpClient()
|
||||
@Shared String casServerUrl = LoginPage.url.replaceFirst('/login','')
|
||||
@Shared JettyCasService service = new JettyCasService().init(casServerUrl)
|
||||
@Shared Cas20ProxyRetriever retriever = new Cas20ProxyRetriever(casServerUrl,'UTF-8')
|
||||
@Shared String pt
|
||||
|
||||
def cleanupSpec() {
|
||||
service.stop()
|
||||
}
|
||||
|
||||
def 'access secure page succeeds with ROLE_USER'() {
|
||||
setup: 'Obtain a pgt for a user with ROLE_USER'
|
||||
driver.get LoginPage.url+"?service="+service.serviceUrl()
|
||||
at LoginPage
|
||||
login 'scott'
|
||||
when: 'User with ROLE_USER accesses the secure page'
|
||||
def content = getSecured(getBaseUrl()+SecurePage.url).responseBodyAsString
|
||||
then: 'The secure page is returned'
|
||||
content.contains('<h1>Secure Page</h1>')
|
||||
}
|
||||
|
||||
def 'access proxy ticket sample succeeds with ROLE_USER'() {
|
||||
when: 'a proxy ticket is used to create another proxy ticket'
|
||||
def content = getSecured(getBaseUrl()+ProxyTicketSamplePage.url).responseBodyAsString
|
||||
then: 'The proxy ticket sample page is returned'
|
||||
content.contains('<h1>Secure Page using a Proxy Ticket</h1>')
|
||||
}
|
||||
|
||||
def 'access extremely secure page with ROLE_USER is denied'() {
|
||||
when: 'User with ROLE_USER accesses the extremely secure page'
|
||||
GetMethod method = getSecured(getBaseUrl()+ExtremelySecurePage.url)
|
||||
then: 'access is denied'
|
||||
assert method.responseBodyAsString =~ /(?i)403.*?Denied/
|
||||
assert 403 == method.statusCode
|
||||
}
|
||||
|
||||
def 'access secure page with ROLE_SUPERVISOR succeeds'() {
|
||||
setup: 'Obtain pgt for user with ROLE_SUPERVISOR'
|
||||
to LocalLogoutPage
|
||||
casServerLogout.click()
|
||||
driver.get(LoginPage.url+"?service="+service.serviceUrl())
|
||||
at LoginPage
|
||||
login 'rod'
|
||||
when: 'User with ROLE_SUPERVISOR accesses the secure page'
|
||||
def content = getSecured(getBaseUrl()+ExtremelySecurePage.url).responseBodyAsString
|
||||
then: 'The secure page is returned'
|
||||
content.contains('<h1>VERY Secure Page</h1>')
|
||||
}
|
||||
|
||||
def 'access extremely secure page with ROLE_SUPERVISOR reusing pt succeeds (stateless mode works)'() {
|
||||
when: 'User with ROLE_SUPERVISOR accesses extremely secure page with used pt'
|
||||
def content = getSecured(getBaseUrl()+ExtremelySecurePage.url,pt).responseBodyAsString
|
||||
then: 'The extremely secure page is returned'
|
||||
content.contains('<h1>VERY Secure Page</h1>')
|
||||
}
|
||||
|
||||
def 'access secure page with invalid proxy ticket fails'() {
|
||||
when: 'Invalid ticket is used to access secure page'
|
||||
GetMethod method = getSecured(getBaseUrl()+SecurePage.url,'invalidticket')
|
||||
then: 'Authentication fails'
|
||||
method.statusCode == 401
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the result of calling a url with a proxy ticket
|
||||
* @param targetUrl the absolute url to attempt to access
|
||||
* @param pt the proxy ticket to use. Defaults to {@link #getPt(String)} with targetUrl specified for the targetUrl.
|
||||
* @return the GetMethod after calling a url with a specified proxy ticket
|
||||
*/
|
||||
GetMethod getSecured(String targetUrl,String pt=getPt(targetUrl)) {
|
||||
assert pt != null
|
||||
GetMethod method = new GetMethod(targetUrl+"?ticket="+pt)
|
||||
int status = client.executeMethod(method)
|
||||
method
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtains a proxy ticket using the pgt from the {@link #service}.
|
||||
* @param targetService the targetService that the proxy ticket will be valid for
|
||||
* @return a proxy ticket for targetService
|
||||
*/
|
||||
String getPt(String targetService) {
|
||||
assert service.pgt != null
|
||||
pt = retriever.getProxyTicketIdFor(service.pgt, targetService)
|
||||
pt
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,135 @@
|
||||
/*
|
||||
* Copyright 2011 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.samples.cas
|
||||
|
||||
import geb.spock.*
|
||||
|
||||
import org.apache.http.impl.conn.DefaultClientConnectionOperator;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.spockframework.runtime.Sputnik;
|
||||
import org.springframework.security.authentication.DefaultAuthenticationEventPublisher;
|
||||
import org.springframework.security.core.context.ThreadLocalSecurityContextHolderStrategy;
|
||||
import org.springframework.security.samples.cas.pages.*
|
||||
|
||||
import spock.lang.Shared;
|
||||
import spock.lang.Stepwise;
|
||||
|
||||
/**
|
||||
* Tests the CAS sample application using service tickets.
|
||||
*
|
||||
* @author Rob Winch
|
||||
*/
|
||||
@Stepwise
|
||||
class CasSampleTests extends AbstractCasTests {
|
||||
@Shared String casServerLogoutUrl = LoginPage.url.replaceFirst('/login','/logout')
|
||||
|
||||
def 'access home page with unauthenticated user succeeds'() {
|
||||
when: 'Unauthenticated user accesses the Home Page'
|
||||
to HomePage
|
||||
then: 'The home page succeeds'
|
||||
at HomePage
|
||||
}
|
||||
|
||||
def 'access extremely secure page with unauthenitcated user requires login'() {
|
||||
when: 'Unauthenticated user accesses the extremely secure page'
|
||||
via ExtremelySecurePage
|
||||
then: 'The login page is displayed'
|
||||
at LoginPage
|
||||
}
|
||||
|
||||
def 'authenticate attempt with invaid ticket fails'() {
|
||||
when: 'present invalid ticket'
|
||||
go "login/cas?ticket=invalid"
|
||||
then: 'the login failed page is displayed'
|
||||
$("h2").text() == 'Login to CAS failed!'
|
||||
}
|
||||
|
||||
def 'access secure page with unauthenticated user requires login'() {
|
||||
when: 'Unauthenticated user accesses the secure page'
|
||||
via SecurePage
|
||||
then: 'The login page is displayed'
|
||||
at LoginPage
|
||||
}
|
||||
|
||||
def 'saved request is used for secure page'() {
|
||||
when: 'login with ROLE_USER after requesting the secure page'
|
||||
login 'scott'
|
||||
then: 'the secure page is displayed'
|
||||
at SecurePage
|
||||
}
|
||||
|
||||
def 'access proxy ticket sample with ROLE_USER is allowed'() {
|
||||
when: 'user with ROLE_USER requests the proxy ticket sample page'
|
||||
to ProxyTicketSamplePage
|
||||
then: 'the proxy ticket sample page is displayed'
|
||||
at ProxyTicketSamplePage
|
||||
}
|
||||
|
||||
def 'access extremely secure page with ROLE_USER is denied'() {
|
||||
when: 'User with ROLE_USER accesses extremely secure page'
|
||||
via ExtremelySecurePage
|
||||
then: 'the access denied page is displayed'
|
||||
at AccessDeniedPage
|
||||
}
|
||||
|
||||
def 'clicking local logout link displays local logout page'() {
|
||||
setup: 'Navigate to page with logout link'
|
||||
to SecurePage
|
||||
when: 'Local logout link is clicked'
|
||||
navModule.logout.click()
|
||||
then: 'the local logout page is displayed'
|
||||
at LocalLogoutPage
|
||||
}
|
||||
|
||||
def 'clicking cas server logout link successfully performs logout'() {
|
||||
when: 'the cas server logout link is clicked and the secure page is requested'
|
||||
casServerLogout.click()
|
||||
via SecurePage
|
||||
then: 'the login page is displayed'
|
||||
at LoginPage
|
||||
}
|
||||
|
||||
def 'access extremely secure page with ROLE_SUPERVISOR succeeds'() {
|
||||
setup: 'login with ROLE_SUPERVISOR'
|
||||
login 'rod'
|
||||
when: 'access extremely secure page'
|
||||
to ExtremelySecurePage
|
||||
then: 'extremely secure page is displayed'
|
||||
at ExtremelySecurePage
|
||||
}
|
||||
|
||||
def 'after logout extremely secure page requires login'() {
|
||||
when: 'logout and request extremely secure page'
|
||||
navModule.logout.click()
|
||||
casServerLogout.click()
|
||||
via ExtremelySecurePage
|
||||
then: 'login page is displayed'
|
||||
at LoginPage
|
||||
}
|
||||
|
||||
def 'logging out of the cas server successfully logs out of the cas sample application'() {
|
||||
setup: 'login with ROLE_USER'
|
||||
via SecurePage
|
||||
at LoginPage
|
||||
login 'rod'
|
||||
at SecurePage
|
||||
when: 'logout of the CAS Server'
|
||||
go casServerLogoutUrl
|
||||
via SecurePage
|
||||
then: 'user is logged out of the CAS Service'
|
||||
at LoginPage
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
/*
|
||||
* Copyright 2011 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.samples.cas;
|
||||
|
||||
import java.io.IOException
|
||||
|
||||
import javax.servlet.ServletException
|
||||
import javax.servlet.http.HttpServletRequest
|
||||
import javax.servlet.http.HttpServletResponse
|
||||
|
||||
import org.apache.commons.httpclient.HttpClient
|
||||
import org.apache.commons.httpclient.methods.GetMethod;
|
||||
import org.eclipse.jetty.server.Request
|
||||
import org.eclipse.jetty.server.Server
|
||||
import org.eclipse.jetty.server.handler.AbstractHandler
|
||||
import org.eclipse.jetty.server.ssl.SslSelectChannelConnector
|
||||
import org.jasig.cas.client.proxy.ProxyGrantingTicketStorage;
|
||||
import org.jasig.cas.client.proxy.ProxyGrantingTicketStorageImpl;
|
||||
import org.jasig.cas.client.validation.Assertion
|
||||
import org.jasig.cas.client.validation.Cas20ProxyTicketValidator;
|
||||
|
||||
/**
|
||||
* A CAS Service that allows a PGT to be obtained. This is useful for testing use of proxy tickets.
|
||||
*
|
||||
* @author Rob Winch
|
||||
*/
|
||||
class JettyCasService extends Server {
|
||||
private Cas20ProxyTicketValidator validator
|
||||
private int port = availablePort()
|
||||
|
||||
/**
|
||||
* The Proxy Granting Ticket. To initialize pgt, authenticate to the CAS Server with the service parameter
|
||||
* equal to {@link #serviceUrl()}.
|
||||
*/
|
||||
String pgt
|
||||
|
||||
/**
|
||||
* Start the CAS Service which will be available at {@link #serviceUrl()}.
|
||||
*
|
||||
* @param casServerUrl
|
||||
* @return
|
||||
*/
|
||||
def init(String casServerUrl) {
|
||||
ProxyGrantingTicketStorage storage = new ProxyGrantingTicketStorageImpl()
|
||||
validator = new Cas20ProxyTicketValidator(casServerUrl)
|
||||
validator.setAcceptAnyProxy(true)
|
||||
validator.setProxyGrantingTicketStorage(storage)
|
||||
validator.setProxyCallbackUrl(absoluteUrl('callback'))
|
||||
|
||||
String password = System.getProperty('javax.net.ssl.trustStorePassword','password')
|
||||
SslSelectChannelConnector ssl_connector = new SslSelectChannelConnector()
|
||||
ssl_connector.setPort(port)
|
||||
ssl_connector.setKeystore(getTrustStore())
|
||||
ssl_connector.setPassword(password)
|
||||
ssl_connector.setKeyPassword(password)
|
||||
addConnector(ssl_connector)
|
||||
setHandler(new AbstractHandler() {
|
||||
public void handle(String target, Request baseRequest,
|
||||
HttpServletRequest request, HttpServletResponse response)
|
||||
throws IOException, ServletException {
|
||||
def st = request.getParameter('ticket')
|
||||
if(st) {
|
||||
JettyCasService.this.validator.validate(st, JettyCasService.this.serviceUrl())
|
||||
}
|
||||
def pgt = request.getParameter('pgtId')
|
||||
if(pgt) {
|
||||
JettyCasService.this.pgt = pgt
|
||||
}
|
||||
response.setStatus(HttpServletResponse.SC_OK);
|
||||
baseRequest.setHandled(true);
|
||||
}
|
||||
})
|
||||
start()
|
||||
this
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the absolute URL that this CAS service is available at.
|
||||
* @return
|
||||
*/
|
||||
String serviceUrl() {
|
||||
absoluteUrl('service')
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a relative url, will provide an absolute url for this CAS Service.
|
||||
* @param relativeUrl the relative url (i.e. service, callback, etc)
|
||||
* @return
|
||||
*/
|
||||
private String absoluteUrl(String relativeUrl) {
|
||||
"https://localhost:${port}/${relativeUrl}"
|
||||
}
|
||||
|
||||
private static String getTrustStore() {
|
||||
String trustStoreLocation = System.getProperty('javax.net.ssl.trustStore')
|
||||
if(trustStoreLocation == null || !new File(trustStoreLocation).isFile()) {
|
||||
throw new IllegalStateException('Could not find the trust store at path "'+trustStoreLocation+'". Specify the location using the javax.net.ssl.trustStore system property.')
|
||||
}
|
||||
trustStoreLocation
|
||||
}
|
||||
/**
|
||||
* Obtains a random available port (i.e. one that is not in use)
|
||||
* @return
|
||||
*/
|
||||
private static int availablePort() {
|
||||
ServerSocket server = new ServerSocket(0)
|
||||
int port = server.localPort
|
||||
server.close()
|
||||
port
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright 2011 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.samples.cas.modules;
|
||||
|
||||
import geb.*
|
||||
import org.springframework.security.samples.cas.pages.*
|
||||
|
||||
/**
|
||||
* Represents the navigation for the CAS Sample application
|
||||
*
|
||||
* @author Rob Winch
|
||||
*/
|
||||
class NavModule extends Module {
|
||||
static content = {
|
||||
home(to: HomePage) { $("a", text: "Home") }
|
||||
logout(to: LocalLogoutPage) { $("a", text: "Logout") }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright 2011 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.samples.cas.pages;
|
||||
|
||||
import geb.*
|
||||
|
||||
/**
|
||||
* Represents the access denied page
|
||||
*
|
||||
* @author Rob Winch
|
||||
*/
|
||||
class AccessDeniedPage extends Page {
|
||||
static at = { $("*",text: iContains(~/.*?403.*/)) }
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright 2011 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.samples.cas.pages;
|
||||
|
||||
import geb.*
|
||||
import org.springframework.security.samples.cas.modules.*
|
||||
|
||||
/**
|
||||
* Represents the extremely secure page of the CAS Sample application.
|
||||
*
|
||||
* @author Rob Winch
|
||||
*/
|
||||
class ExtremelySecurePage extends Page {
|
||||
static url = "secure/extreme/"
|
||||
static at = { assert $('h1').text() == 'VERY Secure Page'; true; }
|
||||
static content = {
|
||||
navModule { module NavModule }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright 2011 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.samples.cas.pages
|
||||
|
||||
import geb.*
|
||||
|
||||
/**
|
||||
* Represents the Home page of the CAS sample application
|
||||
*
|
||||
* @author Rob Winch
|
||||
*/
|
||||
class HomePage extends Page {
|
||||
static at = { assert $('h1').text() == 'Home Page'; true}
|
||||
static url = ''
|
||||
static content = {
|
||||
securePage { $('a',text: 'Secure page') }
|
||||
extremelySecurePage { $('a',text: 'Extremely secure page') }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright 2011 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.samples.cas.pages;
|
||||
|
||||
import geb.*
|
||||
|
||||
|
||||
/**
|
||||
* This represents the local logout page. This page is where the user is logged out of the CAS Sample application, but
|
||||
* since the user is still logged into the CAS Server accessing a protected page within the CAS Sample application would result
|
||||
* in SSO occurring again. To fully logout, the user should click the cas server logout url which logs out of the cas server and performs
|
||||
* single logout on the other services.
|
||||
*
|
||||
* @author Rob Winch
|
||||
*/
|
||||
class LocalLogoutPage extends Page {
|
||||
static url = 'cas-logout.jsp'
|
||||
static at = { assert driver.currentUrl.endsWith(url); true }
|
||||
static content = {
|
||||
casServerLogout { $('a',text: 'Logout of CAS') }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright 2011 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.samples.cas.pages;
|
||||
|
||||
import geb.*
|
||||
|
||||
/**
|
||||
* The CAS login page.
|
||||
*
|
||||
* @author Rob Winch
|
||||
*/
|
||||
class LoginPage extends Page {
|
||||
static url = loginUrl()
|
||||
static at = { assert driver.currentUrl.startsWith(loginUrl()); true}
|
||||
static content = {
|
||||
login(required:false) { user, password=user ->
|
||||
loginForm.username = user
|
||||
loginForm.password = password
|
||||
submit.click()
|
||||
}
|
||||
loginForm { $('#login') }
|
||||
submit { $('input', type: 'submit') }
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the login page url which might change based upon the system properties. This is to support using a randomly available port for CI.
|
||||
* @return
|
||||
*/
|
||||
private static String loginUrl() {
|
||||
def host = System.getProperty('cas.server.host', 'localhost:9443')
|
||||
"https://${host}/cas/login"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright 2011 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.samples.cas.pages;
|
||||
|
||||
import geb.*
|
||||
import org.springframework.security.samples.cas.modules.*
|
||||
|
||||
|
||||
/**
|
||||
* Represents the proxy ticket sample page within the CAS Sample application.
|
||||
*
|
||||
* @author Rob Winch
|
||||
*/
|
||||
class ProxyTicketSamplePage extends Page {
|
||||
static url = "secure/ptSample"
|
||||
static at = { assert $('h1').text() == 'Secure Page using a Proxy Ticket'; true}
|
||||
static content = {
|
||||
navModule { module NavModule }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright 2011 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.samples.cas.pages;
|
||||
|
||||
import geb.*
|
||||
import org.springframework.security.samples.cas.modules.*
|
||||
|
||||
|
||||
/**
|
||||
* Represents the secure page within the CAS Sample application.
|
||||
*
|
||||
* @author Rob Winch
|
||||
*/
|
||||
class SecurePage extends Page {
|
||||
static url = "secure/"
|
||||
static at = { assert $('h1').text() == 'Secure Page'; true}
|
||||
static content = {
|
||||
navModule { module NavModule }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<configuration>
|
||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<root level="error">
|
||||
<appender-ref ref="STDOUT" />
|
||||
</root>
|
||||
</configuration>
|
||||
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
* Copyright 2011-2016 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.samples.cas.web;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.net.URLEncoder;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.jasig.cas.client.util.CommonUtils;
|
||||
import org.springframework.security.cas.authentication.CasAuthenticationToken;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* {@link ProxyTicketSampleServlet} demonstrates how to obtain a proxy ticket and then use
|
||||
* it to make a remote call. To learn how proxy tickets work, see the <a
|
||||
* href="https://wiki.jasig.org/display/CAS/Proxy+CAS+Walkthrough">Proxy CAS
|
||||
* Walkthrough</a>
|
||||
* </p>
|
||||
*
|
||||
* @author Rob Winch
|
||||
*/
|
||||
public final class ProxyTicketSampleServlet extends HttpServlet {
|
||||
/**
|
||||
* This is the URL that will be called and authenticate a proxy ticket.
|
||||
*/
|
||||
private String targetUrl;
|
||||
|
||||
@Override
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
// NOTE: The CasAuthenticationToken can also be obtained using
|
||||
// SecurityContextHolder.getContext().getAuthentication()
|
||||
final CasAuthenticationToken token = (CasAuthenticationToken) request
|
||||
.getUserPrincipal();
|
||||
// proxyTicket could be reused to make calls to to the CAS service even if the
|
||||
// target url differs
|
||||
final String proxyTicket = token.getAssertion().getPrincipal()
|
||||
.getProxyTicketFor(targetUrl);
|
||||
|
||||
// Make a remote call to ourself. This is a bit silly, but it works well to
|
||||
// demonstrate how to use proxy tickets.
|
||||
final String serviceUrl = targetUrl + "?ticket="
|
||||
+ URLEncoder.encode(proxyTicket, "UTF-8");
|
||||
String proxyResponse = CommonUtils.getResponseFromServer(serviceUrl, "UTF-8");
|
||||
|
||||
// modify the response and write it out to inform the user that it was obtained
|
||||
// using a proxy ticket.
|
||||
proxyResponse = proxyResponse.replaceFirst("Secure Page",
|
||||
"Secure Page using a Proxy Ticket");
|
||||
proxyResponse = proxyResponse.replaceFirst("<p>", "<p>This page is rendered by "
|
||||
+ getClass().getSimpleName()
|
||||
+ " by making a remote call to the Secure Page using a proxy ticket ("
|
||||
+ proxyTicket + ") and inserts this message. ");
|
||||
final PrintWriter writer = response.getWriter();
|
||||
writer.write(proxyResponse);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the target URL. It allows for the host to change based upon the
|
||||
* "cas.service.host" system property. If the property is not set, the default is
|
||||
* "localhost:8443".
|
||||
*/
|
||||
@Override
|
||||
public void init() throws ServletException {
|
||||
super.init();
|
||||
String casServiceHost = System.getProperty("cas.service.host", "localhost:8443");
|
||||
targetUrl = "https://" + casServiceHost + "/cas-sample/secure/";
|
||||
}
|
||||
|
||||
private static final long serialVersionUID = -7720161771819727775L;
|
||||
}
|
||||
8
samples/xml/cas/cassample/src/main/webapp/403.jsp
Normal file
8
samples/xml/cas/cassample/src/main/webapp/403.jsp
Normal file
@@ -0,0 +1,8 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>403 - Access Denied</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>403 - Access Denied</h1>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,124 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<b:beans xmlns:b="http://www.springframework.org/schema/beans"
|
||||
xmlns="http://www.springframework.org/schema/security"
|
||||
xmlns:p="http://www.springframework.org/schema/p"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xmlns:util="http://www.springframework.org/schema/util"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security.xsd
|
||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
|
||||
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd
|
||||
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
|
||||
|
||||
<http entry-point-ref="casEntryPoint">
|
||||
<intercept-url pattern="/" access="permitAll"/>
|
||||
<intercept-url pattern="/index.jsp" access="permitAll"/>
|
||||
<intercept-url pattern="/cas-logout.jsp" access="permitAll"/>
|
||||
<intercept-url pattern="/casfailed.jsp" access="permitAll"/>
|
||||
|
||||
<intercept-url pattern="/secure/extreme/**"
|
||||
access="hasRole('ROLE_SUPERVISOR')" />
|
||||
<intercept-url pattern="/secure/**" access="hasRole('ROLE_USER')" />
|
||||
<intercept-url pattern="/**" access="hasRole('ROLE_USER')" />
|
||||
<custom-filter ref="requestSingleLogoutFilter" before="LOGOUT_FILTER"/>
|
||||
<custom-filter ref="singleLogoutFilter" before="CAS_FILTER"/>
|
||||
<custom-filter ref="casFilter" position="CAS_FILTER" />
|
||||
<logout logout-success-url="/cas-logout.jsp"/>
|
||||
<csrf disabled="true"/>
|
||||
</http>
|
||||
|
||||
<authentication-manager alias="authManager">
|
||||
<authentication-provider ref="casAuthProvider" />
|
||||
</authentication-manager>
|
||||
|
||||
<user-service id="userService">
|
||||
<user name="rod" password="rod" authorities="ROLE_SUPERVISOR,ROLE_USER" />
|
||||
<user name="dianne" password="dianne" authorities="ROLE_USER" />
|
||||
<user name="scott" password="scott" authorities="ROLE_USER" />
|
||||
</user-service>
|
||||
|
||||
<!-- This filter handles a Single Logout Request from the CAS Server -->
|
||||
<b:bean id="singleLogoutFilter" class="org.jasig.cas.client.session.SingleSignOutFilter"/>
|
||||
<!-- This filter redirects to the CAS Server to signal Single Logout should be performed -->
|
||||
<b:bean id="requestSingleLogoutFilter" class="org.springframework.security.web.authentication.logout.LogoutFilter"
|
||||
p:filterProcessesUrl="/logout/cas">
|
||||
<b:constructor-arg value="https://${cas.server.host}/cas/logout"/>
|
||||
<b:constructor-arg>
|
||||
<b:bean class="org.springframework.security.web.authentication.logout.SecurityContextLogoutHandler"/>
|
||||
</b:constructor-arg>
|
||||
</b:bean>
|
||||
|
||||
<b:bean id="serviceProperties"
|
||||
class="org.springframework.security.cas.ServiceProperties"
|
||||
p:service="https://${cas.service.host}/cas-sample/login/cas"
|
||||
p:authenticateAllArtifacts="true"/>
|
||||
<b:bean id="casEntryPoint"
|
||||
class="org.springframework.security.cas.web.CasAuthenticationEntryPoint"
|
||||
p:serviceProperties-ref="serviceProperties" p:loginUrl="https://${cas.server.host}/cas/login" />
|
||||
<b:bean id="casFilter"
|
||||
class="org.springframework.security.cas.web.CasAuthenticationFilter"
|
||||
p:authenticationManager-ref="authManager"
|
||||
p:serviceProperties-ref="serviceProperties"
|
||||
p:proxyGrantingTicketStorage-ref="pgtStorage"
|
||||
p:proxyReceptorUrl="/login/cas/proxyreceptor">
|
||||
<b:property name="authenticationDetailsSource">
|
||||
<b:bean class="org.springframework.security.cas.web.authentication.ServiceAuthenticationDetailsSource">
|
||||
<b:constructor-arg ref="serviceProperties"/>
|
||||
</b:bean>
|
||||
</b:property>
|
||||
<b:property name="authenticationFailureHandler">
|
||||
<b:bean class="org.springframework.security.web.authentication.SimpleUrlAuthenticationFailureHandler"
|
||||
p:defaultFailureUrl="/casfailed.jsp"/>
|
||||
</b:property>
|
||||
</b:bean>
|
||||
<!--
|
||||
NOTE: In a real application you should not use an in memory implementation. You will also want
|
||||
to ensure to clean up expired tickets by calling ProxyGrantingTicketStorage.cleanup()
|
||||
-->
|
||||
<b:bean id="pgtStorage" class="org.jasig.cas.client.proxy.ProxyGrantingTicketStorageImpl"/>
|
||||
<b:bean id="casAuthProvider" class="org.springframework.security.cas.authentication.CasAuthenticationProvider"
|
||||
p:serviceProperties-ref="serviceProperties"
|
||||
p:key="casAuthProviderKey">
|
||||
<b:property name="authenticationUserDetailsService">
|
||||
<b:bean
|
||||
class="org.springframework.security.core.userdetails.UserDetailsByNameServiceWrapper">
|
||||
<b:constructor-arg ref="userService" />
|
||||
</b:bean>
|
||||
</b:property>
|
||||
<b:property name="ticketValidator">
|
||||
<b:bean
|
||||
class="org.jasig.cas.client.validation.Cas20ProxyTicketValidator"
|
||||
p:acceptAnyProxy="true"
|
||||
p:proxyCallbackUrl="https://${cas.service.host}/cas-sample/login/cas/proxyreceptor"
|
||||
p:proxyGrantingTicketStorage-ref="pgtStorage">
|
||||
<b:constructor-arg value="https://${cas.server.host}/cas" />
|
||||
</b:bean>
|
||||
</b:property>
|
||||
<b:property name="statelessTicketCache">
|
||||
<b:bean class="org.springframework.security.cas.authentication.EhCacheBasedTicketCache">
|
||||
<b:property name="cache">
|
||||
<b:bean id="ehcache" class="net.sf.ehcache.Cache"
|
||||
init-method="initialise"
|
||||
destroy-method="dispose">
|
||||
<b:constructor-arg value="casTickets"/>
|
||||
<b:constructor-arg value="50"/>
|
||||
<b:constructor-arg value="true"/>
|
||||
<b:constructor-arg value="false"/>
|
||||
<b:constructor-arg value="3600"/>
|
||||
<b:constructor-arg value="900"/>
|
||||
<b:property name="cacheManager">
|
||||
<b:bean class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean"/>
|
||||
</b:property>
|
||||
</b:bean>
|
||||
</b:property>
|
||||
</b:bean>
|
||||
</b:property>
|
||||
</b:bean>
|
||||
|
||||
<!-- Configuration for the environment can be overriden by system properties -->
|
||||
<context:property-placeholder system-properties-mode="OVERRIDE" properties-ref="environment"/>
|
||||
<util:properties id="environment">
|
||||
<b:prop key="cas.service.host">localhost:8443</b:prop>
|
||||
<b:prop key="cas.server.host">localhost:9443</b:prop>
|
||||
</util:properties>
|
||||
</b:beans>
|
||||
85
samples/xml/cas/cassample/src/main/webapp/WEB-INF/web.xml
Normal file
85
samples/xml/cas/cassample/src/main/webapp/WEB-INF/web.xml
Normal file
@@ -0,0 +1,85 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
- Tutorial web application
|
||||
-
|
||||
-->
|
||||
|
||||
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
|
||||
<display-name>Spring Security CAS Demo Application</display-name>
|
||||
|
||||
<!--
|
||||
- Location of the XML file that defines the root application context
|
||||
- Applied by ContextLoaderListener.
|
||||
-->
|
||||
<context-param>
|
||||
<param-name>contextConfigLocation</param-name>
|
||||
<param-value>
|
||||
/WEB-INF/applicationContext-security.xml
|
||||
</param-value>
|
||||
</context-param>
|
||||
|
||||
<context-param>
|
||||
<param-name>webAppRootKey</param-name>
|
||||
<param-value>cas.root</param-value>
|
||||
</context-param>
|
||||
|
||||
<!--
|
||||
Include the character encoding Filter as per JASIG recommenation when doing Single Sign Out
|
||||
https://wiki.jasig.org/display/CASC/Configuring+Single+Sign+Out
|
||||
-->
|
||||
<filter>
|
||||
<filter-name>characterEncodingFilter</filter-name>
|
||||
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
|
||||
<init-param>
|
||||
<param-name>encoding</param-name>
|
||||
<param-value>UTF-8</param-value>
|
||||
</init-param>
|
||||
</filter>
|
||||
<filter>
|
||||
<filter-name>springSecurityFilterChain</filter-name>
|
||||
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
|
||||
</filter>
|
||||
|
||||
<filter-mapping>
|
||||
<filter-name>characterEncodingFilter</filter-name>
|
||||
<url-pattern>/*</url-pattern>
|
||||
</filter-mapping>
|
||||
<filter-mapping>
|
||||
<filter-name>springSecurityFilterChain</filter-name>
|
||||
<url-pattern>/*</url-pattern>
|
||||
</filter-mapping>
|
||||
|
||||
<!--
|
||||
Included to support Single Logout. Note that the SingleSignOutFilter is included in the
|
||||
springSecurityFilterChain. However, it could also be placed as the first filter-mapping
|
||||
in the web.xml
|
||||
-->
|
||||
<listener>
|
||||
<listener-class>org.jasig.cas.client.session.SingleSignOutHttpSessionListener</listener-class>
|
||||
</listener>
|
||||
|
||||
<!--
|
||||
- Loads the root application context of this web app at startup.
|
||||
- The application context is then available via
|
||||
- WebApplicationContextUtils.getWebApplicationContext(servletContext).
|
||||
-->
|
||||
<listener>
|
||||
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
|
||||
</listener>
|
||||
|
||||
<servlet>
|
||||
<servlet-name>ptSampleServlet</servlet-name>
|
||||
<servlet-class>org.springframework.security.samples.cas.web.ProxyTicketSampleServlet</servlet-class>
|
||||
</servlet>
|
||||
|
||||
<servlet-mapping>
|
||||
<servlet-name>ptSampleServlet</servlet-name>
|
||||
<url-pattern>/secure/ptSample</url-pattern>
|
||||
</servlet-mapping>
|
||||
<error-page>
|
||||
<error-code>403</error-code>
|
||||
<location>/403.jsp</location>
|
||||
</error-page>
|
||||
</web-app>
|
||||
15
samples/xml/cas/cassample/src/main/webapp/cas-logout.jsp
Normal file
15
samples/xml/cas/cassample/src/main/webapp/cas-logout.jsp
Normal file
@@ -0,0 +1,15 @@
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>Single-sign out?</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h2>Do you want to log out of CAS?</h2>
|
||||
|
||||
<p>You have logged out of this application, but may still have an active single-sign on session with CAS.</p>
|
||||
|
||||
<p><a href="logout/cas">Logout of CAS</a></p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
17
samples/xml/cas/cassample/src/main/webapp/casfailed.jsp
Normal file
17
samples/xml/cas/cassample/src/main/webapp/casfailed.jsp
Normal file
@@ -0,0 +1,17 @@
|
||||
<%@ page import="org.springframework.security.core.AuthenticationException" %>
|
||||
<%@ page import="org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter" %>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>Login to CAS failed!</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h2>Login to CAS failed!</h2>
|
||||
|
||||
<font color="red">
|
||||
Your CAS credentials were rejected.<br/>
|
||||
</font>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
12
samples/xml/cas/cassample/src/main/webapp/index.jsp
Normal file
12
samples/xml/cas/cassample/src/main/webapp/index.jsp
Normal file
@@ -0,0 +1,12 @@
|
||||
<html>
|
||||
<body>
|
||||
<h1>Home Page</h1>
|
||||
<p>Anyone can view this page.</p>
|
||||
|
||||
<p>Your principal object is....: <%= request.getUserPrincipal() %></p>
|
||||
|
||||
<p><a href="secure/index.jsp">Secure page</a></p>
|
||||
<p><a href="secure/ptSample">Proxy Ticket Sample page</a></p>
|
||||
<p><a href="secure/extreme/index.jsp">Extremely secure page</a></p>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,12 @@
|
||||
<html>
|
||||
<body>
|
||||
<h1>VERY Secure Page</h1>
|
||||
This is a protected page. You can only see me if you are a supervisor.
|
||||
|
||||
<p><a href="../../">Home</a>
|
||||
<p><a href="../../secure/index.jsp">Secure page</a></p>
|
||||
<p><a href="../../secure/ptSample">Proxy Ticket Sample page</a></p>
|
||||
<p><a href="../../logout">Logout</a>
|
||||
<
|
||||
</body>
|
||||
</html>
|
||||
15
samples/xml/cas/cassample/src/main/webapp/secure/index.jsp
Normal file
15
samples/xml/cas/cassample/src/main/webapp/secure/index.jsp
Normal file
@@ -0,0 +1,15 @@
|
||||
<html>
|
||||
<body>
|
||||
<h1>Secure Page</h1>
|
||||
<p>This is a protected page. You can get to me if you've been remembered,
|
||||
or if you've authenticated this session.</p>
|
||||
|
||||
<%if (request.isUserInRole("ROLE_SUPERVISOR")) { %>
|
||||
<p>You are a supervisor! You can therefore see the <a href="extreme/index.jsp">extremely secure page</a>.</p>
|
||||
<% } %>
|
||||
|
||||
<p><a href="../">Home</a>
|
||||
<p><a href="ptSample">Proxy Ticket Sample page</a></p>
|
||||
<p><a href="../logout">Logout</a>
|
||||
</body>
|
||||
</html>
|
||||
63
samples/xml/cas/casserver/casserver.gradle
Normal file
63
samples/xml/cas/casserver/casserver.gradle
Normal file
@@ -0,0 +1,63 @@
|
||||
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:4.0.0@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)
|
||||
System.setProperty('java.naming.factory.url.pkgs','org.mortbay.naming')
|
||||
System.setProperty('java.naming.factory.initial','org.mortbay.naming.InitialContextFactory')
|
||||
}
|
||||
}
|
||||
116
samples/xml/cas/casserver/pom.xml
Normal file
116
samples/xml/cas/casserver/pom.xml
Normal file
@@ -0,0 +1,116 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.springframework.security</groupId>
|
||||
<artifactId>spring-security-samples-xml-casserver</artifactId>
|
||||
<version>4.1.0.BUILD-SNAPSHOT</version>
|
||||
<packaging>war</packaging>
|
||||
<name>spring-security-samples-xml-casserver</name>
|
||||
<description>spring-security-samples-xml-casserver</description>
|
||||
<url>http://spring.io/spring-security</url>
|
||||
<organization>
|
||||
<name>spring.io</name>
|
||||
<url>http://spring.io/</url>
|
||||
</organization>
|
||||
<licenses>
|
||||
<license>
|
||||
<name>The Apache Software License, Version 2.0</name>
|
||||
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
|
||||
<distribution>repo</distribution>
|
||||
</license>
|
||||
</licenses>
|
||||
<developers>
|
||||
<developer>
|
||||
<id>rwinch</id>
|
||||
<name>Rob Winch</name>
|
||||
<email>rwinch@gopivotal.com</email>
|
||||
</developer>
|
||||
</developers>
|
||||
<scm>
|
||||
<connection>scm:git:git://github.com/spring-projects/spring-security</connection>
|
||||
<developerConnection>scm:git:git://github.com/spring-projects/spring-security</developerConnection>
|
||||
<url>https://github.com/spring-projects/spring-security</url>
|
||||
</scm>
|
||||
<properties>
|
||||
<m2eclipse.wtp.contextRoot>/spring-security-samples-xml-casserver</m2eclipse.wtp.contextRoot>
|
||||
</properties>
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-framework-bom</artifactId>
|
||||
<version>4.2.5.RELEASE</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>commons-logging</groupId>
|
||||
<artifactId>commons-logging</artifactId>
|
||||
<version>1.2</version>
|
||||
<scope>compile</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
<artifactId>logback-classic</artifactId>
|
||||
<version>1.1.2</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.12</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.assertj</groupId>
|
||||
<artifactId>assertj-core</artifactId>
|
||||
<version>2.2.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<version>1.10.19</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>jcl-over-slf4j</artifactId>
|
||||
<version>1.7.7</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spring-snapshot</id>
|
||||
<url>https://repo.spring.io/snapshot</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>1.7</source>
|
||||
<target>1.7</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-war-plugin</artifactId>
|
||||
<version>2.3</version>
|
||||
<configuration>
|
||||
<failOnMissingWebXml>false</failOnMissingWebXml>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
|
||||
|
||||
<log4j:configuration debug="false" xmlns:log4j="http://jakarta.apache.org/log4j/">
|
||||
<appender name="console" class="org.apache.log4j.ConsoleAppender">
|
||||
<layout class="org.apache.log4j.PatternLayout">
|
||||
<param name="ConversionPattern" value="%d %p [%c] - <%m>%n"/>
|
||||
</layout>
|
||||
</appender>
|
||||
<logger name="org.jasig" additivity="true">
|
||||
<level value="@logLevel@" />
|
||||
</logger>
|
||||
<root>
|
||||
<level value="ERROR"/>
|
||||
<appender-ref ref="console"/>
|
||||
</root>
|
||||
</log4j:configuration>
|
||||
@@ -0,0 +1,196 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
|
||||
Licensed to Jasig under one or more contributor license
|
||||
agreements. See the NOTICE file distributed with this work
|
||||
for additional information regarding copyright ownership.
|
||||
Jasig licenses this file to you 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 the following location:
|
||||
|
||||
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.
|
||||
|
||||
-->
|
||||
<!--
|
||||
| deployerConfigContext.xml centralizes into one file some of the declarative configuration that
|
||||
| all CAS deployers will need to modify.
|
||||
|
|
||||
| This file declares some of the Spring-managed JavaBeans that make up a CAS deployment.
|
||||
| The beans declared in this file are instantiated at context initialization time by the Spring
|
||||
| ContextLoaderListener declared in web.xml. It finds this file because this
|
||||
| file is among those declared in the context parameter "contextConfigLocation".
|
||||
|
|
||||
| By far the most common change you will need to make in this file is to change the last bean
|
||||
| declaration to replace the default authentication handler with
|
||||
| one implementing your approach for authenticating usernames and passwords.
|
||||
+-->
|
||||
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:p="http://www.springframework.org/schema/p"
|
||||
xmlns:c="http://www.springframework.org/schema/c"
|
||||
xmlns:tx="http://www.springframework.org/schema/tx"
|
||||
xmlns:util="http://www.springframework.org/schema/util"
|
||||
xmlns:sec="http://www.springframework.org/schema/security"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
|
||||
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd
|
||||
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.2.xsd
|
||||
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">
|
||||
|
||||
<!--
|
||||
| The authentication manager defines security policy for authentication by specifying at a minimum
|
||||
| the authentication handlers that will be used to authenticate credential. While the AuthenticationManager
|
||||
| interface supports plugging in another implementation, the default PolicyBasedAuthenticationManager should
|
||||
| be sufficient in most cases.
|
||||
+-->
|
||||
<bean id="authenticationManager" class="org.jasig.cas.authentication.PolicyBasedAuthenticationManager">
|
||||
<constructor-arg>
|
||||
<map>
|
||||
<!--
|
||||
| IMPORTANT
|
||||
| Every handler requires a unique name.
|
||||
| If more than one instance of the same handler class is configured, you must explicitly
|
||||
| set its name to something other than its default name (typically the simple class name).
|
||||
-->
|
||||
<entry key-ref="proxyAuthenticationHandler" value-ref="proxyPrincipalResolver" />
|
||||
<entry key-ref="primaryAuthenticationHandler" value-ref="primaryPrincipalResolver" />
|
||||
</map>
|
||||
</constructor-arg>
|
||||
|
||||
<!-- Uncomment the metadata populator to allow clearpass to capture and cache the password
|
||||
This switch effectively will turn on clearpass.
|
||||
<property name="authenticationMetaDataPopulators">
|
||||
<util:list>
|
||||
<bean class="org.jasig.cas.extension.clearpass.CacheCredentialsMetaDataPopulator"
|
||||
c:credentialCache-ref="encryptedMap" />
|
||||
</util:list>
|
||||
</property>
|
||||
-->
|
||||
|
||||
<!--
|
||||
| Defines the security policy around authentication. Some alternative policies that ship with CAS:
|
||||
|
|
||||
| * NotPreventedAuthenticationPolicy - all credential must either pass or fail authentication
|
||||
| * AllAuthenticationPolicy - all presented credential must be authenticated successfully
|
||||
| * RequiredHandlerAuthenticationPolicy - specifies a handler that must authenticate its credential to pass
|
||||
-->
|
||||
<property name="authenticationPolicy">
|
||||
<bean class="org.jasig.cas.authentication.AnyAuthenticationPolicy" />
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<!-- Required for proxy ticket mechanism. -->
|
||||
<bean id="proxyAuthenticationHandler"
|
||||
class="org.jasig.cas.authentication.handler.support.HttpBasedServiceCredentialsAuthenticationHandler"
|
||||
p:httpClient-ref="httpClient" />
|
||||
|
||||
<!--
|
||||
| TODO: Replace this component with one suitable for your enviroment.
|
||||
|
|
||||
| This component provides authentication for the kind of credential used in your environment. In most cases
|
||||
| credential is a username/password pair that lives in a system of record like an LDAP directory.
|
||||
| The most common authentication handler beans:
|
||||
|
|
||||
| * org.jasig.cas.authentication.LdapAuthenticationHandler
|
||||
| * org.jasig.cas.adaptors.jdbc.QueryDatabaseAuthenticationHandler
|
||||
| * org.jasig.cas.adaptors.x509.authentication.handler.support.X509CredentialsAuthenticationHandler
|
||||
| * org.jasig.cas.support.spnego.authentication.handler.support.JCIFSSpnegoAuthenticationHandler
|
||||
-->
|
||||
<bean id="primaryAuthenticationHandler"
|
||||
class="org.jasig.cas.authentication.AcceptUsersAuthenticationHandler">
|
||||
<property name="users">
|
||||
<map>
|
||||
<entry key="scott" value="scott"/>
|
||||
<entry key="rod" value="rod"/>
|
||||
<entry key="dianne" value="dianne"/>
|
||||
</map>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<!-- Required for proxy ticket mechanism -->
|
||||
<bean id="proxyPrincipalResolver"
|
||||
class="org.jasig.cas.authentication.principal.BasicPrincipalResolver" />
|
||||
|
||||
<!--
|
||||
| Resolves a principal from a credential using an attribute repository that is configured to resolve
|
||||
| against a deployer-specific store (e.g. LDAP).
|
||||
-->
|
||||
<bean id="primaryPrincipalResolver"
|
||||
class="org.jasig.cas.authentication.principal.PersonDirectoryPrincipalResolver" >
|
||||
<property name="attributeRepository" ref="attributeRepository" />
|
||||
</bean>
|
||||
|
||||
<!--
|
||||
Bean that defines the attributes that a service may return. This example uses the Stub/Mock version. A real implementation
|
||||
may go against a database or LDAP server. The id should remain "attributeRepository" though.
|
||||
+-->
|
||||
<bean id="attributeRepository" class="org.jasig.services.persondir.support.StubPersonAttributeDao"
|
||||
p:backingMap-ref="attrRepoBackingMap" />
|
||||
|
||||
<util:map id="attrRepoBackingMap">
|
||||
<entry key="uid" value="uid" />
|
||||
<entry key="eduPersonAffiliation" value="eduPersonAffiliation" />
|
||||
<entry key="groupMembership" value="groupMembership" />
|
||||
</util:map>
|
||||
|
||||
<!--
|
||||
Sample, in-memory data store for the ServiceRegistry. A real implementation
|
||||
would probably want to replace this with the JPA-backed ServiceRegistry DAO
|
||||
The name of this bean should remain "serviceRegistryDao".
|
||||
+-->
|
||||
<bean id="serviceRegistryDao" class="org.jasig.cas.services.InMemoryServiceRegistryDaoImpl"
|
||||
p:registeredServices-ref="registeredServicesList" />
|
||||
|
||||
<util:list id="registeredServicesList">
|
||||
<bean class="org.jasig.cas.services.RegexRegisteredService"
|
||||
p:id="0" p:name="HTTP and IMAP" p:description="Allows HTTP(S) and IMAP(S) protocols"
|
||||
p:serviceId="^(https?|imaps?)://.*" p:evaluationOrder="10000001"
|
||||
p:allowedToProxy="true"/>
|
||||
<!--
|
||||
Use the following definition instead of the above to further restrict access
|
||||
to services within your domain (including sub domains).
|
||||
Note that example.com must be replaced with the domain you wish to permit.
|
||||
This example also demonstrates the configuration of an attribute filter
|
||||
that only allows for attributes whose length is 3.
|
||||
-->
|
||||
<!--
|
||||
<bean class="org.jasig.cas.services.RegexRegisteredService">
|
||||
<property name="id" value="1" />
|
||||
<property name="name" value="HTTP and IMAP on example.com" />
|
||||
<property name="description" value="Allows HTTP(S) and IMAP(S) protocols on example.com" />
|
||||
<property name="serviceId" value="^(https?|imaps?)://([A-Za-z0-9_-]+\.)*example\.com/.*" />
|
||||
<property name="evaluationOrder" value="0" />
|
||||
<property name="attributeFilter">
|
||||
<bean class="org.jasig.cas.services.support.RegisteredServiceRegexAttributeFilter" c:regex="^\w{3}$" />
|
||||
</property>
|
||||
</bean>
|
||||
-->
|
||||
</util:list>
|
||||
|
||||
<bean id="auditTrailManager" class="com.github.inspektr.audit.support.Slf4jLoggingAuditTrailManager" />
|
||||
|
||||
<bean id="healthCheckMonitor" class="org.jasig.cas.monitor.HealthCheckMonitor" p:monitors-ref="monitorsList" />
|
||||
|
||||
<util:list id="monitorsList">
|
||||
<bean class="org.jasig.cas.monitor.MemoryMonitor" p:freeMemoryWarnThreshold="10" />
|
||||
<!--
|
||||
NOTE
|
||||
The following ticket registries support SessionMonitor:
|
||||
* DefaultTicketRegistry
|
||||
* JpaTicketRegistry
|
||||
Remove this monitor if you use an unsupported registry.
|
||||
-->
|
||||
<bean class="org.jasig.cas.monitor.SessionMonitor"
|
||||
p:ticketRegistry-ref="ticketRegistry"
|
||||
p:serviceTicketCountWarnThreshold="5000"
|
||||
p:sessionCountWarnThreshold="100000" />
|
||||
</util:list>
|
||||
</beans>
|
||||
@@ -0,0 +1,149 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
|
||||
Licensed to Jasig under one or more contributor license
|
||||
agreements. See the NOTICE file distributed with this work
|
||||
for additional information regarding copyright ownership.
|
||||
Jasig licenses this file to you 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 the following location:
|
||||
|
||||
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.
|
||||
|
||||
-->
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:p="http://www.springframework.org/schema/p"
|
||||
xmlns:c="http://www.springframework.org/schema/c"
|
||||
xmlns:util="http://www.springframework.org/schema/util"
|
||||
xmlns:aop="http://www.springframework.org/schema/aop"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
|
||||
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">
|
||||
<description>
|
||||
This is the main Spring configuration file with some of the main "core" classes defined. You shouldn't really
|
||||
modify this unless you
|
||||
know what you're doing!
|
||||
</description>
|
||||
|
||||
<!--
|
||||
Including this aspectj-autoproxy element will cause spring to automatically
|
||||
create proxies around any beans defined in this file that match the pointcuts
|
||||
of any aspects defined in this file.
|
||||
-->
|
||||
<aop:aspectj-autoproxy/>
|
||||
|
||||
<!--
|
||||
Declare the TimingAspect that we want to weave into the other beans
|
||||
defined in this config file.
|
||||
-->
|
||||
<bean id="timingAspect" class="org.perf4j.log4j.aop.TimingAspect"/>
|
||||
|
||||
|
||||
<!--
|
||||
Message source for this context, loaded from localized "messages_xx" files.]
|
||||
|
||||
Disable the fallback mechanism to the system/JVM locale. By turning off this behavior, CAS
|
||||
will be able to revert back to the default language bundle that is "messages.properties"
|
||||
and will not rely on the JVM default locale which introduces the side effect of rendering
|
||||
the UI in the JVM locale by default.
|
||||
|
||||
Also, explicitly set the default encoding to be UTF-8 when parsing message bundles.
|
||||
The default, if not set, is none which forces ISO-8859-1 of java.util.ResourceBundle.
|
||||
-->
|
||||
<bean id="messageSource" class="org.jasig.cas.web.view.CasReloadableMessageBundle"
|
||||
p:basenames-ref="basenames" p:fallbackToSystemLocale="false" p:defaultEncoding="UTF-8"
|
||||
p:cacheSeconds="180" p:useCodeAsDefaultMessage="true" />
|
||||
|
||||
<util:list id="basenames">
|
||||
<value>classpath:custom_messages</value>
|
||||
<value>classpath:messages</value>
|
||||
</util:list>
|
||||
|
||||
<bean id="servicesManager" class="org.jasig.cas.services.DefaultServicesManagerImpl"
|
||||
c:serviceRegistryDao-ref="serviceRegistryDao" />
|
||||
|
||||
<!--
|
||||
Job to periodically reload services from service registry.
|
||||
This job is needed for a clustered CAS environment since service changes
|
||||
in one CAS node are not known to the other until a reload.
|
||||
-->
|
||||
<bean id="serviceRegistryReloaderJobDetail"
|
||||
class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean"
|
||||
p:targetObject-ref="servicesManager"
|
||||
p:targetMethod="reload"/>
|
||||
|
||||
<bean id="periodicServiceRegistryReloaderTrigger" class="org.springframework.scheduling.quartz.SimpleTriggerBean"
|
||||
p:jobDetail-ref="serviceRegistryReloaderJobDetail"
|
||||
p:startDelay="${service.registry.quartz.reloader.startDelay:120000}"
|
||||
p:repeatInterval="${service.registry.quartz.reloader.repeatInterval:120000}"/>
|
||||
|
||||
|
||||
<bean id="noRedirectHttpClient" class="org.jasig.cas.util.SimpleHttpClient" parent="httpClient"
|
||||
p:followRedirects="false" />
|
||||
|
||||
<bean id="persistentIdGenerator"
|
||||
class="org.jasig.cas.authentication.principal.ShibbolethCompatiblePersistentIdGenerator"
|
||||
p:salt="casrocks"/>
|
||||
|
||||
<bean id="logoutManager" class="org.jasig.cas.logout.LogoutManagerImpl"
|
||||
c:servicesManager-ref="servicesManager"
|
||||
c:httpClient-ref="noRedirectHttpClient"
|
||||
c:logoutMessageBuilder-ref="logoutBuilder"
|
||||
p:disableSingleSignOut="${slo.callbacks.disabled:false}" />
|
||||
|
||||
<bean id="logoutBuilder" class="org.jasig.cas.logout.SamlCompliantLogoutMessageCreator" />
|
||||
|
||||
<!-- CentralAuthenticationService -->
|
||||
<bean id="centralAuthenticationService" class="org.jasig.cas.CentralAuthenticationServiceImpl">
|
||||
<constructor-arg index="0" ref="ticketRegistry"/>
|
||||
<constructor-arg index="1">
|
||||
<null />
|
||||
</constructor-arg>
|
||||
<constructor-arg index="2" ref="authenticationManager"/>
|
||||
<constructor-arg index="3" ref="ticketGrantingTicketUniqueIdGenerator"/>
|
||||
<constructor-arg index="4" ref="uniqueIdGeneratorsMap"/>
|
||||
<constructor-arg index="5" ref="grantingTicketExpirationPolicy"/>
|
||||
<constructor-arg index="6" ref="serviceTicketExpirationPolicy"/>
|
||||
<constructor-arg index="7" ref="servicesManager"/>
|
||||
<constructor-arg index="8" ref="logoutManager"/>
|
||||
<property name="persistentIdGenerator" ref="persistentIdGenerator"/>
|
||||
</bean>
|
||||
|
||||
<bean id="proxy10Handler" class="org.jasig.cas.ticket.proxy.support.Cas10ProxyHandler"/>
|
||||
|
||||
<bean id="proxy20Handler" class="org.jasig.cas.ticket.proxy.support.Cas20ProxyHandler"
|
||||
p:httpClient-ref="httpClient"
|
||||
p:uniqueTicketIdGenerator-ref="proxy20TicketUniqueIdGenerator"/>
|
||||
|
||||
<!-- ADVISORS -->
|
||||
<bean id="advisorAutoProxyCreator"
|
||||
class="org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator"/>
|
||||
|
||||
<bean id="validationAnnotationBeanPostProcessor" class="org.jasig.cas.util.CustomBeanValidationPostProcessor"
|
||||
p:afterInitialization="true" />
|
||||
|
||||
<!-- The scheduler bean wires up any triggers that define scheduled tasks -->
|
||||
<bean id="scheduler" class="org.jasig.cas.util.AutowiringSchedulerFactoryBean"/>
|
||||
|
||||
|
||||
<bean id="httpClient" class="org.jasig.cas.util.SimpleHttpClient"
|
||||
p:readTimeout="5000"
|
||||
p:connectionTimeout="5000">
|
||||
<property name="executorService">
|
||||
<bean class="org.springframework.core.task.support.ExecutorServiceAdapter">
|
||||
<constructor-arg>
|
||||
<bean class="org.springframework.core.task.SyncTaskExecutor"/>
|
||||
</constructor-arg>
|
||||
</bean>
|
||||
</property>
|
||||
</bean>
|
||||
</beans>
|
||||
105
samples/xml/cas/pom.xml
Normal file
105
samples/xml/cas/pom.xml
Normal file
@@ -0,0 +1,105 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.springframework.security</groupId>
|
||||
<artifactId>cas</artifactId>
|
||||
<version>4.1.0.BUILD-SNAPSHOT</version>
|
||||
<name>cas</name>
|
||||
<description>cas</description>
|
||||
<url>http://spring.io/spring-security</url>
|
||||
<organization>
|
||||
<name>spring.io</name>
|
||||
<url>http://spring.io/</url>
|
||||
</organization>
|
||||
<licenses>
|
||||
<license>
|
||||
<name>The Apache Software License, Version 2.0</name>
|
||||
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
|
||||
<distribution>repo</distribution>
|
||||
</license>
|
||||
</licenses>
|
||||
<developers>
|
||||
<developer>
|
||||
<id>rwinch</id>
|
||||
<name>Rob Winch</name>
|
||||
<email>rwinch@gopivotal.com</email>
|
||||
</developer>
|
||||
</developers>
|
||||
<scm>
|
||||
<connection>scm:git:git://github.com/spring-projects/spring-security</connection>
|
||||
<developerConnection>scm:git:git://github.com/spring-projects/spring-security</developerConnection>
|
||||
<url>https://github.com/spring-projects/spring-security</url>
|
||||
</scm>
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-framework-bom</artifactId>
|
||||
<version>4.2.5.RELEASE</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>commons-logging</groupId>
|
||||
<artifactId>commons-logging</artifactId>
|
||||
<version>1.2</version>
|
||||
<scope>compile</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
<artifactId>logback-classic</artifactId>
|
||||
<version>1.1.2</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.12</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.assertj</groupId>
|
||||
<artifactId>assertj-core</artifactId>
|
||||
<version>2.2.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<version>1.10.19</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>jcl-over-slf4j</artifactId>
|
||||
<version>1.7.7</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spring-snapshot</id>
|
||||
<url>https://repo.spring.io/snapshot</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>1.7</source>
|
||||
<target>1.7</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
Reference in New Issue
Block a user