cassample.gradle 4.8 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 = '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 "org.apache.tomcat:tomcat-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.slf4j:jcl-over-slf4j:$slf4jVersion",
  29. "ch.qos.logback:logback-classic:$logbackVersion"
  30. integrationTestCompile project(':spring-security-cas'),
  31. "org.seleniumhq.selenium:selenium-htmlunit-driver:$seleniumVersion",
  32. "org.spockframework:spock-core:$spockVersion",
  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. }
  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. def casServiceHost = jettyRunWar.httpsHost
  62. systemProperties['cas.server.host'] = casServer().httpsHost
  63. systemProperties['cas.service.host'] = casServiceHost
  64. systemProperties['geb.build.baseUrl'] = 'https://'+casServiceHost+'/cas-sample/'
  65. systemProperties['geb.build.reportsDir'] = 'build/geb-reports'
  66. systemProperties['jar.path'] = jar.archivePath
  67. systemProperties['javax.net.ssl.trustStore'] = keystore
  68. systemProperties['javax.net.ssl.trustStorePassword'] = password
  69. }
  70. gradle.taskGraph.whenReady {graph ->
  71. def casServer = casServer()
  72. [casServer,jettyRunWar]*.metaClass*.getHttpsConnector {->
  73. def sslSocketConnClass = jettyRunWar.class.classLoader.loadClass('org.mortbay.jetty.security.SslSocketConnector')
  74. delegate.connectors.find { it in sslSocketConnClass }
  75. }
  76. [casServer,jettyRunWar]*.metaClass*.getHttpsHost {->
  77. "localhost:"+delegate.httpsConnector.port
  78. }
  79. jettyRunWar.metaClass.getHttpConnector {->
  80. def channelConnClass = jettyRunWar.class.classLoader.loadClass('org.mortbay.jetty.nio.SelectChannelConnector')
  81. delegate.connectors.find { it in channelConnClass }
  82. }
  83. if (graph.hasTask(cas)) {
  84. casServer.daemon = true
  85. }
  86. if(graph.hasTask(integrationTest)) {
  87. tasks.getByPath(':spring-security-samples-casserver:casServerOverlay').logLevel = 'ERROR'
  88. jettyRunWar {
  89. additionalRuntimeJars += file("src/integration-test/resources")
  90. daemon = true
  91. }
  92. [jettyRunWar.httpConnector,jettyRunWar.httpsConnector,casServer.httpsConnector]*.metaClass*.reservePort { taskToCloseSocket ->
  93. def serverSocket = new ServerSocket(0)
  94. delegate.metaClass.serverSocket = serverSocket
  95. delegate.port = serverSocket.localPort
  96. taskToCloseSocket.doFirst {
  97. serverSocket.close()
  98. }
  99. }
  100. [jettyRunWar.httpConnector,jettyRunWar.httpsConnector]*.reservePort(jettyRunWar)
  101. jettyRunWar.httpConnector.confidentialPort = jettyRunWar.httpsConnector.port
  102. casServer.httpsConnector.reservePort(casServer)
  103. }
  104. }
  105. def casServer() {
  106. tasks.getByPath(':spring-security-samples-casserver:casServer')
  107. }