cassample.gradle 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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 {
  18. test.resources.exclude 'GebConfig.groovy'
  19. integrationTest.groovy.srcDir file('src/integration-test/groovy')
  20. }
  21. eclipse.classpath.plusConfigurations += configurations.integrationTestRuntime
  22. dependencies {
  23. groovy 'org.codehaus.groovy:groovy:1.8.7'
  24. providedCompile 'javax.servlet:servlet-api:2.5@jar'
  25. compile project(':spring-security-core'),
  26. project(':spring-security-cas-client'),
  27. "org.jasig.cas.client:cas-client-core:3.1.12"
  28. runtime project(':spring-security-web'),
  29. project(':spring-security-config'),
  30. "org.slf4j:jcl-over-slf4j:$slf4jVersion",
  31. "ch.qos.logback:logback-classic:$logbackVersion"
  32. integrationTestCompile project(':spring-security-cas-client'),
  33. 'org.seleniumhq.selenium:selenium-htmlunit-driver:2.25.0',
  34. 'org.spockframework:spock-core:0.6-groovy-1.8',
  35. 'org.codehaus.geb:geb-spock:0.7.2',
  36. 'commons-httpclient:commons-httpclient:3.1',
  37. "org.eclipse.jetty:jetty-server:$jettyVersion",
  38. "org.eclipse.jetty:jetty-servlet:$jettyVersion"
  39. }
  40. [jettyRun, jettyRunWar]*.configure {
  41. contextPath = "/cas-sample"
  42. def httpConnector = jettyRunWar.class.classLoader.loadClass('org.mortbay.jetty.nio.SelectChannelConnector').newInstance()
  43. httpConnector.port = 8080
  44. httpConnector.confidentialPort = 8443
  45. def httpsConnector = jettyRunWar.class.classLoader.loadClass('org.mortbay.jetty.security.SslSocketConnector').newInstance()
  46. httpsConnector.port = 8443
  47. httpsConnector.keystore = httpsConnector.truststore = keystore
  48. httpsConnector.keyPassword = httpsConnector.trustPassword = password
  49. connectors = [httpConnector, httpsConnector]
  50. doFirst() {
  51. System.setProperty('cas.server.host', casServer().httpsHost)
  52. System.setProperty('cas.service.host', jettyRunWar.httpsHost)
  53. }
  54. }
  55. task cas (dependsOn: [jettyRunWar]) {
  56. jettyRunWar.dependsOn(':spring-security-samples-casserver:casServer')
  57. }
  58. task casServer(dependsOn: ':spring-security-samples-casserver:casServer') {
  59. }
  60. integrationTest.dependsOn cas
  61. integrationTest.doFirst {
  62. def casServiceHost = jettyRunWar.httpsHost
  63. systemProperties['cas.server.host'] = casServer().httpsHost
  64. systemProperties['cas.service.host'] = casServiceHost
  65. systemProperties['geb.build.baseUrl'] = 'https://'+casServiceHost+'/cas-sample/'
  66. systemProperties['geb.build.reportsDir'] = 'build/geb-reports'
  67. systemProperties['jar.path'] = jar.archivePath
  68. systemProperties['javax.net.ssl.trustStore'] = keystore
  69. systemProperties['javax.net.ssl.trustStorePassword'] = password
  70. }
  71. gradle.taskGraph.whenReady {graph ->
  72. def casServer = casServer()
  73. [casServer,jettyRunWar]*.metaClass*.getHttpsConnector {->
  74. def sslSocketConnClass = jettyRunWar.class.classLoader.loadClass('org.mortbay.jetty.security.SslSocketConnector')
  75. delegate.connectors.find { it in sslSocketConnClass }
  76. }
  77. [casServer,jettyRunWar]*.metaClass*.getHttpsHost {->
  78. "localhost:"+delegate.httpsConnector.port
  79. }
  80. jettyRunWar.metaClass.getHttpConnector {->
  81. def channelConnClass = jettyRunWar.class.classLoader.loadClass('org.mortbay.jetty.nio.SelectChannelConnector')
  82. delegate.connectors.find { it in channelConnClass }
  83. }
  84. if (graph.hasTask(cas)) {
  85. casServer.daemon = true
  86. }
  87. if(graph.hasTask(integrationTest)) {
  88. tasks.getByPath(':spring-security-samples-casserver:casServerOverlay').logLevel = 'ERROR'
  89. jettyRunWar {
  90. additionalRuntimeJars += file("src/integration-test/resources")
  91. daemon = true
  92. }
  93. [jettyRunWar.httpConnector,jettyRunWar.httpsConnector,casServer.httpsConnector]*.metaClass*.reservePort { taskToCloseSocket ->
  94. def serverSocket = new ServerSocket(0)
  95. delegate.metaClass.serverSocket = serverSocket
  96. delegate.port = serverSocket.localPort
  97. taskToCloseSocket.doFirst {
  98. serverSocket.close()
  99. }
  100. }
  101. [jettyRunWar.httpConnector,jettyRunWar.httpsConnector]*.reservePort(jettyRunWar)
  102. jettyRunWar.httpConnector.confidentialPort = jettyRunWar.httpsConnector.port
  103. casServer.httpsConnector.reservePort(casServer)
  104. }
  105. }
  106. def casServer() {
  107. tasks.getByPath(':spring-security-samples-casserver:casServer')
  108. }