cas.gradle 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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. casServer "org.jasig.cas:cas-server-webapp:3.4.3.1@war"
  26. providedCompile 'javax.servlet:servlet-api:2.5@jar'
  27. compile project(':spring-security-core'),
  28. project(':spring-security-cas'),
  29. "org.jasig.cas.client:cas-client-core:3.1.12"
  30. runtime project(':spring-security-web'),
  31. project(':spring-security-config'),
  32. "org.slf4j:jcl-over-slf4j:$slf4jVersion",
  33. "ch.qos.logback:logback-classic:$logbackVersion"
  34. integrationTestCompile project(':spring-security-cas'),
  35. 'org.seleniumhq.selenium:selenium-htmlunit-driver:2.0a7',
  36. 'org.spockframework:spock-core:0.4-groovy-1.7',
  37. 'org.codehaus.geb:geb-spock:0.5.1',
  38. 'commons-httpclient:commons-httpclient:3.1',
  39. "org.eclipse.jetty:jetty-server:$jettyVersion",
  40. "org.eclipse.jetty:jetty-servlet:$jettyVersion"
  41. }
  42. [jettyRun, jettyRunWar]*.configure {
  43. contextPath = "/cas-sample"
  44. def httpConnector = new org.mortbay.jetty.nio.SelectChannelConnector();
  45. httpConnector.port = 8080
  46. httpConnector.confidentialPort = 8443
  47. def httpsConnector = new org.mortbay.jetty.security.SslSocketConnector();
  48. httpsConnector.port = 8443
  49. httpsConnector.keystore = httpsConnector.truststore = keystore
  50. httpsConnector.keyPassword = httpsConnector.trustPassword = password
  51. connectors = [httpConnector, httpsConnector]
  52. doFirst() {
  53. System.setProperty('cas.server.host', casServer.httpsHost)
  54. System.setProperty('cas.service.host', jettyRunWar.httpsHost)
  55. }
  56. }
  57. task casServer (type: org.gradle.api.plugins.jetty.JettyRunWar) {
  58. contextPath = "/cas"
  59. connectors = [new org.mortbay.jetty.security.SslSocketConnector()]
  60. connectors[0].port = 9443
  61. connectors[0].keystore = connectors[0].truststore = keystore
  62. connectors[0].keyPassword = connectors[0].trustPassword = password
  63. connectors[0].wantClientAuth = true
  64. connectors[0].needClientAuth = false
  65. webApp = configurations.casServer.resolve().toArray()[0]
  66. doFirst() {
  67. System.setProperty('javax.net.ssl.trustStore', keystore)
  68. System.setProperty('javax.net.ssl.trustStorePassword', password)
  69. }
  70. }
  71. task cas (dependsOn: [jettyRunWar, casServer]) {
  72. }
  73. integrationTest.dependsOn cas
  74. integrationTest.doFirst {
  75. systemProperties['cas.server.host'] = casServer.httpsHost
  76. systemProperties['cas.service.host'] = jettyRunWar.httpsHost
  77. systemProperties['jar.path'] = jar.archivePath
  78. systemProperties['javax.net.ssl.trustStore'] = keystore
  79. systemProperties['javax.net.ssl.trustStorePassword'] = password
  80. }
  81. gradle.taskGraph.whenReady {graph ->
  82. if (graph.hasTask(cas)) {
  83. jettyRunWar.dependsOn(casServer)
  84. casServer.daemon = true
  85. }
  86. if(graph.hasTask(integrationTest)) {
  87. jettyRunWar.daemon = true
  88. jettyRunWar.httpConnector.port = availablePort()
  89. jettyRunWar.httpsConnector.port = jettyRunWar.httpConnector.confidentialPort = availablePort()
  90. casServer.httpsConnector.port = availablePort()
  91. }
  92. }
  93. [casServer,jettyRunWar]*.metaClass*.getHttpsConnector {->
  94. delegate.connectors.find { it instanceof org.mortbay.jetty.security.SslSocketConnector }
  95. }
  96. [casServer,jettyRunWar]*.metaClass*.getHttpsHost {->
  97. "localhost:"+delegate.httpsConnector.port
  98. }
  99. jettyRunWar.metaClass.getHttpConnector {->
  100. delegate.connectors.find { it instanceof org.mortbay.jetty.nio.SelectChannelConnector }
  101. }
  102. def availablePort() {
  103. ServerSocket server = new ServerSocket(0)
  104. int port = server.localPort
  105. server.close()
  106. port
  107. }