cassample.gradle 4.9 KB

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