cassample.gradle 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. // CAS sample build file
  2. apply plugin: 'war'
  3. apply plugin: 'jetty'
  4. apply plugin: 'groovy'
  5. def excludeModules = ['spring-security-acl', 'jsr250-api', 'spring-jdbc', 'spring-tx']
  6. def jettyVersion = '7.1.6.v20100715'
  7. def keystore = "$rootDir/samples/certificates/server.jks"
  8. def password = 'password'
  9. configurations {
  10. casServer
  11. excludeModules.each {name ->
  12. runtime.exclude module: name
  13. }
  14. runtime.exclude group: 'org.aspectj'
  15. integrationTestCompile.extendsFrom groovy
  16. }
  17. sourceSets.integrationTest {
  18. groovy.srcDir file('src/integration-test/groovy')
  19. }
  20. eclipseClasspath {
  21. plusConfigurations += configurations.integrationTestRuntime
  22. }
  23. dependencies {
  24. groovy 'org.codehaus.groovy:groovy:1.7.7'
  25. providedCompile 'javax.servlet:servlet-api:2.5@jar'
  26. compile project(':spring-security-core'),
  27. project(':spring-security-cas'),
  28. "org.jasig.cas.client:cas-client-core:3.1.12"
  29. runtime project(':spring-security-web'),
  30. project(':spring-security-config'),
  31. "org.slf4j:jcl-over-slf4j:$slf4jVersion",
  32. "ch.qos.logback:logback-classic:$logbackVersion"
  33. integrationTestCompile project(':spring-security-cas'),
  34. 'org.seleniumhq.selenium:selenium-htmlunit-driver:2.0a7',
  35. 'org.spockframework:spock-core:0.4-groovy-1.7',
  36. 'org.codehaus.geb:geb-spock:0.5.1',
  37. 'commons-httpclient:commons-httpclient:3.1',
  38. "org.eclipse.jetty:jetty-server:$jettyVersion",
  39. "org.eclipse.jetty:jetty-servlet:$jettyVersion"
  40. }
  41. [jettyRun, jettyRunWar]*.configure {
  42. contextPath = "/cas-sample"
  43. def httpConnector = new org.mortbay.jetty.nio.SelectChannelConnector();
  44. httpConnector.port = 8080
  45. httpConnector.confidentialPort = 8443
  46. def httpsConnector = new org.mortbay.jetty.security.SslSocketConnector();
  47. httpsConnector.port = 8443
  48. httpsConnector.keystore = httpsConnector.truststore = keystore
  49. httpsConnector.keyPassword = httpsConnector.trustPassword = password
  50. connectors = [httpConnector, httpsConnector]
  51. doFirst() {
  52. System.setProperty('cas.server.host', casServer().httpsHost)
  53. System.setProperty('cas.service.host', jettyRunWar.httpsHost)
  54. }
  55. }
  56. task cas (dependsOn: [jettyRunWar]) {
  57. jettyRunWar.dependsOn(':spring-security-samples-casserver:casServer')
  58. }
  59. task casServer(dependsOn: ':spring-security-samples-casserver:casServer') {
  60. }
  61. integrationTest.dependsOn cas
  62. integrationTest.doFirst {
  63. systemProperties['cas.server.host'] = casServer().httpsHost
  64. systemProperties['cas.service.host'] = jettyRunWar.httpsHost
  65. systemProperties['jar.path'] = jar.archivePath
  66. systemProperties['javax.net.ssl.trustStore'] = keystore
  67. systemProperties['javax.net.ssl.trustStorePassword'] = password
  68. }
  69. gradle.taskGraph.whenReady {graph ->
  70. def casServer = casServer()
  71. [casServer,jettyRunWar]*.metaClass*.getHttpsConnector {->
  72. delegate.connectors.find { it instanceof org.mortbay.jetty.security.SslSocketConnector }
  73. }
  74. [casServer,jettyRunWar]*.metaClass*.getHttpsHost {->
  75. "localhost:"+delegate.httpsConnector.port
  76. }
  77. jettyRunWar.metaClass.getHttpConnector {->
  78. delegate.connectors.find { it instanceof org.mortbay.jetty.nio.SelectChannelConnector }
  79. }
  80. if (graph.hasTask(cas)) {
  81. casServer.daemon = true
  82. }
  83. if(graph.hasTask(integrationTest)) {
  84. tasks.getByPath(':spring-security-samples-casserver:casServerOverlay').logLevel = 'ERROR'
  85. jettyRunWar.additionalRuntimeJars += file("src/integration-test/resources")
  86. jettyRunWar.daemon = true
  87. jettyRunWar.httpConnector.port = availablePort()
  88. jettyRunWar.httpsConnector.port = jettyRunWar.httpConnector.confidentialPort = availablePort()
  89. casServer.httpsConnector.port = availablePort()
  90. }
  91. }
  92. def casServer() {
  93. tasks.getByPath(':spring-security-samples-casserver:casServer')
  94. }
  95. def availablePort() {
  96. ServerSocket server = new ServerSocket(0)
  97. int port = server.localPort
  98. server.close()
  99. port
  100. }