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