spring-security-samples-xml-cassample.gradle 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. apply plugin: 'io.spring.convention.spring-sample'
  2. apply plugin: 'war'
  3. apply plugin: 'jetty'
  4. def excludeModules = ['spring-security-acl', 'jsr250-api', 'spring-jdbc', 'spring-tx']
  5. def keystore = "$rootDir/samples/certificates/server.jks"
  6. def password = 'password'
  7. configurations {
  8. casServer
  9. excludeModules.each {name ->
  10. runtime.exclude module: name
  11. }
  12. runtime.exclude group: 'org.aspectj'
  13. }
  14. sourceSets {
  15. test.resources.exclude 'GebConfig.groovy'
  16. integrationTest.groovy.srcDir file('src/integration-test/groovy')
  17. }
  18. eclipse.classpath.plusConfigurations += [configurations.integrationTestRuntime]
  19. dependencies {
  20. compile project(':spring-security-cas')
  21. compile project(':spring-security-core')
  22. compile 'org.jasig.cas.client:cas-client-core'
  23. providedCompile 'javax.servlet:javax.servlet-api'
  24. runtime project(':spring-security-config')
  25. runtime project(':spring-security-web')
  26. runtime 'ch.qos.logback:logback-classic'
  27. runtime 'net.sf.ehcache:ehcache'
  28. runtime 'org.slf4j:jcl-over-slf4j'
  29. runtime 'org.springframework:spring-context-support'
  30. integrationTestCompile project(':spring-security-cas')
  31. integrationTestCompile gebDependencies
  32. integrationTestCompile seleniumDependencies
  33. integrationTestCompile spockDependencies
  34. integrationTestCompile 'org.codehaus.groovy:groovy'
  35. integrationTestCompile 'org.eclipse.jetty:jetty-server'
  36. integrationTestCompile 'org.eclipse.jetty:jetty-servlet'
  37. integrationTestCompile 'org.slf4j:jcl-over-slf4j'
  38. }
  39. [project.tasks.jettyRun, project.tasks.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-xml-casserver:casServer')
  56. }
  57. task casServer(dependsOn: ':spring-security-samples-xml-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-xml-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-xml-casserver:casServer')
  107. }