cassample.gradle 4.3 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. eclipse.classpath.plusConfigurations += configurations.integrationTestRuntime
  21. dependencies {
  22. groovy 'org.codehaus.groovy:groovy:1.7.10'
  23. providedCompile 'javax.servlet:servlet-api:2.5@jar'
  24. compile project(':spring-security-core'),
  25. project(':spring-security-cas'),
  26. "org.jasig.cas.client:cas-client-core:3.1.12"
  27. runtime project(':spring-security-web'),
  28. project(':spring-security-config'),
  29. "org.slf4j:jcl-over-slf4j:$slf4jVersion",
  30. "ch.qos.logback:logback-classic:$logbackVersion"
  31. integrationTestCompile project(':spring-security-cas'),
  32. 'org.seleniumhq.selenium:selenium-htmlunit-driver:2.0a7',
  33. 'org.spockframework:spock-core:0.4-groovy-1.7',
  34. 'org.codehaus.geb:geb-spock:0.5.1',
  35. 'commons-httpclient:commons-httpclient:3.1',
  36. "org.eclipse.jetty:jetty-server:$jettyVersion",
  37. "org.eclipse.jetty:jetty-servlet:$jettyVersion"
  38. }
  39. [jettyRun, jettyRunWar]*.configure {
  40. contextPath = "/cas-sample"
  41. def httpConnector = jettyRunWar.class.classLoader.loadClass('org.mortbay.jetty.nio.SelectChannelConnector').newInstance()
  42. httpConnector.port = 8080
  43. httpConnector.confidentialPort = 8443
  44. def httpsConnector = jettyRunWar.class.classLoader.loadClass('org.mortbay.jetty.security.SslSocketConnector').newInstance()
  45. httpsConnector.port = 8443
  46. httpsConnector.keystore = httpsConnector.truststore = keystore
  47. httpsConnector.keyPassword = httpsConnector.trustPassword = password
  48. connectors = [httpConnector, httpsConnector]
  49. doFirst() {
  50. System.setProperty('cas.server.host', casServer().httpsHost)
  51. System.setProperty('cas.service.host', jettyRunWar.httpsHost)
  52. }
  53. }
  54. task cas (dependsOn: [jettyRunWar]) {
  55. jettyRunWar.dependsOn(':spring-security-samples-casserver:casServer')
  56. }
  57. task casServer(dependsOn: ':spring-security-samples-casserver:casServer') {
  58. }
  59. integrationTest.dependsOn cas
  60. integrationTest.doFirst {
  61. systemProperties['cas.server.host'] = casServer().httpsHost
  62. systemProperties['cas.service.host'] = jettyRunWar.httpsHost
  63. systemProperties['jar.path'] = jar.archivePath
  64. systemProperties['javax.net.ssl.trustStore'] = keystore
  65. systemProperties['javax.net.ssl.trustStorePassword'] = password
  66. }
  67. gradle.taskGraph.whenReady {graph ->
  68. def casServer = casServer()
  69. [casServer,jettyRunWar]*.metaClass*.getHttpsConnector {->
  70. def sslSocketConnClass = jettyRunWar.class.classLoader.loadClass('org.mortbay.jetty.security.SslSocketConnector')
  71. delegate.connectors.find { it in sslSocketConnClass }
  72. }
  73. [casServer,jettyRunWar]*.metaClass*.getHttpsHost {->
  74. "localhost:"+delegate.httpsConnector.port
  75. }
  76. jettyRunWar.metaClass.getHttpConnector {->
  77. def channelConnClass = jettyRunWar.class.classLoader.loadClass('org.mortbay.jetty.nio.SelectChannelConnector')
  78. delegate.connectors.find { it in channelConnClass }
  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. }