diff --git a/.travis.yml b/.travis.yml
index 87df8eb2b..e8457482d 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -2,13 +2,13 @@ language: groovy
matrix:
include:
- jdk: openjdk11
- env: TEST_ALL_CONTAINERS="['jetty9.3','jetty9.4','tomcat85','tomcat9']" TEST_ALL_GRADLE_VERSION="5.6.4"
+ env: TEST_ALL_CONTAINERS="['tomcat10']" TEST_ALL_GRADLE_VERSION="5.6.4"
- jdk: openjdk8
- env: TEST_ALL_CONTAINERS="['jetty9.3','jetty9.4','tomcat85','tomcat9']" TEST_ALL_GRADLE_VERSION="5.6.4"
+ env: TEST_ALL_CONTAINERS="['tomcat10']" TEST_ALL_GRADLE_VERSION="5.6.4"
- jdk: openjdk11
- env: TEST_ALL_CONTAINERS="['jetty9.3','jetty9.4','tomcat85','tomcat9']" TEST_ALL_GRADLE_VERSION="6.3"
+ env: TEST_ALL_CONTAINERS="['tomcat10']" TEST_ALL_GRADLE_VERSION="6.3"
- jdk: openjdk8
- env: TEST_ALL_CONTAINERS="['jetty9.3','jetty9.4','tomcat85','tomcat9']" TEST_ALL_GRADLE_VERSION="6.3"
+ env: TEST_ALL_CONTAINERS="['tomcat10']" TEST_ALL_GRADLE_VERSION="6.3"
before_cache:
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
cache:
diff --git a/gradle.properties b/gradle.properties
index 88fe38144..8ece840fb 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -6,19 +6,11 @@ developerId = gretty-gradle-plugin
developerName = Andrey Hihlovskiy
license = MIT
group = org.gretty
-version = 3.0.3-SNAPSHOT
-jetty7_version = 7.6.21.v20160908
-jetty7_servlet_api_version = 2.5
-jetty8_version = 8.1.22.v20160922
-jetty8_servlet_api_version = 3.0.1
-jetty9_version = 9.2.26.v20180806
-jetty93_version = 9.3.28.v20191105
-jetty94_version = 9.4.24.v20191120
-jetty9_servlet_api_version = 3.1.0
-tomcat85_version = 8.5.49
-tomcat85_servlet_api_version = 3.1.0
-tomcat9_version = 9.0.34
-tomcat9_servlet_api_version = 4.0.1
+version = 4.0.0-SNAPSHOT
+jetty10_version = 10.0.0.alpha2
+jetty10_servlet_api_version = 5.0.0-M1
+tomcat10_version = 10.0.0-M4
+tomcat10_servlet_api_version = 5.0.0-M1
asm_version = 8.0.1
groovy_version = 2.5.10
spock_version = 1.3-groovy-2.5
diff --git a/integrationTests/testJettyServerConfig/jetty/jetty7.xml b/integrationTests/testJettyServerConfig/jetty/jetty7.xml
deleted file mode 100644
index 3dd81aac3..000000000
--- a/integrationTests/testJettyServerConfig/jetty/jetty7.xml
+++ /dev/null
@@ -1,16 +0,0 @@
-
-
-
-
- 10
- 1000
-
-
-
-
-
- 7777
-
-
-
-
diff --git a/integrationTests/testJettyServerConfig/jetty/jetty8.xml b/integrationTests/testJettyServerConfig/jetty/jetty8.xml
deleted file mode 100644
index 3dd81aac3..000000000
--- a/integrationTests/testJettyServerConfig/jetty/jetty8.xml
+++ /dev/null
@@ -1,16 +0,0 @@
-
-
-
-
- 10
- 1000
-
-
-
-
-
- 7777
-
-
-
-
diff --git a/libs/gretty-core/build.gradle b/libs/gretty-core/build.gradle
index 003be0046..edd8595f1 100644
--- a/libs/gretty-core/build.gradle
+++ b/libs/gretty-core/build.gradle
@@ -19,18 +19,10 @@ dependencies {
tasks.processResources {
def props = [
grettyVersion: project.version,
- jetty7Version: project.jetty7_version,
- jetty7ServletApiVersion: project.jetty7_servlet_api_version,
- jetty8Version: project.jetty8_version,
- jetty8ServletApiVersion: project.jetty8_servlet_api_version,
- jetty9Version: project.jetty9_version,
- jetty93Version: project.jetty93_version,
- jetty94Version: project.jetty94_version,
- jetty9ServletApiVersion: project.jetty9_servlet_api_version,
- tomcat85Version: project.tomcat85_version,
- tomcat85ServletApiVersion: project.tomcat85_servlet_api_version,
- tomcat9Version: project.tomcat9_version,
- tomcat9ServletApiVersion: project.tomcat9_servlet_api_version,
+ jetty10Version: project.jetty10_version,
+ jetty10ServletApiVersion: project.jetty10_servlet_api_version,
+ tomcat10Version: project.tomcat10_version,
+ tomcat10ServletApiVersion: project.tomcat10_servlet_api_version,
springBootVersion: project.springBootVersion,
springLoadedVersion: project.springLoadedVersion,
springVersion: project.springVersion,
diff --git a/libs/gretty-core/src/main/groovy/org/akhikhl/gretty/ServerConfig.groovy b/libs/gretty-core/src/main/groovy/org/akhikhl/gretty/ServerConfig.groovy
index cfee72021..62a8f8758 100644
--- a/libs/gretty-core/src/main/groovy/org/akhikhl/gretty/ServerConfig.groovy
+++ b/libs/gretty-core/src/main/groovy/org/akhikhl/gretty/ServerConfig.groovy
@@ -77,7 +77,7 @@ class ServerConfig {
static ServerConfig getDefaultServerConfig(String serverName) {
ServerConfig result = new ServerConfig()
result.jvmArgs = []
- result.servletContainer = 'jetty9.4'
+ result.servletContainer = 'tomcat10'
result.managedClassReload = false
result.httpEnabled = true
result.httpsEnabled = false
@@ -89,7 +89,7 @@ class ServerConfig {
result.logFileName = serverName
result.redeployMode = 'restart'
result.logDir = "${System.getProperty('user.home')}/logs" as String
- result.scanner = 'jetty'
+ result.scanner = 'jdk'
result.portPropertiesFileName = 'gretty_ports.properties'
result.liveReloadEnabled = false
return result
diff --git a/libs/gretty-core/src/main/resources/org/akhikhl/gretty/Externalized.properties b/libs/gretty-core/src/main/resources/org/akhikhl/gretty/Externalized.properties
index 908daa9ab..029038aae 100644
--- a/libs/gretty-core/src/main/resources/org/akhikhl/gretty/Externalized.properties
+++ b/libs/gretty-core/src/main/resources/org/akhikhl/gretty/Externalized.properties
@@ -1,16 +1,8 @@
grettyVersion=@grettyVersion@
-jetty7Version=@jetty7Version@
-jetty7ServletApiVersion=@jetty7ServletApiVersion@
-jetty8Version=@jetty8Version@
-jetty8ServletApiVersion=@jetty8ServletApiVersion@
-jetty9Version=@jetty9Version@
-jetty93Version=@jetty93Version@
-jetty94Version=@jetty94Version@
-jetty9ServletApiVersion=@jetty9ServletApiVersion@
-tomcat85Version=@tomcat85Version@
-tomcat85ServletApiVersion=@tomcat85ServletApiVersion@
-tomcat9Version=@tomcat9Version@
-tomcat9ServletApiVersion=@tomcat9ServletApiVersion@
+jetty10Version=@jetty10Version@
+jetty10ServletApiVersion=@jetty10ServletApiVersion@
+tomcat10Version=@tomcat10Version@
+tomcat10ServletApiVersion=@tomcat10ServletApiVersion@
springBootVersion=@springBootVersion@
springLoadedVersion=@springLoadedVersion@
springVersion=@springVersion@
diff --git a/libs/gretty-filter/build.gradle b/libs/gretty-filter/build.gradle
index 7db162e65..3a6615082 100644
--- a/libs/gretty-filter/build.gradle
+++ b/libs/gretty-filter/build.gradle
@@ -1,7 +1,7 @@
apply from: rootProject.file('common.gradle')
dependencies {
- compile 'javax.servlet:servlet-api:2.5'
+ compile "jakarta.servlet:jakarta.servlet-api:$tomcat10_servlet_api_version"
compile 'org.codehaus.groovy.modules.http-builder:http-builder:0.7.1', {
exclude group: 'commons-logging', module: 'commons-logging'
}
diff --git a/libs/gretty-filter/src/main/groovy/org/akhikhl/gretty/RedirectFilter.groovy b/libs/gretty-filter/src/main/groovy/org/akhikhl/gretty/RedirectFilter.groovy
index 10e4d760c..916ce531f 100644
--- a/libs/gretty-filter/src/main/groovy/org/akhikhl/gretty/RedirectFilter.groovy
+++ b/libs/gretty-filter/src/main/groovy/org/akhikhl/gretty/RedirectFilter.groovy
@@ -4,7 +4,7 @@ import groovy.servlet.ServletCategory
import groovyx.net.http.URIBuilder
import groovy.transform.CompileStatic
import groovy.transform.TypeCheckingMode
-import javax.servlet.*
+import jakarta.servlet.*
import java.util.regex.Pattern
import javax.management.ObjectName
import org.codehaus.groovy.control.customizers.ImportCustomizer
@@ -165,17 +165,10 @@ class RedirectFilter implements Filter {
// jetty-specific
def server = servletContext.contextHandler.server
server.connectors.each { conn ->
- if(server.version.startsWith('7.') || server.version.startsWith('8.')) {
- if(conn.getClass().getName() == 'org.eclipse.jetty.server.bio.SocketConnector')
- httpPort = conn.port instanceof Integer ? conn.port : Integer.parseInt(conn.port.toString(), 8080)
- else if(conn.getClass().getName() == 'org.eclipse.jetty.server.ssl.SslSocketConnector')
- httpsPort = conn.port instanceof Integer ? conn.port : Integer.parseInt(conn.port.toString(), 8443)
- } else {
- if(conn.protocols.find { it.startsWith 'http/' } && !conn.protocols.find { it.startsWith 'ssl-http/' })
- httpPort = conn.port instanceof Integer ? conn.port : Integer.parseInt(conn.port.toString(), 8080)
- else if(conn.protocols.find { it.startsWith 'http/' } && conn.protocols.find { it.startsWith 'ssl-http/' })
- httpsPort = conn.port instanceof Integer ? conn.port : Integer.parseInt(conn.port.toString(), 8443)
- }
+ if(conn.protocols.find { it.startsWith 'http/' } && !conn.protocols.find { it.startsWith 'ssl-http/' })
+ httpPort = conn.port instanceof Integer ? conn.port : Integer.parseInt(conn.port.toString(), 8080)
+ else if(conn.protocols.find { it.startsWith 'http/' } && conn.protocols.find { it.startsWith 'ssl-http/' })
+ httpsPort = conn.port instanceof Integer ? conn.port : Integer.parseInt(conn.port.toString(), 8443)
}
}
else {
diff --git a/libs/gretty-runner-jetty7/build.gradle b/libs/gretty-runner-jetty7/build.gradle
deleted file mode 100644
index 09f955b91..000000000
--- a/libs/gretty-runner-jetty7/build.gradle
+++ /dev/null
@@ -1,20 +0,0 @@
-apply from: rootProject.file('common.gradle')
-
-configurations {
- compile {
- exclude group: 'org.eclipse.jetty.orbit', module: 'javax.servlet'
- exclude group: 'org.slf4j', module: 'slf4j-simple'
- exclude group: 'org.slf4j', module: 'jcl104-over-slf4j'
- }
-}
-
-dependencies {
- compile project(':libs:gretty-runner-jetty')
- compile "javax.servlet:servlet-api:$jetty7_servlet_api_version"
- compile "org.eclipse.jetty:jetty-server:$jetty7_version"
- compile "org.eclipse.jetty:jetty-servlet:$jetty7_version"
- compile "org.eclipse.jetty:jetty-webapp:$jetty7_version"
- compile "org.eclipse.jetty:jetty-security:$jetty7_version"
- compile "org.eclipse.jetty:jetty-jsp:$jetty7_version"
- compile "org.eclipse.jetty:jetty-plus:$jetty7_version"
-}
diff --git a/libs/gretty-runner-jetty7/src/main/groovy/org/akhikhl/gretty/DefaultServletEx.groovy b/libs/gretty-runner-jetty7/src/main/groovy/org/akhikhl/gretty/DefaultServletEx.groovy
deleted file mode 100644
index c807f7d70..000000000
--- a/libs/gretty-runner-jetty7/src/main/groovy/org/akhikhl/gretty/DefaultServletEx.groovy
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Gretty
- *
- * Copyright (C) 2013-2015 Andrey Hihlovskiy and contributors.
- *
- * See the file "LICENSE" for copying and usage permission.
- * See the file "CONTRIBUTORS" for complete list of contributors.
- */
-package org.akhikhl.gretty
-
-import org.eclipse.jetty.servlet.DefaultServlet
-import org.eclipse.jetty.util.resource.FileResource
-import org.eclipse.jetty.util.resource.Resource
-
-/**
- * This servlet emulates webjars for servlet-api older than 3.0.
- *
- * @author akhikhl
- */
-class DefaultServletEx extends DefaultServlet {
-
- Resource getResource(String pathInContext) {
- def result = super.getResource(pathInContext)
- if(result instanceof FileResource && !result.getFile()?.exists()) {
- if(pathInContext.startsWith('/webjars/')) {
- String webjarsPath = 'META-INF/resources' + pathInContext
- URL resourceURL = Thread.currentThread().getContextClassLoader().getResource(webjarsPath)
- if(resourceURL)
- result = Resource.newResource(resourceURL)
- }
- }
- result
- }
-}
diff --git a/libs/gretty-runner-jetty7/src/main/groovy/org/akhikhl/gretty/JettyConfigurerImpl.groovy b/libs/gretty-runner-jetty7/src/main/groovy/org/akhikhl/gretty/JettyConfigurerImpl.groovy
deleted file mode 100644
index 4cb14581f..000000000
--- a/libs/gretty-runner-jetty7/src/main/groovy/org/akhikhl/gretty/JettyConfigurerImpl.groovy
+++ /dev/null
@@ -1,314 +0,0 @@
-/*
- * Gretty
- *
- * Copyright (C) 2013-2015 Andrey Hihlovskiy and contributors.
- *
- * See the file "LICENSE" for copying and usage permission.
- * See the file "CONTRIBUTORS" for complete list of contributors.
- */
-package org.akhikhl.gretty
-
-import groovy.transform.CompileStatic
-import groovy.transform.TypeCheckingMode
-import org.eclipse.jetty.plus.webapp.EnvConfiguration
-import org.eclipse.jetty.plus.webapp.PlusConfiguration
-import org.eclipse.jetty.security.HashLoginService
-import org.eclipse.jetty.server.Connector
-import org.eclipse.jetty.server.Handler
-import org.eclipse.jetty.server.Server
-import org.eclipse.jetty.server.bio.SocketConnector
-import org.eclipse.jetty.server.handler.ContextHandlerCollection
-import org.eclipse.jetty.server.session.HashSessionManager
-import org.eclipse.jetty.server.session.SessionHandler
-import org.eclipse.jetty.server.ssl.SslSocketConnector
-import org.eclipse.jetty.util.component.LifeCycle
-import org.eclipse.jetty.util.resource.Resource
-import org.eclipse.jetty.util.resource.ResourceCollection
-import org.eclipse.jetty.util.ssl.SslContextFactory
-import org.eclipse.jetty.webapp.*
-import org.eclipse.jetty.xml.XmlConfiguration
-import org.slf4j.Logger
-import org.slf4j.LoggerFactory
-
-/**
- *
- * @author akhikhl
- */
-@CompileStatic(TypeCheckingMode.SKIP)
-class JettyConfigurerImpl implements JettyConfigurer {
-
- private static final Logger log = LoggerFactory.getLogger(JettyConfigurerImpl)
-
- private SSOAuthenticatorFactory ssoAuthenticatorFactory
- private HashSessionManager sharedSessionManager
-
- @Override
- def addLifeCycleListener(lifecycle, listener) {
- def lifeCycleListener = listener as LifeCycleListenerAdapter
- lifecycle.addLifeCycleListener(lifeCycleListener)
- lifeCycleListener
- }
-
- @Override
- void applyContextConfigFile(webAppContext, URL contextConfigFile) {
- if(contextConfigFile) {
- log.info 'Configuring {} with {}', webAppContext.contextPath, contextConfigFile
- XmlConfiguration xmlConfiguration = new XmlConfiguration(contextConfigFile)
- xmlConfiguration.configure(webAppContext)
- }
- }
-
- @Override
- void applyJettyXml(server, String jettyXml) {
- if(jettyXml != null) {
- log.info 'Configuring server with {}', jettyXml
- XmlConfiguration xmlConfiguration = new XmlConfiguration(new File(jettyXml).toURI().toURL())
- xmlConfiguration.configure(server)
- }
- }
-
- @Override
- void configureConnectors(server, Map params) {
-
- Connector httpConn = findHttpConnector(server)
-
- boolean newConnector = false
- if(params.httpEnabled && !httpConn) {
- newConnector = true
- httpConn = new SocketConnector()
- httpConn.soLingerTime = -1
- }
-
- if(httpConn) {
- if(!httpConn.host)
- httpConn.host = params.host ?: ServerDefaults.defaultHost
-
- if(!httpConn.port)
- httpConn.port = params.httpPort ?: ServerDefaults.defaultHttpPort
-
- if(httpConn.port == PortUtils.RANDOM_FREE_PORT)
- httpConn.port = 0
-
- if(params.httpIdleTimeout)
- httpConn.maxIdleTime = params.httpIdleTimeout
-
- if(newConnector)
- server.addConnector(httpConn)
- }
-
- Connector httpsConn = findHttpsConnector(server)
-
- boolean newHttpsConnector = false
- if(params.httpsEnabled && !httpsConn) {
- newHttpsConnector = true
- httpsConn = new SslSocketConnector(new SslContextFactory())
- httpsConn.soLingerTime = -1
- }
-
- if(httpsConn) {
- if(!httpsConn.host)
- httpsConn.host = params.host ?: ServerDefaults.defaultHost
-
- if(!httpsConn.port)
- httpsConn.port = params.httpsPort ?: ServerDefaults.defaultHttpsPort
-
- if(httpsConn.port == PortUtils.RANDOM_FREE_PORT)
- httpsConn.port = 0
-
- def sslContextFactory = httpsConn.getSslContextFactory()
- if(params.sslKeyStorePath) {
- if(params.sslKeyStorePath.startsWith('classpath:')) {
- String resString = params.sslKeyStorePath - 'classpath:'
- URL url = getClass().getResource(resString)
- if(url == null)
- throw new Exception("Could not resource referenced in sslKeyStorePath: '${resString}'")
- sslContextFactory.setKeyStoreResource(Resource.newResource(url))
- }
- else
- sslContextFactory.setKeyStorePath(params.sslKeyStorePath)
- }
- if(params.sslKeyStorePassword)
- sslContextFactory.setKeyStorePassword(params.sslKeyStorePassword)
- if(params.sslKeyManagerPassword)
- sslContextFactory.setKeyManagerPassword(params.sslKeyManagerPassword)
- if(params.sslTrustStorePath) {
- if(params.sslTrustStorePath.startsWith('classpath:')) {
- String resString = params.sslTrustStorePath - 'classpath:'
- URL url = getClass().getResource(resString)
- if(url == null)
- throw new Exception("Could not resource referenced in sslTrustStorePath: '${resString}'")
- sslContextFactory.setTrustStoreResource(Resource.newResource(url))
- }
- else
- sslContextFactory.setTrustStorePath(params.sslTrustStorePath)
- }
- if(params.sslTrustStorePassword)
- sslContextFactory.setTrustStorePassword(params.sslTrustStorePassword)
- if(params.sslNeedClientAuth)
- sslContextFactory.setNeedClientAuth(params.sslNeedClientAuth)
-
- if(params.httpsIdleTimeout)
- httpsConn.maxIdleTime = params.httpsIdleTimeout
-
- if(newHttpsConnector)
- server.addConnector(httpsConn)
- }
- }
-
- @Override
- void configureSecurity(context, String realm, String realmConfigFile, boolean singleSignOn) {
- context.securityHandler.loginService = new HashLoginService(realm, realmConfigFile)
- if(singleSignOn) {
- if(ssoAuthenticatorFactory == null)
- ssoAuthenticatorFactory = new SSOAuthenticatorFactory()
- context.securityHandler.authenticatorFactory = ssoAuthenticatorFactory
- }
- }
-
- @Override
- void configureSessionManager(server, context, Map serverParams, Map webappParams) {
- HashSessionManager sessionManager
- if(serverParams.singleSignOn) {
- sessionManager = sharedSessionManager
- if(sessionManager == null) {
- sessionManager = sharedSessionManager = new HashSessionManager() {
-
- }
- sessionManager.setMaxInactiveInterval(60 * 30) // 30 minutes
- sessionManager.setSessionPath('/')
- }
- } else {
- sessionManager = new HashSessionManager()
- sessionManager.setMaxInactiveInterval(60 * 30) // 30 minutes
- }
- def sessionHandler = new SessionHandler(sessionManager)
- // By setting server we fix bug with older jetty versions: sessionHandler produces NullPointerException, when session manager is reassigned.
- sessionHandler.setServer(server)
- context.setSessionHandler(sessionHandler)
- }
-
- @Override
- def createResourceCollection(List paths) {
- new ResourceCollection(paths as String[])
- }
-
- @Override
- def createServer() {
- // fix for issue https://github.com/akhikhl/gretty/issues/24
- org.eclipse.jetty.util.resource.Resource.defaultUseCaches = false
- return new Server()
- }
-
- @Override
- def createWebAppContext(Map serverParams, Map webappParams) {
- List webappClassPath = webappParams.webappClassPath
- JettyWebAppContext context = new JettyWebAppContext()
- context.setWebInfLib(webappClassPath.findAll { it.endsWith('.jar') }.collect { new File(it) })
- context.setExtraClasspath(webappClassPath.collect { it.endsWith('.jar') ? it : (it.endsWith('/') ? it : it + '/') }.join(';'))
- if (webappParams.webXml != null) context.setDescriptor(webappParams.webXml);
- FilteringClassLoader classLoader = new FilteringClassLoader(context)
- classLoader.addServerClass('ch.qos.logback.')
- classLoader.addServerClass('org.apache.groovy.')
- classLoader.addServerClass('org.slf4j.')
- classLoader.addServerClass('org.codehaus.groovy.')
- classLoader.addServerClass('groovy.')
- classLoader.addServerClass('groovyx.')
- classLoader.addServerClass('groovyjarjarantlr.')
- classLoader.addServerClass('groovyjarjarasm.')
- classLoader.addServerClass('groovyjarjarcommonscli.')
- context.classLoader = classLoader
- context.addLifeCycleListener(new LifeCycleListenerAdapter() {
- public void lifeCycleStopped(LifeCycle event) {
- context.classLoader = null
- }
- })
- context.setOverrideDescriptor('/org/akhikhl/gretty/override-web.xml')
- return context
- }
-
- @Override
- def findHttpConnector(server) {
- server.connectors.find { (it instanceof SocketConnector) && !(it instanceof SslSocketConnector) }
- }
-
- @Override
- def findHttpsConnector(server) {
- server.connectors.find { it instanceof SslSocketConnector }
- }
-
- @Override
- URL findResourceURL(baseResource, String path) {
- Resource res
- if(baseResource instanceof ResourceCollection)
- res = baseResource.findResource(path)
- else
- res = baseResource.addPath(path)
- if(res.exists())
- return res.getURL()
- null
- }
-
- @Override
- List getConfigurations(Map webappParams) {
- [
- new WebInfConfigurationEx(),
- new WebXmlConfiguration(),
- new MetaInfConfiguration(),
- new FragmentConfiguration(),
- new EnvConfiguration(),
- new PlusConfiguration(),
- new JettyWebXmlConfiguration()
- ]
- }
-
- @Override
- void removeLifeCycleListener(lifecycle, listener) {
- lifecycle.removeLifeCycleListener(listener)
- }
-
- @Override
- void setConfigurationsToWebAppContext(webAppContext, List configurations) {
- webAppContext.setConfigurations(configurations as Configuration[])
- }
-
- private ContextHandlerCollection findContextHandlerCollection(Handler handler) {
- if(handler instanceof ContextHandlerCollection)
- return handler
- if(handler.respondsTo('getHandlers'))
- return handler.getHandlers().findResult { findContextHandlerCollection(it) }
- return null
- }
-
- @Override
- void setHandlersToServer(server, List handlers) {
- ContextHandlerCollection contexts = findContextHandlerCollection(server.handler)
- if(!contexts)
- contexts = new ContextHandlerCollection()
-
- contexts.setHandlers(handlers as Handler[])
- if(server.handler == null)
- server.handler = contexts
- }
-
- @Override
- List getHandlersByContextPaths(Object server, List contextPaths) {
- ContextHandlerCollection context = findContextHandlerCollection(server.handler)
- return context.getHandlers().findAll {
- if(it.respondsTo("getContextPath")) {
- contextPaths.contains(it.getContextPath())
- }
- }
- }
-
- @Override
- void removeHandlerFromServer(server, handler) {
- ContextHandlerCollection collection = findContextHandlerCollection(server.handler)
- collection.removeHandler(handler)
- }
-
- @Override
- void addHandlerToServer(server, handler) {
- ContextHandlerCollection collection = findContextHandlerCollection(server.handler)
- collection.addHandler(handler)
- }
-}
diff --git a/libs/gretty-runner-jetty7/src/main/groovy/org/akhikhl/gretty/JettyWebAppContext.groovy b/libs/gretty-runner-jetty7/src/main/groovy/org/akhikhl/gretty/JettyWebAppContext.groovy
deleted file mode 100644
index e7496d468..000000000
--- a/libs/gretty-runner-jetty7/src/main/groovy/org/akhikhl/gretty/JettyWebAppContext.groovy
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Gretty
- *
- * Copyright (C) 2013-2015 Andrey Hihlovskiy and contributors.
- *
- * See the file "LICENSE" for copying and usage permission.
- * See the file "CONTRIBUTORS" for complete list of contributors.
- */
-package org.akhikhl.gretty
-
-import org.eclipse.jetty.util.URIUtil
-import org.eclipse.jetty.util.log.Log
-import org.eclipse.jetty.util.log.Logger
-import org.eclipse.jetty.util.resource.Resource
-import org.eclipse.jetty.webapp.WebAppContext
-
-/**
- * Inspired by maven-jetty-plugin's JettyWebAppContext
- *
- * @author sala
- */
-class JettyWebAppContext extends WebAppContext {
- private static final Logger LOG = Log.getLogger(JettyWebAppContext.class)
-
- private static final String WEB_INF_LIB_PREFIX = '/WEB-INF/lib'
- private final Map webInfJarMap = [:]
- private final List webInfJars = []
-
- void setWebInfLib (List jars) {
- webInfJars.addAll(jars);
- }
-
- @Override
- protected void doStart() throws Exception {
- // preparing our pathes patch
- webInfJarMap.clear()
- webInfJars.each {
- String fileName = it.getName()
- if(fileName.endsWith('.jar')) {
- webInfJarMap.put(fileName, it)
- }
- }
- super.doStart()
- }
-
- @Override
- protected void doStop() throws Exception {
- // cancelling our pathes patch
- if(webInfJarMap != null) {
- webInfJarMap.clear()
- }
- webInfJars.clear()
- super.doStop()
- }
-
- @Override
- Set getResourcePaths(String path) {
- Set paths = super.getResourcePaths(path)
- // Tinkering with pathes, adding pathes provided manually
- if(path != null) {
- def allPaths = new TreeSet()
- allPaths.addAll(paths)
-
- if(path.startsWith(WEB_INF_LIB_PREFIX)) {
- webInfJarMap.keySet().each {
- allPaths.add(WEB_INF_LIB_PREFIX + '/' + it)
- }
- }
- return allPaths
- }
-
- return paths
- }
-
- @Override
- Resource getResource(String uriInContext) throws MalformedURLException {
- Resource resource = super.getResource(uriInContext)
-
- if((resource == null || !resource.exists()) && uriInContext != null) {
- String uri = URIUtil.canonicalPath(uriInContext)
- if(uri == null) {
- return null
- }
-
- try {
- if(uri.startsWith(WEB_INF_LIB_PREFIX)) {
- String jarName = uri.replace(WEB_INF_LIB_PREFIX, '')
- if(jarName.startsWith('/') || jarName.startsWith('\\')) {
- jarName = jarName.substring(1)
- }
- if(jarName.isEmpty()) {
- return null
- }
- File jarFile = webInfJarMap.get(jarName)
- if(jarFile != null) {
- return Resource.newResource(jarFile.getPath())
- }
- return null;
- }
- } catch (MalformedURLException e) {
- throw e;
- } catch (IOException e) {
- LOG.ignore(e)
- }
- }
- return resource
- }
-}
diff --git a/libs/gretty-runner-jetty7/src/main/groovy/org/akhikhl/gretty/LifeCycleListenerAdapter.java b/libs/gretty-runner-jetty7/src/main/groovy/org/akhikhl/gretty/LifeCycleListenerAdapter.java
deleted file mode 100644
index 2ccf906ca..000000000
--- a/libs/gretty-runner-jetty7/src/main/groovy/org/akhikhl/gretty/LifeCycleListenerAdapter.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Gretty
- *
- * Copyright (C) 2013-2015 Andrey Hihlovskiy and contributors.
- *
- * See the file "LICENSE" for copying and usage permission.
- * See the file "CONTRIBUTORS" for complete list of contributors.
- */
-package org.akhikhl.gretty;
-
-import org.eclipse.jetty.util.component.LifeCycle;
-
-/**
- *
- * @author akhikhl
- */
-public class LifeCycleListenerAdapter implements LifeCycle.Listener {
-
- @Override
- public void lifeCycleStarting(LifeCycle event) {
-
- }
-
- @Override
- public void lifeCycleStarted(LifeCycle event) {
-
- }
-
- @Override
- public void lifeCycleFailure(LifeCycle event, Throwable cause) {
-
- }
-
- @Override
- public void lifeCycleStopping(LifeCycle event) {
-
- }
-
- @Override
- public void lifeCycleStopped(LifeCycle event) {
-
- }
-}
diff --git a/libs/gretty-runner-jetty7/src/main/groovy/org/akhikhl/gretty/SSOAuthenticatorFactory.java b/libs/gretty-runner-jetty7/src/main/groovy/org/akhikhl/gretty/SSOAuthenticatorFactory.java
deleted file mode 100644
index 5395cfcca..000000000
--- a/libs/gretty-runner-jetty7/src/main/groovy/org/akhikhl/gretty/SSOAuthenticatorFactory.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Gretty
- *
- * Copyright (C) 2013-2015 Andrey Hihlovskiy and contributors.
- *
- * See the file "LICENSE" for copying and usage permission.
- * See the file "CONTRIBUTORS" for complete list of contributors.
- */
-package org.akhikhl.gretty;
-
-import org.eclipse.jetty.security.Authenticator.AuthConfiguration;
-import org.eclipse.jetty.security.DefaultAuthenticatorFactory;
-import org.eclipse.jetty.security.IdentityService;
-import org.eclipse.jetty.security.LoginService;
-import org.eclipse.jetty.server.Server;
-import org.eclipse.jetty.util.security.Constraint;
-
-import javax.servlet.ServletContext;
-
-/**
- *
- * @author akhikhl
- */
-public class SSOAuthenticatorFactory extends DefaultAuthenticatorFactory {
-
- @Override
- public org.eclipse.jetty.security.Authenticator getAuthenticator(Server server, ServletContext ctx, AuthConfiguration configuration, IdentityService identityService, LoginService loginService) {
- String auth = configuration.getAuthMethod();
- if (auth==null || Constraint.__BASIC_AUTH.equalsIgnoreCase(auth))
- return new SSOBasicAuthenticator();
- if (Constraint.__DIGEST_AUTH.equalsIgnoreCase(auth))
- return new SSODigestAuthenticator();
- if ( Constraint.__SPNEGO_AUTH.equalsIgnoreCase(auth) )
- return new SSOSpnegoAuthenticator();
- if ( Constraint.__NEGOTIATE_AUTH.equalsIgnoreCase(auth) ) // see Bug #377076
- return new SSOSpnegoAuthenticator(Constraint.__NEGOTIATE_AUTH);
- if (Constraint.__CERT_AUTH.equalsIgnoreCase(auth)||Constraint.__CERT_AUTH2.equalsIgnoreCase(auth))
- return new SSOClientCertAuthenticator();
- return super.getAuthenticator(server, ctx, configuration, identityService, loginService);
- }
-}
diff --git a/libs/gretty-runner-jetty7/src/main/groovy/org/akhikhl/gretty/SSOBasicAuthenticator.java b/libs/gretty-runner-jetty7/src/main/groovy/org/akhikhl/gretty/SSOBasicAuthenticator.java
deleted file mode 100644
index bb3a0a247..000000000
--- a/libs/gretty-runner-jetty7/src/main/groovy/org/akhikhl/gretty/SSOBasicAuthenticator.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Gretty
- *
- * Copyright (C) 2013-2015 Andrey Hihlovskiy and contributors.
- *
- * See the file "LICENSE" for copying and usage permission.
- * See the file "CONTRIBUTORS" for complete list of contributors.
- */
-package org.akhikhl.gretty;
-
-import org.eclipse.jetty.http.HttpMethods;
-import org.eclipse.jetty.security.ServerAuthException;
-import org.eclipse.jetty.security.authentication.BasicAuthenticator;
-import org.eclipse.jetty.security.authentication.DeferredAuthentication;
-import org.eclipse.jetty.security.authentication.SessionAuthentication;
-import org.eclipse.jetty.server.AbstractHttpConnection;
-import org.eclipse.jetty.server.Authentication;
-import org.eclipse.jetty.server.Request;
-import org.eclipse.jetty.util.MultiMap;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpSession;
-
-import static org.eclipse.jetty.security.authentication.FormAuthenticator.__J_POST;
-import static org.eclipse.jetty.security.authentication.FormAuthenticator.__J_URI;
-
-/**
- *
- * @author akhikhl
- */
-public class SSOBasicAuthenticator extends BasicAuthenticator {
-
- private static final Logger LOG = LoggerFactory.getLogger(SSOBasicAuthenticator.class);
-
- @Override
- public Authentication validateRequest(ServletRequest req, ServletResponse res, boolean mandatory) throws ServerAuthException
- {
- HttpServletRequest request = (HttpServletRequest)req;
-
- if (!mandatory)
- return new DeferredAuthentication(this);
-
- // ++ copied from FormAuthenticator
-
- HttpSession session = request.getSession(true);
-
- // Look for cached authentication
- Authentication authentication = (Authentication) session.getAttribute(SessionAuthentication.__J_AUTHENTICATED);
- if (authentication != null)
- {
- // Has authentication been revoked?
- if (authentication instanceof Authentication.User &&
- _loginService!=null &&
- !_loginService.validate(((Authentication.User)authentication).getUserIdentity()))
- {
-
- session.removeAttribute(SessionAuthentication.__J_AUTHENTICATED);
- }
- else
- {
- String j_uri=(String)session.getAttribute(__J_URI);
- if (j_uri!=null)
- {
- MultiMap j_post = (MultiMap)session.getAttribute(__J_POST);
- if (j_post!=null)
- {
- StringBuffer buf = request.getRequestURL();
- if (request.getQueryString() != null)
- buf.append("?").append(request.getQueryString());
-
- if (j_uri.equals(buf.toString()))
- {
- // This is a retry of an original POST request
- // so restore method and parameters
-
- session.removeAttribute(__J_POST);
- Request base_request = (req instanceof Request)?(Request)req:AbstractHttpConnection.getCurrentConnection().getRequest();
- base_request.setMethod(HttpMethods.POST);
- base_request.setParameters(j_post);
- }
- }
- else
- session.removeAttribute(__J_URI);
-
- }
- return authentication;
- }
- }
- // -- copied from FormAuthenticator
-
- return super.validateRequest(req, res, mandatory);
- }
-}
diff --git a/libs/gretty-runner-jetty7/src/main/groovy/org/akhikhl/gretty/SSOClientCertAuthenticator.java b/libs/gretty-runner-jetty7/src/main/groovy/org/akhikhl/gretty/SSOClientCertAuthenticator.java
deleted file mode 100644
index b9b2346ba..000000000
--- a/libs/gretty-runner-jetty7/src/main/groovy/org/akhikhl/gretty/SSOClientCertAuthenticator.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Gretty
- *
- * Copyright (C) 2013-2015 Andrey Hihlovskiy and contributors.
- *
- * See the file "LICENSE" for copying and usage permission.
- * See the file "CONTRIBUTORS" for complete list of contributors.
- */
-package org.akhikhl.gretty;
-
-import org.eclipse.jetty.http.HttpMethods;
-import org.eclipse.jetty.security.ServerAuthException;
-import org.eclipse.jetty.security.authentication.ClientCertAuthenticator;
-import org.eclipse.jetty.security.authentication.DeferredAuthentication;
-import org.eclipse.jetty.security.authentication.SessionAuthentication;
-import org.eclipse.jetty.server.AbstractHttpConnection;
-import org.eclipse.jetty.server.Authentication;
-import org.eclipse.jetty.server.Request;
-import org.eclipse.jetty.util.MultiMap;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpSession;
-
-import static org.eclipse.jetty.security.authentication.FormAuthenticator.__J_POST;
-import static org.eclipse.jetty.security.authentication.FormAuthenticator.__J_URI;
-
-/**
- *
- * @author akhikhl
- */
-public class SSOClientCertAuthenticator extends ClientCertAuthenticator {
-
- private static final Logger LOG = LoggerFactory.getLogger(SSOClientCertAuthenticator.class);
-
- @Override
- public Authentication validateRequest(ServletRequest req, ServletResponse res, boolean mandatory) throws ServerAuthException
- {
- HttpServletRequest request = (HttpServletRequest)req;
-
- if (!mandatory)
- return new DeferredAuthentication(this);
-
- // ++ copied from FormAuthenticator
-
- HttpSession session = request.getSession(true);
-
- // Look for cached authentication
- Authentication authentication = (Authentication) session.getAttribute(SessionAuthentication.__J_AUTHENTICATED);
- if (authentication != null)
- {
- // Has authentication been revoked?
- if (authentication instanceof Authentication.User &&
- _loginService!=null &&
- !_loginService.validate(((Authentication.User)authentication).getUserIdentity()))
- {
-
- session.removeAttribute(SessionAuthentication.__J_AUTHENTICATED);
- }
- else
- {
- String j_uri=(String)session.getAttribute(__J_URI);
- if (j_uri!=null)
- {
- MultiMap j_post = (MultiMap)session.getAttribute(__J_POST);
- if (j_post!=null)
- {
- StringBuffer buf = request.getRequestURL();
- if (request.getQueryString() != null)
- buf.append("?").append(request.getQueryString());
-
- if (j_uri.equals(buf.toString()))
- {
- // This is a retry of an original POST request
- // so restore method and parameters
-
- session.removeAttribute(__J_POST);
- Request base_request = (req instanceof Request)?(Request)req:AbstractHttpConnection.getCurrentConnection().getRequest();
- base_request.setMethod(HttpMethods.POST);
- base_request.setParameters(j_post);
- }
- }
- else
- session.removeAttribute(__J_URI);
-
- }
- return authentication;
- }
- }
- // -- copied from FormAuthenticator
-
- return super.validateRequest(req, res, mandatory);
- }
-}
diff --git a/libs/gretty-runner-jetty7/src/main/groovy/org/akhikhl/gretty/SSODigestAuthenticator.java b/libs/gretty-runner-jetty7/src/main/groovy/org/akhikhl/gretty/SSODigestAuthenticator.java
deleted file mode 100644
index 7e767bfb2..000000000
--- a/libs/gretty-runner-jetty7/src/main/groovy/org/akhikhl/gretty/SSODigestAuthenticator.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Gretty
- *
- * Copyright (C) 2013-2015 Andrey Hihlovskiy and contributors.
- *
- * See the file "LICENSE" for copying and usage permission.
- * See the file "CONTRIBUTORS" for complete list of contributors.
- */
-package org.akhikhl.gretty;
-
-import org.eclipse.jetty.http.HttpMethods;
-import org.eclipse.jetty.security.ServerAuthException;
-import org.eclipse.jetty.security.authentication.DeferredAuthentication;
-import org.eclipse.jetty.security.authentication.DigestAuthenticator;
-import org.eclipse.jetty.security.authentication.SessionAuthentication;
-import org.eclipse.jetty.server.AbstractHttpConnection;
-import org.eclipse.jetty.server.Authentication;
-import org.eclipse.jetty.server.Request;
-import org.eclipse.jetty.util.MultiMap;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpSession;
-
-import static org.eclipse.jetty.security.authentication.FormAuthenticator.__J_POST;
-import static org.eclipse.jetty.security.authentication.FormAuthenticator.__J_URI;
-
-/**
- *
- * @author akhikhl
- */
-class SSODigestAuthenticator extends DigestAuthenticator {
-
- private static final Logger LOG = LoggerFactory.getLogger(SSOBasicAuthenticator.class);
-
- @Override
- public Authentication validateRequest(ServletRequest req, ServletResponse res, boolean mandatory) throws ServerAuthException
- {
- HttpServletRequest request = (HttpServletRequest)req;
-
- if (!mandatory)
- return new DeferredAuthentication(this);
-
- // ++ copied from FormAuthenticator
-
- HttpSession session = request.getSession(true);
-
- // Look for cached authentication
- Authentication authentication = (Authentication) session.getAttribute(SessionAuthentication.__J_AUTHENTICATED);
- if (authentication != null)
- {
- // Has authentication been revoked?
- if (authentication instanceof Authentication.User &&
- _loginService!=null &&
- !_loginService.validate(((Authentication.User)authentication).getUserIdentity()))
- {
-
- session.removeAttribute(SessionAuthentication.__J_AUTHENTICATED);
- }
- else
- {
- String j_uri=(String)session.getAttribute(__J_URI);
- if (j_uri!=null)
- {
- MultiMap j_post = (MultiMap)session.getAttribute(__J_POST);
- if (j_post!=null)
- {
- StringBuffer buf = request.getRequestURL();
- if (request.getQueryString() != null)
- buf.append("?").append(request.getQueryString());
-
- if (j_uri.equals(buf.toString()))
- {
- // This is a retry of an original POST request
- // so restore method and parameters
-
- session.removeAttribute(__J_POST);
- Request base_request = (req instanceof Request)?(Request)req:AbstractHttpConnection.getCurrentConnection().getRequest();
- base_request.setMethod(HttpMethods.POST);
- base_request.setParameters(j_post);
- }
- }
- else
- session.removeAttribute(__J_URI);
-
- }
- return authentication;
- }
- }
- // -- copied from FormAuthenticator
-
- return super.validateRequest(req, res, mandatory);
- }
-}
diff --git a/libs/gretty-runner-jetty7/src/main/groovy/org/akhikhl/gretty/SSOSpnegoAuthenticator.java b/libs/gretty-runner-jetty7/src/main/groovy/org/akhikhl/gretty/SSOSpnegoAuthenticator.java
deleted file mode 100644
index ae4847109..000000000
--- a/libs/gretty-runner-jetty7/src/main/groovy/org/akhikhl/gretty/SSOSpnegoAuthenticator.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Gretty
- *
- * Copyright (C) 2013-2015 Andrey Hihlovskiy and contributors.
- *
- * See the file "LICENSE" for copying and usage permission.
- * See the file "CONTRIBUTORS" for complete list of contributors.
- */
-package org.akhikhl.gretty;
-
-import org.eclipse.jetty.http.HttpMethods;
-import org.eclipse.jetty.security.ServerAuthException;
-import org.eclipse.jetty.security.authentication.DeferredAuthentication;
-import org.eclipse.jetty.security.authentication.SessionAuthentication;
-import org.eclipse.jetty.security.authentication.SpnegoAuthenticator;
-import org.eclipse.jetty.server.AbstractHttpConnection;
-import org.eclipse.jetty.server.Authentication;
-import org.eclipse.jetty.server.Request;
-import org.eclipse.jetty.util.MultiMap;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpSession;
-
-import static org.eclipse.jetty.security.authentication.FormAuthenticator.__J_POST;
-import static org.eclipse.jetty.security.authentication.FormAuthenticator.__J_URI;
-
-/**
- *
- * @author akhikhl
- */
-public class SSOSpnegoAuthenticator extends SpnegoAuthenticator {
-
- private static final Logger LOG = LoggerFactory.getLogger(SSOSpnegoAuthenticator.class);
-
- public SSOSpnegoAuthenticator() {
- }
-
- public SSOSpnegoAuthenticator(String authMethod) {
- super(authMethod);
- }
-
- @Override
- public Authentication validateRequest(ServletRequest req, ServletResponse res, boolean mandatory) throws ServerAuthException
- {
- HttpServletRequest request = (HttpServletRequest)req;
-
- if (!mandatory)
- return new DeferredAuthentication(this);
-
- // ++ copied from FormAuthenticator
-
- HttpSession session = request.getSession(true);
-
- // Look for cached authentication
- Authentication authentication = (Authentication) session.getAttribute(SessionAuthentication.__J_AUTHENTICATED);
- if (authentication != null)
- {
- // Has authentication been revoked?
- if (authentication instanceof Authentication.User &&
- _loginService!=null &&
- !_loginService.validate(((Authentication.User)authentication).getUserIdentity()))
- {
-
- session.removeAttribute(SessionAuthentication.__J_AUTHENTICATED);
- }
- else
- {
- String j_uri=(String)session.getAttribute(__J_URI);
- if (j_uri!=null)
- {
- MultiMap j_post = (MultiMap)session.getAttribute(__J_POST);
- if (j_post!=null)
- {
- StringBuffer buf = request.getRequestURL();
- if (request.getQueryString() != null)
- buf.append("?").append(request.getQueryString());
-
- if (j_uri.equals(buf.toString()))
- {
- // This is a retry of an original POST request
- // so restore method and parameters
-
- session.removeAttribute(__J_POST);
- Request base_request = (req instanceof Request)?(Request)req:AbstractHttpConnection.getCurrentConnection().getRequest();
- base_request.setMethod(HttpMethods.POST);
- base_request.setParameters(j_post);
- }
- }
- else
- session.removeAttribute(__J_URI);
-
- }
- return authentication;
- }
- }
- // -- copied from FormAuthenticator
-
- return super.validateRequest(req, res, mandatory);
- }
-}
diff --git a/libs/gretty-runner-jetty7/src/main/groovy/org/akhikhl/gretty/WebInfConfigurationEx.groovy b/libs/gretty-runner-jetty7/src/main/groovy/org/akhikhl/gretty/WebInfConfigurationEx.groovy
deleted file mode 100644
index 6b10fa14b..000000000
--- a/libs/gretty-runner-jetty7/src/main/groovy/org/akhikhl/gretty/WebInfConfigurationEx.groovy
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Gretty
- *
- * Copyright (C) 2013-2015 Andrey Hihlovskiy and contributors.
- *
- * See the file "LICENSE" for copying and usage permission.
- * See the file "CONTRIBUTORS" for complete list of contributors.
- */
-package org.akhikhl.gretty
-
-import groovy.transform.CompileStatic
-import groovy.transform.TypeCheckingMode
-import org.eclipse.jetty.util.resource.Resource
-import org.eclipse.jetty.util.resource.ResourceCollection
-import org.eclipse.jetty.webapp.WebAppContext
-import org.eclipse.jetty.webapp.WebInfConfiguration
-
-@CompileStatic(TypeCheckingMode.SKIP)
-class WebInfConfigurationEx extends WebInfConfiguration implements BaseResourceConfiguration {
-
- private List extraResourceBases
- private final List baseResourceListeners = []
-
- @Override
- void addBaseResourceListener(Closure closure) {
- baseResourceListeners.add(closure)
- }
-
- @Override
- void setExtraResourceBases(List extraResourceBases) {
- this.extraResourceBases = extraResourceBases
- }
-
- @Override
- public void unpack (WebAppContext context) throws IOException {
- super.unpack(context)
- if(extraResourceBases) {
- Resource res = context.getBaseResource()
- List resources = []
- if(res instanceof ResourceCollection)
- resources.addAll(res.getResources())
- else
- resources.add(res)
- for(def e in extraResourceBases)
- resources.add(Resource.newResource(e))
- context.setBaseResource(new ResourceCollection(resources as Resource[]))
- }
- for(Closure closure in baseResourceListeners)
- closure(context)
- }
-}
diff --git a/libs/gretty-runner-jetty7/src/main/java/org/akhikhl/gretty/FilteringClassLoader.java b/libs/gretty-runner-jetty7/src/main/java/org/akhikhl/gretty/FilteringClassLoader.java
deleted file mode 100644
index 7d97d21d1..000000000
--- a/libs/gretty-runner-jetty7/src/main/java/org/akhikhl/gretty/FilteringClassLoader.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Gretty
- *
- * Copyright (C) 2013-2015 Andrey Hihlovskiy and contributors.
- *
- * See the file "LICENSE" for copying and usage permission.
- * See the file "CONTRIBUTORS" for complete list of contributors.
- */
-package org.akhikhl.gretty;
-
-import org.eclipse.jetty.webapp.WebAppClassLoader;
-
-import java.io.IOException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Enumeration;
-import java.util.List;
-
-/**
- * Properly implements "server classes" concept.
- *
- * @author akhikhl
- */
-public class FilteringClassLoader extends WebAppClassLoader {
-
- private final List serverClasses = new ArrayList();
-
- private final List serverResources = new ArrayList();
-
- private ClassLoader bootClassLoader;
-
- public FilteringClassLoader(Context context) throws IOException {
- super(context);
- findBootClassLoader();
- }
-
- public FilteringClassLoader(ClassLoader parent, Context context) throws IOException {
- super(parent, context);
- findBootClassLoader();
- }
-
- protected void findBootClassLoader() {
- bootClassLoader = getParent();
- if (bootClassLoader != null) {
- while(bootClassLoader.getParent() != null) {
- bootClassLoader = bootClassLoader.getParent();
- }
- }
- }
-
- public void addServerClass(String serverClass) {
- serverClasses.add(serverClass);
- serverResources.add(serverClass.replace('.', '/'));
- serverResources.add("META-INF/services/" + serverClass);
- }
-
- @Override
- protected Class> loadClass(String name, boolean resolve) throws ClassNotFoundException {
- for(String serverClass : serverClasses)
- if(name.startsWith(serverClass)) {
- Class> c = findLoadedClass(name);
- if(c == null)
- c = findClass(name);
- if(c != null) {
- if(resolve)
- resolveClass(c);
- return c;
- }
- throw new ClassNotFoundException(name);
- }
- return super.loadClass(name, resolve);
- }
-
- @Override
- public Enumeration getResources(String name) throws IOException {
- for(String serverResource : serverResources) {
- if(name.startsWith(serverResource)) {
- final List resources = new ArrayList<>();
- resources.addAll(Collections.list(getBootstrapResources(name)));
- resources.addAll(Collections.list(findResources(name)));
- return Collections.enumeration(resources);
- }
- }
- return super.getResources(name);
- }
-
- private Enumeration getBootstrapResources(String name) throws IOException {
- return bootClassLoader.getResources(name);
- }
-}
diff --git a/libs/gretty-runner-jetty7/src/main/resources/org/akhikhl/gretty/override-web.xml b/libs/gretty-runner-jetty7/src/main/resources/org/akhikhl/gretty/override-web.xml
deleted file mode 100644
index 6a6932d9c..000000000
--- a/libs/gretty-runner-jetty7/src/main/resources/org/akhikhl/gretty/override-web.xml
+++ /dev/null
@@ -1,74 +0,0 @@
-
-
-
- defaultex
- org.akhikhl.gretty.DefaultServletEx
-
- aliases
- false
-
-
- acceptRanges
- true
-
-
- dirAllowed
-
- false
-
-
- welcomeServlets
- false
-
-
- redirectWelcome
- false
-
-
- maxCacheSize
- 256000000
-
-
- maxCachedFileSize
- 200000000
-
-
- maxCachedFiles
- 2048
-
-
- gzip
- true
-
-
- useFileMappedBuffer
-
- false
-
-
-
- 0
-
-
-
- defaultex
- /
-
-
-
-
diff --git a/libs/gretty-runner-jetty8/build.gradle b/libs/gretty-runner-jetty8/build.gradle
deleted file mode 100644
index 6f12d4b43..000000000
--- a/libs/gretty-runner-jetty8/build.gradle
+++ /dev/null
@@ -1,19 +0,0 @@
-apply from: rootProject.file('common.gradle')
-
-configurations {
- compile {
- exclude group: 'org.eclipse.jetty.orbit', module: 'javax.servlet'
- }
-}
-
-dependencies {
- compile project(':libs:gretty-runner-jetty')
- compile "javax.servlet:javax.servlet-api:$jetty8_servlet_api_version"
- compile "org.eclipse.jetty:jetty-server:$jetty8_version"
- compile "org.eclipse.jetty:jetty-servlet:$jetty8_version"
- compile "org.eclipse.jetty:jetty-webapp:$jetty8_version"
- compile "org.eclipse.jetty:jetty-security:$jetty8_version"
- compile "org.eclipse.jetty:jetty-jsp:$jetty8_version"
- compile "org.eclipse.jetty:jetty-annotations:$jetty8_version"
- compile "org.eclipse.jetty:jetty-plus:$jetty8_version"
-}
diff --git a/libs/gretty-runner-jetty8/src/main/groovy/org/akhikhl/gretty/AnnotationConfigurationEx.groovy b/libs/gretty-runner-jetty8/src/main/groovy/org/akhikhl/gretty/AnnotationConfigurationEx.groovy
deleted file mode 100644
index d44457f01..000000000
--- a/libs/gretty-runner-jetty8/src/main/groovy/org/akhikhl/gretty/AnnotationConfigurationEx.groovy
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * Gretty
- *
- * Copyright (C) 2013-2015 Andrey Hihlovskiy and contributors.
- *
- * See the file "LICENSE" for copying and usage permission.
- * See the file "CONTRIBUTORS" for complete list of contributors.
- */
-package org.akhikhl.gretty
-
-import groovy.transform.CompileStatic
-import groovy.transform.TypeCheckingMode
-import org.eclipse.jetty.annotations.*
-import org.eclipse.jetty.annotations.AnnotationParser.DiscoverableAnnotationHandler
-import org.eclipse.jetty.util.MultiMap
-import org.eclipse.jetty.util.resource.Resource
-import org.eclipse.jetty.webapp.WebAppContext
-
-@CompileStatic(TypeCheckingMode.SKIP)
-class AnnotationConfigurationEx extends AnnotationConfiguration {
-
- private final Set classPath
-
- AnnotationConfigurationEx(List classPath) {
- this.classPath = classPath as LinkedHashSet
- }
-
- @Override
- public void configure(WebAppContext context) {
-
- context.addDecorator(new AnnotationDecorator(context))
-
- //Even if metadata is complete, we still need to scan for ServletContainerInitializers - if there are any
- if (!context.getMetaData().isMetaDataComplete()) {
- //If metadata isn't complete, if this is a servlet 3 webapp or isConfigDiscovered is true, we need to search for annotations
- if (context.getServletContext().getEffectiveMajorVersion() >= 3 || context.isConfigurationDiscovered()) {
- _discoverableAnnotationHandlers.add(new WebServletAnnotationHandler(context))
- _discoverableAnnotationHandlers.add(new WebFilterAnnotationHandler(context))
- _discoverableAnnotationHandlers.add(new WebListenerAnnotationHandler(context))
- }
- }
-
- MultiMap map = new MultiMap()
- context.setAttribute(CLASS_INHERITANCE_MAP, map)
- _classInheritanceHandler = new ClassInheritanceHandler(map) {
- public void handle(String className, int version, int access, String signature, String superName, String[] interfaces) {
- super.handle(className, version, access, signature, superName, interfaces)
- }
- }
-
- //Regardless of metadata, if there are any ServletContainerInitializers with @HandlesTypes, then we need to scan all the
- //classes so we can call their onStartup() methods correctly
- createServletContainerInitializerAnnotationHandlers(context, getNonExcludedInitializers(context))
-
- if (!_discoverableAnnotationHandlers.isEmpty() || _classInheritanceHandler != null || !_containerInitializerAnnotationHandlers.isEmpty()) {
-
- parseAnnotations(context)
-
- for (DiscoverableAnnotationHandler h : _discoverableAnnotationHandlers)
- context.getMetaData().addDiscoveredAnnotations(h.getAnnotationList())
- }
- }
-
- @Override
- protected AnnotationParser createAnnotationParser() {
- return new AnnotationParserEx()
- }
-
- private void parseAnnotations(WebAppContext context) {
-
- def containerIncludeJarPattern = context.getAttribute('org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern')
- if(containerIncludeJarPattern)
- containerIncludeJarPattern = java.util.regex.Pattern.compile(containerIncludeJarPattern)
-
- def containerExcludeJarPattern = context.getAttribute('org.eclipse.jetty.server.webapp.ContainerExcludeJarPattern')
- if(containerExcludeJarPattern)
- containerExcludeJarPattern = java.util.regex.Pattern.compile(containerExcludeJarPattern)
-
- AnnotationParser parser = createAnnotationParser()
-
- for(String classPathElem in classPath) {
- URL url = new URL(classPathElem)
- Resource res = Resource.newResource(url)
- if (res == null)
- continue
- if(containerIncludeJarPattern != null && !(url.toString() =~ containerIncludeJarPattern))
- continue
- if(containerExcludeJarPattern != null && (url.toString() =~ containerExcludeJarPattern))
- continue
-
- parser.clearHandlers()
- for (DiscoverableAnnotationHandler h : _discoverableAnnotationHandlers)
- if (h instanceof AbstractDiscoverableAnnotationHandler)
- ((AbstractDiscoverableAnnotationHandler)h).setResource(null)
-
- parser.registerHandlers(_discoverableAnnotationHandlers)
- parser.registerHandler(_classInheritanceHandler)
- parser.registerHandlers(_containerInitializerAnnotationHandlers)
-
- parser.parse(res, new ClassNameResolver() {
-
- @Override
- public boolean isExcluded (String name) {
- return context.isSystemClass(name)
- }
-
- @Override
- public boolean shouldOverride (String name) {
- //looking at webapp classpath, found already-parsed class of same name - did it come from system or duplicate in webapp?
- return !context.isParentLoaderPriority()
- }
- })
- }
- }
-}
-
diff --git a/libs/gretty-runner-jetty8/src/main/groovy/org/akhikhl/gretty/AnnotationParserEx.groovy b/libs/gretty-runner-jetty8/src/main/groovy/org/akhikhl/gretty/AnnotationParserEx.groovy
deleted file mode 100644
index fc63acfec..000000000
--- a/libs/gretty-runner-jetty8/src/main/groovy/org/akhikhl/gretty/AnnotationParserEx.groovy
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Gretty
- *
- * Copyright (C) 2013-2015 Andrey Hihlovskiy and contributors.
- *
- * See the file "LICENSE" for copying and usage permission.
- * See the file "CONTRIBUTORS" for complete list of contributors.
- */
-package org.akhikhl.gretty
-
-import org.eclipse.jetty.annotations.AnnotationParser
-import org.eclipse.jetty.annotations.ClassNameResolver
-import org.eclipse.jetty.util.MultiException
-import org.eclipse.jetty.util.log.Log
-import org.eclipse.jetty.util.log.Logger
-import org.eclipse.jetty.util.resource.Resource
-
-import java.util.jar.JarEntry
-import java.util.jar.JarInputStream
-
-/**
- *
- * @author akhikhl
- */
-class AnnotationParserEx extends AnnotationParser {
-
- private static final Logger LOG = Log.getLogger(AnnotationParserEx.class)
-
- private boolean isValidClassFileName (String name) {
- //no name cannot be valid
- if (name == null || name.length()==0)
- return false
-
- //skip anything that is not a class file
- if (!name.toLowerCase(Locale.ENGLISH).endsWith(".class")) {
- if (LOG.isDebugEnabled()) LOG.debug("Not a class: {}",name);
- return false;
- }
-
- //skip any classfiles that are not a valid java identifier
- int c0 = 0
- int ldir = name.lastIndexOf('/', name.length()-6)
- c0 = (ldir > -1 ? ldir+1 : c0)
- if (!Character.isJavaIdentifierStart(name.charAt(c0))) {
- if (LOG.isDebugEnabled()) LOG.debug("Not a java identifier: {}"+name)
- return false
- }
-
- return true
- }
-
- private boolean isValidClassFilePath (String path) {
- //no path is not valid
- if (path == null || path.length()==0)
- return false
-
- //skip any classfiles that are in a hidden directory
- if (path.startsWith(".") || path.contains("/.")) {
- if (LOG.isDebugEnabled()) LOG.debug("Contains hidden dirs: {}"+path)
- return false
- }
-
- return true
- }
-
- @Override
- public void parse(Resource res, ClassNameResolver resolver) {
- if(res.exists() && !res.isDirectory() && res.toString().endsWith('.jar'))
- parseJar(res, resolver)
- else
- super.parse(res, resolver)
- }
-
- protected void parseJar(Resource jarResource, ClassNameResolver resolver) {
-
- InputStream ins = jarResource.getInputStream()
- if (ins == null)
- return
-
- MultiException me = new MultiException()
-
- JarInputStream jar_in = new JarInputStream(ins)
- try {
- JarEntry entry = jar_in.getNextJarEntry()
- while(entry != null) {
- try {
- parseJarEntry(jarResource, entry, resolver)
- } catch (Exception e) {
- println "Error scanning entry "+entry.getName()+" from jar "+jarResource + " e=$e"
- me.add(new RuntimeException("Error scanning entry "+entry.getName()+" from jar "+jarResource, e))
- }
- entry = jar_in.getNextJarEntry()
- }
- } finally {
- jar_in.close()
- }
- me.ifExceptionThrow()
- }
-
- protected void parseJarEntry(Resource jar, JarEntry entry, final ClassNameResolver resolver) {
- if (jar == null || entry == null)
- return
-
- //skip directories
- if (entry.isDirectory())
- return
-
- String name = entry.getName()
-
- //check file is a valid class file name
- if (isValidClassFileName(name) && isValidClassFilePath(name)) {
-
- String shortName = name.replace('/', '.').substring(0,name.length()-6)
-
- if ((resolver == null)
- ||
- (!resolver.isExcluded(shortName) && (!isParsed(shortName) || resolver.shouldOverride(shortName)))) {
- Resource clazz = Resource.newResource("jar:"+jar.getURI()+"!/"+name)
- if (LOG.isDebugEnabled()) {
- LOG.debug("Scanning class from jar {}", clazz)
- }
- scanClass(clazz.getInputStream())
- }
- }
- }
-}
diff --git a/libs/gretty-runner-jetty8/src/main/groovy/org/akhikhl/gretty/JettyConfigurerImpl.groovy b/libs/gretty-runner-jetty8/src/main/groovy/org/akhikhl/gretty/JettyConfigurerImpl.groovy
deleted file mode 100644
index 5f6b8b03e..000000000
--- a/libs/gretty-runner-jetty8/src/main/groovy/org/akhikhl/gretty/JettyConfigurerImpl.groovy
+++ /dev/null
@@ -1,327 +0,0 @@
-/*
- * Gretty
- *
- * Copyright (C) 2013-2015 Andrey Hihlovskiy and contributors.
- *
- * See the file "LICENSE" for copying and usage permission.
- * See the file "CONTRIBUTORS" for complete list of contributors.
- */
-package org.akhikhl.gretty
-
-import groovy.transform.CompileStatic
-import groovy.transform.TypeCheckingMode
-import org.eclipse.jetty.plus.webapp.EnvConfiguration
-import org.eclipse.jetty.plus.webapp.PlusConfiguration
-import org.eclipse.jetty.security.HashLoginService
-import org.eclipse.jetty.server.Connector
-import org.eclipse.jetty.server.Handler
-import org.eclipse.jetty.server.Server
-import org.eclipse.jetty.server.bio.SocketConnector
-import org.eclipse.jetty.server.handler.ContextHandlerCollection
-import org.eclipse.jetty.server.session.HashSessionManager
-import org.eclipse.jetty.server.session.SessionHandler
-import org.eclipse.jetty.server.ssl.SslSocketConnector
-import org.eclipse.jetty.util.component.LifeCycle
-import org.eclipse.jetty.util.resource.Resource
-import org.eclipse.jetty.util.resource.ResourceCollection
-import org.eclipse.jetty.util.ssl.SslContextFactory
-import org.eclipse.jetty.webapp.*
-import org.eclipse.jetty.xml.XmlConfiguration
-import org.slf4j.Logger
-import org.slf4j.LoggerFactory
-
-/**
- *
- * @author akhikhl
- */
-@CompileStatic(TypeCheckingMode.SKIP)
-class JettyConfigurerImpl implements JettyConfigurer {
-
- private static final Logger log = LoggerFactory.getLogger(JettyConfigurerImpl)
-
- private SSOAuthenticatorFactory ssoAuthenticatorFactory
- private HashSessionManager sharedSessionManager
-
- @Override
- def addLifeCycleListener(lifecycle, listener) {
- def lifeCycleListener = listener as LifeCycleListenerAdapter
- lifecycle.addLifeCycleListener(lifeCycleListener)
- lifeCycleListener
- }
-
- @Override
- void applyContextConfigFile(webAppContext, URL contextConfigFile) {
- if(contextConfigFile) {
- log.info 'Configuring {} with {}', webAppContext.contextPath, contextConfigFile
- XmlConfiguration xmlConfiguration = new XmlConfiguration(contextConfigFile)
- xmlConfiguration.configure(webAppContext)
- }
- }
-
- @Override
- void applyJettyXml(server, String jettyXml) {
- if(jettyXml != null) {
- log.info 'Configuring server with {}', jettyXml
- XmlConfiguration xmlConfiguration = new XmlConfiguration(new File(jettyXml).toURI().toURL())
- xmlConfiguration.configure(server)
- }
- }
-
- @Override
- void configureConnectors(server, Map params) {
-
- Connector httpConn = findHttpConnector(server)
-
- boolean newConnector = false
- if(params.httpEnabled && !httpConn) {
- newConnector = true
- httpConn = new SocketConnector()
- httpConn.soLingerTime = -1
- }
-
- if(httpConn) {
- if(!httpConn.host)
- httpConn.host = params.host ?: ServerDefaults.defaultHost
-
- if(!httpConn.port)
- httpConn.port = params.httpPort ?: ServerDefaults.defaultHttpPort
-
- if(httpConn.port == PortUtils.RANDOM_FREE_PORT)
- httpConn.port = 0
-
- if(params.httpIdleTimeout)
- httpConn.maxIdleTime = params.httpIdleTimeout
-
- if(newConnector)
- server.addConnector(httpConn)
- }
-
- Connector httpsConn = findHttpsConnector(server)
-
- boolean newHttpsConnector = false
- if(params.httpsEnabled && !httpsConn) {
- newHttpsConnector = true
- httpsConn = new SslSocketConnector(new SslContextFactory())
- httpsConn.soLingerTime = -1
- }
-
- if(httpsConn) {
- if(!httpsConn.host)
- httpsConn.host = params.host ?: ServerDefaults.defaultHost
-
- if(!httpsConn.port)
- httpsConn.port = params.httpsPort ?: ServerDefaults.defaultHttpsPort
-
- if(httpsConn.port == PortUtils.RANDOM_FREE_PORT)
- httpsConn.port = 0
-
- def sslContextFactory = httpsConn.getSslContextFactory()
- if(params.sslKeyStorePath) {
- if(params.sslKeyStorePath.startsWith('classpath:')) {
- String resString = params.sslKeyStorePath - 'classpath:'
- URL url = getClass().getResource(resString)
- if(url == null)
- throw new Exception("Could not resource referenced in sslKeyStorePath: '${resString}'")
- sslContextFactory.setKeyStoreResource(Resource.newResource(url))
- }
- else
- sslContextFactory.setKeyStorePath(params.sslKeyStorePath)
- }
- if(params.sslKeyStorePassword)
- sslContextFactory.setKeyStorePassword(params.sslKeyStorePassword)
- if(params.sslKeyManagerPassword)
- sslContextFactory.setKeyManagerPassword(params.sslKeyManagerPassword)
- if(params.sslTrustStorePath) {
- if(params.sslTrustStorePath.startsWith('classpath:')) {
- String resString = params.sslTrustStorePath - 'classpath:'
- URL url = getClass().getResource(resString)
- if(url == null)
- throw new Exception("Could not resource referenced in sslTrustStorePath: '${resString}'")
- sslContextFactory.setTrustStoreResource(Resource.newResource(url))
- }
- else
- sslContextFactory.setTrustStorePath(params.sslTrustStorePath)
- }
- if(params.sslTrustStorePassword)
- sslContextFactory.setTrustStorePassword(params.sslTrustStorePassword)
- if(params.sslNeedClientAuth)
- sslContextFactory.setNeedClientAuth(params.sslNeedClientAuth)
-
- if(params.httpsIdleTimeout)
- httpsConn.maxIdleTime = params.httpsIdleTimeout
-
- if(newHttpsConnector)
- server.addConnector(httpsConn)
- }
- }
-
- @Override
- void configureSecurity(context, String realm, String realmConfigFile, boolean singleSignOn) {
- context.securityHandler.loginService = new HashLoginService(realm, realmConfigFile)
- if(singleSignOn) {
- if(ssoAuthenticatorFactory == null)
- ssoAuthenticatorFactory = new SSOAuthenticatorFactory()
- context.securityHandler.authenticatorFactory = ssoAuthenticatorFactory
- }
- }
-
- @Override
- void configureSessionManager(server, context, Map serverParams, Map webappParams) {
- HashSessionManager sessionManager
- if(serverParams.singleSignOn) {
- sessionManager = sharedSessionManager
- if(sessionManager == null) {
- sessionManager = sharedSessionManager = new HashSessionManager() {
-
- }
- sessionManager.setMaxInactiveInterval(60 * 30) // 30 minutes
- sessionManager.getSessionCookieConfig().setPath('/')
- }
- } else {
- sessionManager = new HashSessionManager()
- sessionManager.setMaxInactiveInterval(60 * 30) // 30 minutes
- }
- def sessionHandler = new SessionHandler(sessionManager)
- // By setting server we fix bug with older jetty versions: sessionHandler produces NullPointerException, when session manager is reassigned.
- sessionHandler.setServer(server)
- context.setSessionHandler(sessionHandler)
- }
-
- @Override
- def createResourceCollection(List paths) {
- new ResourceCollection(paths as String[])
- }
-
- @Override
- def createServer() {
- // fix for issue https://github.com/akhikhl/gretty/issues/24
- org.eclipse.jetty.util.resource.Resource.defaultUseCaches = false
- return new Server()
- }
-
- @Override
- def createWebAppContext(Map serverParams, Map webappParams) {
- List webappClassPath = webappParams.webappClassPath
- JettyWebAppContext context = new JettyWebAppContext()
- context.setWebInfLib(webappClassPath.findAll { it.endsWith('.jar') }.collect { new File(it) })
- context.setExtraClasspath(webappClassPath.collect { it.endsWith('.jar') ? it : (it.endsWith('/') ? it : it + '/') }.join(';'))
- if (webappParams.webXml != null) context.setDescriptor(webappParams.webXml);
- FilteringClassLoader classLoader = new FilteringClassLoader(context)
- classLoader.addServerClass('ch.qos.logback.')
- classLoader.addServerClass('org.apache.groovy.')
- classLoader.addServerClass('org.slf4j.')
- classLoader.addServerClass('org.codehaus.groovy.')
- classLoader.addServerClass('groovy.')
- classLoader.addServerClass('groovyx.')
- classLoader.addServerClass('groovyjarjarantlr.')
- classLoader.addServerClass('groovyjarjarasm.')
- classLoader.addServerClass('groovyjarjarcommonscli.')
- context.classLoader = classLoader
- context.addLifeCycleListener(new LifeCycleListenerAdapter() {
- public void lifeCycleStopped(LifeCycle event) {
- context.classLoader = null
- }
- })
- context.setAttribute('org.eclipse.jetty.server.webapp.ContainerExcludeJarPattern', getAnnotationExcludeJarPattern())
- return context
- }
-
- @Override
- def findHttpConnector(server) {
- server.connectors.find { (it instanceof SocketConnector) && !(it instanceof SslSocketConnector) }
- }
-
- @Override
- def findHttpsConnector(server) {
- server.connectors.find { it instanceof SslSocketConnector }
- }
-
- @Override
- URL findResourceURL(baseResource, String path) {
- Resource res
- if(baseResource instanceof ResourceCollection)
- res = baseResource.findResource(path)
- else
- res = baseResource.addPath(path)
- if(res.exists())
- return res.getURL()
- null
- }
-
- private String getAnnotationExcludeJarPattern() {
- String result
- URLConnection resConn = this.getClass().getResource('AnnotationExcludeJarPattern.txt').openConnection()
- // this fixes exceptions when reloading classes in running application
- resConn.setUseCaches(false)
- resConn.getInputStream().withStream {
- result = it.readLines('UTF-8').join('|')
- }
- result
- }
-
- @Override
- List getConfigurations(Map webappParams) {
- [
- new WebInfConfigurationEx(),
- new WebXmlConfiguration(),
- new MetaInfConfiguration(),
- new FragmentConfiguration(),
- new EnvConfiguration(),
- new PlusConfiguration(),
- new AnnotationConfigurationEx(webappParams.webappClassPath),
- new JettyWebXmlConfiguration()
- ]
- }
-
- @Override
- void removeLifeCycleListener(lifecycle, listener) {
- lifecycle.removeLifeCycleListener(listener)
- }
-
- @Override
- void setConfigurationsToWebAppContext(webAppContext, List configurations) {
- webAppContext.setConfigurations(configurations as Configuration[])
- }
-
-
- private ContextHandlerCollection findContextHandlerCollection(Handler handler) {
- if(handler instanceof ContextHandlerCollection)
- return handler
- if(handler.respondsTo('getHandlers'))
- return handler.getHandlers().findResult { findContextHandlerCollection(it) }
- return null
- }
-
- @Override
- void setHandlersToServer(server, List handlers) {
- ContextHandlerCollection contexts = findContextHandlerCollection(server.handler)
- if(!contexts)
- contexts = new ContextHandlerCollection()
-
- contexts.setHandlers(handlers as Handler[])
- if(server.handler == null)
- server.handler = contexts
- }
-
- @Override
- List getHandlersByContextPaths(server, List contextPaths) {
- ContextHandlerCollection context = findContextHandlerCollection(((Server)server).handler)
- return context.getHandlers().findAll {
- if(it.respondsTo("getContextPath")) {
- contextPaths.contains(it.getContextPath())
- }
- }
- }
-
- @Override
- void removeHandlerFromServer(server, handler) {
- def collection = findContextHandlerCollection(server.handler)
- collection.removeHandler(handler)
- }
-
- @Override
- void addHandlerToServer(server, handler) {
- def collection = findContextHandlerCollection(server.handler)
- collection.addHandler(handler)
- }
-}
diff --git a/libs/gretty-runner-jetty8/src/main/groovy/org/akhikhl/gretty/JettyWebAppContext.groovy b/libs/gretty-runner-jetty8/src/main/groovy/org/akhikhl/gretty/JettyWebAppContext.groovy
deleted file mode 100644
index a065241a4..000000000
--- a/libs/gretty-runner-jetty8/src/main/groovy/org/akhikhl/gretty/JettyWebAppContext.groovy
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Gretty
- *
- * Copyright (C) 2013-2015 Andrey Hihlovskiy and contributors.
- *
- * See the file "LICENSE" for copying and usage permission.
- * See the file "CONTRIBUTORS" for complete list of contributors.
- */
-package org.akhikhl.gretty
-
-import org.eclipse.jetty.util.URIUtil
-import org.eclipse.jetty.util.log.Log
-import org.eclipse.jetty.util.log.Logger
-import org.eclipse.jetty.util.resource.Resource
-import org.eclipse.jetty.webapp.WebAppContext
-
-/**
- * Inspired by maven-jetty-plugin's JettyWebAppContext
- *
- * @author sala
- */
-class JettyWebAppContext extends WebAppContext {
-
- private static final Logger LOG = Log.getLogger(JettyWebAppContext.class)
-
- private static final String WEB_INF_LIB_PREFIX = '/WEB-INF/lib'
- private final Map webInfJarMap = [:]
- private final List webInfJars = []
-
- void setWebInfLib (List jars) {
- webInfJars.addAll(jars);
- }
-
- @Override
- protected void doStart() throws Exception {
- // preparing our pathes patch
- webInfJarMap.clear()
- webInfJars.each {
- String fileName = it.getName()
- if(fileName.endsWith('.jar')) {
- webInfJarMap.put(fileName, it)
- }
- }
- super.doStart()
- }
-
- @Override
- protected void doStop() throws Exception {
- // cancelling our pathes patch
- if(webInfJarMap != null) {
- webInfJarMap.clear()
- }
- webInfJars.clear()
- super.doStop()
- }
-
- @Override
- Set getResourcePaths(String path) {
- Set paths = super.getResourcePaths(path)
- // Tinkering with pathes, adding pathes provided manually
- if(path != null) {
- def allPaths = new TreeSet()
- allPaths.addAll(paths)
-
- if(path.startsWith(WEB_INF_LIB_PREFIX)) {
- webInfJarMap.keySet().each {
- allPaths.add(WEB_INF_LIB_PREFIX + '/' + it)
- }
- }
- return allPaths
- }
-
- return paths
- }
-
- @Override
- Resource getResource(String uriInContext) throws MalformedURLException {
- Resource resource = super.getResource(uriInContext)
-
- if((resource == null || !resource.exists()) && uriInContext != null) {
- String uri = URIUtil.canonicalPath(uriInContext)
- if(uri == null) {
- return null
- }
-
- try {
- if(uri.startsWith(WEB_INF_LIB_PREFIX)) {
- String jarName = uri.replace(WEB_INF_LIB_PREFIX, '')
- if(jarName.startsWith('/') || jarName.startsWith('\\')) {
- jarName = jarName.substring(1)
- }
- if(jarName.isEmpty()) {
- return null
- }
- File jarFile = webInfJarMap.get(jarName)
- if(jarFile != null) {
- return Resource.newResource(jarFile.getPath())
- }
- return null;
- }
- } catch (MalformedURLException e) {
- throw e;
- } catch (IOException e) {
- LOG.ignore(e)
- }
- }
- return resource
- }
-}
diff --git a/libs/gretty-runner-jetty8/src/main/groovy/org/akhikhl/gretty/LifeCycleListenerAdapter.java b/libs/gretty-runner-jetty8/src/main/groovy/org/akhikhl/gretty/LifeCycleListenerAdapter.java
deleted file mode 100644
index 2ccf906ca..000000000
--- a/libs/gretty-runner-jetty8/src/main/groovy/org/akhikhl/gretty/LifeCycleListenerAdapter.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Gretty
- *
- * Copyright (C) 2013-2015 Andrey Hihlovskiy and contributors.
- *
- * See the file "LICENSE" for copying and usage permission.
- * See the file "CONTRIBUTORS" for complete list of contributors.
- */
-package org.akhikhl.gretty;
-
-import org.eclipse.jetty.util.component.LifeCycle;
-
-/**
- *
- * @author akhikhl
- */
-public class LifeCycleListenerAdapter implements LifeCycle.Listener {
-
- @Override
- public void lifeCycleStarting(LifeCycle event) {
-
- }
-
- @Override
- public void lifeCycleStarted(LifeCycle event) {
-
- }
-
- @Override
- public void lifeCycleFailure(LifeCycle event, Throwable cause) {
-
- }
-
- @Override
- public void lifeCycleStopping(LifeCycle event) {
-
- }
-
- @Override
- public void lifeCycleStopped(LifeCycle event) {
-
- }
-}
diff --git a/libs/gretty-runner-jetty8/src/main/groovy/org/akhikhl/gretty/SSOAuthenticatorFactory.java b/libs/gretty-runner-jetty8/src/main/groovy/org/akhikhl/gretty/SSOAuthenticatorFactory.java
deleted file mode 100644
index 5395cfcca..000000000
--- a/libs/gretty-runner-jetty8/src/main/groovy/org/akhikhl/gretty/SSOAuthenticatorFactory.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Gretty
- *
- * Copyright (C) 2013-2015 Andrey Hihlovskiy and contributors.
- *
- * See the file "LICENSE" for copying and usage permission.
- * See the file "CONTRIBUTORS" for complete list of contributors.
- */
-package org.akhikhl.gretty;
-
-import org.eclipse.jetty.security.Authenticator.AuthConfiguration;
-import org.eclipse.jetty.security.DefaultAuthenticatorFactory;
-import org.eclipse.jetty.security.IdentityService;
-import org.eclipse.jetty.security.LoginService;
-import org.eclipse.jetty.server.Server;
-import org.eclipse.jetty.util.security.Constraint;
-
-import javax.servlet.ServletContext;
-
-/**
- *
- * @author akhikhl
- */
-public class SSOAuthenticatorFactory extends DefaultAuthenticatorFactory {
-
- @Override
- public org.eclipse.jetty.security.Authenticator getAuthenticator(Server server, ServletContext ctx, AuthConfiguration configuration, IdentityService identityService, LoginService loginService) {
- String auth = configuration.getAuthMethod();
- if (auth==null || Constraint.__BASIC_AUTH.equalsIgnoreCase(auth))
- return new SSOBasicAuthenticator();
- if (Constraint.__DIGEST_AUTH.equalsIgnoreCase(auth))
- return new SSODigestAuthenticator();
- if ( Constraint.__SPNEGO_AUTH.equalsIgnoreCase(auth) )
- return new SSOSpnegoAuthenticator();
- if ( Constraint.__NEGOTIATE_AUTH.equalsIgnoreCase(auth) ) // see Bug #377076
- return new SSOSpnegoAuthenticator(Constraint.__NEGOTIATE_AUTH);
- if (Constraint.__CERT_AUTH.equalsIgnoreCase(auth)||Constraint.__CERT_AUTH2.equalsIgnoreCase(auth))
- return new SSOClientCertAuthenticator();
- return super.getAuthenticator(server, ctx, configuration, identityService, loginService);
- }
-}
diff --git a/libs/gretty-runner-jetty8/src/main/groovy/org/akhikhl/gretty/SSOBasicAuthenticator.java b/libs/gretty-runner-jetty8/src/main/groovy/org/akhikhl/gretty/SSOBasicAuthenticator.java
deleted file mode 100644
index cde2d1e66..000000000
--- a/libs/gretty-runner-jetty8/src/main/groovy/org/akhikhl/gretty/SSOBasicAuthenticator.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Gretty
- *
- * Copyright (C) 2013-2015 Andrey Hihlovskiy and contributors.
- *
- * See the file "LICENSE" for copying and usage permission.
- * See the file "CONTRIBUTORS" for complete list of contributors.
- */
-package org.akhikhl.gretty;
-
-import org.eclipse.jetty.http.HttpMethods;
-import org.eclipse.jetty.security.ServerAuthException;
-import org.eclipse.jetty.security.authentication.BasicAuthenticator;
-import org.eclipse.jetty.security.authentication.DeferredAuthentication;
-import org.eclipse.jetty.security.authentication.SessionAuthentication;
-import org.eclipse.jetty.server.AbstractHttpConnection;
-import org.eclipse.jetty.server.Authentication;
-import org.eclipse.jetty.server.Request;
-import org.eclipse.jetty.server.UserIdentity;
-import org.eclipse.jetty.util.MultiMap;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpSession;
-
-import static org.eclipse.jetty.security.authentication.FormAuthenticator.__J_POST;
-import static org.eclipse.jetty.security.authentication.FormAuthenticator.__J_URI;
-
-/**
- *
- * @author akhikhl
- */
-public class SSOBasicAuthenticator extends BasicAuthenticator {
-
- private static final Logger LOG = LoggerFactory.getLogger(SSOBasicAuthenticator.class);
-
- // "login" is copied without changes from FormAuthenticator
- @Override
- public UserIdentity login(String username, Object password, ServletRequest request)
- {
-
- UserIdentity user = super.login(username,password,request);
- if (user!=null)
- {
- HttpSession session = ((HttpServletRequest)request).getSession(true);
- Authentication cached=new SessionAuthentication(getAuthMethod(),user,password);
- session.setAttribute(SessionAuthentication.__J_AUTHENTICATED, cached);
- }
- return user;
- }
-
- @Override
- public Authentication validateRequest(ServletRequest req, ServletResponse res, boolean mandatory) throws ServerAuthException
- {
- HttpServletRequest request = (HttpServletRequest)req;
-
- if (!mandatory)
- return new DeferredAuthentication(this);
-
- // ++ copied from FormAuthenticator
-
- HttpSession session = request.getSession(true);
-
- // Look for cached authentication
- Authentication authentication = (Authentication) session.getAttribute(SessionAuthentication.__J_AUTHENTICATED);
- if (authentication != null)
- {
- // Has authentication been revoked?
- if (authentication instanceof Authentication.User &&
- _loginService!=null &&
- !_loginService.validate(((Authentication.User)authentication).getUserIdentity()))
- {
-
- session.removeAttribute(SessionAuthentication.__J_AUTHENTICATED);
- }
- else
- {
- String j_uri=(String)session.getAttribute(__J_URI);
- if (j_uri!=null)
- {
- MultiMap j_post = (MultiMap)session.getAttribute(__J_POST);
- if (j_post!=null)
- {
- StringBuffer buf = request.getRequestURL();
- if (request.getQueryString() != null)
- buf.append("?").append(request.getQueryString());
-
- if (j_uri.equals(buf.toString()))
- {
- // This is a retry of an original POST request
- // so restore method and parameters
-
- session.removeAttribute(__J_POST);
- Request base_request = (req instanceof Request)?(Request)req:AbstractHttpConnection.getCurrentConnection().getRequest();
- base_request.setMethod(HttpMethods.POST);
- base_request.setParameters(j_post);
- }
- }
- else
- session.removeAttribute(__J_URI);
-
- }
- return authentication;
- }
- }
- // -- copied from FormAuthenticator
-
- return super.validateRequest(req, res, mandatory);
- }
-}
diff --git a/libs/gretty-runner-jetty8/src/main/groovy/org/akhikhl/gretty/SSOClientCertAuthenticator.java b/libs/gretty-runner-jetty8/src/main/groovy/org/akhikhl/gretty/SSOClientCertAuthenticator.java
deleted file mode 100644
index 637a7ed50..000000000
--- a/libs/gretty-runner-jetty8/src/main/groovy/org/akhikhl/gretty/SSOClientCertAuthenticator.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Gretty
- *
- * Copyright (C) 2013-2015 Andrey Hihlovskiy and contributors.
- *
- * See the file "LICENSE" for copying and usage permission.
- * See the file "CONTRIBUTORS" for complete list of contributors.
- */
-package org.akhikhl.gretty;
-
-import org.eclipse.jetty.http.HttpMethods;
-import org.eclipse.jetty.security.ServerAuthException;
-import org.eclipse.jetty.security.authentication.ClientCertAuthenticator;
-import org.eclipse.jetty.security.authentication.DeferredAuthentication;
-import org.eclipse.jetty.security.authentication.SessionAuthentication;
-import org.eclipse.jetty.server.AbstractHttpConnection;
-import org.eclipse.jetty.server.Authentication;
-import org.eclipse.jetty.server.Request;
-import org.eclipse.jetty.server.UserIdentity;
-import org.eclipse.jetty.util.MultiMap;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpSession;
-
-import static org.eclipse.jetty.security.authentication.FormAuthenticator.__J_POST;
-import static org.eclipse.jetty.security.authentication.FormAuthenticator.__J_URI;
-
-/**
- *
- * @author akhikhl
- */
-public class SSOClientCertAuthenticator extends ClientCertAuthenticator {
-
- private static final Logger LOG = LoggerFactory.getLogger(SSOClientCertAuthenticator.class);
-
- // "login" is copied without changes from FormAuthenticator
- @Override
- public UserIdentity login(String username, Object password, ServletRequest request)
- {
-
- UserIdentity user = super.login(username,password,request);
- if (user!=null)
- {
- HttpSession session = ((HttpServletRequest)request).getSession(true);
- Authentication cached=new SessionAuthentication(getAuthMethod(),user,password);
- session.setAttribute(SessionAuthentication.__J_AUTHENTICATED, cached);
- }
- return user;
- }
-
- @Override
- public Authentication validateRequest(ServletRequest req, ServletResponse res, boolean mandatory) throws ServerAuthException
- {
- HttpServletRequest request = (HttpServletRequest)req;
-
- if (!mandatory)
- return new DeferredAuthentication(this);
-
- // ++ copied from FormAuthenticator
-
- HttpSession session = request.getSession(true);
-
- // Look for cached authentication
- Authentication authentication = (Authentication) session.getAttribute(SessionAuthentication.__J_AUTHENTICATED);
- if (authentication != null)
- {
- // Has authentication been revoked?
- if (authentication instanceof Authentication.User &&
- _loginService!=null &&
- !_loginService.validate(((Authentication.User)authentication).getUserIdentity()))
- {
-
- session.removeAttribute(SessionAuthentication.__J_AUTHENTICATED);
- }
- else
- {
- String j_uri=(String)session.getAttribute(__J_URI);
- if (j_uri!=null)
- {
- MultiMap j_post = (MultiMap)session.getAttribute(__J_POST);
- if (j_post!=null)
- {
- StringBuffer buf = request.getRequestURL();
- if (request.getQueryString() != null)
- buf.append("?").append(request.getQueryString());
-
- if (j_uri.equals(buf.toString()))
- {
- // This is a retry of an original POST request
- // so restore method and parameters
-
- session.removeAttribute(__J_POST);
- Request base_request = (req instanceof Request)?(Request)req:AbstractHttpConnection.getCurrentConnection().getRequest();
- base_request.setMethod(HttpMethods.POST);
- base_request.setParameters(j_post);
- }
- }
- else
- session.removeAttribute(__J_URI);
-
- }
- return authentication;
- }
- }
- // -- copied from FormAuthenticator
-
- return super.validateRequest(req, res, mandatory);
- }
-}
diff --git a/libs/gretty-runner-jetty8/src/main/groovy/org/akhikhl/gretty/SSODigestAuthenticator.java b/libs/gretty-runner-jetty8/src/main/groovy/org/akhikhl/gretty/SSODigestAuthenticator.java
deleted file mode 100644
index 30cbfef4b..000000000
--- a/libs/gretty-runner-jetty8/src/main/groovy/org/akhikhl/gretty/SSODigestAuthenticator.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Gretty
- *
- * Copyright (C) 2013-2015 Andrey Hihlovskiy and contributors.
- *
- * See the file "LICENSE" for copying and usage permission.
- * See the file "CONTRIBUTORS" for complete list of contributors.
- */
-package org.akhikhl.gretty;
-
-import org.eclipse.jetty.http.HttpMethods;
-import org.eclipse.jetty.security.ServerAuthException;
-import org.eclipse.jetty.security.authentication.DeferredAuthentication;
-import org.eclipse.jetty.security.authentication.DigestAuthenticator;
-import org.eclipse.jetty.security.authentication.SessionAuthentication;
-import org.eclipse.jetty.server.AbstractHttpConnection;
-import org.eclipse.jetty.server.Authentication;
-import org.eclipse.jetty.server.Request;
-import org.eclipse.jetty.server.UserIdentity;
-import org.eclipse.jetty.util.MultiMap;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpSession;
-
-import static org.eclipse.jetty.security.authentication.FormAuthenticator.__J_POST;
-import static org.eclipse.jetty.security.authentication.FormAuthenticator.__J_URI;
-
-/**
- *
- * @author akhikhl
- */
-class SSODigestAuthenticator extends DigestAuthenticator {
-
- private static final Logger LOG = LoggerFactory.getLogger(SSOBasicAuthenticator.class);
-
- // "login" is copied without changes from FormAuthenticator
- @Override
- public UserIdentity login(String username, Object password, ServletRequest request)
- {
-
- UserIdentity user = super.login(username,password,request);
- if (user!=null)
- {
- HttpSession session = ((HttpServletRequest)request).getSession(true);
- Authentication cached=new SessionAuthentication(getAuthMethod(),user,password);
- session.setAttribute(SessionAuthentication.__J_AUTHENTICATED, cached);
- }
- return user;
- }
-
- @Override
- public Authentication validateRequest(ServletRequest req, ServletResponse res, boolean mandatory) throws ServerAuthException
- {
- HttpServletRequest request = (HttpServletRequest)req;
-
- if (!mandatory)
- return new DeferredAuthentication(this);
-
- // ++ copied from FormAuthenticator
-
- HttpSession session = request.getSession(true);
-
- // Look for cached authentication
- Authentication authentication = (Authentication) session.getAttribute(SessionAuthentication.__J_AUTHENTICATED);
- if (authentication != null)
- {
- // Has authentication been revoked?
- if (authentication instanceof Authentication.User &&
- _loginService!=null &&
- !_loginService.validate(((Authentication.User)authentication).getUserIdentity()))
- {
-
- session.removeAttribute(SessionAuthentication.__J_AUTHENTICATED);
- }
- else
- {
- String j_uri=(String)session.getAttribute(__J_URI);
- if (j_uri!=null)
- {
- MultiMap j_post = (MultiMap)session.getAttribute(__J_POST);
- if (j_post!=null)
- {
- StringBuffer buf = request.getRequestURL();
- if (request.getQueryString() != null)
- buf.append("?").append(request.getQueryString());
-
- if (j_uri.equals(buf.toString()))
- {
- // This is a retry of an original POST request
- // so restore method and parameters
-
- session.removeAttribute(__J_POST);
- Request base_request = (req instanceof Request)?(Request)req:AbstractHttpConnection.getCurrentConnection().getRequest();
- base_request.setMethod(HttpMethods.POST);
- base_request.setParameters(j_post);
- }
- }
- else
- session.removeAttribute(__J_URI);
-
- }
- return authentication;
- }
- }
- // -- copied from FormAuthenticator
-
- return super.validateRequest(req, res, mandatory);
- }
-}
diff --git a/libs/gretty-runner-jetty8/src/main/groovy/org/akhikhl/gretty/SSOSpnegoAuthenticator.java b/libs/gretty-runner-jetty8/src/main/groovy/org/akhikhl/gretty/SSOSpnegoAuthenticator.java
deleted file mode 100644
index 2f7146a38..000000000
--- a/libs/gretty-runner-jetty8/src/main/groovy/org/akhikhl/gretty/SSOSpnegoAuthenticator.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * Gretty
- *
- * Copyright (C) 2013-2015 Andrey Hihlovskiy and contributors.
- *
- * See the file "LICENSE" for copying and usage permission.
- * See the file "CONTRIBUTORS" for complete list of contributors.
- */
-package org.akhikhl.gretty;
-
-import org.eclipse.jetty.http.HttpMethods;
-import org.eclipse.jetty.security.ServerAuthException;
-import org.eclipse.jetty.security.authentication.DeferredAuthentication;
-import org.eclipse.jetty.security.authentication.SessionAuthentication;
-import org.eclipse.jetty.security.authentication.SpnegoAuthenticator;
-import org.eclipse.jetty.server.AbstractHttpConnection;
-import org.eclipse.jetty.server.Authentication;
-import org.eclipse.jetty.server.Request;
-import org.eclipse.jetty.server.UserIdentity;
-import org.eclipse.jetty.util.MultiMap;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpSession;
-
-import static org.eclipse.jetty.security.authentication.FormAuthenticator.__J_POST;
-import static org.eclipse.jetty.security.authentication.FormAuthenticator.__J_URI;
-
-/**
- *
- * @author akhikhl
- */
-public class SSOSpnegoAuthenticator extends SpnegoAuthenticator {
-
- private static final Logger LOG = LoggerFactory.getLogger(SSOSpnegoAuthenticator.class);
-
- public SSOSpnegoAuthenticator() {
- }
-
- public SSOSpnegoAuthenticator(String authMethod) {
- super(authMethod);
- }
-
- // "login" is copied without changes from FormAuthenticator
- @Override
- public UserIdentity login(String username, Object password, ServletRequest request)
- {
-
- UserIdentity user = super.login(username,password,request);
- if (user!=null)
- {
- HttpSession session = ((HttpServletRequest)request).getSession(true);
- Authentication cached=new SessionAuthentication(getAuthMethod(),user,password);
- session.setAttribute(SessionAuthentication.__J_AUTHENTICATED, cached);
- }
- return user;
- }
-
- @Override
- public Authentication validateRequest(ServletRequest req, ServletResponse res, boolean mandatory) throws ServerAuthException
- {
- HttpServletRequest request = (HttpServletRequest)req;
-
- if (!mandatory)
- return new DeferredAuthentication(this);
-
- // ++ copied from FormAuthenticator
-
- HttpSession session = request.getSession(true);
-
- // Look for cached authentication
- Authentication authentication = (Authentication) session.getAttribute(SessionAuthentication.__J_AUTHENTICATED);
- if (authentication != null)
- {
- // Has authentication been revoked?
- if (authentication instanceof Authentication.User &&
- _loginService!=null &&
- !_loginService.validate(((Authentication.User)authentication).getUserIdentity()))
- {
-
- session.removeAttribute(SessionAuthentication.__J_AUTHENTICATED);
- }
- else
- {
- String j_uri=(String)session.getAttribute(__J_URI);
- if (j_uri!=null)
- {
- MultiMap j_post = (MultiMap)session.getAttribute(__J_POST);
- if (j_post!=null)
- {
- StringBuffer buf = request.getRequestURL();
- if (request.getQueryString() != null)
- buf.append("?").append(request.getQueryString());
-
- if (j_uri.equals(buf.toString()))
- {
- // This is a retry of an original POST request
- // so restore method and parameters
-
- session.removeAttribute(__J_POST);
- Request base_request = (req instanceof Request)?(Request)req:AbstractHttpConnection.getCurrentConnection().getRequest();
- base_request.setMethod(HttpMethods.POST);
- base_request.setParameters(j_post);
- }
- }
- else
- session.removeAttribute(__J_URI);
-
- }
- return authentication;
- }
- }
- // -- copied from FormAuthenticator
-
- return super.validateRequest(req, res, mandatory);
- }
-}
diff --git a/libs/gretty-runner-jetty8/src/main/groovy/org/akhikhl/gretty/WebInfConfigurationEx.groovy b/libs/gretty-runner-jetty8/src/main/groovy/org/akhikhl/gretty/WebInfConfigurationEx.groovy
deleted file mode 100644
index 5946aca8a..000000000
--- a/libs/gretty-runner-jetty8/src/main/groovy/org/akhikhl/gretty/WebInfConfigurationEx.groovy
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * Gretty
- *
- * Copyright (C) 2013-2015 Andrey Hihlovskiy and contributors.
- *
- * See the file "LICENSE" for copying and usage permission.
- * See the file "CONTRIBUTORS" for complete list of contributors.
- */
-package org.akhikhl.gretty
-
-import groovy.transform.CompileStatic
-import groovy.transform.TypeCheckingMode
-import org.eclipse.jetty.util.resource.Resource
-import org.eclipse.jetty.util.resource.ResourceCollection
-import org.eclipse.jetty.webapp.WebAppContext
-import org.eclipse.jetty.webapp.WebInfConfiguration
-
-@CompileStatic(TypeCheckingMode.SKIP)
-class WebInfConfigurationEx extends WebInfConfiguration implements BaseResourceConfiguration {
-
- private List extraResourceBases
- private final List baseResourceListeners = []
-
- @Override
- void addBaseResourceListener(Closure closure) {
- baseResourceListeners.add(closure)
- }
-
- // backported from jetty-9
- @Override
- protected List findJars(WebAppContext context) throws Exception {
- List jarResources = new ArrayList();
- List webInfLibJars = findWebInfLibJars(context);
- if (webInfLibJars != null)
- jarResources.addAll(webInfLibJars);
- List extraClasspathJars = findExtraClasspathJars(context);
- if (extraClasspathJars != null)
- jarResources.addAll(extraClasspathJars);
- return jarResources;
- }
-
- // backported from jetty-9
- protected List findWebInfLibJars(WebAppContext context) throws Exception {
- Resource web_inf = context.getWebInf();
- if (web_inf==null || !web_inf.exists())
- return null;
-
- List jarResources = new ArrayList();
- Resource web_inf_lib = web_inf.addPath("/lib");
- if (web_inf_lib.exists() && web_inf_lib.isDirectory())
- {
- String[] files=web_inf_lib.list();
- for (int f=0;files!=null && f findExtraClasspathJars(WebAppContext context) throws Exception {
- if (context == null || context.getExtraClasspath() == null)
- return null;
-
- List jarResources = new ArrayList();
- StringTokenizer tokenizer = new StringTokenizer(context.getExtraClasspath(), ",;");
- while (tokenizer.hasMoreTokens())
- {
- Resource resource = context.newResource(tokenizer.nextToken().trim());
- String fnlc = resource.getName().toLowerCase(Locale.ENGLISH);
- int dot = fnlc.lastIndexOf('.');
- String extension = (dot < 0 ? null : fnlc.substring(dot));
- if (extension != null && (extension.equals(".jar") || extension.equals(".zip")))
- {
- jarResources.add(resource);
- }
- }
-
- return jarResources;
- }
-
- @Override
- void setExtraResourceBases(List extraResourceBases) {
- this.extraResourceBases = extraResourceBases
- }
-
- @Override
- public void unpack (WebAppContext context) throws IOException {
- super.unpack(context)
- if(extraResourceBases) {
- Resource res = context.getBaseResource()
- List resources = []
- if(res instanceof ResourceCollection)
- resources.addAll(res.getResources())
- else
- resources.add(res)
- for(def e in extraResourceBases)
- resources.add(Resource.newResource(e))
- context.setBaseResource(new ResourceCollection(resources as Resource[]))
- }
- for(Closure closure in baseResourceListeners)
- closure(context)
- }
-}
diff --git a/libs/gretty-runner-jetty8/src/main/java/org/akhikhl/gretty/FilteringClassLoader.java b/libs/gretty-runner-jetty8/src/main/java/org/akhikhl/gretty/FilteringClassLoader.java
deleted file mode 100644
index 7d97d21d1..000000000
--- a/libs/gretty-runner-jetty8/src/main/java/org/akhikhl/gretty/FilteringClassLoader.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Gretty
- *
- * Copyright (C) 2013-2015 Andrey Hihlovskiy and contributors.
- *
- * See the file "LICENSE" for copying and usage permission.
- * See the file "CONTRIBUTORS" for complete list of contributors.
- */
-package org.akhikhl.gretty;
-
-import org.eclipse.jetty.webapp.WebAppClassLoader;
-
-import java.io.IOException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Enumeration;
-import java.util.List;
-
-/**
- * Properly implements "server classes" concept.
- *
- * @author akhikhl
- */
-public class FilteringClassLoader extends WebAppClassLoader {
-
- private final List serverClasses = new ArrayList();
-
- private final List serverResources = new ArrayList();
-
- private ClassLoader bootClassLoader;
-
- public FilteringClassLoader(Context context) throws IOException {
- super(context);
- findBootClassLoader();
- }
-
- public FilteringClassLoader(ClassLoader parent, Context context) throws IOException {
- super(parent, context);
- findBootClassLoader();
- }
-
- protected void findBootClassLoader() {
- bootClassLoader = getParent();
- if (bootClassLoader != null) {
- while(bootClassLoader.getParent() != null) {
- bootClassLoader = bootClassLoader.getParent();
- }
- }
- }
-
- public void addServerClass(String serverClass) {
- serverClasses.add(serverClass);
- serverResources.add(serverClass.replace('.', '/'));
- serverResources.add("META-INF/services/" + serverClass);
- }
-
- @Override
- protected Class> loadClass(String name, boolean resolve) throws ClassNotFoundException {
- for(String serverClass : serverClasses)
- if(name.startsWith(serverClass)) {
- Class> c = findLoadedClass(name);
- if(c == null)
- c = findClass(name);
- if(c != null) {
- if(resolve)
- resolveClass(c);
- return c;
- }
- throw new ClassNotFoundException(name);
- }
- return super.loadClass(name, resolve);
- }
-
- @Override
- public Enumeration getResources(String name) throws IOException {
- for(String serverResource : serverResources) {
- if(name.startsWith(serverResource)) {
- final List resources = new ArrayList<>();
- resources.addAll(Collections.list(getBootstrapResources(name)));
- resources.addAll(Collections.list(findResources(name)));
- return Collections.enumeration(resources);
- }
- }
- return super.getResources(name);
- }
-
- private Enumeration getBootstrapResources(String name) throws IOException {
- return bootClassLoader.getResources(name);
- }
-}
diff --git a/libs/gretty-runner-jetty8/src/main/resources/org/akhikhl/gretty/AnnotationExcludeJarPattern.txt b/libs/gretty-runner-jetty8/src/main/resources/org/akhikhl/gretty/AnnotationExcludeJarPattern.txt
deleted file mode 100644
index 0f21dac67..000000000
--- a/libs/gretty-runner-jetty8/src/main/resources/org/akhikhl/gretty/AnnotationExcludeJarPattern.txt
+++ /dev/null
@@ -1,44 +0,0 @@
-\baopalliance-((\d+)\.)*(\d)+
-\bbootstrap-((\d+)\.)*(\d)+
-\bclassmate-((\d+)\.)*(\d)+
-\bcommons-beanutils\b
-\bcommons-codec\b
-\bcommons-collections\b
-\bcommons-lang\b
-\bcommons-logging\b
-\bezmorph-((\d+)\.)*(\d)+
-\bgroovy-all\b
-\bhibernate-validator\b
-\bhttp-builder-((\d+)\.)*(\d)+
-\bhttpclient-((\d+)\.)*(\d)+
-\bhttpcore-((\d+)\.)*(\d)+
-\bjackson-annotations\b
-\bjackson-core\b
-\bjackson-databind\b
-\bjavax.servlet-api-((\d+)\.)*(\d)+
-\bjavax.websocket-api-((\d+)\.)*(\d)+
-\bjboss-logging\b
-\bjcl-over-slf4j\b
-\bjquery-((\d+)\.)*(\d)+
-\bjson-lib-((\d+)\.)*(\d)+
-\bjul-to-slf4j\b
-\blog4j-over-slf4j\b
-\blogback-classic\b+
-\blogback-core\b+
-\bnekohtml-((\d+)\.)*(\d)+
-\bslf4j-api\b
-\bsnakeyaml-((\d+)\.)*(\d)+
-\bspring-aop\b
-\bspring-beans\b
-\bspring-boot-autoconfigure\b
-\bspring-boot-starter\b
-\bspring-context\b
-\bspring-core\b
-\bspring-expression\b
-\bspring-messaging\b
-\bspring-web\b
-\bspring-webmvc\b
-\bspring-websocket\b
-\bvalidation-api\b
-\bxercesImpl-((\d+)\.)*(\d)+
-\bxml-resolver-((\d+)\.)*(\d)+
diff --git a/libs/gretty-runner-jetty9/build.gradle b/libs/gretty-runner-jetty9/build.gradle
deleted file mode 100644
index bef952d0c..000000000
--- a/libs/gretty-runner-jetty9/build.gradle
+++ /dev/null
@@ -1,22 +0,0 @@
-apply from: rootProject.file('common.gradle')
-
-configurations {
- compile {
- exclude group: 'org.eclipse.jetty.orbit', module: 'javax.servlet'
- }
-}
-
-dependencies {
- compile project(':libs:gretty-runner-jetty')
- compile "javax.servlet:javax.servlet-api:$jetty9_servlet_api_version"
- compile "org.eclipse.jetty:jetty-server:$jetty9_version"
- compile "org.eclipse.jetty:jetty-servlet:$jetty9_version"
- compile "org.eclipse.jetty:jetty-webapp:$jetty9_version"
- compile "org.eclipse.jetty:jetty-security:$jetty9_version"
- compile "org.eclipse.jetty:jetty-jsp:$jetty9_version"
- compile "org.eclipse.jetty:jetty-annotations:$jetty9_version"
- compile "org.eclipse.jetty:jetty-plus:$jetty9_version"
- compile "org.eclipse.jetty.websocket:javax-websocket-server-impl:$jetty9_version"
- compile "org.ow2.asm:asm:$asm_version"
- compile "org.ow2.asm:asm-commons:$asm_version"
-}
diff --git a/libs/gretty-runner-jetty9/src/main/groovy/org/akhikhl/gretty/JettyConfigurerImpl.groovy b/libs/gretty-runner-jetty9/src/main/groovy/org/akhikhl/gretty/JettyConfigurerImpl.groovy
deleted file mode 100644
index e6fdf423d..000000000
--- a/libs/gretty-runner-jetty9/src/main/groovy/org/akhikhl/gretty/JettyConfigurerImpl.groovy
+++ /dev/null
@@ -1,321 +0,0 @@
-/*
- * Gretty
- *
- * Copyright (C) 2013-2015 Andrey Hihlovskiy and contributors.
- *
- * See the file "LICENSE" for copying and usage permission.
- * See the file "CONTRIBUTORS" for complete list of contributors.
- */
-package org.akhikhl.gretty
-
-import groovy.transform.CompileStatic
-import groovy.transform.TypeCheckingMode
-import org.eclipse.jetty.annotations.AnnotationConfiguration
-import org.eclipse.jetty.plus.webapp.EnvConfiguration
-import org.eclipse.jetty.plus.webapp.PlusConfiguration
-import org.eclipse.jetty.security.HashLoginService
-import org.eclipse.jetty.server.*
-import org.eclipse.jetty.server.handler.ContextHandlerCollection
-import org.eclipse.jetty.server.session.HashSessionManager
-import org.eclipse.jetty.util.component.LifeCycle
-import org.eclipse.jetty.util.resource.FileResource
-import org.eclipse.jetty.util.resource.Resource
-import org.eclipse.jetty.util.resource.ResourceCollection
-import org.eclipse.jetty.util.ssl.SslContextFactory
-import org.eclipse.jetty.webapp.*
-import org.eclipse.jetty.xml.XmlConfiguration
-import org.slf4j.Logger
-import org.slf4j.LoggerFactory
-
-/**
- *
- * @author akhikhl
- */
-@CompileStatic(TypeCheckingMode.SKIP)
-class JettyConfigurerImpl implements JettyConfigurer {
-
- private static final Logger log = LoggerFactory.getLogger(JettyConfigurerImpl)
-
- private SSOAuthenticatorFactory ssoAuthenticatorFactory
- private HashSessionManager sharedSessionManager
-
- @Override
- def addLifeCycleListener(lifecycle, listener) {
- def lifeCycleListener = listener as LifeCycleListenerAdapter
- lifecycle.addLifeCycleListener(lifeCycleListener)
- lifeCycleListener
- }
-
- @Override
- void applyContextConfigFile(webAppContext, URL contextConfigFile) {
- if(contextConfigFile) {
- log.info 'Configuring {} with {}', webAppContext.contextPath, contextConfigFile
- XmlConfiguration xmlConfiguration = new XmlConfiguration(contextConfigFile)
- xmlConfiguration.configure(webAppContext)
- }
- }
-
- @Override
- void applyJettyXml(server, String jettyXml) {
- if(jettyXml != null) {
- log.info 'Configuring server with {}', jettyXml
- XmlConfiguration xmlConfiguration = new XmlConfiguration(new File(jettyXml).toURI().toURL())
- xmlConfiguration.configure(server)
- }
- }
-
- @Override
- void configureConnectors(server, Map params) {
-
- HttpConfiguration http_config = new HttpConfiguration()
- if(params.httpsPort) {
- http_config.setSecureScheme('https')
- http_config.setSecurePort(params.httpsPort)
- }
-
- Connector httpConn = findHttpConnector(server)
-
- boolean newHttpConnector = false
- if(params.httpEnabled && !httpConn) {
- newHttpConnector = true
- httpConn = new ServerConnector(server, new HttpConnectionFactory(http_config))
- httpConn.soLingerTime = -1
- }
-
- if(httpConn) {
- if(!httpConn.host)
- httpConn.host = params.host ?: ServerDefaults.defaultHost
-
- if(!httpConn.port)
- httpConn.port = params.httpPort ?: ServerDefaults.defaultHttpPort
-
- if(httpConn.port == PortUtils.RANDOM_FREE_PORT)
- httpConn.port = 0
-
- if(params.httpIdleTimeout)
- httpConn.idleTimeout = params.httpIdleTimeout
-
- if(newHttpConnector)
- server.addConnector(httpConn)
- }
-
- Connector httpsConn = findHttpsConnector(server)
-
- boolean newHttpsConnector = false
- if(params.httpsEnabled && !httpsConn) {
- newHttpsConnector = true
- HttpConfiguration https_config = new HttpConfiguration(http_config)
- https_config.addCustomizer(new SecureRequestCustomizer())
- httpsConn = new ServerConnector(server,
- new SslConnectionFactory(new SslContextFactory(), 'http/1.1'),
- new HttpConnectionFactory(https_config))
- httpsConn.soLingerTime = -1
- }
-
- if(httpsConn) {
- if(!httpsConn.host)
- httpsConn.host = params.host ?: ServerDefaults.defaultHost
-
- if(!httpsConn.port)
- httpsConn.port = params.httpsPort ?: ServerDefaults.defaultHttpsPort
-
- if(httpsConn.port == PortUtils.RANDOM_FREE_PORT)
- httpsConn.port = 0
-
- def sslContextFactory = httpsConn.getConnectionFactories().find { it instanceof SslConnectionFactory }?.getSslContextFactory()
- if(sslContextFactory) {
- if(params.sslKeyStorePath) {
- if(params.sslKeyStorePath.startsWith('classpath:')) {
- String resString = params.sslKeyStorePath - 'classpath:'
- URL url = getClass().getResource(resString)
- if(url == null)
- throw new Exception("Could not resource referenced in sslKeyStorePath: '${resString}'")
- sslContextFactory.setKeyStoreResource(new FileResource(url))
- }
- else
- sslContextFactory.setKeyStorePath(params.sslKeyStorePath)
- }
- if(params.sslKeyStorePassword)
- sslContextFactory.setKeyStorePassword(params.sslKeyStorePassword)
- if(params.sslKeyManagerPassword)
- sslContextFactory.setKeyManagerPassword(params.sslKeyManagerPassword)
- if(params.sslTrustStorePath) {
- if(params.sslTrustStorePath.startsWith('classpath:')) {
- String resString = params.sslTrustStorePath - 'classpath:'
- URL url = getClass().getResource(resString)
- if(url == null)
- throw new Exception("Could not resource referenced in sslTrustStorePath: '${resString}'")
- sslContextFactory.setTrustStoreResource(new FileResource(url))
- }
- else
- sslContextFactory.setTrustStorePath(params.sslTrustStorePath)
- }
- if(params.sslTrustStorePassword)
- sslContextFactory.setTrustStorePassword(params.sslTrustStorePassword)
- if(params.sslNeedClientAuth)
- sslContextFactory.setNeedClientAuth(params.sslNeedClientAuth)
- }
-
- if(params.httpsIdleTimeout)
- httpsConn.idleTimeout = params.httpsIdleTimeout
-
- if(newHttpsConnector)
- server.addConnector(httpsConn)
- }
- }
-
- @Override
- void configureSecurity(context, String realm, String realmConfigFile, boolean singleSignOn) {
- context.securityHandler.loginService = new HashLoginService(realm, realmConfigFile)
- if(singleSignOn) {
- if(ssoAuthenticatorFactory == null)
- ssoAuthenticatorFactory = new SSOAuthenticatorFactory()
- context.securityHandler.authenticatorFactory = ssoAuthenticatorFactory
- }
- }
-
- @Override
- void configureSessionManager(server, context, Map serverParams, Map webappParams) {
- HashSessionManager sessionManager
- if(serverParams.singleSignOn) {
- sessionManager = sharedSessionManager
- if(sessionManager == null) {
- sessionManager = sharedSessionManager = new HashSessionManager()
- sessionManager.setMaxInactiveInterval(60 * 30) // 30 minutes
- sessionManager.getSessionCookieConfig().setPath('/')
- }
- } else {
- sessionManager = new HashSessionManager()
- sessionManager.setMaxInactiveInterval(60 * 30) // 30 minutes
- }
- context.getSessionHandler().setSessionManager(sessionManager)
- }
-
- @Override
- def createResourceCollection(List paths) {
- new ResourceCollection(paths as String[])
- }
-
- @Override
- def createServer() {
- // fix for issue https://github.com/akhikhl/gretty/issues/24
- org.eclipse.jetty.util.resource.Resource.defaultUseCaches = false
- return new Server()
- }
-
- @Override
- def createWebAppContext(Map serverParams, Map webappParams) {
- List webappClassPath = webappParams.webappClassPath
- String webappClasspathScanPattern = webappParams.webInfIncludeJarPattern
- JettyWebAppContext context = new JettyWebAppContext()
- context.setAttribute("org.eclipse.jetty.server.webapp.WebInfIncludeJarPattern", webappClasspathScanPattern)
- context.setWebInfLib(webappClassPath.findAll { it.endsWith('.jar') }.collect { new File(it) })
- context.setExtraClasspath(webappClassPath.collect { it.endsWith('.jar') ? it : (it.endsWith('/') ? it : it + '/') }.join(';'))
- context.setInitParameter('org.eclipse.jetty.servlet.Default.useFileMappedBuffer', serverParams.productMode ? 'true' : 'false')
- if (webappParams.webXml != null) context.setDescriptor(webappParams.webXml);
- FilteringClassLoader classLoader = new FilteringClassLoader(context)
- classLoader.addServerClass('ch.qos.logback.')
- classLoader.addServerClass('org.slf4j.')
- classLoader.addServerClass('org.codehaus.groovy.')
- classLoader.addServerClass('groovy.')
- classLoader.addServerClass('groovyx.')
- classLoader.addServerClass('groovyjarjarantlr.')
- classLoader.addServerClass('groovyjarjarasm.')
- classLoader.addServerClass('groovyjarjarcommonscli.')
- context.classLoader = classLoader
- context.addLifeCycleListener(new LifeCycleListenerAdapter() {
- public void lifeCycleStopped(LifeCycle event) {
- context.classLoader = null
- }
- })
- return context
- }
-
- @Override
- def findHttpConnector(server) {
- server.connectors.find { it.connectionFactories.find { it.protocol.startsWith('HTTP') } && !it.connectionFactories.find { it.protocol.startsWith('SSL') } }
- }
-
- @Override
- def findHttpsConnector(server) {
- server.connectors.find { it.connectionFactories.find { it.protocol.startsWith('HTTP') } && it.connectionFactories.find { it.protocol.startsWith('SSL') } }
- }
-
- @Override
- URL findResourceURL(baseResource, String path) {
- Resource res
- if(baseResource instanceof ResourceCollection)
- res = baseResource.findResource(path)
- else
- res = baseResource.addPath(path)
- if(res.exists())
- return res.getURL()
- null
- }
-
- @Override
- List getConfigurations(Map webappParams) {
- [
- new WebInfConfigurationEx(),
- new WebXmlConfiguration(),
- new MetaInfConfiguration(),
- new FragmentConfiguration(),
- new EnvConfiguration(),
- new PlusConfiguration(),
- new AnnotationConfiguration(),
- new JettyWebXmlConfiguration()
- ]
- }
-
- @Override
- void removeLifeCycleListener(lifecycle, listener) {
- lifecycle.removeLifeCycleListener(listener)
- }
-
- @Override
- void setConfigurationsToWebAppContext(webAppContext, List configurations) {
- webAppContext.setConfigurations(configurations as Configuration[])
- }
-
- private ContextHandlerCollection findContextHandlerCollection(Handler handler) {
- if(handler instanceof ContextHandlerCollection)
- return handler
- if(handler.respondsTo('getHandlers'))
- return handler.getHandlers().findResult { findContextHandlerCollection(it) }
- null
- }
-
- @Override
- void setHandlersToServer(server, List handlers) {
- ContextHandlerCollection contexts = findContextHandlerCollection(server.handler)
- if(!contexts)
- contexts = new ContextHandlerCollection()
-
- contexts.setHandlers(handlers as Handler[])
- if(server.handler == null)
- server.handler = contexts
- }
-
- @Override
- List getHandlersByContextPaths(server, List contextPaths) {
- ContextHandlerCollection context = findContextHandlerCollection(((Server)server).handler)
- return context.getHandlers().findAll {
- if(it.respondsTo("getContextPath")) {
- contextPaths.contains(it.getContextPath())
- }
- }
- }
-
- @Override
- void removeHandlerFromServer(server, handler) {
- def collection = findContextHandlerCollection(server.handler)
- collection.removeHandler(handler)
- }
-
- @Override
- void addHandlerToServer(server, handler) {
- def collection = findContextHandlerCollection(server.handler)
- collection.addHandler(handler)
- }
-
-}
diff --git a/libs/gretty-runner-jetty9/src/main/groovy/org/akhikhl/gretty/JettyWebAppContext.groovy b/libs/gretty-runner-jetty9/src/main/groovy/org/akhikhl/gretty/JettyWebAppContext.groovy
deleted file mode 100644
index a065241a4..000000000
--- a/libs/gretty-runner-jetty9/src/main/groovy/org/akhikhl/gretty/JettyWebAppContext.groovy
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Gretty
- *
- * Copyright (C) 2013-2015 Andrey Hihlovskiy and contributors.
- *
- * See the file "LICENSE" for copying and usage permission.
- * See the file "CONTRIBUTORS" for complete list of contributors.
- */
-package org.akhikhl.gretty
-
-import org.eclipse.jetty.util.URIUtil
-import org.eclipse.jetty.util.log.Log
-import org.eclipse.jetty.util.log.Logger
-import org.eclipse.jetty.util.resource.Resource
-import org.eclipse.jetty.webapp.WebAppContext
-
-/**
- * Inspired by maven-jetty-plugin's JettyWebAppContext
- *
- * @author sala
- */
-class JettyWebAppContext extends WebAppContext {
-
- private static final Logger LOG = Log.getLogger(JettyWebAppContext.class)
-
- private static final String WEB_INF_LIB_PREFIX = '/WEB-INF/lib'
- private final Map webInfJarMap = [:]
- private final List webInfJars = []
-
- void setWebInfLib (List jars) {
- webInfJars.addAll(jars);
- }
-
- @Override
- protected void doStart() throws Exception {
- // preparing our pathes patch
- webInfJarMap.clear()
- webInfJars.each {
- String fileName = it.getName()
- if(fileName.endsWith('.jar')) {
- webInfJarMap.put(fileName, it)
- }
- }
- super.doStart()
- }
-
- @Override
- protected void doStop() throws Exception {
- // cancelling our pathes patch
- if(webInfJarMap != null) {
- webInfJarMap.clear()
- }
- webInfJars.clear()
- super.doStop()
- }
-
- @Override
- Set getResourcePaths(String path) {
- Set paths = super.getResourcePaths(path)
- // Tinkering with pathes, adding pathes provided manually
- if(path != null) {
- def allPaths = new TreeSet()
- allPaths.addAll(paths)
-
- if(path.startsWith(WEB_INF_LIB_PREFIX)) {
- webInfJarMap.keySet().each {
- allPaths.add(WEB_INF_LIB_PREFIX + '/' + it)
- }
- }
- return allPaths
- }
-
- return paths
- }
-
- @Override
- Resource getResource(String uriInContext) throws MalformedURLException {
- Resource resource = super.getResource(uriInContext)
-
- if((resource == null || !resource.exists()) && uriInContext != null) {
- String uri = URIUtil.canonicalPath(uriInContext)
- if(uri == null) {
- return null
- }
-
- try {
- if(uri.startsWith(WEB_INF_LIB_PREFIX)) {
- String jarName = uri.replace(WEB_INF_LIB_PREFIX, '')
- if(jarName.startsWith('/') || jarName.startsWith('\\')) {
- jarName = jarName.substring(1)
- }
- if(jarName.isEmpty()) {
- return null
- }
- File jarFile = webInfJarMap.get(jarName)
- if(jarFile != null) {
- return Resource.newResource(jarFile.getPath())
- }
- return null;
- }
- } catch (MalformedURLException e) {
- throw e;
- } catch (IOException e) {
- LOG.ignore(e)
- }
- }
- return resource
- }
-}
diff --git a/libs/gretty-runner-jetty9/src/main/groovy/org/akhikhl/gretty/LifeCycleListenerAdapter.java b/libs/gretty-runner-jetty9/src/main/groovy/org/akhikhl/gretty/LifeCycleListenerAdapter.java
deleted file mode 100644
index 2ccf906ca..000000000
--- a/libs/gretty-runner-jetty9/src/main/groovy/org/akhikhl/gretty/LifeCycleListenerAdapter.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Gretty
- *
- * Copyright (C) 2013-2015 Andrey Hihlovskiy and contributors.
- *
- * See the file "LICENSE" for copying and usage permission.
- * See the file "CONTRIBUTORS" for complete list of contributors.
- */
-package org.akhikhl.gretty;
-
-import org.eclipse.jetty.util.component.LifeCycle;
-
-/**
- *
- * @author akhikhl
- */
-public class LifeCycleListenerAdapter implements LifeCycle.Listener {
-
- @Override
- public void lifeCycleStarting(LifeCycle event) {
-
- }
-
- @Override
- public void lifeCycleStarted(LifeCycle event) {
-
- }
-
- @Override
- public void lifeCycleFailure(LifeCycle event, Throwable cause) {
-
- }
-
- @Override
- public void lifeCycleStopping(LifeCycle event) {
-
- }
-
- @Override
- public void lifeCycleStopped(LifeCycle event) {
-
- }
-}
diff --git a/libs/gretty-runner-jetty9/src/main/groovy/org/akhikhl/gretty/SSOAuthenticatorFactory.java b/libs/gretty-runner-jetty9/src/main/groovy/org/akhikhl/gretty/SSOAuthenticatorFactory.java
deleted file mode 100644
index 5395cfcca..000000000
--- a/libs/gretty-runner-jetty9/src/main/groovy/org/akhikhl/gretty/SSOAuthenticatorFactory.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Gretty
- *
- * Copyright (C) 2013-2015 Andrey Hihlovskiy and contributors.
- *
- * See the file "LICENSE" for copying and usage permission.
- * See the file "CONTRIBUTORS" for complete list of contributors.
- */
-package org.akhikhl.gretty;
-
-import org.eclipse.jetty.security.Authenticator.AuthConfiguration;
-import org.eclipse.jetty.security.DefaultAuthenticatorFactory;
-import org.eclipse.jetty.security.IdentityService;
-import org.eclipse.jetty.security.LoginService;
-import org.eclipse.jetty.server.Server;
-import org.eclipse.jetty.util.security.Constraint;
-
-import javax.servlet.ServletContext;
-
-/**
- *
- * @author akhikhl
- */
-public class SSOAuthenticatorFactory extends DefaultAuthenticatorFactory {
-
- @Override
- public org.eclipse.jetty.security.Authenticator getAuthenticator(Server server, ServletContext ctx, AuthConfiguration configuration, IdentityService identityService, LoginService loginService) {
- String auth = configuration.getAuthMethod();
- if (auth==null || Constraint.__BASIC_AUTH.equalsIgnoreCase(auth))
- return new SSOBasicAuthenticator();
- if (Constraint.__DIGEST_AUTH.equalsIgnoreCase(auth))
- return new SSODigestAuthenticator();
- if ( Constraint.__SPNEGO_AUTH.equalsIgnoreCase(auth) )
- return new SSOSpnegoAuthenticator();
- if ( Constraint.__NEGOTIATE_AUTH.equalsIgnoreCase(auth) ) // see Bug #377076
- return new SSOSpnegoAuthenticator(Constraint.__NEGOTIATE_AUTH);
- if (Constraint.__CERT_AUTH.equalsIgnoreCase(auth)||Constraint.__CERT_AUTH2.equalsIgnoreCase(auth))
- return new SSOClientCertAuthenticator();
- return super.getAuthenticator(server, ctx, configuration, identityService, loginService);
- }
-}
diff --git a/libs/gretty-runner-jetty9/src/main/groovy/org/akhikhl/gretty/SSOBasicAuthenticator.java b/libs/gretty-runner-jetty9/src/main/groovy/org/akhikhl/gretty/SSOBasicAuthenticator.java
deleted file mode 100644
index eee01c0b2..000000000
--- a/libs/gretty-runner-jetty9/src/main/groovy/org/akhikhl/gretty/SSOBasicAuthenticator.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Gretty
- *
- * Copyright (C) 2013-2015 Andrey Hihlovskiy and contributors.
- *
- * See the file "LICENSE" for copying and usage permission.
- * See the file "CONTRIBUTORS" for complete list of contributors.
- */
-package org.akhikhl.gretty;
-
-import org.eclipse.jetty.security.ServerAuthException;
-import org.eclipse.jetty.security.authentication.BasicAuthenticator;
-import org.eclipse.jetty.security.authentication.DeferredAuthentication;
-import org.eclipse.jetty.security.authentication.SessionAuthentication;
-import org.eclipse.jetty.server.Authentication;
-import org.eclipse.jetty.server.HttpChannel;
-import org.eclipse.jetty.server.Request;
-import org.eclipse.jetty.server.UserIdentity;
-import org.eclipse.jetty.util.MultiMap;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpSession;
-
-import static org.eclipse.jetty.security.authentication.FormAuthenticator.*;
-
-/**
- *
- * @author akhikhl
- */
-public class SSOBasicAuthenticator extends BasicAuthenticator {
-
- private static final Logger LOG = LoggerFactory.getLogger(SSOBasicAuthenticator.class);
-
- // "login" is copied without changes from FormAuthenticator
- @Override
- public UserIdentity login(String username, Object password, ServletRequest request)
- {
-
- UserIdentity user = super.login(username,password,request);
- if (user!=null)
- {
- HttpSession session = ((HttpServletRequest)request).getSession(true);
- Authentication cached=new SessionAuthentication(getAuthMethod(),user,password);
- session.setAttribute(SessionAuthentication.__J_AUTHENTICATED, cached);
- }
- return user;
- }
-
- @Override
- public Authentication validateRequest(ServletRequest req, ServletResponse res, boolean mandatory) throws ServerAuthException
- {
- HttpServletRequest request = (HttpServletRequest)req;
-
- if (!mandatory)
- return new DeferredAuthentication(this);
-
- // ++ copied from FormAuthenticator
-
- HttpSession session = request.getSession(true);
-
- // Look for cached authentication
- Authentication authentication = (Authentication) session.getAttribute(SessionAuthentication.__J_AUTHENTICATED);
- if (authentication != null)
- {
- // Has authentication been revoked?
- if (authentication instanceof Authentication.User &&
- _loginService!=null &&
- !_loginService.validate(((Authentication.User)authentication).getUserIdentity()))
- {
- LOG.debug("auth revoked {}",authentication);
- session.removeAttribute(SessionAuthentication.__J_AUTHENTICATED);
- }
- else
- {
- synchronized (session)
- {
- String j_uri=(String)session.getAttribute(__J_URI);
- if (j_uri!=null)
- {
- //check if the request is for the same url as the original and restore
- //params if it was a post
- LOG.debug("auth retry {}->{}",authentication,j_uri);
- StringBuffer buf = request.getRequestURL();
- if (request.getQueryString() != null)
- buf.append("?").append(request.getQueryString());
-
- if (j_uri.equals(buf.toString()))
- {
- MultiMap j_post = (MultiMap)session.getAttribute(__J_POST);
- if (j_post!=null)
- {
- LOG.debug("auth rePOST {}->{}",authentication,j_uri);
- Request base_request = HttpChannel.getCurrentHttpChannel().getRequest();
- base_request.setContentParameters(j_post);
- }
- session.removeAttribute(__J_URI);
- session.removeAttribute(__J_METHOD);
- session.removeAttribute(__J_POST);
- }
- }
- }
- LOG.debug("auth {}",authentication);
- return authentication;
- }
- }
- // -- copied from FormAuthenticator
-
- return super.validateRequest(req, res, mandatory);
- }
-}
diff --git a/libs/gretty-runner-jetty9/src/main/groovy/org/akhikhl/gretty/SSOClientCertAuthenticator.java b/libs/gretty-runner-jetty9/src/main/groovy/org/akhikhl/gretty/SSOClientCertAuthenticator.java
deleted file mode 100644
index 1ba1a1946..000000000
--- a/libs/gretty-runner-jetty9/src/main/groovy/org/akhikhl/gretty/SSOClientCertAuthenticator.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Gretty
- *
- * Copyright (C) 2013-2015 Andrey Hihlovskiy and contributors.
- *
- * See the file "LICENSE" for copying and usage permission.
- * See the file "CONTRIBUTORS" for complete list of contributors.
- */
-package org.akhikhl.gretty;
-
-import org.eclipse.jetty.security.ServerAuthException;
-import org.eclipse.jetty.security.authentication.ClientCertAuthenticator;
-import org.eclipse.jetty.security.authentication.DeferredAuthentication;
-import org.eclipse.jetty.security.authentication.SessionAuthentication;
-import org.eclipse.jetty.server.Authentication;
-import org.eclipse.jetty.server.HttpChannel;
-import org.eclipse.jetty.server.Request;
-import org.eclipse.jetty.server.UserIdentity;
-import org.eclipse.jetty.util.MultiMap;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpSession;
-
-import static org.eclipse.jetty.security.authentication.FormAuthenticator.*;
-
-/**
- *
- * @author akhikhl
- */
-public class SSOClientCertAuthenticator extends ClientCertAuthenticator {
-
- private static final Logger LOG = LoggerFactory.getLogger(SSOClientCertAuthenticator.class);
-
- // "login" is copied without changes from FormAuthenticator
- @Override
- public UserIdentity login(String username, Object password, ServletRequest request)
- {
-
- UserIdentity user = super.login(username,password,request);
- if (user!=null)
- {
- HttpSession session = ((HttpServletRequest)request).getSession(true);
- Authentication cached=new SessionAuthentication(getAuthMethod(),user,password);
- session.setAttribute(SessionAuthentication.__J_AUTHENTICATED, cached);
- }
- return user;
- }
-
- @Override
- public Authentication validateRequest(ServletRequest req, ServletResponse res, boolean mandatory) throws ServerAuthException
- {
- HttpServletRequest request = (HttpServletRequest)req;
-
- if (!mandatory)
- return new DeferredAuthentication(this);
-
- // ++ copied from FormAuthenticator
-
- HttpSession session = request.getSession(true);
-
- // Look for cached authentication
- Authentication authentication = (Authentication) session.getAttribute(SessionAuthentication.__J_AUTHENTICATED);
- if (authentication != null)
- {
- // Has authentication been revoked?
- if (authentication instanceof Authentication.User &&
- _loginService!=null &&
- !_loginService.validate(((Authentication.User)authentication).getUserIdentity()))
- {
- LOG.debug("auth revoked {}",authentication);
- session.removeAttribute(SessionAuthentication.__J_AUTHENTICATED);
- }
- else
- {
- synchronized (session)
- {
- String j_uri=(String)session.getAttribute(__J_URI);
- if (j_uri!=null)
- {
- //check if the request is for the same url as the original and restore
- //params if it was a post
- LOG.debug("auth retry {}->{}",authentication,j_uri);
- StringBuffer buf = request.getRequestURL();
- if (request.getQueryString() != null)
- buf.append("?").append(request.getQueryString());
-
- if (j_uri.equals(buf.toString()))
- {
- MultiMap j_post = (MultiMap)session.getAttribute(__J_POST);
- if (j_post!=null)
- {
- LOG.debug("auth rePOST {}->{}",authentication,j_uri);
- Request base_request = HttpChannel.getCurrentHttpChannel().getRequest();
- base_request.setContentParameters(j_post);
- }
- session.removeAttribute(__J_URI);
- session.removeAttribute(__J_METHOD);
- session.removeAttribute(__J_POST);
- }
- }
- }
- LOG.debug("auth {}",authentication);
- return authentication;
- }
- }
- // -- copied from FormAuthenticator
-
- return super.validateRequest(req, res, mandatory);
- }
-}
diff --git a/libs/gretty-runner-jetty9/src/main/groovy/org/akhikhl/gretty/SSODigestAuthenticator.java b/libs/gretty-runner-jetty9/src/main/groovy/org/akhikhl/gretty/SSODigestAuthenticator.java
deleted file mode 100644
index 3ce5f30e6..000000000
--- a/libs/gretty-runner-jetty9/src/main/groovy/org/akhikhl/gretty/SSODigestAuthenticator.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Gretty
- *
- * Copyright (C) 2013-2015 Andrey Hihlovskiy and contributors.
- *
- * See the file "LICENSE" for copying and usage permission.
- * See the file "CONTRIBUTORS" for complete list of contributors.
- */
-package org.akhikhl.gretty;
-
-import org.eclipse.jetty.security.ServerAuthException;
-import org.eclipse.jetty.security.authentication.DeferredAuthentication;
-import org.eclipse.jetty.security.authentication.DigestAuthenticator;
-import org.eclipse.jetty.security.authentication.SessionAuthentication;
-import org.eclipse.jetty.server.Authentication;
-import org.eclipse.jetty.server.HttpChannel;
-import org.eclipse.jetty.server.Request;
-import org.eclipse.jetty.server.UserIdentity;
-import org.eclipse.jetty.util.MultiMap;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpSession;
-
-import static org.eclipse.jetty.security.authentication.FormAuthenticator.*;
-
-/**
- *
- * @author akhikhl
- */
-class SSODigestAuthenticator extends DigestAuthenticator {
-
- private static final Logger LOG = LoggerFactory.getLogger(SSOBasicAuthenticator.class);
-
- // "login" is copied without changes from FormAuthenticator
- @Override
- public UserIdentity login(String username, Object password, ServletRequest request)
- {
-
- UserIdentity user = super.login(username,password,request);
- if (user!=null)
- {
- HttpSession session = ((HttpServletRequest)request).getSession(true);
- Authentication cached=new SessionAuthentication(getAuthMethod(),user,password);
- session.setAttribute(SessionAuthentication.__J_AUTHENTICATED, cached);
- }
- return user;
- }
-
- @Override
- public Authentication validateRequest(ServletRequest req, ServletResponse res, boolean mandatory) throws ServerAuthException
- {
- HttpServletRequest request = (HttpServletRequest)req;
-
- if (!mandatory)
- return new DeferredAuthentication(this);
-
- // ++ copied from FormAuthenticator
-
- HttpSession session = request.getSession(true);
-
- // Look for cached authentication
- Authentication authentication = (Authentication) session.getAttribute(SessionAuthentication.__J_AUTHENTICATED);
- if (authentication != null)
- {
- // Has authentication been revoked?
- if (authentication instanceof Authentication.User &&
- _loginService!=null &&
- !_loginService.validate(((Authentication.User)authentication).getUserIdentity()))
- {
- LOG.debug("auth revoked {}",authentication);
- session.removeAttribute(SessionAuthentication.__J_AUTHENTICATED);
- }
- else
- {
- synchronized (session)
- {
- String j_uri=(String)session.getAttribute(__J_URI);
- if (j_uri!=null)
- {
- //check if the request is for the same url as the original and restore
- //params if it was a post
- LOG.debug("auth retry {}->{}",authentication,j_uri);
- StringBuffer buf = request.getRequestURL();
- if (request.getQueryString() != null)
- buf.append("?").append(request.getQueryString());
-
- if (j_uri.equals(buf.toString()))
- {
- MultiMap j_post = (MultiMap)session.getAttribute(__J_POST);
- if (j_post!=null)
- {
- LOG.debug("auth rePOST {}->{}",authentication,j_uri);
- Request base_request = HttpChannel.getCurrentHttpChannel().getRequest();
- base_request.setContentParameters(j_post);
- }
- session.removeAttribute(__J_URI);
- session.removeAttribute(__J_METHOD);
- session.removeAttribute(__J_POST);
- }
- }
- }
- LOG.debug("auth {}",authentication);
- return authentication;
- }
- }
- // -- copied from FormAuthenticator
-
- return super.validateRequest(req, res, mandatory);
- }
-}
diff --git a/libs/gretty-runner-jetty9/src/main/groovy/org/akhikhl/gretty/SSOSpnegoAuthenticator.java b/libs/gretty-runner-jetty9/src/main/groovy/org/akhikhl/gretty/SSOSpnegoAuthenticator.java
deleted file mode 100644
index e4482af9b..000000000
--- a/libs/gretty-runner-jetty9/src/main/groovy/org/akhikhl/gretty/SSOSpnegoAuthenticator.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * Gretty
- *
- * Copyright (C) 2013-2015 Andrey Hihlovskiy and contributors.
- *
- * See the file "LICENSE" for copying and usage permission.
- * See the file "CONTRIBUTORS" for complete list of contributors.
- */
-package org.akhikhl.gretty;
-
-import org.eclipse.jetty.security.ServerAuthException;
-import org.eclipse.jetty.security.authentication.DeferredAuthentication;
-import org.eclipse.jetty.security.authentication.SessionAuthentication;
-import org.eclipse.jetty.security.authentication.SpnegoAuthenticator;
-import org.eclipse.jetty.server.Authentication;
-import org.eclipse.jetty.server.HttpChannel;
-import org.eclipse.jetty.server.Request;
-import org.eclipse.jetty.server.UserIdentity;
-import org.eclipse.jetty.util.MultiMap;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpSession;
-
-import static org.eclipse.jetty.security.authentication.FormAuthenticator.*;
-
-/**
- *
- * @author akhikhl
- */
-public class SSOSpnegoAuthenticator extends SpnegoAuthenticator {
-
- private static final Logger LOG = LoggerFactory.getLogger(SSOSpnegoAuthenticator.class);
-
- public SSOSpnegoAuthenticator() {
- }
-
- public SSOSpnegoAuthenticator(String authMethod) {
- super(authMethod);
- }
-
- // "login" is copied without changes from FormAuthenticator
- @Override
- public UserIdentity login(String username, Object password, ServletRequest request)
- {
-
- UserIdentity user = super.login(username,password,request);
- if (user!=null)
- {
- HttpSession session = ((HttpServletRequest)request).getSession(true);
- Authentication cached=new SessionAuthentication(getAuthMethod(),user,password);
- session.setAttribute(SessionAuthentication.__J_AUTHENTICATED, cached);
- }
- return user;
- }
-
- @Override
- public Authentication validateRequest(ServletRequest req, ServletResponse res, boolean mandatory) throws ServerAuthException
- {
- HttpServletRequest request = (HttpServletRequest)req;
-
- if (!mandatory)
- return new DeferredAuthentication(this);
-
- // ++ copied from FormAuthenticator
-
- HttpSession session = request.getSession(true);
-
- // Look for cached authentication
- Authentication authentication = (Authentication) session.getAttribute(SessionAuthentication.__J_AUTHENTICATED);
- if (authentication != null)
- {
- // Has authentication been revoked?
- if (authentication instanceof Authentication.User &&
- _loginService!=null &&
- !_loginService.validate(((Authentication.User)authentication).getUserIdentity()))
- {
- LOG.debug("auth revoked {}",authentication);
- session.removeAttribute(SessionAuthentication.__J_AUTHENTICATED);
- }
- else
- {
- synchronized (session)
- {
- String j_uri=(String)session.getAttribute(__J_URI);
- if (j_uri!=null)
- {
- //check if the request is for the same url as the original and restore
- //params if it was a post
- LOG.debug("auth retry {}->{}",authentication,j_uri);
- StringBuffer buf = request.getRequestURL();
- if (request.getQueryString() != null)
- buf.append("?").append(request.getQueryString());
-
- if (j_uri.equals(buf.toString()))
- {
- MultiMap j_post = (MultiMap)session.getAttribute(__J_POST);
- if (j_post!=null)
- {
- LOG.debug("auth rePOST {}->{}",authentication,j_uri);
- Request base_request = HttpChannel.getCurrentHttpChannel().getRequest();
- base_request.setContentParameters(j_post);
- }
- session.removeAttribute(__J_URI);
- session.removeAttribute(__J_METHOD);
- session.removeAttribute(__J_POST);
- }
- }
- }
- LOG.debug("auth {}",authentication);
- return authentication;
- }
- }
- // -- copied from FormAuthenticator
-
- return super.validateRequest(req, res, mandatory);
- }
-}
diff --git a/libs/gretty-runner-jetty9/src/main/groovy/org/akhikhl/gretty/WebInfConfigurationEx.groovy b/libs/gretty-runner-jetty9/src/main/groovy/org/akhikhl/gretty/WebInfConfigurationEx.groovy
deleted file mode 100644
index 6b10fa14b..000000000
--- a/libs/gretty-runner-jetty9/src/main/groovy/org/akhikhl/gretty/WebInfConfigurationEx.groovy
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Gretty
- *
- * Copyright (C) 2013-2015 Andrey Hihlovskiy and contributors.
- *
- * See the file "LICENSE" for copying and usage permission.
- * See the file "CONTRIBUTORS" for complete list of contributors.
- */
-package org.akhikhl.gretty
-
-import groovy.transform.CompileStatic
-import groovy.transform.TypeCheckingMode
-import org.eclipse.jetty.util.resource.Resource
-import org.eclipse.jetty.util.resource.ResourceCollection
-import org.eclipse.jetty.webapp.WebAppContext
-import org.eclipse.jetty.webapp.WebInfConfiguration
-
-@CompileStatic(TypeCheckingMode.SKIP)
-class WebInfConfigurationEx extends WebInfConfiguration implements BaseResourceConfiguration {
-
- private List extraResourceBases
- private final List baseResourceListeners = []
-
- @Override
- void addBaseResourceListener(Closure closure) {
- baseResourceListeners.add(closure)
- }
-
- @Override
- void setExtraResourceBases(List extraResourceBases) {
- this.extraResourceBases = extraResourceBases
- }
-
- @Override
- public void unpack (WebAppContext context) throws IOException {
- super.unpack(context)
- if(extraResourceBases) {
- Resource res = context.getBaseResource()
- List resources = []
- if(res instanceof ResourceCollection)
- resources.addAll(res.getResources())
- else
- resources.add(res)
- for(def e in extraResourceBases)
- resources.add(Resource.newResource(e))
- context.setBaseResource(new ResourceCollection(resources as Resource[]))
- }
- for(Closure closure in baseResourceListeners)
- closure(context)
- }
-}
diff --git a/libs/gretty-runner-jetty9/src/main/java/org/akhikhl/gretty/FilteringClassLoader.java b/libs/gretty-runner-jetty9/src/main/java/org/akhikhl/gretty/FilteringClassLoader.java
deleted file mode 100644
index 7d97d21d1..000000000
--- a/libs/gretty-runner-jetty9/src/main/java/org/akhikhl/gretty/FilteringClassLoader.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Gretty
- *
- * Copyright (C) 2013-2015 Andrey Hihlovskiy and contributors.
- *
- * See the file "LICENSE" for copying and usage permission.
- * See the file "CONTRIBUTORS" for complete list of contributors.
- */
-package org.akhikhl.gretty;
-
-import org.eclipse.jetty.webapp.WebAppClassLoader;
-
-import java.io.IOException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Enumeration;
-import java.util.List;
-
-/**
- * Properly implements "server classes" concept.
- *
- * @author akhikhl
- */
-public class FilteringClassLoader extends WebAppClassLoader {
-
- private final List serverClasses = new ArrayList();
-
- private final List serverResources = new ArrayList();
-
- private ClassLoader bootClassLoader;
-
- public FilteringClassLoader(Context context) throws IOException {
- super(context);
- findBootClassLoader();
- }
-
- public FilteringClassLoader(ClassLoader parent, Context context) throws IOException {
- super(parent, context);
- findBootClassLoader();
- }
-
- protected void findBootClassLoader() {
- bootClassLoader = getParent();
- if (bootClassLoader != null) {
- while(bootClassLoader.getParent() != null) {
- bootClassLoader = bootClassLoader.getParent();
- }
- }
- }
-
- public void addServerClass(String serverClass) {
- serverClasses.add(serverClass);
- serverResources.add(serverClass.replace('.', '/'));
- serverResources.add("META-INF/services/" + serverClass);
- }
-
- @Override
- protected Class> loadClass(String name, boolean resolve) throws ClassNotFoundException {
- for(String serverClass : serverClasses)
- if(name.startsWith(serverClass)) {
- Class> c = findLoadedClass(name);
- if(c == null)
- c = findClass(name);
- if(c != null) {
- if(resolve)
- resolveClass(c);
- return c;
- }
- throw new ClassNotFoundException(name);
- }
- return super.loadClass(name, resolve);
- }
-
- @Override
- public Enumeration getResources(String name) throws IOException {
- for(String serverResource : serverResources) {
- if(name.startsWith(serverResource)) {
- final List resources = new ArrayList<>();
- resources.addAll(Collections.list(getBootstrapResources(name)));
- resources.addAll(Collections.list(findResources(name)));
- return Collections.enumeration(resources);
- }
- }
- return super.getResources(name);
- }
-
- private Enumeration getBootstrapResources(String name) throws IOException {
- return bootClassLoader.getResources(name);
- }
-}
diff --git a/libs/gretty-runner-jetty93/build.gradle b/libs/gretty-runner-jetty93/build.gradle
deleted file mode 100644
index 47dea0d27..000000000
--- a/libs/gretty-runner-jetty93/build.gradle
+++ /dev/null
@@ -1,22 +0,0 @@
-apply from: rootProject.file('common.gradle')
-
-configurations {
- compile {
- exclude group: 'org.eclipse.jetty.orbit', module: 'javax.servlet'
- }
-}
-
-dependencies {
- compile project(':libs:gretty-runner-jetty')
- compile "javax.servlet:javax.servlet-api:$jetty9_servlet_api_version"
- compile "org.eclipse.jetty:jetty-server:$jetty93_version"
- compile "org.eclipse.jetty:jetty-servlet:$jetty93_version"
- compile "org.eclipse.jetty:jetty-webapp:$jetty93_version"
- compile "org.eclipse.jetty:jetty-security:$jetty93_version"
- compile "org.eclipse.jetty:apache-jsp:$jetty93_version"
- compile "org.eclipse.jetty:jetty-annotations:$jetty93_version"
- compile "org.eclipse.jetty:jetty-plus:$jetty93_version"
- compile "org.eclipse.jetty.websocket:javax-websocket-server-impl:$jetty93_version"
- compile "org.ow2.asm:asm:$asm_version"
- compile "org.ow2.asm:asm-commons:$asm_version"
-}
diff --git a/libs/gretty-runner-jetty93/src/main/groovy/org/akhikhl/gretty/JettyConfigurerImpl.groovy b/libs/gretty-runner-jetty93/src/main/groovy/org/akhikhl/gretty/JettyConfigurerImpl.groovy
deleted file mode 100644
index 78533147c..000000000
--- a/libs/gretty-runner-jetty93/src/main/groovy/org/akhikhl/gretty/JettyConfigurerImpl.groovy
+++ /dev/null
@@ -1,320 +0,0 @@
-/*
- * Gretty
- *
- * Copyright (C) 2013-2015 Andrey Hihlovskiy and contributors.
- *
- * See the file "LICENSE" for copying and usage permission.
- * See the file "CONTRIBUTORS" for complete list of contributors.
- */
-package org.akhikhl.gretty
-
-import groovy.transform.CompileStatic
-import groovy.transform.TypeCheckingMode
-import org.eclipse.jetty.annotations.AnnotationConfiguration
-import org.eclipse.jetty.plus.webapp.EnvConfiguration
-import org.eclipse.jetty.plus.webapp.PlusConfiguration
-import org.eclipse.jetty.security.HashLoginService
-import org.eclipse.jetty.server.*
-import org.eclipse.jetty.server.handler.ContextHandlerCollection
-import org.eclipse.jetty.server.session.HashSessionManager
-import org.eclipse.jetty.util.component.LifeCycle
-import org.eclipse.jetty.util.resource.FileResource
-import org.eclipse.jetty.util.resource.Resource
-import org.eclipse.jetty.util.resource.ResourceCollection
-import org.eclipse.jetty.util.ssl.SslContextFactory
-import org.eclipse.jetty.webapp.*
-import org.eclipse.jetty.xml.XmlConfiguration
-import org.slf4j.Logger
-import org.slf4j.LoggerFactory
-
-/**
- *
- * @author akhikhl
- */
-@CompileStatic(TypeCheckingMode.SKIP)
-class JettyConfigurerImpl implements JettyConfigurer {
-
- private static final Logger log = LoggerFactory.getLogger(JettyConfigurerImpl)
-
- private SSOAuthenticatorFactory ssoAuthenticatorFactory
- private HashSessionManager sharedSessionManager
-
- @Override
- def addLifeCycleListener(lifecycle, listener) {
- def lifeCycleListener = listener as LifeCycleListenerAdapter
- lifecycle.addLifeCycleListener(lifeCycleListener)
- lifeCycleListener
- }
-
- @Override
- void applyContextConfigFile(webAppContext, URL contextConfigFile) {
- if(contextConfigFile) {
- log.info 'Configuring {} with {}', webAppContext.contextPath, contextConfigFile
- XmlConfiguration xmlConfiguration = new XmlConfiguration(contextConfigFile)
- xmlConfiguration.configure(webAppContext)
- }
- }
-
- @Override
- void applyJettyXml(server, String jettyXml) {
- if(jettyXml != null) {
- log.info 'Configuring server with {}', jettyXml
- XmlConfiguration xmlConfiguration = new XmlConfiguration(new File(jettyXml).toURI().toURL())
- xmlConfiguration.configure(server)
- }
- }
-
- @Override
- void configureConnectors(server, Map params) {
-
- HttpConfiguration http_config = new HttpConfiguration()
- if(params.httpsPort) {
- http_config.setSecureScheme('https')
- http_config.setSecurePort(params.httpsPort)
- }
-
- Connector httpConn = findHttpConnector(server)
-
- boolean newHttpConnector = false
- if(params.httpEnabled && !httpConn) {
- newHttpConnector = true
- httpConn = new ServerConnector(server, new HttpConnectionFactory(http_config))
- httpConn.soLingerTime = -1
- }
-
- if(httpConn) {
- if(!httpConn.host)
- httpConn.host = params.host ?: ServerDefaults.defaultHost
-
- if(!httpConn.port)
- httpConn.port = params.httpPort ?: ServerDefaults.defaultHttpPort
-
- if(httpConn.port == PortUtils.RANDOM_FREE_PORT)
- httpConn.port = 0
-
- if(params.httpIdleTimeout)
- httpConn.idleTimeout = params.httpIdleTimeout
-
- if(newHttpConnector)
- server.addConnector(httpConn)
- }
-
- Connector httpsConn = findHttpsConnector(server)
-
- boolean newHttpsConnector = false
- if(params.httpsEnabled && !httpsConn) {
- newHttpsConnector = true
- HttpConfiguration https_config = new HttpConfiguration(http_config)
- https_config.addCustomizer(new SecureRequestCustomizer())
- httpsConn = new ServerConnector(server,
- new SslConnectionFactory(new SslContextFactory(), 'http/1.1'),
- new HttpConnectionFactory(https_config))
- httpsConn.soLingerTime = -1
- }
-
- if(httpsConn) {
- if(!httpsConn.host)
- httpsConn.host = params.host ?: ServerDefaults.defaultHost
-
- if(!httpsConn.port)
- httpsConn.port = params.httpsPort ?: ServerDefaults.defaultHttpsPort
-
- if(httpsConn.port == PortUtils.RANDOM_FREE_PORT)
- httpsConn.port = 0
-
- def sslContextFactory = httpsConn.getConnectionFactories().find { it instanceof SslConnectionFactory }?.getSslContextFactory()
- if(sslContextFactory) {
- if(params.sslKeyStorePath) {
- if(params.sslKeyStorePath.startsWith('classpath:')) {
- String resString = params.sslKeyStorePath - 'classpath:'
- URL url = getClass().getResource(resString)
- if(url == null)
- throw new Exception("Could not resource referenced in sslKeyStorePath: '${resString}'")
- sslContextFactory.setKeyStoreResource(new FileResource(url))
- }
- else
- sslContextFactory.setKeyStorePath(params.sslKeyStorePath)
- }
- if(params.sslKeyStorePassword)
- sslContextFactory.setKeyStorePassword(params.sslKeyStorePassword)
- if(params.sslKeyManagerPassword)
- sslContextFactory.setKeyManagerPassword(params.sslKeyManagerPassword)
- if(params.sslTrustStorePath) {
- if(params.sslTrustStorePath.startsWith('classpath:')) {
- String resString = params.sslTrustStorePath - 'classpath:'
- URL url = getClass().getResource(resString)
- if(url == null)
- throw new Exception("Could not resource referenced in sslTrustStorePath: '${resString}'")
- sslContextFactory.setTrustStoreResource(new FileResource(url))
- }
- else
- sslContextFactory.setTrustStorePath(params.sslTrustStorePath)
- }
- if(params.sslTrustStorePassword)
- sslContextFactory.setTrustStorePassword(params.sslTrustStorePassword)
- if(params.sslNeedClientAuth)
- sslContextFactory.setNeedClientAuth(params.sslNeedClientAuth)
- }
-
- if(params.httpsIdleTimeout)
- httpsConn.idleTimeout = params.httpsIdleTimeout
-
- if(newHttpsConnector)
- server.addConnector(httpsConn)
- }
- }
-
- @Override
- void configureSecurity(context, String realm, String realmConfigFile, boolean singleSignOn) {
- context.securityHandler.loginService = new HashLoginService(realm, realmConfigFile)
- if(singleSignOn) {
- if(ssoAuthenticatorFactory == null)
- ssoAuthenticatorFactory = new SSOAuthenticatorFactory()
- context.securityHandler.authenticatorFactory = ssoAuthenticatorFactory
- }
- }
-
- @Override
- void configureSessionManager(server, context, Map serverParams, Map webappParams) {
- HashSessionManager sessionManager
- if(serverParams.singleSignOn) {
- sessionManager = sharedSessionManager
- if(sessionManager == null) {
- sessionManager = sharedSessionManager = new HashSessionManager()
- sessionManager.setMaxInactiveInterval(60 * 30) // 30 minutes
- sessionManager.getSessionCookieConfig().setPath('/')
- }
- } else {
- sessionManager = new HashSessionManager()
- sessionManager.setMaxInactiveInterval(60 * 30) // 30 minutes
- }
- context.getSessionHandler().setSessionManager(sessionManager)
- }
-
- @Override
- def createResourceCollection(List paths) {
- new ResourceCollection(paths as String[])
- }
-
- @Override
- def createServer() {
- // fix for issue https://github.com/akhikhl/gretty/issues/24
- org.eclipse.jetty.util.resource.Resource.defaultUseCaches = false
- return new Server()
- }
-
- @Override
- def createWebAppContext(Map serverParams, Map webappParams) {
- List webappClassPath = webappParams.webappClassPath
- JettyWebAppContext context = new JettyWebAppContext()
- context.setWebInfLib(webappClassPath.findAll { it.endsWith('.jar') }.collect { new File(it) })
- context.setExtraClasspath(webappClassPath.collect { it.endsWith('.jar') ? it : (it.endsWith('/') ? it : it + '/') }.join(';'))
- context.setInitParameter('org.eclipse.jetty.servlet.Default.useFileMappedBuffer', serverParams.productMode ? 'true' : 'false')
- context.setAttribute('org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern',
- '.*/[^/]*servlet-api-[^/]*\\.jar$|.*/javax.servlet.jsp.jstl-.*\\.jar$|.*/[^/]*taglibs.*\\.jar$');
- FilteringClassLoader classLoader = new FilteringClassLoader(context)
- classLoader.addServerClass('ch.qos.logback.')
- classLoader.addServerClass('org.slf4j.')
- classLoader.addServerClass('org.codehaus.groovy.')
- classLoader.addServerClass('groovy.')
- classLoader.addServerClass('groovyx.')
- classLoader.addServerClass('groovyjarjarantlr.')
- classLoader.addServerClass('groovyjarjarasm.')
- classLoader.addServerClass('groovyjarjarcommonscli.')
- context.classLoader = classLoader
- context.addLifeCycleListener(new LifeCycleListenerAdapter() {
- public void lifeCycleStopped(LifeCycle event) {
- context.classLoader = null
- }
- })
- return context
- }
-
- @Override
- def findHttpConnector(server) {
- server.connectors.find { it.connectionFactories.find { it.protocol.startsWith('HTTP') } && !it.connectionFactories.find { it.protocol.startsWith('SSL') } }
- }
-
- @Override
- def findHttpsConnector(server) {
- server.connectors.find { it.connectionFactories.find { it.protocol.startsWith('HTTP') } && it.connectionFactories.find { it.protocol.startsWith('SSL') } }
- }
-
- @Override
- URL findResourceURL(baseResource, String path) {
- Resource res
- if(baseResource instanceof ResourceCollection)
- res = baseResource.findResource(path)
- else
- res = baseResource.addPath(path)
- if(res.exists())
- return res.getURL()
- null
- }
-
- @Override
- List getConfigurations(Map webappParams) {
- [
- new WebInfConfigurationEx(),
- new WebXmlConfiguration(),
- new MetaInfConfiguration(),
- new FragmentConfiguration(),
- new EnvConfiguration(),
- new PlusConfiguration(),
- new AnnotationConfiguration(),
- new JettyWebXmlConfiguration()
- ]
- }
-
- @Override
- void removeLifeCycleListener(lifecycle, listener) {
- lifecycle.removeLifeCycleListener(listener)
- }
-
- @Override
- void setConfigurationsToWebAppContext(webAppContext, List configurations) {
- webAppContext.setConfigurations(configurations as Configuration[])
- }
-
- private ContextHandlerCollection findContextHandlerCollection(Handler handler) {
- if(handler instanceof ContextHandlerCollection)
- return handler
- if(handler.respondsTo('getHandlers'))
- return handler.getHandlers().findResult { findContextHandlerCollection(it) }
- null
- }
-
- @Override
- void setHandlersToServer(server, List handlers) {
- ContextHandlerCollection contexts = findContextHandlerCollection(server.handler)
- if(!contexts)
- contexts = new ContextHandlerCollection()
-
- contexts.setHandlers(handlers as Handler[])
- if(server.handler == null)
- server.handler = contexts
- }
-
- @Override
- List getHandlersByContextPaths(server, List contextPaths) {
- ContextHandlerCollection context = findContextHandlerCollection(((Server)server).handler)
- return context.getHandlers().findAll {
- if(it.respondsTo("getContextPath")) {
- contextPaths.contains(it.getContextPath())
- }
- }
- }
-
- @Override
- void removeHandlerFromServer(server, handler) {
- def collection = findContextHandlerCollection(server.handler)
- collection.removeHandler(handler)
- }
-
- @Override
- void addHandlerToServer(server, handler) {
- def collection = findContextHandlerCollection(server.handler)
- collection.addHandler(handler)
- }
-
-}
diff --git a/libs/gretty-runner-jetty93/src/main/groovy/org/akhikhl/gretty/JettyWebAppContext.groovy b/libs/gretty-runner-jetty93/src/main/groovy/org/akhikhl/gretty/JettyWebAppContext.groovy
deleted file mode 100644
index a065241a4..000000000
--- a/libs/gretty-runner-jetty93/src/main/groovy/org/akhikhl/gretty/JettyWebAppContext.groovy
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Gretty
- *
- * Copyright (C) 2013-2015 Andrey Hihlovskiy and contributors.
- *
- * See the file "LICENSE" for copying and usage permission.
- * See the file "CONTRIBUTORS" for complete list of contributors.
- */
-package org.akhikhl.gretty
-
-import org.eclipse.jetty.util.URIUtil
-import org.eclipse.jetty.util.log.Log
-import org.eclipse.jetty.util.log.Logger
-import org.eclipse.jetty.util.resource.Resource
-import org.eclipse.jetty.webapp.WebAppContext
-
-/**
- * Inspired by maven-jetty-plugin's JettyWebAppContext
- *
- * @author sala
- */
-class JettyWebAppContext extends WebAppContext {
-
- private static final Logger LOG = Log.getLogger(JettyWebAppContext.class)
-
- private static final String WEB_INF_LIB_PREFIX = '/WEB-INF/lib'
- private final Map webInfJarMap = [:]
- private final List webInfJars = []
-
- void setWebInfLib (List jars) {
- webInfJars.addAll(jars);
- }
-
- @Override
- protected void doStart() throws Exception {
- // preparing our pathes patch
- webInfJarMap.clear()
- webInfJars.each {
- String fileName = it.getName()
- if(fileName.endsWith('.jar')) {
- webInfJarMap.put(fileName, it)
- }
- }
- super.doStart()
- }
-
- @Override
- protected void doStop() throws Exception {
- // cancelling our pathes patch
- if(webInfJarMap != null) {
- webInfJarMap.clear()
- }
- webInfJars.clear()
- super.doStop()
- }
-
- @Override
- Set getResourcePaths(String path) {
- Set paths = super.getResourcePaths(path)
- // Tinkering with pathes, adding pathes provided manually
- if(path != null) {
- def allPaths = new TreeSet()
- allPaths.addAll(paths)
-
- if(path.startsWith(WEB_INF_LIB_PREFIX)) {
- webInfJarMap.keySet().each {
- allPaths.add(WEB_INF_LIB_PREFIX + '/' + it)
- }
- }
- return allPaths
- }
-
- return paths
- }
-
- @Override
- Resource getResource(String uriInContext) throws MalformedURLException {
- Resource resource = super.getResource(uriInContext)
-
- if((resource == null || !resource.exists()) && uriInContext != null) {
- String uri = URIUtil.canonicalPath(uriInContext)
- if(uri == null) {
- return null
- }
-
- try {
- if(uri.startsWith(WEB_INF_LIB_PREFIX)) {
- String jarName = uri.replace(WEB_INF_LIB_PREFIX, '')
- if(jarName.startsWith('/') || jarName.startsWith('\\')) {
- jarName = jarName.substring(1)
- }
- if(jarName.isEmpty()) {
- return null
- }
- File jarFile = webInfJarMap.get(jarName)
- if(jarFile != null) {
- return Resource.newResource(jarFile.getPath())
- }
- return null;
- }
- } catch (MalformedURLException e) {
- throw e;
- } catch (IOException e) {
- LOG.ignore(e)
- }
- }
- return resource
- }
-}
diff --git a/libs/gretty-runner-jetty93/src/main/groovy/org/akhikhl/gretty/LifeCycleListenerAdapter.java b/libs/gretty-runner-jetty93/src/main/groovy/org/akhikhl/gretty/LifeCycleListenerAdapter.java
deleted file mode 100644
index 2ccf906ca..000000000
--- a/libs/gretty-runner-jetty93/src/main/groovy/org/akhikhl/gretty/LifeCycleListenerAdapter.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Gretty
- *
- * Copyright (C) 2013-2015 Andrey Hihlovskiy and contributors.
- *
- * See the file "LICENSE" for copying and usage permission.
- * See the file "CONTRIBUTORS" for complete list of contributors.
- */
-package org.akhikhl.gretty;
-
-import org.eclipse.jetty.util.component.LifeCycle;
-
-/**
- *
- * @author akhikhl
- */
-public class LifeCycleListenerAdapter implements LifeCycle.Listener {
-
- @Override
- public void lifeCycleStarting(LifeCycle event) {
-
- }
-
- @Override
- public void lifeCycleStarted(LifeCycle event) {
-
- }
-
- @Override
- public void lifeCycleFailure(LifeCycle event, Throwable cause) {
-
- }
-
- @Override
- public void lifeCycleStopping(LifeCycle event) {
-
- }
-
- @Override
- public void lifeCycleStopped(LifeCycle event) {
-
- }
-}
diff --git a/libs/gretty-runner-jetty93/src/main/groovy/org/akhikhl/gretty/SSOAuthenticatorFactory.java b/libs/gretty-runner-jetty93/src/main/groovy/org/akhikhl/gretty/SSOAuthenticatorFactory.java
deleted file mode 100644
index 5395cfcca..000000000
--- a/libs/gretty-runner-jetty93/src/main/groovy/org/akhikhl/gretty/SSOAuthenticatorFactory.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Gretty
- *
- * Copyright (C) 2013-2015 Andrey Hihlovskiy and contributors.
- *
- * See the file "LICENSE" for copying and usage permission.
- * See the file "CONTRIBUTORS" for complete list of contributors.
- */
-package org.akhikhl.gretty;
-
-import org.eclipse.jetty.security.Authenticator.AuthConfiguration;
-import org.eclipse.jetty.security.DefaultAuthenticatorFactory;
-import org.eclipse.jetty.security.IdentityService;
-import org.eclipse.jetty.security.LoginService;
-import org.eclipse.jetty.server.Server;
-import org.eclipse.jetty.util.security.Constraint;
-
-import javax.servlet.ServletContext;
-
-/**
- *
- * @author akhikhl
- */
-public class SSOAuthenticatorFactory extends DefaultAuthenticatorFactory {
-
- @Override
- public org.eclipse.jetty.security.Authenticator getAuthenticator(Server server, ServletContext ctx, AuthConfiguration configuration, IdentityService identityService, LoginService loginService) {
- String auth = configuration.getAuthMethod();
- if (auth==null || Constraint.__BASIC_AUTH.equalsIgnoreCase(auth))
- return new SSOBasicAuthenticator();
- if (Constraint.__DIGEST_AUTH.equalsIgnoreCase(auth))
- return new SSODigestAuthenticator();
- if ( Constraint.__SPNEGO_AUTH.equalsIgnoreCase(auth) )
- return new SSOSpnegoAuthenticator();
- if ( Constraint.__NEGOTIATE_AUTH.equalsIgnoreCase(auth) ) // see Bug #377076
- return new SSOSpnegoAuthenticator(Constraint.__NEGOTIATE_AUTH);
- if (Constraint.__CERT_AUTH.equalsIgnoreCase(auth)||Constraint.__CERT_AUTH2.equalsIgnoreCase(auth))
- return new SSOClientCertAuthenticator();
- return super.getAuthenticator(server, ctx, configuration, identityService, loginService);
- }
-}
diff --git a/libs/gretty-runner-jetty93/src/main/groovy/org/akhikhl/gretty/SSOBasicAuthenticator.java b/libs/gretty-runner-jetty93/src/main/groovy/org/akhikhl/gretty/SSOBasicAuthenticator.java
deleted file mode 100644
index 04988f134..000000000
--- a/libs/gretty-runner-jetty93/src/main/groovy/org/akhikhl/gretty/SSOBasicAuthenticator.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Gretty
- *
- * Copyright (C) 2013-2015 Andrey Hihlovskiy and contributors.
- *
- * See the file "LICENSE" for copying and usage permission.
- * See the file "CONTRIBUTORS" for complete list of contributors.
- */
-package org.akhikhl.gretty;
-
-import org.eclipse.jetty.security.ServerAuthException;
-import org.eclipse.jetty.security.authentication.BasicAuthenticator;
-import org.eclipse.jetty.security.authentication.DeferredAuthentication;
-import org.eclipse.jetty.security.authentication.SessionAuthentication;
-import org.eclipse.jetty.server.Authentication;
-import org.eclipse.jetty.server.Request;
-import org.eclipse.jetty.server.UserIdentity;
-import org.eclipse.jetty.util.MultiMap;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpSession;
-
-import static org.eclipse.jetty.security.authentication.FormAuthenticator.*;
-
-/**
- *
- * @author akhikhl
- */
-public class SSOBasicAuthenticator extends BasicAuthenticator {
-
- private static final Logger LOG = LoggerFactory.getLogger(SSOBasicAuthenticator.class);
-
- // "login" is copied without changes from FormAuthenticator
- @Override
- public UserIdentity login(String username, Object password, ServletRequest request)
- {
-
- UserIdentity user = super.login(username,password,request);
- if (user!=null)
- {
- HttpSession session = ((HttpServletRequest)request).getSession(true);
- Authentication cached=new SessionAuthentication(getAuthMethod(),user,password);
- session.setAttribute(SessionAuthentication.__J_AUTHENTICATED, cached);
- }
- return user;
- }
-
- @Override
- public Authentication validateRequest(ServletRequest req, ServletResponse res, boolean mandatory) throws ServerAuthException
- {
- HttpServletRequest request = (HttpServletRequest)req;
-
- if (!mandatory)
- return new DeferredAuthentication(this);
-
- // ++ copied from FormAuthenticator
-
- HttpSession session = request.getSession(true);
-
- // Look for cached authentication
- Authentication authentication = (Authentication) session.getAttribute(SessionAuthentication.__J_AUTHENTICATED);
- if (authentication != null)
- {
- // Has authentication been revoked?
- if (authentication instanceof Authentication.User &&
- _loginService!=null &&
- !_loginService.validate(((Authentication.User)authentication).getUserIdentity()))
- {
- LOG.debug("auth revoked {}",authentication);
- session.removeAttribute(SessionAuthentication.__J_AUTHENTICATED);
- }
- else
- {
- synchronized (session)
- {
- String j_uri=(String)session.getAttribute(__J_URI);
- if (j_uri!=null)
- {
- //check if the request is for the same url as the original and restore
- //params if it was a post
- LOG.debug("auth retry {}->{}",authentication,j_uri);
- StringBuffer buf = request.getRequestURL();
- if (request.getQueryString() != null)
- buf.append("?").append(request.getQueryString());
-
- if (j_uri.equals(buf.toString()))
- {
- MultiMap j_post = (MultiMap)session.getAttribute(__J_POST);
- if (j_post!=null)
- {
- LOG.debug("auth rePOST {}->{}",authentication,j_uri);
- Request base_request = Request.getBaseRequest(request);
- base_request.setContentParameters(j_post);
- }
- session.removeAttribute(__J_URI);
- session.removeAttribute(__J_METHOD);
- session.removeAttribute(__J_POST);
- }
- }
- }
- LOG.debug("auth {}",authentication);
- return authentication;
- }
- }
- // -- copied from FormAuthenticator
-
- return super.validateRequest(req, res, mandatory);
- }
-}
diff --git a/libs/gretty-runner-jetty93/src/main/groovy/org/akhikhl/gretty/SSOClientCertAuthenticator.java b/libs/gretty-runner-jetty93/src/main/groovy/org/akhikhl/gretty/SSOClientCertAuthenticator.java
deleted file mode 100644
index def86dc4a..000000000
--- a/libs/gretty-runner-jetty93/src/main/groovy/org/akhikhl/gretty/SSOClientCertAuthenticator.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Gretty
- *
- * Copyright (C) 2013-2015 Andrey Hihlovskiy and contributors.
- *
- * See the file "LICENSE" for copying and usage permission.
- * See the file "CONTRIBUTORS" for complete list of contributors.
- */
-package org.akhikhl.gretty;
-
-import org.eclipse.jetty.security.ServerAuthException;
-import org.eclipse.jetty.security.authentication.ClientCertAuthenticator;
-import org.eclipse.jetty.security.authentication.DeferredAuthentication;
-import org.eclipse.jetty.security.authentication.SessionAuthentication;
-import org.eclipse.jetty.server.Authentication;
-import org.eclipse.jetty.server.Request;
-import org.eclipse.jetty.server.UserIdentity;
-import org.eclipse.jetty.util.MultiMap;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpSession;
-
-import static org.eclipse.jetty.security.authentication.FormAuthenticator.*;
-
-/**
- *
- * @author akhikhl
- */
-public class SSOClientCertAuthenticator extends ClientCertAuthenticator {
-
- private static final Logger LOG = LoggerFactory.getLogger(SSOClientCertAuthenticator.class);
-
- // "login" is copied without changes from FormAuthenticator
- @Override
- public UserIdentity login(String username, Object password, ServletRequest request)
- {
-
- UserIdentity user = super.login(username,password,request);
- if (user!=null)
- {
- HttpSession session = ((HttpServletRequest)request).getSession(true);
- Authentication cached=new SessionAuthentication(getAuthMethod(),user,password);
- session.setAttribute(SessionAuthentication.__J_AUTHENTICATED, cached);
- }
- return user;
- }
-
- @Override
- public Authentication validateRequest(ServletRequest req, ServletResponse res, boolean mandatory) throws ServerAuthException
- {
- HttpServletRequest request = (HttpServletRequest)req;
-
- if (!mandatory)
- return new DeferredAuthentication(this);
-
- // ++ copied from FormAuthenticator
-
- HttpSession session = request.getSession(true);
-
- // Look for cached authentication
- Authentication authentication = (Authentication) session.getAttribute(SessionAuthentication.__J_AUTHENTICATED);
- if (authentication != null)
- {
- // Has authentication been revoked?
- if (authentication instanceof Authentication.User &&
- _loginService!=null &&
- !_loginService.validate(((Authentication.User)authentication).getUserIdentity()))
- {
- LOG.debug("auth revoked {}",authentication);
- session.removeAttribute(SessionAuthentication.__J_AUTHENTICATED);
- }
- else
- {
- synchronized (session)
- {
- String j_uri=(String)session.getAttribute(__J_URI);
- if (j_uri!=null)
- {
- //check if the request is for the same url as the original and restore
- //params if it was a post
- LOG.debug("auth retry {}->{}",authentication,j_uri);
- StringBuffer buf = request.getRequestURL();
- if (request.getQueryString() != null)
- buf.append("?").append(request.getQueryString());
-
- if (j_uri.equals(buf.toString()))
- {
- MultiMap j_post = (MultiMap)session.getAttribute(__J_POST);
- if (j_post!=null)
- {
- LOG.debug("auth rePOST {}->{}",authentication,j_uri);
- Request base_request = Request.getBaseRequest(request);
- base_request.setContentParameters(j_post);
- }
- session.removeAttribute(__J_URI);
- session.removeAttribute(__J_METHOD);
- session.removeAttribute(__J_POST);
- }
- }
- }
- LOG.debug("auth {}",authentication);
- return authentication;
- }
- }
- // -- copied from FormAuthenticator
-
- return super.validateRequest(req, res, mandatory);
- }
-}
diff --git a/libs/gretty-runner-jetty93/src/main/groovy/org/akhikhl/gretty/SSODigestAuthenticator.java b/libs/gretty-runner-jetty93/src/main/groovy/org/akhikhl/gretty/SSODigestAuthenticator.java
deleted file mode 100644
index a05c877b4..000000000
--- a/libs/gretty-runner-jetty93/src/main/groovy/org/akhikhl/gretty/SSODigestAuthenticator.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Gretty
- *
- * Copyright (C) 2013-2015 Andrey Hihlovskiy and contributors.
- *
- * See the file "LICENSE" for copying and usage permission.
- * See the file "CONTRIBUTORS" for complete list of contributors.
- */
-package org.akhikhl.gretty;
-
-import org.eclipse.jetty.security.ServerAuthException;
-import org.eclipse.jetty.security.authentication.DeferredAuthentication;
-import org.eclipse.jetty.security.authentication.DigestAuthenticator;
-import org.eclipse.jetty.security.authentication.SessionAuthentication;
-import org.eclipse.jetty.server.Authentication;
-import org.eclipse.jetty.server.Request;
-import org.eclipse.jetty.server.UserIdentity;
-import org.eclipse.jetty.util.MultiMap;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpSession;
-
-import static org.eclipse.jetty.security.authentication.FormAuthenticator.*;
-
-/**
- *
- * @author akhikhl
- */
-class SSODigestAuthenticator extends DigestAuthenticator {
-
- private static final Logger LOG = LoggerFactory.getLogger(SSOBasicAuthenticator.class);
-
- // "login" is copied without changes from FormAuthenticator
- @Override
- public UserIdentity login(String username, Object password, ServletRequest request)
- {
-
- UserIdentity user = super.login(username,password,request);
- if (user!=null)
- {
- HttpSession session = ((HttpServletRequest)request).getSession(true);
- Authentication cached=new SessionAuthentication(getAuthMethod(),user,password);
- session.setAttribute(SessionAuthentication.__J_AUTHENTICATED, cached);
- }
- return user;
- }
-
- @Override
- public Authentication validateRequest(ServletRequest req, ServletResponse res, boolean mandatory) throws ServerAuthException
- {
- HttpServletRequest request = (HttpServletRequest)req;
-
- if (!mandatory)
- return new DeferredAuthentication(this);
-
- // ++ copied from FormAuthenticator
-
- HttpSession session = request.getSession(true);
-
- // Look for cached authentication
- Authentication authentication = (Authentication) session.getAttribute(SessionAuthentication.__J_AUTHENTICATED);
- if (authentication != null)
- {
- // Has authentication been revoked?
- if (authentication instanceof Authentication.User &&
- _loginService!=null &&
- !_loginService.validate(((Authentication.User)authentication).getUserIdentity()))
- {
- LOG.debug("auth revoked {}",authentication);
- session.removeAttribute(SessionAuthentication.__J_AUTHENTICATED);
- }
- else
- {
- synchronized (session)
- {
- String j_uri=(String)session.getAttribute(__J_URI);
- if (j_uri!=null)
- {
- //check if the request is for the same url as the original and restore
- //params if it was a post
- LOG.debug("auth retry {}->{}",authentication,j_uri);
- StringBuffer buf = request.getRequestURL();
- if (request.getQueryString() != null)
- buf.append("?").append(request.getQueryString());
-
- if (j_uri.equals(buf.toString()))
- {
- MultiMap j_post = (MultiMap)session.getAttribute(__J_POST);
- if (j_post!=null)
- {
- LOG.debug("auth rePOST {}->{}",authentication,j_uri);
- Request base_request = Request.getBaseRequest(request);
- base_request.setContentParameters(j_post);
- }
- session.removeAttribute(__J_URI);
- session.removeAttribute(__J_METHOD);
- session.removeAttribute(__J_POST);
- }
- }
- }
- LOG.debug("auth {}",authentication);
- return authentication;
- }
- }
- // -- copied from FormAuthenticator
-
- return super.validateRequest(req, res, mandatory);
- }
-}
diff --git a/libs/gretty-runner-jetty93/src/main/groovy/org/akhikhl/gretty/SSOSpnegoAuthenticator.java b/libs/gretty-runner-jetty93/src/main/groovy/org/akhikhl/gretty/SSOSpnegoAuthenticator.java
deleted file mode 100644
index f57415380..000000000
--- a/libs/gretty-runner-jetty93/src/main/groovy/org/akhikhl/gretty/SSOSpnegoAuthenticator.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * Gretty
- *
- * Copyright (C) 2013-2015 Andrey Hihlovskiy and contributors.
- *
- * See the file "LICENSE" for copying and usage permission.
- * See the file "CONTRIBUTORS" for complete list of contributors.
- */
-package org.akhikhl.gretty;
-
-import org.eclipse.jetty.security.ServerAuthException;
-import org.eclipse.jetty.security.authentication.DeferredAuthentication;
-import org.eclipse.jetty.security.authentication.SessionAuthentication;
-import org.eclipse.jetty.security.authentication.SpnegoAuthenticator;
-import org.eclipse.jetty.server.Authentication;
-import org.eclipse.jetty.server.Request;
-import org.eclipse.jetty.server.UserIdentity;
-import org.eclipse.jetty.util.MultiMap;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpSession;
-
-import static org.eclipse.jetty.security.authentication.FormAuthenticator.*;
-
-/**
- *
- * @author akhikhl
- */
-public class SSOSpnegoAuthenticator extends SpnegoAuthenticator {
-
- private static final Logger LOG = LoggerFactory.getLogger(SSOSpnegoAuthenticator.class);
-
- public SSOSpnegoAuthenticator() {
- }
-
- public SSOSpnegoAuthenticator(String authMethod) {
- super(authMethod);
- }
-
- // "login" is copied without changes from FormAuthenticator
- @Override
- public UserIdentity login(String username, Object password, ServletRequest request)
- {
-
- UserIdentity user = super.login(username,password,request);
- if (user!=null)
- {
- HttpSession session = ((HttpServletRequest)request).getSession(true);
- Authentication cached=new SessionAuthentication(getAuthMethod(),user,password);
- session.setAttribute(SessionAuthentication.__J_AUTHENTICATED, cached);
- }
- return user;
- }
-
- @Override
- public Authentication validateRequest(ServletRequest req, ServletResponse res, boolean mandatory) throws ServerAuthException
- {
- HttpServletRequest request = (HttpServletRequest)req;
-
- if (!mandatory)
- return new DeferredAuthentication(this);
-
- // ++ copied from FormAuthenticator
-
- HttpSession session = request.getSession(true);
-
- // Look for cached authentication
- Authentication authentication = (Authentication) session.getAttribute(SessionAuthentication.__J_AUTHENTICATED);
- if (authentication != null)
- {
- // Has authentication been revoked?
- if (authentication instanceof Authentication.User &&
- _loginService!=null &&
- !_loginService.validate(((Authentication.User)authentication).getUserIdentity()))
- {
- LOG.debug("auth revoked {}",authentication);
- session.removeAttribute(SessionAuthentication.__J_AUTHENTICATED);
- }
- else
- {
- synchronized (session)
- {
- String j_uri=(String)session.getAttribute(__J_URI);
- if (j_uri!=null)
- {
- //check if the request is for the same url as the original and restore
- //params if it was a post
- LOG.debug("auth retry {}->{}",authentication,j_uri);
- StringBuffer buf = request.getRequestURL();
- if (request.getQueryString() != null)
- buf.append("?").append(request.getQueryString());
-
- if (j_uri.equals(buf.toString()))
- {
- MultiMap j_post = (MultiMap)session.getAttribute(__J_POST);
- if (j_post!=null)
- {
- LOG.debug("auth rePOST {}->{}",authentication,j_uri);
- Request base_request = Request.getBaseRequest(request);
- base_request.setContentParameters(j_post);
- }
- session.removeAttribute(__J_URI);
- session.removeAttribute(__J_METHOD);
- session.removeAttribute(__J_POST);
- }
- }
- }
- LOG.debug("auth {}",authentication);
- return authentication;
- }
- }
- // -- copied from FormAuthenticator
-
- return super.validateRequest(req, res, mandatory);
- }
-}
diff --git a/libs/gretty-runner-jetty93/src/main/groovy/org/akhikhl/gretty/WebInfConfigurationEx.groovy b/libs/gretty-runner-jetty93/src/main/groovy/org/akhikhl/gretty/WebInfConfigurationEx.groovy
deleted file mode 100644
index 6b10fa14b..000000000
--- a/libs/gretty-runner-jetty93/src/main/groovy/org/akhikhl/gretty/WebInfConfigurationEx.groovy
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Gretty
- *
- * Copyright (C) 2013-2015 Andrey Hihlovskiy and contributors.
- *
- * See the file "LICENSE" for copying and usage permission.
- * See the file "CONTRIBUTORS" for complete list of contributors.
- */
-package org.akhikhl.gretty
-
-import groovy.transform.CompileStatic
-import groovy.transform.TypeCheckingMode
-import org.eclipse.jetty.util.resource.Resource
-import org.eclipse.jetty.util.resource.ResourceCollection
-import org.eclipse.jetty.webapp.WebAppContext
-import org.eclipse.jetty.webapp.WebInfConfiguration
-
-@CompileStatic(TypeCheckingMode.SKIP)
-class WebInfConfigurationEx extends WebInfConfiguration implements BaseResourceConfiguration {
-
- private List extraResourceBases
- private final List baseResourceListeners = []
-
- @Override
- void addBaseResourceListener(Closure closure) {
- baseResourceListeners.add(closure)
- }
-
- @Override
- void setExtraResourceBases(List extraResourceBases) {
- this.extraResourceBases = extraResourceBases
- }
-
- @Override
- public void unpack (WebAppContext context) throws IOException {
- super.unpack(context)
- if(extraResourceBases) {
- Resource res = context.getBaseResource()
- List resources = []
- if(res instanceof ResourceCollection)
- resources.addAll(res.getResources())
- else
- resources.add(res)
- for(def e in extraResourceBases)
- resources.add(Resource.newResource(e))
- context.setBaseResource(new ResourceCollection(resources as Resource[]))
- }
- for(Closure closure in baseResourceListeners)
- closure(context)
- }
-}
diff --git a/libs/gretty-runner-jetty93/src/main/java/org/akhikhl/gretty/FilteringClassLoader.java b/libs/gretty-runner-jetty93/src/main/java/org/akhikhl/gretty/FilteringClassLoader.java
deleted file mode 100644
index 7d97d21d1..000000000
--- a/libs/gretty-runner-jetty93/src/main/java/org/akhikhl/gretty/FilteringClassLoader.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Gretty
- *
- * Copyright (C) 2013-2015 Andrey Hihlovskiy and contributors.
- *
- * See the file "LICENSE" for copying and usage permission.
- * See the file "CONTRIBUTORS" for complete list of contributors.
- */
-package org.akhikhl.gretty;
-
-import org.eclipse.jetty.webapp.WebAppClassLoader;
-
-import java.io.IOException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Enumeration;
-import java.util.List;
-
-/**
- * Properly implements "server classes" concept.
- *
- * @author akhikhl
- */
-public class FilteringClassLoader extends WebAppClassLoader {
-
- private final List serverClasses = new ArrayList();
-
- private final List serverResources = new ArrayList();
-
- private ClassLoader bootClassLoader;
-
- public FilteringClassLoader(Context context) throws IOException {
- super(context);
- findBootClassLoader();
- }
-
- public FilteringClassLoader(ClassLoader parent, Context context) throws IOException {
- super(parent, context);
- findBootClassLoader();
- }
-
- protected void findBootClassLoader() {
- bootClassLoader = getParent();
- if (bootClassLoader != null) {
- while(bootClassLoader.getParent() != null) {
- bootClassLoader = bootClassLoader.getParent();
- }
- }
- }
-
- public void addServerClass(String serverClass) {
- serverClasses.add(serverClass);
- serverResources.add(serverClass.replace('.', '/'));
- serverResources.add("META-INF/services/" + serverClass);
- }
-
- @Override
- protected Class> loadClass(String name, boolean resolve) throws ClassNotFoundException {
- for(String serverClass : serverClasses)
- if(name.startsWith(serverClass)) {
- Class> c = findLoadedClass(name);
- if(c == null)
- c = findClass(name);
- if(c != null) {
- if(resolve)
- resolveClass(c);
- return c;
- }
- throw new ClassNotFoundException(name);
- }
- return super.loadClass(name, resolve);
- }
-
- @Override
- public Enumeration getResources(String name) throws IOException {
- for(String serverResource : serverResources) {
- if(name.startsWith(serverResource)) {
- final List resources = new ArrayList<>();
- resources.addAll(Collections.list(getBootstrapResources(name)));
- resources.addAll(Collections.list(findResources(name)));
- return Collections.enumeration(resources);
- }
- }
- return super.getResources(name);
- }
-
- private Enumeration getBootstrapResources(String name) throws IOException {
- return bootClassLoader.getResources(name);
- }
-}
diff --git a/libs/gretty-runner-jetty94/build.gradle b/libs/gretty-runner-jetty94/build.gradle
deleted file mode 100644
index 6d922cc28..000000000
--- a/libs/gretty-runner-jetty94/build.gradle
+++ /dev/null
@@ -1,22 +0,0 @@
-apply from: rootProject.file('common.gradle')
-
-configurations {
- compile {
- exclude group: 'org.eclipse.jetty.orbit', module: 'javax.servlet'
- }
-}
-
-dependencies {
- compile project(':libs:gretty-runner-jetty')
- compile "javax.servlet:javax.servlet-api:$jetty9_servlet_api_version"
- compile "org.eclipse.jetty:jetty-server:$jetty94_version"
- compile "org.eclipse.jetty:jetty-servlet:$jetty94_version"
- compile "org.eclipse.jetty:jetty-webapp:$jetty94_version"
- compile "org.eclipse.jetty:jetty-security:$jetty94_version"
- compile "org.eclipse.jetty:apache-jsp:$jetty94_version"
- compile "org.eclipse.jetty:jetty-annotations:$jetty94_version"
- compile "org.eclipse.jetty:jetty-plus:$jetty94_version"
- compile "org.eclipse.jetty.websocket:javax-websocket-server-impl:$jetty94_version"
- compile "org.ow2.asm:asm:$asm_version"
- compile "org.ow2.asm:asm-commons:$asm_version"
-}
diff --git a/libs/gretty-runner-jetty94/src/main/groovy/org/akhikhl/gretty/JettyConfigurerImpl.groovy b/libs/gretty-runner-jetty94/src/main/groovy/org/akhikhl/gretty/JettyConfigurerImpl.groovy
deleted file mode 100644
index efbde814e..000000000
--- a/libs/gretty-runner-jetty94/src/main/groovy/org/akhikhl/gretty/JettyConfigurerImpl.groovy
+++ /dev/null
@@ -1,315 +0,0 @@
-/*
- * Gretty
- *
- * Copyright (C) 2013-2015 Andrey Hihlovskiy and contributors.
- *
- * See the file "LICENSE" for copying and usage permission.
- * See the file "CONTRIBUTORS" for complete list of contributors.
- */
-package org.akhikhl.gretty
-
-import groovy.transform.CompileStatic
-import groovy.transform.TypeCheckingMode
-import org.eclipse.jetty.annotations.AnnotationConfiguration
-import org.eclipse.jetty.plus.webapp.EnvConfiguration
-import org.eclipse.jetty.plus.webapp.PlusConfiguration
-import org.eclipse.jetty.security.HashLoginService
-import org.eclipse.jetty.server.*
-import org.eclipse.jetty.server.handler.ContextHandlerCollection
-import org.eclipse.jetty.server.session.SessionHandler
-import org.eclipse.jetty.util.component.LifeCycle
-import org.eclipse.jetty.util.resource.FileResource
-import org.eclipse.jetty.util.resource.Resource
-import org.eclipse.jetty.util.resource.ResourceCollection
-import org.eclipse.jetty.util.ssl.SslContextFactory
-import org.eclipse.jetty.webapp.*
-import org.eclipse.jetty.xml.XmlConfiguration
-import org.slf4j.Logger
-import org.slf4j.LoggerFactory
-/**
- *
- * @author akhikhl
- */
-@CompileStatic(TypeCheckingMode.SKIP)
-class JettyConfigurerImpl implements JettyConfigurer {
-
- private static final Logger log = LoggerFactory.getLogger(JettyConfigurerImpl)
-
- private SSOAuthenticatorFactory ssoAuthenticatorFactory
- private SessionHandler sharedSessionHandler
-
- @Override
- def addLifeCycleListener(lifecycle, listener) {
- def lifeCycleListener = listener as LifeCycleListenerAdapter
- lifecycle.addLifeCycleListener(lifeCycleListener)
- lifeCycleListener
- }
-
- @Override
- void applyContextConfigFile(webAppContext, URL contextConfigFile) {
- if(contextConfigFile) {
- log.info 'Configuring {} with {}', webAppContext.contextPath, contextConfigFile
- XmlConfiguration xmlConfiguration = new XmlConfiguration(contextConfigFile)
- xmlConfiguration.configure(webAppContext)
- }
- }
-
- @Override
- void applyJettyXml(server, String jettyXml) {
- if(jettyXml != null) {
- log.info 'Configuring server with {}', jettyXml
- XmlConfiguration xmlConfiguration = new XmlConfiguration(new File(jettyXml).toURI().toURL())
- xmlConfiguration.configure(server)
- }
- }
-
- @Override
- void configureConnectors(server, Map params) {
-
- HttpConfiguration http_config = new HttpConfiguration()
- if(params.httpsPort) {
- http_config.setSecureScheme('https')
- http_config.setSecurePort(params.httpsPort)
- }
-
- Connector httpConn = findHttpConnector(server)
-
- boolean newHttpConnector = false
- if(params.httpEnabled && !httpConn) {
- newHttpConnector = true
- httpConn = new ServerConnector(server, new HttpConnectionFactory(http_config))
- httpConn.soLingerTime = -1
- }
-
- if(httpConn) {
- if(!httpConn.host)
- httpConn.host = params.host ?: ServerDefaults.defaultHost
-
- if(!httpConn.port)
- httpConn.port = params.httpPort ?: ServerDefaults.defaultHttpPort
-
- if(httpConn.port == PortUtils.RANDOM_FREE_PORT)
- httpConn.port = 0
-
- if(params.httpIdleTimeout)
- httpConn.idleTimeout = params.httpIdleTimeout
-
- if(newHttpConnector)
- server.addConnector(httpConn)
- }
-
- Connector httpsConn = findHttpsConnector(server)
-
- boolean newHttpsConnector = false
- if(params.httpsEnabled && !httpsConn) {
- newHttpsConnector = true
- HttpConfiguration https_config = new HttpConfiguration(http_config)
- https_config.addCustomizer(new SecureRequestCustomizer())
- httpsConn = new ServerConnector(server,
- new SslConnectionFactory(new SslContextFactory(), 'http/1.1'),
- new HttpConnectionFactory(https_config))
- httpsConn.soLingerTime = -1
- }
-
- if(httpsConn) {
- if(!httpsConn.host)
- httpsConn.host = params.host ?: ServerDefaults.defaultHost
-
- if(!httpsConn.port)
- httpsConn.port = params.httpsPort ?: ServerDefaults.defaultHttpsPort
-
- if(httpsConn.port == PortUtils.RANDOM_FREE_PORT)
- httpsConn.port = 0
-
- def sslContextFactory = httpsConn.getConnectionFactories().find { it instanceof SslConnectionFactory }?.getSslContextFactory()
- if(sslContextFactory) {
- if(params.sslKeyStorePath) {
- if(params.sslKeyStorePath.startsWith('classpath:')) {
- String resString = params.sslKeyStorePath - 'classpath:'
- URL url = getClass().getResource(resString)
- if(url == null)
- throw new Exception("Could not resource referenced in sslKeyStorePath: '${resString}'")
- sslContextFactory.setKeyStoreResource(new FileResource(url))
- }
- else
- sslContextFactory.setKeyStorePath(params.sslKeyStorePath)
- }
- if(params.sslKeyStorePassword)
- sslContextFactory.setKeyStorePassword(params.sslKeyStorePassword)
- if(params.sslKeyManagerPassword)
- sslContextFactory.setKeyManagerPassword(params.sslKeyManagerPassword)
- if(params.sslTrustStorePath) {
- if(params.sslTrustStorePath.startsWith('classpath:')) {
- String resString = params.sslTrustStorePath - 'classpath:'
- URL url = getClass().getResource(resString)
- if(url == null)
- throw new Exception("Could not resource referenced in sslTrustStorePath: '${resString}'")
- sslContextFactory.setTrustStoreResource(new FileResource(url))
- }
- else
- sslContextFactory.setTrustStorePath(params.sslTrustStorePath)
- }
- if(params.sslTrustStorePassword)
- sslContextFactory.setTrustStorePassword(params.sslTrustStorePassword)
- if(params.sslNeedClientAuth)
- sslContextFactory.setNeedClientAuth(params.sslNeedClientAuth)
- }
-
- if(params.httpsIdleTimeout)
- httpsConn.idleTimeout = params.httpsIdleTimeout
-
- if(newHttpsConnector)
- server.addConnector(httpsConn)
- }
- }
-
- @Override
- void configureSecurity(context, String realm, String realmConfigFile, boolean singleSignOn) {
- context.securityHandler.loginService = new HashLoginService(realm, realmConfigFile)
- if(singleSignOn) {
- if(ssoAuthenticatorFactory == null)
- ssoAuthenticatorFactory = new SSOAuthenticatorFactory()
- context.securityHandler.authenticatorFactory = ssoAuthenticatorFactory
- }
- }
-
- @Override
- void configureSessionManager(server, context, Map serverParams, Map webappParams) {
- SessionHandler sessionHandler
- if(serverParams.singleSignOn) {
- sessionHandler = sharedSessionHandler
- if(sessionHandler == null) {
- sessionHandler = sharedSessionHandler = new SessionHandler()
- sessionHandler.setMaxInactiveInterval(60 * 30) // 30 minutes
- sessionHandler.getSessionCookieConfig().setPath('/')
- }
- } else {
- sessionHandler = new SessionHandler()
- sessionHandler.setMaxInactiveInterval(60 * 30) // 30 minutes
- }
- context.setSessionHandler(sessionHandler)
- }
-
- @Override
- def createResourceCollection(List paths) {
- new ResourceCollection(paths as String[])
- }
-
- @Override
- def createServer() {
- // fix for issue https://github.com/akhikhl/gretty/issues/24
- org.eclipse.jetty.util.resource.Resource.defaultUseCaches = false
- return new Server()
- }
-
- @Override
- def createWebAppContext(Map serverParams, Map webappParams) {
- List webappClassPath = webappParams.webappClassPath
- JettyWebAppContext context = new JettyWebAppContext()
- context.setWebInfLib(webappClassPath.findAll { it.endsWith('.jar') }.collect { new File(it) })
- context.setExtraClasspath(webappClassPath.collect { it.endsWith('.jar') ? it : (it.endsWith('/') ? it : it + '/') }.join(';'))
- context.setInitParameter('org.eclipse.jetty.servlet.Default.useFileMappedBuffer', serverParams.productMode ? 'true' : 'false')
- context.setAttribute(WebInfConfiguration.CONTAINER_JAR_PATTERN,
- '.*/[^/]*servlet-api-[^/]*\\.jar$|.*/javax.servlet.jsp.jstl-.*\\.jar$|.*/[^/]*taglibs.*\\.jar$');
- FilteringClassLoader classLoader = new FilteringClassLoader(context)
- classLoader.addServerClass('ch.qos.logback.')
- classLoader.addServerClass('org.slf4j.')
- classLoader.addServerClass('org.codehaus.groovy.')
- classLoader.addServerClass('groovy.')
- classLoader.addServerClass('groovyx.')
- classLoader.addServerClass('groovyjarjarantlr.')
- classLoader.addServerClass('groovyjarjarasm.')
- classLoader.addServerClass('groovyjarjarcommonscli.')
- context.classLoader = classLoader
- context.addLifeCycleListener(new LifeCycleListenerAdapter() {
- public void lifeCycleStopped(LifeCycle event) {
- context.classLoader = null
- }
- })
- return context
- }
-
- @Override
- def findHttpConnector(server) {
- server.connectors.find { it.connectionFactories.find { it.protocol.startsWith('HTTP') } && !it.connectionFactories.find { it.protocol.startsWith('SSL') } }
- }
-
- @Override
- def findHttpsConnector(server) {
- server.connectors.find { it.connectionFactories.find { it.protocol.startsWith('HTTP') } && it.connectionFactories.find { it.protocol.startsWith('SSL') } }
- }
-
- @Override
- URL findResourceURL(baseResource, String path) {
- Resource res = baseResource.addPath(path)
- if(res.exists())
- return res.getURL()
- null
- }
-
- @Override
- List getConfigurations(Map webappParams) {
- [
- new WebInfConfigurationEx(),
- new WebXmlConfiguration(),
- new MetaInfConfiguration(),
- new FragmentConfiguration(),
- new EnvConfiguration(),
- new PlusConfiguration(),
- new AnnotationConfiguration(),
- new JettyWebXmlConfiguration()
- ]
- }
-
- @Override
- void removeLifeCycleListener(lifecycle, listener) {
- lifecycle.removeLifeCycleListener(listener)
- }
-
- @Override
- void setConfigurationsToWebAppContext(webAppContext, List configurations) {
- webAppContext.setConfigurations(configurations as Configuration[])
- }
-
- private ContextHandlerCollection findContextHandlerCollection(Handler handler) {
- if(handler instanceof ContextHandlerCollection)
- return handler
- if(handler.respondsTo('getHandlers'))
- return handler.getHandlers().findResult { findContextHandlerCollection(it) }
- null
- }
-
- @Override
- void setHandlersToServer(server, List handlers) {
- ContextHandlerCollection contexts = findContextHandlerCollection(server.handler)
- if(!contexts)
- contexts = new ContextHandlerCollection()
-
- contexts.setHandlers(handlers as Handler[])
- if(server.handler == null)
- server.handler = contexts
- }
-
- @Override
- List getHandlersByContextPaths(server, List contextPaths) {
- ContextHandlerCollection context = findContextHandlerCollection(((Server)server).handler)
- return context.getHandlers().findAll {
- if(it.respondsTo("getContextPath")) {
- contextPaths.contains(it.getContextPath())
- }
- }
- }
-
- @Override
- void removeHandlerFromServer(server, handler) {
- def collection = findContextHandlerCollection(server.handler)
- collection.removeHandler(handler)
- }
-
- @Override
- void addHandlerToServer(server, handler) {
- def collection = findContextHandlerCollection(server.handler)
- collection.addHandler(handler)
- }
-
-}
diff --git a/libs/gretty-runner-jetty94/src/main/groovy/org/akhikhl/gretty/JettyWebAppContext.groovy b/libs/gretty-runner-jetty94/src/main/groovy/org/akhikhl/gretty/JettyWebAppContext.groovy
deleted file mode 100644
index a065241a4..000000000
--- a/libs/gretty-runner-jetty94/src/main/groovy/org/akhikhl/gretty/JettyWebAppContext.groovy
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Gretty
- *
- * Copyright (C) 2013-2015 Andrey Hihlovskiy and contributors.
- *
- * See the file "LICENSE" for copying and usage permission.
- * See the file "CONTRIBUTORS" for complete list of contributors.
- */
-package org.akhikhl.gretty
-
-import org.eclipse.jetty.util.URIUtil
-import org.eclipse.jetty.util.log.Log
-import org.eclipse.jetty.util.log.Logger
-import org.eclipse.jetty.util.resource.Resource
-import org.eclipse.jetty.webapp.WebAppContext
-
-/**
- * Inspired by maven-jetty-plugin's JettyWebAppContext
- *
- * @author sala
- */
-class JettyWebAppContext extends WebAppContext {
-
- private static final Logger LOG = Log.getLogger(JettyWebAppContext.class)
-
- private static final String WEB_INF_LIB_PREFIX = '/WEB-INF/lib'
- private final Map webInfJarMap = [:]
- private final List webInfJars = []
-
- void setWebInfLib (List jars) {
- webInfJars.addAll(jars);
- }
-
- @Override
- protected void doStart() throws Exception {
- // preparing our pathes patch
- webInfJarMap.clear()
- webInfJars.each {
- String fileName = it.getName()
- if(fileName.endsWith('.jar')) {
- webInfJarMap.put(fileName, it)
- }
- }
- super.doStart()
- }
-
- @Override
- protected void doStop() throws Exception {
- // cancelling our pathes patch
- if(webInfJarMap != null) {
- webInfJarMap.clear()
- }
- webInfJars.clear()
- super.doStop()
- }
-
- @Override
- Set getResourcePaths(String path) {
- Set paths = super.getResourcePaths(path)
- // Tinkering with pathes, adding pathes provided manually
- if(path != null) {
- def allPaths = new TreeSet()
- allPaths.addAll(paths)
-
- if(path.startsWith(WEB_INF_LIB_PREFIX)) {
- webInfJarMap.keySet().each {
- allPaths.add(WEB_INF_LIB_PREFIX + '/' + it)
- }
- }
- return allPaths
- }
-
- return paths
- }
-
- @Override
- Resource getResource(String uriInContext) throws MalformedURLException {
- Resource resource = super.getResource(uriInContext)
-
- if((resource == null || !resource.exists()) && uriInContext != null) {
- String uri = URIUtil.canonicalPath(uriInContext)
- if(uri == null) {
- return null
- }
-
- try {
- if(uri.startsWith(WEB_INF_LIB_PREFIX)) {
- String jarName = uri.replace(WEB_INF_LIB_PREFIX, '')
- if(jarName.startsWith('/') || jarName.startsWith('\\')) {
- jarName = jarName.substring(1)
- }
- if(jarName.isEmpty()) {
- return null
- }
- File jarFile = webInfJarMap.get(jarName)
- if(jarFile != null) {
- return Resource.newResource(jarFile.getPath())
- }
- return null;
- }
- } catch (MalformedURLException e) {
- throw e;
- } catch (IOException e) {
- LOG.ignore(e)
- }
- }
- return resource
- }
-}
diff --git a/libs/gretty-runner-jetty94/src/main/groovy/org/akhikhl/gretty/LifeCycleListenerAdapter.java b/libs/gretty-runner-jetty94/src/main/groovy/org/akhikhl/gretty/LifeCycleListenerAdapter.java
deleted file mode 100644
index 2ccf906ca..000000000
--- a/libs/gretty-runner-jetty94/src/main/groovy/org/akhikhl/gretty/LifeCycleListenerAdapter.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Gretty
- *
- * Copyright (C) 2013-2015 Andrey Hihlovskiy and contributors.
- *
- * See the file "LICENSE" for copying and usage permission.
- * See the file "CONTRIBUTORS" for complete list of contributors.
- */
-package org.akhikhl.gretty;
-
-import org.eclipse.jetty.util.component.LifeCycle;
-
-/**
- *
- * @author akhikhl
- */
-public class LifeCycleListenerAdapter implements LifeCycle.Listener {
-
- @Override
- public void lifeCycleStarting(LifeCycle event) {
-
- }
-
- @Override
- public void lifeCycleStarted(LifeCycle event) {
-
- }
-
- @Override
- public void lifeCycleFailure(LifeCycle event, Throwable cause) {
-
- }
-
- @Override
- public void lifeCycleStopping(LifeCycle event) {
-
- }
-
- @Override
- public void lifeCycleStopped(LifeCycle event) {
-
- }
-}
diff --git a/libs/gretty-runner-jetty94/src/main/groovy/org/akhikhl/gretty/SSOAuthenticatorFactory.java b/libs/gretty-runner-jetty94/src/main/groovy/org/akhikhl/gretty/SSOAuthenticatorFactory.java
deleted file mode 100644
index 5395cfcca..000000000
--- a/libs/gretty-runner-jetty94/src/main/groovy/org/akhikhl/gretty/SSOAuthenticatorFactory.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Gretty
- *
- * Copyright (C) 2013-2015 Andrey Hihlovskiy and contributors.
- *
- * See the file "LICENSE" for copying and usage permission.
- * See the file "CONTRIBUTORS" for complete list of contributors.
- */
-package org.akhikhl.gretty;
-
-import org.eclipse.jetty.security.Authenticator.AuthConfiguration;
-import org.eclipse.jetty.security.DefaultAuthenticatorFactory;
-import org.eclipse.jetty.security.IdentityService;
-import org.eclipse.jetty.security.LoginService;
-import org.eclipse.jetty.server.Server;
-import org.eclipse.jetty.util.security.Constraint;
-
-import javax.servlet.ServletContext;
-
-/**
- *
- * @author akhikhl
- */
-public class SSOAuthenticatorFactory extends DefaultAuthenticatorFactory {
-
- @Override
- public org.eclipse.jetty.security.Authenticator getAuthenticator(Server server, ServletContext ctx, AuthConfiguration configuration, IdentityService identityService, LoginService loginService) {
- String auth = configuration.getAuthMethod();
- if (auth==null || Constraint.__BASIC_AUTH.equalsIgnoreCase(auth))
- return new SSOBasicAuthenticator();
- if (Constraint.__DIGEST_AUTH.equalsIgnoreCase(auth))
- return new SSODigestAuthenticator();
- if ( Constraint.__SPNEGO_AUTH.equalsIgnoreCase(auth) )
- return new SSOSpnegoAuthenticator();
- if ( Constraint.__NEGOTIATE_AUTH.equalsIgnoreCase(auth) ) // see Bug #377076
- return new SSOSpnegoAuthenticator(Constraint.__NEGOTIATE_AUTH);
- if (Constraint.__CERT_AUTH.equalsIgnoreCase(auth)||Constraint.__CERT_AUTH2.equalsIgnoreCase(auth))
- return new SSOClientCertAuthenticator();
- return super.getAuthenticator(server, ctx, configuration, identityService, loginService);
- }
-}
diff --git a/libs/gretty-runner-jetty94/src/main/groovy/org/akhikhl/gretty/SSOBasicAuthenticator.java b/libs/gretty-runner-jetty94/src/main/groovy/org/akhikhl/gretty/SSOBasicAuthenticator.java
deleted file mode 100644
index 04988f134..000000000
--- a/libs/gretty-runner-jetty94/src/main/groovy/org/akhikhl/gretty/SSOBasicAuthenticator.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Gretty
- *
- * Copyright (C) 2013-2015 Andrey Hihlovskiy and contributors.
- *
- * See the file "LICENSE" for copying and usage permission.
- * See the file "CONTRIBUTORS" for complete list of contributors.
- */
-package org.akhikhl.gretty;
-
-import org.eclipse.jetty.security.ServerAuthException;
-import org.eclipse.jetty.security.authentication.BasicAuthenticator;
-import org.eclipse.jetty.security.authentication.DeferredAuthentication;
-import org.eclipse.jetty.security.authentication.SessionAuthentication;
-import org.eclipse.jetty.server.Authentication;
-import org.eclipse.jetty.server.Request;
-import org.eclipse.jetty.server.UserIdentity;
-import org.eclipse.jetty.util.MultiMap;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpSession;
-
-import static org.eclipse.jetty.security.authentication.FormAuthenticator.*;
-
-/**
- *
- * @author akhikhl
- */
-public class SSOBasicAuthenticator extends BasicAuthenticator {
-
- private static final Logger LOG = LoggerFactory.getLogger(SSOBasicAuthenticator.class);
-
- // "login" is copied without changes from FormAuthenticator
- @Override
- public UserIdentity login(String username, Object password, ServletRequest request)
- {
-
- UserIdentity user = super.login(username,password,request);
- if (user!=null)
- {
- HttpSession session = ((HttpServletRequest)request).getSession(true);
- Authentication cached=new SessionAuthentication(getAuthMethod(),user,password);
- session.setAttribute(SessionAuthentication.__J_AUTHENTICATED, cached);
- }
- return user;
- }
-
- @Override
- public Authentication validateRequest(ServletRequest req, ServletResponse res, boolean mandatory) throws ServerAuthException
- {
- HttpServletRequest request = (HttpServletRequest)req;
-
- if (!mandatory)
- return new DeferredAuthentication(this);
-
- // ++ copied from FormAuthenticator
-
- HttpSession session = request.getSession(true);
-
- // Look for cached authentication
- Authentication authentication = (Authentication) session.getAttribute(SessionAuthentication.__J_AUTHENTICATED);
- if (authentication != null)
- {
- // Has authentication been revoked?
- if (authentication instanceof Authentication.User &&
- _loginService!=null &&
- !_loginService.validate(((Authentication.User)authentication).getUserIdentity()))
- {
- LOG.debug("auth revoked {}",authentication);
- session.removeAttribute(SessionAuthentication.__J_AUTHENTICATED);
- }
- else
- {
- synchronized (session)
- {
- String j_uri=(String)session.getAttribute(__J_URI);
- if (j_uri!=null)
- {
- //check if the request is for the same url as the original and restore
- //params if it was a post
- LOG.debug("auth retry {}->{}",authentication,j_uri);
- StringBuffer buf = request.getRequestURL();
- if (request.getQueryString() != null)
- buf.append("?").append(request.getQueryString());
-
- if (j_uri.equals(buf.toString()))
- {
- MultiMap j_post = (MultiMap)session.getAttribute(__J_POST);
- if (j_post!=null)
- {
- LOG.debug("auth rePOST {}->{}",authentication,j_uri);
- Request base_request = Request.getBaseRequest(request);
- base_request.setContentParameters(j_post);
- }
- session.removeAttribute(__J_URI);
- session.removeAttribute(__J_METHOD);
- session.removeAttribute(__J_POST);
- }
- }
- }
- LOG.debug("auth {}",authentication);
- return authentication;
- }
- }
- // -- copied from FormAuthenticator
-
- return super.validateRequest(req, res, mandatory);
- }
-}
diff --git a/libs/gretty-runner-jetty94/src/main/groovy/org/akhikhl/gretty/SSOClientCertAuthenticator.java b/libs/gretty-runner-jetty94/src/main/groovy/org/akhikhl/gretty/SSOClientCertAuthenticator.java
deleted file mode 100644
index def86dc4a..000000000
--- a/libs/gretty-runner-jetty94/src/main/groovy/org/akhikhl/gretty/SSOClientCertAuthenticator.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Gretty
- *
- * Copyright (C) 2013-2015 Andrey Hihlovskiy and contributors.
- *
- * See the file "LICENSE" for copying and usage permission.
- * See the file "CONTRIBUTORS" for complete list of contributors.
- */
-package org.akhikhl.gretty;
-
-import org.eclipse.jetty.security.ServerAuthException;
-import org.eclipse.jetty.security.authentication.ClientCertAuthenticator;
-import org.eclipse.jetty.security.authentication.DeferredAuthentication;
-import org.eclipse.jetty.security.authentication.SessionAuthentication;
-import org.eclipse.jetty.server.Authentication;
-import org.eclipse.jetty.server.Request;
-import org.eclipse.jetty.server.UserIdentity;
-import org.eclipse.jetty.util.MultiMap;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpSession;
-
-import static org.eclipse.jetty.security.authentication.FormAuthenticator.*;
-
-/**
- *
- * @author akhikhl
- */
-public class SSOClientCertAuthenticator extends ClientCertAuthenticator {
-
- private static final Logger LOG = LoggerFactory.getLogger(SSOClientCertAuthenticator.class);
-
- // "login" is copied without changes from FormAuthenticator
- @Override
- public UserIdentity login(String username, Object password, ServletRequest request)
- {
-
- UserIdentity user = super.login(username,password,request);
- if (user!=null)
- {
- HttpSession session = ((HttpServletRequest)request).getSession(true);
- Authentication cached=new SessionAuthentication(getAuthMethod(),user,password);
- session.setAttribute(SessionAuthentication.__J_AUTHENTICATED, cached);
- }
- return user;
- }
-
- @Override
- public Authentication validateRequest(ServletRequest req, ServletResponse res, boolean mandatory) throws ServerAuthException
- {
- HttpServletRequest request = (HttpServletRequest)req;
-
- if (!mandatory)
- return new DeferredAuthentication(this);
-
- // ++ copied from FormAuthenticator
-
- HttpSession session = request.getSession(true);
-
- // Look for cached authentication
- Authentication authentication = (Authentication) session.getAttribute(SessionAuthentication.__J_AUTHENTICATED);
- if (authentication != null)
- {
- // Has authentication been revoked?
- if (authentication instanceof Authentication.User &&
- _loginService!=null &&
- !_loginService.validate(((Authentication.User)authentication).getUserIdentity()))
- {
- LOG.debug("auth revoked {}",authentication);
- session.removeAttribute(SessionAuthentication.__J_AUTHENTICATED);
- }
- else
- {
- synchronized (session)
- {
- String j_uri=(String)session.getAttribute(__J_URI);
- if (j_uri!=null)
- {
- //check if the request is for the same url as the original and restore
- //params if it was a post
- LOG.debug("auth retry {}->{}",authentication,j_uri);
- StringBuffer buf = request.getRequestURL();
- if (request.getQueryString() != null)
- buf.append("?").append(request.getQueryString());
-
- if (j_uri.equals(buf.toString()))
- {
- MultiMap j_post = (MultiMap)session.getAttribute(__J_POST);
- if (j_post!=null)
- {
- LOG.debug("auth rePOST {}->{}",authentication,j_uri);
- Request base_request = Request.getBaseRequest(request);
- base_request.setContentParameters(j_post);
- }
- session.removeAttribute(__J_URI);
- session.removeAttribute(__J_METHOD);
- session.removeAttribute(__J_POST);
- }
- }
- }
- LOG.debug("auth {}",authentication);
- return authentication;
- }
- }
- // -- copied from FormAuthenticator
-
- return super.validateRequest(req, res, mandatory);
- }
-}
diff --git a/libs/gretty-runner-jetty94/src/main/groovy/org/akhikhl/gretty/SSODigestAuthenticator.java b/libs/gretty-runner-jetty94/src/main/groovy/org/akhikhl/gretty/SSODigestAuthenticator.java
deleted file mode 100644
index a05c877b4..000000000
--- a/libs/gretty-runner-jetty94/src/main/groovy/org/akhikhl/gretty/SSODigestAuthenticator.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Gretty
- *
- * Copyright (C) 2013-2015 Andrey Hihlovskiy and contributors.
- *
- * See the file "LICENSE" for copying and usage permission.
- * See the file "CONTRIBUTORS" for complete list of contributors.
- */
-package org.akhikhl.gretty;
-
-import org.eclipse.jetty.security.ServerAuthException;
-import org.eclipse.jetty.security.authentication.DeferredAuthentication;
-import org.eclipse.jetty.security.authentication.DigestAuthenticator;
-import org.eclipse.jetty.security.authentication.SessionAuthentication;
-import org.eclipse.jetty.server.Authentication;
-import org.eclipse.jetty.server.Request;
-import org.eclipse.jetty.server.UserIdentity;
-import org.eclipse.jetty.util.MultiMap;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpSession;
-
-import static org.eclipse.jetty.security.authentication.FormAuthenticator.*;
-
-/**
- *
- * @author akhikhl
- */
-class SSODigestAuthenticator extends DigestAuthenticator {
-
- private static final Logger LOG = LoggerFactory.getLogger(SSOBasicAuthenticator.class);
-
- // "login" is copied without changes from FormAuthenticator
- @Override
- public UserIdentity login(String username, Object password, ServletRequest request)
- {
-
- UserIdentity user = super.login(username,password,request);
- if (user!=null)
- {
- HttpSession session = ((HttpServletRequest)request).getSession(true);
- Authentication cached=new SessionAuthentication(getAuthMethod(),user,password);
- session.setAttribute(SessionAuthentication.__J_AUTHENTICATED, cached);
- }
- return user;
- }
-
- @Override
- public Authentication validateRequest(ServletRequest req, ServletResponse res, boolean mandatory) throws ServerAuthException
- {
- HttpServletRequest request = (HttpServletRequest)req;
-
- if (!mandatory)
- return new DeferredAuthentication(this);
-
- // ++ copied from FormAuthenticator
-
- HttpSession session = request.getSession(true);
-
- // Look for cached authentication
- Authentication authentication = (Authentication) session.getAttribute(SessionAuthentication.__J_AUTHENTICATED);
- if (authentication != null)
- {
- // Has authentication been revoked?
- if (authentication instanceof Authentication.User &&
- _loginService!=null &&
- !_loginService.validate(((Authentication.User)authentication).getUserIdentity()))
- {
- LOG.debug("auth revoked {}",authentication);
- session.removeAttribute(SessionAuthentication.__J_AUTHENTICATED);
- }
- else
- {
- synchronized (session)
- {
- String j_uri=(String)session.getAttribute(__J_URI);
- if (j_uri!=null)
- {
- //check if the request is for the same url as the original and restore
- //params if it was a post
- LOG.debug("auth retry {}->{}",authentication,j_uri);
- StringBuffer buf = request.getRequestURL();
- if (request.getQueryString() != null)
- buf.append("?").append(request.getQueryString());
-
- if (j_uri.equals(buf.toString()))
- {
- MultiMap j_post = (MultiMap)session.getAttribute(__J_POST);
- if (j_post!=null)
- {
- LOG.debug("auth rePOST {}->{}",authentication,j_uri);
- Request base_request = Request.getBaseRequest(request);
- base_request.setContentParameters(j_post);
- }
- session.removeAttribute(__J_URI);
- session.removeAttribute(__J_METHOD);
- session.removeAttribute(__J_POST);
- }
- }
- }
- LOG.debug("auth {}",authentication);
- return authentication;
- }
- }
- // -- copied from FormAuthenticator
-
- return super.validateRequest(req, res, mandatory);
- }
-}
diff --git a/libs/gretty-runner-jetty94/src/main/groovy/org/akhikhl/gretty/SSOSpnegoAuthenticator.java b/libs/gretty-runner-jetty94/src/main/groovy/org/akhikhl/gretty/SSOSpnegoAuthenticator.java
deleted file mode 100644
index f57415380..000000000
--- a/libs/gretty-runner-jetty94/src/main/groovy/org/akhikhl/gretty/SSOSpnegoAuthenticator.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * Gretty
- *
- * Copyright (C) 2013-2015 Andrey Hihlovskiy and contributors.
- *
- * See the file "LICENSE" for copying and usage permission.
- * See the file "CONTRIBUTORS" for complete list of contributors.
- */
-package org.akhikhl.gretty;
-
-import org.eclipse.jetty.security.ServerAuthException;
-import org.eclipse.jetty.security.authentication.DeferredAuthentication;
-import org.eclipse.jetty.security.authentication.SessionAuthentication;
-import org.eclipse.jetty.security.authentication.SpnegoAuthenticator;
-import org.eclipse.jetty.server.Authentication;
-import org.eclipse.jetty.server.Request;
-import org.eclipse.jetty.server.UserIdentity;
-import org.eclipse.jetty.util.MultiMap;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpSession;
-
-import static org.eclipse.jetty.security.authentication.FormAuthenticator.*;
-
-/**
- *
- * @author akhikhl
- */
-public class SSOSpnegoAuthenticator extends SpnegoAuthenticator {
-
- private static final Logger LOG = LoggerFactory.getLogger(SSOSpnegoAuthenticator.class);
-
- public SSOSpnegoAuthenticator() {
- }
-
- public SSOSpnegoAuthenticator(String authMethod) {
- super(authMethod);
- }
-
- // "login" is copied without changes from FormAuthenticator
- @Override
- public UserIdentity login(String username, Object password, ServletRequest request)
- {
-
- UserIdentity user = super.login(username,password,request);
- if (user!=null)
- {
- HttpSession session = ((HttpServletRequest)request).getSession(true);
- Authentication cached=new SessionAuthentication(getAuthMethod(),user,password);
- session.setAttribute(SessionAuthentication.__J_AUTHENTICATED, cached);
- }
- return user;
- }
-
- @Override
- public Authentication validateRequest(ServletRequest req, ServletResponse res, boolean mandatory) throws ServerAuthException
- {
- HttpServletRequest request = (HttpServletRequest)req;
-
- if (!mandatory)
- return new DeferredAuthentication(this);
-
- // ++ copied from FormAuthenticator
-
- HttpSession session = request.getSession(true);
-
- // Look for cached authentication
- Authentication authentication = (Authentication) session.getAttribute(SessionAuthentication.__J_AUTHENTICATED);
- if (authentication != null)
- {
- // Has authentication been revoked?
- if (authentication instanceof Authentication.User &&
- _loginService!=null &&
- !_loginService.validate(((Authentication.User)authentication).getUserIdentity()))
- {
- LOG.debug("auth revoked {}",authentication);
- session.removeAttribute(SessionAuthentication.__J_AUTHENTICATED);
- }
- else
- {
- synchronized (session)
- {
- String j_uri=(String)session.getAttribute(__J_URI);
- if (j_uri!=null)
- {
- //check if the request is for the same url as the original and restore
- //params if it was a post
- LOG.debug("auth retry {}->{}",authentication,j_uri);
- StringBuffer buf = request.getRequestURL();
- if (request.getQueryString() != null)
- buf.append("?").append(request.getQueryString());
-
- if (j_uri.equals(buf.toString()))
- {
- MultiMap j_post = (MultiMap)session.getAttribute(__J_POST);
- if (j_post!=null)
- {
- LOG.debug("auth rePOST {}->{}",authentication,j_uri);
- Request base_request = Request.getBaseRequest(request);
- base_request.setContentParameters(j_post);
- }
- session.removeAttribute(__J_URI);
- session.removeAttribute(__J_METHOD);
- session.removeAttribute(__J_POST);
- }
- }
- }
- LOG.debug("auth {}",authentication);
- return authentication;
- }
- }
- // -- copied from FormAuthenticator
-
- return super.validateRequest(req, res, mandatory);
- }
-}
diff --git a/libs/gretty-runner-jetty94/src/main/groovy/org/akhikhl/gretty/WebInfConfigurationEx.groovy b/libs/gretty-runner-jetty94/src/main/groovy/org/akhikhl/gretty/WebInfConfigurationEx.groovy
deleted file mode 100644
index 6b10fa14b..000000000
--- a/libs/gretty-runner-jetty94/src/main/groovy/org/akhikhl/gretty/WebInfConfigurationEx.groovy
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Gretty
- *
- * Copyright (C) 2013-2015 Andrey Hihlovskiy and contributors.
- *
- * See the file "LICENSE" for copying and usage permission.
- * See the file "CONTRIBUTORS" for complete list of contributors.
- */
-package org.akhikhl.gretty
-
-import groovy.transform.CompileStatic
-import groovy.transform.TypeCheckingMode
-import org.eclipse.jetty.util.resource.Resource
-import org.eclipse.jetty.util.resource.ResourceCollection
-import org.eclipse.jetty.webapp.WebAppContext
-import org.eclipse.jetty.webapp.WebInfConfiguration
-
-@CompileStatic(TypeCheckingMode.SKIP)
-class WebInfConfigurationEx extends WebInfConfiguration implements BaseResourceConfiguration {
-
- private List extraResourceBases
- private final List baseResourceListeners = []
-
- @Override
- void addBaseResourceListener(Closure closure) {
- baseResourceListeners.add(closure)
- }
-
- @Override
- void setExtraResourceBases(List extraResourceBases) {
- this.extraResourceBases = extraResourceBases
- }
-
- @Override
- public void unpack (WebAppContext context) throws IOException {
- super.unpack(context)
- if(extraResourceBases) {
- Resource res = context.getBaseResource()
- List resources = []
- if(res instanceof ResourceCollection)
- resources.addAll(res.getResources())
- else
- resources.add(res)
- for(def e in extraResourceBases)
- resources.add(Resource.newResource(e))
- context.setBaseResource(new ResourceCollection(resources as Resource[]))
- }
- for(Closure closure in baseResourceListeners)
- closure(context)
- }
-}
diff --git a/libs/gretty-runner-jetty94/src/main/java/org/akhikhl/gretty/FilteringClassLoader.java b/libs/gretty-runner-jetty94/src/main/java/org/akhikhl/gretty/FilteringClassLoader.java
deleted file mode 100644
index 7d97d21d1..000000000
--- a/libs/gretty-runner-jetty94/src/main/java/org/akhikhl/gretty/FilteringClassLoader.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Gretty
- *
- * Copyright (C) 2013-2015 Andrey Hihlovskiy and contributors.
- *
- * See the file "LICENSE" for copying and usage permission.
- * See the file "CONTRIBUTORS" for complete list of contributors.
- */
-package org.akhikhl.gretty;
-
-import org.eclipse.jetty.webapp.WebAppClassLoader;
-
-import java.io.IOException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Enumeration;
-import java.util.List;
-
-/**
- * Properly implements "server classes" concept.
- *
- * @author akhikhl
- */
-public class FilteringClassLoader extends WebAppClassLoader {
-
- private final List serverClasses = new ArrayList();
-
- private final List serverResources = new ArrayList();
-
- private ClassLoader bootClassLoader;
-
- public FilteringClassLoader(Context context) throws IOException {
- super(context);
- findBootClassLoader();
- }
-
- public FilteringClassLoader(ClassLoader parent, Context context) throws IOException {
- super(parent, context);
- findBootClassLoader();
- }
-
- protected void findBootClassLoader() {
- bootClassLoader = getParent();
- if (bootClassLoader != null) {
- while(bootClassLoader.getParent() != null) {
- bootClassLoader = bootClassLoader.getParent();
- }
- }
- }
-
- public void addServerClass(String serverClass) {
- serverClasses.add(serverClass);
- serverResources.add(serverClass.replace('.', '/'));
- serverResources.add("META-INF/services/" + serverClass);
- }
-
- @Override
- protected Class> loadClass(String name, boolean resolve) throws ClassNotFoundException {
- for(String serverClass : serverClasses)
- if(name.startsWith(serverClass)) {
- Class> c = findLoadedClass(name);
- if(c == null)
- c = findClass(name);
- if(c != null) {
- if(resolve)
- resolveClass(c);
- return c;
- }
- throw new ClassNotFoundException(name);
- }
- return super.loadClass(name, resolve);
- }
-
- @Override
- public Enumeration getResources(String name) throws IOException {
- for(String serverResource : serverResources) {
- if(name.startsWith(serverResource)) {
- final List resources = new ArrayList<>();
- resources.addAll(Collections.list(getBootstrapResources(name)));
- resources.addAll(Collections.list(findResources(name)));
- return Collections.enumeration(resources);
- }
- }
- return super.getResources(name);
- }
-
- private Enumeration getBootstrapResources(String name) throws IOException {
- return bootClassLoader.getResources(name);
- }
-}
diff --git a/libs/gretty-runner-tomcat/build.gradle b/libs/gretty-runner-tomcat/build.gradle
index 006c896af..3279152df 100644
--- a/libs/gretty-runner-tomcat/build.gradle
+++ b/libs/gretty-runner-tomcat/build.gradle
@@ -1,14 +1,8 @@
-import org.gradle.util.VersionNumber
-
apply from: rootProject.file('common.gradle')
dependencies {
compile project(':libs:gretty-runner')
compile "org.slf4j:log4j-over-slf4j:$slf4j_version"
- // These dependencies are needed for compiling gretty-runner-tomcat.
- // They are replaced by "real" dependencies at runtime.
- compile "javax.servlet:javax.servlet-api:$tomcat85_servlet_api_version"
- compile "org.apache.tomcat.embed:tomcat-embed-core:$tomcat85_version"
- if (VersionNumber.parse(tomcat85_version) <= VersionNumber.parse('8.5.2'))
- compile "org.apache.tomcat.embed:tomcat-embed-logging-log4j:$tomcat85_version"
+ compileOnly "jakarta.servlet:jakarta.servlet-api:$tomcat10_servlet_api_version"
+ compileOnly "org.apache.tomcat.embed:tomcat-embed-core:$tomcat10_version"
}
diff --git a/libs/gretty-runner-tomcat/src/main/java/org/akhikhl/gretty/TomcatEmbeddedWebappClassLoader.java b/libs/gretty-runner-tomcat/src/main/java/org/akhikhl/gretty/TomcatEmbeddedWebappClassLoader.java
index f47cb7527..0b8834b21 100644
--- a/libs/gretty-runner-tomcat/src/main/java/org/akhikhl/gretty/TomcatEmbeddedWebappClassLoader.java
+++ b/libs/gretty-runner-tomcat/src/main/java/org/akhikhl/gretty/TomcatEmbeddedWebappClassLoader.java
@@ -46,7 +46,7 @@ public synchronized Class> loadClass(String name, boolean resolve) throws Clas
checkPackageAccess(name);
// Perform the actual load
- boolean delegateLoad = (this.delegate || filter(name));
+ boolean delegateLoad = (this.delegate || filter(name, true));
if (delegateLoad)
resultClass = (resultClass == null ? loadFromParent(name) : resultClass);
diff --git a/libs/gretty-runner-tomcat10/build.gradle b/libs/gretty-runner-tomcat10/build.gradle
new file mode 100644
index 000000000..e69de29bb
diff --git a/libs/gretty-runner-tomcat85/build.gradle b/libs/gretty-runner-tomcat85/build.gradle
deleted file mode 100644
index 48c698104..000000000
--- a/libs/gretty-runner-tomcat85/build.gradle
+++ /dev/null
@@ -1,17 +0,0 @@
-import org.gradle.util.VersionNumber
-
-apply from: rootProject.file('common.gradle')
-
-dependencies {
- compile project(':libs:gretty-runner-tomcat8plus'), {
- exclude group: 'org.apache.tomcat.embed'
- exclude group: 'javax.servlet', module: 'javax.servlet-api'
- }
- compile "org.apache.tomcat.embed:tomcat-embed-core:$tomcat85_version"
- compile "org.apache.tomcat.embed:tomcat-embed-el:$tomcat85_version"
- compile "org.apache.tomcat.embed:tomcat-embed-jasper:$tomcat85_version"
- if (VersionNumber.parse(tomcat85_version) <= VersionNumber.parse('8.5.2'))
- compile "org.apache.tomcat.embed:tomcat-embed-logging-log4j:$tomcat85_version"
- compile "org.apache.tomcat.embed:tomcat-embed-websocket:$tomcat85_version"
- compile "javax.servlet:javax.servlet-api:$tomcat85_servlet_api_version"
-}
diff --git a/libs/gretty-runner-tomcat85/src/main/groovy/org/akhikhl/gretty/TomcatConfigurerImpl.groovy b/libs/gretty-runner-tomcat85/src/main/groovy/org/akhikhl/gretty/TomcatConfigurerImpl.groovy
deleted file mode 100644
index f6d743ecf..000000000
--- a/libs/gretty-runner-tomcat85/src/main/groovy/org/akhikhl/gretty/TomcatConfigurerImpl.groovy
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Gretty
- *
- * Copyright (C) 2013-2015 Andrey Hihlovskiy and contributors.
- *
- * See the file "LICENSE" for copying and usage permission.
- * See the file "CONTRIBUTORS" for complete list of contributors.
- */
-package org.akhikhl.gretty
-import org.apache.catalina.Service
-import org.apache.catalina.startup.Tomcat
-/**
- *
- * @author akhikhl
- */
-class TomcatConfigurerImpl extends AbstractTomcatConfigurerImpl {
- @Override
- void setService(Tomcat tomcat, Service service) {
- }
-
- @Override
- void setEngine(Tomcat tomcat, Service service) {
- }
-}
diff --git a/libs/gretty-runner-tomcat8plus/build.gradle b/libs/gretty-runner-tomcat8plus/build.gradle
deleted file mode 100644
index 3d6be38cc..000000000
--- a/libs/gretty-runner-tomcat8plus/build.gradle
+++ /dev/null
@@ -1,13 +0,0 @@
-apply from: rootProject.file('common.gradle')
-
-dependencies {
- compile project(':libs:gretty-runner-tomcat'), {
- exclude group: 'org.apache.tomcat.embed'
- exclude group: 'javax.servlet', module: 'javax.servlet-api'
- }
- compile "org.apache.tomcat.embed:tomcat-embed-core:$tomcat85_version"
- compile "org.apache.tomcat.embed:tomcat-embed-el:$tomcat85_version"
- compile "org.apache.tomcat.embed:tomcat-embed-jasper:$tomcat85_version"
- compile "org.apache.tomcat.embed:tomcat-embed-websocket:$tomcat85_version"
- compile "javax.servlet:javax.servlet-api:$tomcat85_servlet_api_version"
-}
diff --git a/libs/gretty-runner-tomcat8plus/src/main/groovy/org/akhikhl/gretty/AbstractTomcatConfigurerImpl.groovy b/libs/gretty-runner-tomcat8plus/src/main/groovy/org/akhikhl/gretty/AbstractTomcatConfigurerImpl.groovy
deleted file mode 100644
index e1c0e6aec..000000000
--- a/libs/gretty-runner-tomcat8plus/src/main/groovy/org/akhikhl/gretty/AbstractTomcatConfigurerImpl.groovy
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Gretty
- *
- * Copyright (C) 2013-2015 Andrey Hihlovskiy and contributors.
- *
- * See the file "LICENSE" for copying and usage permission.
- * See the file "CONTRIBUTORS" for complete list of contributors.
- */
-package org.akhikhl.gretty
-
-import groovy.transform.CompileStatic
-import groovy.transform.TypeCheckingMode
-import org.apache.catalina.WebResourceRoot
-import org.apache.catalina.core.StandardContext
-import org.apache.catalina.startup.ContextConfig
-import org.apache.catalina.startup.Tomcat
-import org.apache.catalina.webresources.StandardRoot
-import org.apache.tomcat.JarScanner
-import org.apache.tomcat.util.descriptor.web.WebXml
-import org.slf4j.Logger
-import org.slf4j.LoggerFactory
-/**
- *
- * @author akhikhl
- */
-@CompileStatic(TypeCheckingMode.SKIP)
-abstract class AbstractTomcatConfigurerImpl implements TomcatConfigurer {
-
- private static final Logger log = LoggerFactory.getLogger(AbstractTomcatConfigurerImpl)
-
- @Override
- ContextConfig createContextConfig(URL[] classpathUrls) {
-
- new ContextConfig() {
-
- protected Map processJarsForWebFragments(WebXml application) {
- def fragments = super.processJarsForWebFragments(application)
- // here we enable annotation processing for non-jar urls on the classpath
- for(URL url in classpathUrls.findAll { !it.path.endsWith('.jar') && new File(it.path).exists() }) {
- WebXml fragment = new WebXml()
- fragment.setDistributable(true)
- fragment.setURL(url)
- fragment.setName(url.toString())
- fragments[fragment.getName()] = fragment
- }
- fragments
- }
- }
- }
-
- @Override
- JarScanner createJarScanner(JarScanner jarScanner, JarSkipPatterns skipPatterns) {
- new SkipPatternJarScanner(jarScanner, skipPatterns)
- }
-
- @Override
- void setBaseDir(Tomcat tomcat, File baseDir) {
- tomcat.baseDir = baseDir.absolutePath
- tomcat.server.setCatalinaHome(baseDir)
- tomcat.server.setCatalinaBase(baseDir)
- }
-
- @Override
- void setResourceBase(StandardContext context, Map webappParams) {
-
- context.setDocBase(webappParams.resourceBase)
-
- WebResourceRoot root = new StandardRoot(context)
- context.setResources(root)
-
- if(webappParams.extraResourceBases)
- webappParams.extraResourceBases.each { root.createWebResourceSet(WebResourceRoot.ResourceSetType.POST, '/', it, null, '/') }
-
-
- if (webappParams.webXml)
- context.setAltDDName(webappParams.webXml);
-
- Set classpathJarParentDirs = webappParams.webappClassPath.findAll { it.endsWith('.jar') }.collect({
- File jarFile = it.startsWith('file:') ? new File(new URI(it)) : new File(it)
- jarFile
- }) as Set
-
- classpathJarParentDirs.each { File it ->
- root.createWebResourceSet(WebResourceRoot.ResourceSetType.POST, '/WEB-INF/lib/' + it.name, it.absolutePath, null, '/')
- }
- }
-}
diff --git a/libs/gretty-runner-tomcat8plus/src/main/groovy/org/akhikhl/gretty/SkipPatternJarScanner.groovy b/libs/gretty-runner-tomcat8plus/src/main/groovy/org/akhikhl/gretty/SkipPatternJarScanner.groovy
deleted file mode 100644
index 5258cd848..000000000
--- a/libs/gretty-runner-tomcat8plus/src/main/groovy/org/akhikhl/gretty/SkipPatternJarScanner.groovy
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Gretty
- *
- * Copyright (C) 2013-2015 Andrey Hihlovskiy and contributors.
- *
- * See the file "LICENSE" for copying and usage permission.
- * See the file "CONTRIBUTORS" for complete list of contributors.
- */
-package org.akhikhl.gretty
-
-import org.apache.tomcat.Jar
-
-import javax.servlet.ServletContext
-import org.apache.tomcat.JarScanFilter
-import org.apache.tomcat.JarScanner
-import org.apache.tomcat.JarScannerCallback
-import org.apache.tomcat.util.scan.StandardJarScanFilter
-import org.apache.tomcat.util.scan.StandardJarScanner
-import org.apache.tomcat.JarScanType
-import org.apache.tomcat.util.file.Matcher;
-import org.slf4j.Logger
-import org.slf4j.LoggerFactory
-
-/**
- *
- * @author akhikhl
- */
-class SkipPatternJarScanner extends StandardJarScanner {
-
- private static final Logger log = LoggerFactory.getLogger(SkipPatternJarScanner)
-
- protected final JarScanner jarScanner
- protected final JarSkipPatterns skipPatterns
-
- SkipPatternJarScanner(JarScanner jarScanner, JarSkipPatterns skipPatterns) {
- assert jarScanner != null
- this.jarScanner = jarScanner
- this.skipPatterns = skipPatterns
- setJarScanFilter(new StandardJarScanFilter())
- }
-
- protected JarScannerCallback augmentCallback(final JarScannerCallback callback) {
-
- if(!log.isDebugEnabled())
- return callback
-
- return new JarScannerCallback() {
-
- void scan(Jar jar, String webappPath, boolean isWebapp) throws IOException {
- log.debug('jarScannerCallback.scan {}, {}, {}', jar, webappPath, isWebapp)
- callback.scan(jar, webappPath, isWebapp)
- }
-
- void scan(File file, String webappPath, boolean isWebapp) throws IOException {
- log.debug('jarScannerCallback.scan {}, {}, {}', file, webappPath, isWebapp)
- callback.scan(file, webappPath, isWebapp)
- }
-
- void scanWebInfClasses() throws IOException {
- log.debug('jarScannerCallback.scanWebInfClasses')
- callback.scanWebInfClasses()
- }
- }
- }
-
- protected boolean checkJar(String path) {
- String name = path.substring(path.lastIndexOf('/') + 1)
- boolean result = !Matcher.matchName(skipPatterns.asSet(), name)
- log.debug 'filter jar: {} -> {}', name, result
- result
- }
-
- @Override
- public void setJarScanFilter(JarScanFilter newFilter) {
- super.setJarScanFilter(newFilter)
- jarScanner.setJarScanFilter(new TomcatJarScanFilter(newFilter))
- }
-
- @Override
- public void scan(JarScanType scanType, ServletContext context, JarScannerCallback callback) {
- jarScanner.scan(scanType, context, augmentCallback(callback))
- }
-
- private class TomcatJarScanFilter implements JarScanFilter {
-
- private final JarScanFilter additionalScanFilter
-
- TomcatJarScanFilter(JarScanFilter additionalScanFilter) {
- this.additionalScanFilter = additionalScanFilter
- }
-
- @Override
- boolean check(JarScanType jarScanType, String jarName) {
- checkJar(jarName) && (additionalScanFilter == null || additionalScanFilter.check(jarScanType, jarName))
- }
- }
-}
diff --git a/libs/gretty-runner-tomcat8plus/src/main/groovy/org/akhikhl/gretty/TomcatConfigurerImpl.groovy b/libs/gretty-runner-tomcat8plus/src/main/groovy/org/akhikhl/gretty/TomcatConfigurerImpl.groovy
deleted file mode 100644
index 727f963c2..000000000
--- a/libs/gretty-runner-tomcat8plus/src/main/groovy/org/akhikhl/gretty/TomcatConfigurerImpl.groovy
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Gretty
- *
- * Copyright (C) 2013-2015 Andrey Hihlovskiy and contributors.
- *
- * See the file "LICENSE" for copying and usage permission.
- * See the file "CONTRIBUTORS" for complete list of contributors.
- */
-package org.akhikhl.gretty
-
-import groovy.transform.CompileStatic
-import groovy.transform.TypeCheckingMode
-import org.apache.catalina.Service
-import org.apache.catalina.startup.Tomcat
-/**
- *
- * @author akhikhl
- */
-@CompileStatic(TypeCheckingMode.SKIP)
-class TomcatConfigurerImpl extends AbstractTomcatConfigurerImpl {
- @Override
- void setService(Tomcat tomcat, Service service) {
- tomcat.service = service
- }
-
- @Override
- void setEngine(Tomcat tomcat, Service service) {
- tomcat.engine = service.getContainer()
- }
-}
diff --git a/libs/gretty-runner-tomcat9/build.gradle b/libs/gretty-runner-tomcat9/build.gradle
deleted file mode 100644
index cdbc83a2d..000000000
--- a/libs/gretty-runner-tomcat9/build.gradle
+++ /dev/null
@@ -1,13 +0,0 @@
-apply from: rootProject.file('common.gradle')
-
-dependencies {
- compile project(':libs:gretty-runner-tomcat85'), {
- exclude group: 'org.apache.tomcat.embed'
- exclude group: 'javax.servlet', module: 'javax.servlet-api'
- }
- compile "org.apache.tomcat.embed:tomcat-embed-core:$tomcat9_version"
- compile "org.apache.tomcat.embed:tomcat-embed-el:$tomcat9_version"
- compile "org.apache.tomcat.embed:tomcat-embed-jasper:$tomcat9_version"
- compile "org.apache.tomcat.embed:tomcat-embed-websocket:$tomcat9_version"
- compile "javax.servlet:javax.servlet-api:$tomcat9_servlet_api_version"
-}
diff --git a/libs/gretty/build.gradle b/libs/gretty/build.gradle
index 8cefcf6d6..56ba22b5c 100644
--- a/libs/gretty/build.gradle
+++ b/libs/gretty/build.gradle
@@ -11,7 +11,7 @@ dependencies {
exclude group: 'ch.qos.logback', module: 'logback-classic'
}
compile "org.springframework.boot:spring-boot-loader-tools:${springBootVersion}"
- compile "org.eclipse.jetty:jetty-util:$jetty8_version"
+ compile "org.eclipse.jetty:jetty-util:$jetty10_version"
compile gradleApi()
}
diff --git a/libs/gretty/src/main/groovy/org/akhikhl/gretty/GrettyPlugin.groovy b/libs/gretty/src/main/groovy/org/akhikhl/gretty/GrettyPlugin.groovy
index 66b71c71b..259eabbba 100644
--- a/libs/gretty/src/main/groovy/org/akhikhl/gretty/GrettyPlugin.groovy
+++ b/libs/gretty/src/main/groovy/org/akhikhl/gretty/GrettyPlugin.groovy
@@ -768,30 +768,14 @@ class GrettyPlugin implements Plugin {
project.ext {
grettyVersion = Externalized.getString('grettyVersion')
- if(!has('jetty7Version'))
- jetty7Version = Externalized.getString('jetty7Version')
- if(!has('jetty7ServletApiVersion'))
- jetty7ServletApiVersion = Externalized.getString('jetty7ServletApiVersion')
- if(!has('jetty8Version'))
- jetty8Version = Externalized.getString('jetty8Version')
- if(!has('jetty8ServletApiVersion'))
- jetty8ServletApiVersion = Externalized.getString('jetty8ServletApiVersion')
- if(!has('jetty9Version'))
- jetty9Version = Externalized.getString('jetty9Version')
- if(!has('jetty93Version'))
- jetty93Version = Externalized.getString('jetty93Version')
- if(!has('jetty94Version'))
- jetty94Version = Externalized.getString('jetty94Version')
- if(!has('jetty9ServletApiVersion'))
- jetty9ServletApiVersion = Externalized.getString('jetty9ServletApiVersion')
- if(!has('tomcat85Version'))
- tomcat85Version = Externalized.getString('tomcat85Version')
- if(!has('tomcat85ServletApiVersion'))
- tomcat85ServletApiVersion = Externalized.getString('tomcat85ServletApiVersion')
- if(!has('tomcat9Version'))
- tomcat9Version = Externalized.getString('tomcat9Version')
- if(!has('tomcat9ServletApiVersion'))
- tomcat9ServletApiVersion = Externalized.getString('tomcat9ServletApiVersion')
+ if(!has('jetty10Version'))
+ jetty10Version = Externalized.getString('jetty10Version')
+ if(!has('jetty10ServletApiVersion'))
+ jetty10ServletApiVersion = Externalized.getString('jetty10ServletApiVersion')
+ if(!has('tomcat10Version'))
+ tomcat10Version = Externalized.getString('tomcat10Version')
+ if(!has('tomcat10ServletApiVersion'))
+ tomcat10ServletApiVersion = Externalized.getString('tomcat10ServletApiVersion')
if(!has('asmVersion'))
asmVersion = Externalized.getString('asmVersion')
}
diff --git a/libs/gretty/src/main/groovy/org/akhikhl/gretty/ServletContainerConfig.groovy b/libs/gretty/src/main/groovy/org/akhikhl/gretty/ServletContainerConfig.groovy
index 18e2aa2c9..193877e8b 100644
--- a/libs/gretty/src/main/groovy/org/akhikhl/gretty/ServletContainerConfig.groovy
+++ b/libs/gretty/src/main/groovy/org/akhikhl/gretty/ServletContainerConfig.groovy
@@ -48,213 +48,70 @@ class ServletContainerConfig {
private static createConfigs() {
String grettyVersion = Externalized.getString('grettyVersion')
def runnerGroup = "org.gretty"
- def configs = [ 'jetty7': [
- servletContainerType: 'jetty',
- servletContainerVersion: { project -> project.ext.jetty7Version },
- servletContainerDescription: { project -> "Jetty ${project.ext.jetty7Version}" },
- servletContainerRunnerConfig: 'grettyRunnerJetty7',
- servletContainerRunnerDependencies: { project ->
- project.dependencies.add servletContainerRunnerConfig, "${runnerGroup}:gretty-runner-jetty7:$grettyVersion"
- addRedirectFilter(project, servletContainerRunnerConfig)
- project.configurations[servletContainerRunnerConfig].resolutionStrategy {
- force "javax.servlet:servlet-api:$project.ext.jetty7ServletApiVersion"
- def jetty7_version = project.ext.jetty7Version
- force "org.eclipse.jetty:jetty-server:$jetty7_version"
- force "org.eclipse.jetty:jetty-servlet:$jetty7_version"
- force "org.eclipse.jetty:jetty-webapp:$jetty7_version"
- force "org.eclipse.jetty:jetty-security:$jetty7_version"
- force "org.eclipse.jetty:jetty-jsp:$jetty7_version"
- force "org.eclipse.jetty:jetty-plus:$jetty7_version"
- }
- },
- servletApiVersion: { project -> project.ext.jetty7ServletApiVersion },
- servletApiDependencies: { project ->
- project.dependencies {
- grettyProvidedCompile "javax.servlet:servlet-api:$project.ext.jetty7ServletApiVersion"
- }
- }
- ],
- 'jetty8': [
- servletContainerType: 'jetty',
- servletContainerVersion: { project -> project.ext.jetty8Version },
- servletContainerDescription: { project -> "Jetty ${project.ext.jetty8Version}" },
- servletContainerRunnerConfig: 'grettyRunnerJetty8',
- servletContainerRunnerDependencies: { project ->
- project.dependencies.add servletContainerRunnerConfig, "${runnerGroup}:gretty-runner-jetty8:$grettyVersion"
- addRedirectFilter(project, servletContainerRunnerConfig)
- project.configurations[servletContainerRunnerConfig].resolutionStrategy {
- force "javax.servlet:javax.servlet-api:${project.ext.jetty8ServletApiVersion}"
- def jetty8_version = project.ext.jetty8Version
- force "org.eclipse.jetty:jetty-server:$jetty8_version"
- force "org.eclipse.jetty:jetty-servlet:$jetty8_version"
- force "org.eclipse.jetty:jetty-webapp:$jetty8_version"
- force "org.eclipse.jetty:jetty-security:$jetty8_version"
- force "org.eclipse.jetty:jetty-jsp:$jetty8_version"
- force "org.eclipse.jetty:jetty-annotations:$jetty8_version"
- force "org.eclipse.jetty:jetty-plus:$jetty8_version"
- }
- },
- servletApiVersion: { project -> project.ext.jetty8ServletApiVersion },
- servletApiDependencies: { project ->
- project.dependencies {
- grettyProvidedCompile "javax.servlet:javax.servlet-api:${project.ext.jetty8ServletApiVersion}"
- }
+ def configs = [:]
+ configs['jetty10'] = [
+ servletContainerType: 'jetty',
+ servletContainerVersion: { project -> project.ext.jetty10Version },
+ servletContainerDescription: { project -> "Jetty ${project.ext.jetty10Version}" },
+ servletContainerRunnerConfig: 'grettyRunnerJetty10',
+ servletContainerRunnerDependencies: { project ->
+ project.dependencies.add servletContainerRunnerConfig, "${runnerGroup}:gretty-runner-jetty10:$grettyVersion"
+ addRedirectFilter(project, servletContainerRunnerConfig)
+ project.configurations[servletContainerRunnerConfig].resolutionStrategy {
+ force "jakarta.servlet:jakarta.servlet-api:${project.ext.jetty10ServletApiVersion}"
+ def jettyVversion = project.ext.jetty10Version
+ force "org.eclipse.jetty:jetty-server:$jettVersion"
+ force "org.eclipse.jetty:jetty-servlet:$jettyVersion"
+ force "org.eclipse.jetty:jetty-webapp:$jettyVersion"
+ force "org.eclipse.jetty:jetty-security:$jettyVersion"
+ force "org.eclipse.jetty:apache-jsp:$jettyVersion"
+ force "org.eclipse.jetty:jetty-annotations:$jettyVersion"
+ force "org.eclipse.jetty:jetty-plus:$jettyVersion"
+ force "org.eclipse.jetty.websocket:javax-websocket-server-impl:$jettyVersion"
+ def asm_version = project.ext.asmVersion
+ force "org.ow2.asm:asm:$asm_version"
+ force "org.ow2.asm:asm-commons:$asm_version"
}
- ],
- 'jetty9': [
- servletContainerType: 'jetty',
- servletContainerVersion: { project -> project.ext.jetty9Version },
- servletContainerDescription: { project -> "Jetty ${project.ext.jetty9Version}" },
- servletContainerRunnerConfig: 'grettyRunnerJetty9',
- servletContainerRunnerDependencies: { project ->
- project.dependencies.add servletContainerRunnerConfig, "${runnerGroup}:gretty-runner-jetty9:$grettyVersion"
- addRedirectFilter(project, servletContainerRunnerConfig)
- project.configurations[servletContainerRunnerConfig].resolutionStrategy {
- force "javax.servlet:javax.servlet-api:${project.ext.jetty9ServletApiVersion}"
- def jetty9_version = project.ext.jetty9Version
- force "org.eclipse.jetty:jetty-server:$jetty9_version"
- force "org.eclipse.jetty:jetty-servlet:$jetty9_version"
- force "org.eclipse.jetty:jetty-webapp:$jetty9_version"
- force "org.eclipse.jetty:jetty-security:$jetty9_version"
- force "org.eclipse.jetty:jetty-jsp:$jetty9_version"
- force "org.eclipse.jetty:jetty-annotations:$jetty9_version"
- force "org.eclipse.jetty:jetty-plus:$jetty9_version"
- force "org.eclipse.jetty.websocket:javax-websocket-server-impl:$jetty9_version"
- def asm_version = project.ext.asmVersion
- force "org.ow2.asm:asm:$asm_version"
- force "org.ow2.asm:asm-commons:$asm_version"
- }
- },
- servletApiVersion: { project -> project.ext.jetty9ServletApiVersion },
- servletApiDependencies: { project ->
- project.dependencies {
- grettyProvidedCompile "javax.servlet:javax.servlet-api:${project.ext.jetty9ServletApiVersion}"
- grettyProvidedCompile 'javax.websocket:javax.websocket-api:1.0'
- }
- }
- ],
- 'tomcat85': [
- servletContainerType: 'tomcat',
- servletContainerVersion: { project -> project.ext.tomcat85Version },
- servletContainerDescription: { project -> "Tomcat ${project.ext.tomcat85Version}" },
- servletContainerRunnerConfig: 'grettyRunnerTomcat85',
- servletContainerRunnerDependencies: { project ->
- project.dependencies.add servletContainerRunnerConfig, "${runnerGroup}:gretty-runner-tomcat85:$grettyVersion"
- addRedirectFilter(project, servletContainerRunnerConfig)
- project.configurations[servletContainerRunnerConfig].resolutionStrategy {
- force "javax.servlet:javax.servlet-api:${project.ext.tomcat85ServletApiVersion}"
- def tomcat85_version = project.ext.tomcat85Version
- force "org.apache.tomcat.embed:tomcat-embed-core:$tomcat85_version"
- force "org.apache.tomcat.embed:tomcat-embed-el:$tomcat85_version"
- force "org.apache.tomcat.embed:tomcat-embed-jasper:$tomcat85_version"
- if (VersionNumber.parse(tomcat85_version) <= VersionNumber.parse('8.5.2'))
- force "org.apache.tomcat.embed:tomcat-embed-logging-log4j:$tomcat85_version"
- force "org.apache.tomcat.embed:tomcat-embed-websocket:$tomcat85_version"
- }
- },
- servletApiVersion: { project -> project.ext.tomcat85ServletApiVersion },
- servletApiDependencies: { project ->
- project.dependencies {
- grettyProvidedCompile "javax.servlet:javax.servlet-api:${project.ext.tomcat85ServletApiVersion}"
- }
+ },
+ servletApiVersion: { project -> project.ext.jetty10ServletApiVersion },
+ servletApiDependencies: { project ->
+ project.dependencies {
+ grettyProvidedCompile "jakarta.servlet:jakarta.servlet-api:${project.ext.jetty10ServletApiVersion}"
+ grettyProvidedCompile 'jakarta.websocket:jakarta.websocket-api:2.0.0-M1'
}
- ],
+ }
]
- if (JavaVersion.current().isJava8Compatible()) {
- configs['jetty9.3'] = [
- servletContainerType: 'jetty',
- servletContainerVersion: { project -> project.ext.jetty93Version },
- servletContainerDescription: { project -> "Jetty ${project.ext.jetty93Version}" },
- servletContainerRunnerConfig: 'grettyRunnerJetty93',
- servletContainerRunnerDependencies: { project ->
- project.dependencies.add servletContainerRunnerConfig, "${runnerGroup}:gretty-runner-jetty93:$grettyVersion"
- addRedirectFilter(project, servletContainerRunnerConfig)
- project.configurations[servletContainerRunnerConfig].resolutionStrategy {
- force "javax.servlet:javax.servlet-api:${project.ext.jetty9ServletApiVersion}"
- def jetty93_version = project.ext.jetty93Version
- force "org.eclipse.jetty:jetty-server:$jetty93_version"
- force "org.eclipse.jetty:jetty-servlet:$jetty93_version"
- force "org.eclipse.jetty:jetty-webapp:$jetty93_version"
- force "org.eclipse.jetty:jetty-security:$jetty93_version"
- force "org.eclipse.jetty:apache-jsp:$jetty93_version"
- force "org.eclipse.jetty:jetty-annotations:$jetty93_version"
- force "org.eclipse.jetty:jetty-plus:$jetty93_version"
- force "org.eclipse.jetty.websocket:javax-websocket-server-impl:$jetty93_version"
- def asm_version = project.ext.asmVersion
- force "org.ow2.asm:asm:$asm_version"
- force "org.ow2.asm:asm-commons:$asm_version"
- }
- },
- servletApiVersion: { project -> project.ext.jetty9ServletApiVersion },
- servletApiDependencies: { project ->
- project.dependencies {
- grettyProvidedCompile "javax.servlet:javax.servlet-api:${project.ext.jetty9ServletApiVersion}"
- grettyProvidedCompile 'javax.websocket:javax.websocket-api:1.0'
- }
+
+ configs['tomcat10'] = [
+ servletContainerType: 'tomcat',
+ servletContainerVersion: { project -> project.ext.tomcat10Version },
+ servletContainerDescription: { project -> "Tomcat ${project.ext.tomcat10Version}" },
+ servletContainerRunnerConfig: 'grettyRunnerTomcat10',
+ servletContainerRunnerDependencies: { project ->
+ project.dependencies.add servletContainerRunnerConfig, "${runnerGroup}:gretty-runner-tomcat10:$grettyVersion"
+ addRedirectFilter(project, servletContainerRunnerConfig)
+ project.configurations[servletContainerRunnerConfig].resolutionStrategy {
+ force "jakarta.servlet:jakarta.servlet-api:${project.ext.tomcat10ServletApiVersion}"
+ def tomcatVersion = project.ext.tomcat10Version
+ force "org.apache.tomcat.embed:tomcat-embed-core:$tomcatVersion"
+ force "org.apache.tomcat.embed:tomcat-embed-el:$tomcatVersion"
+ force "org.apache.tomcat.embed:tomcat-embed-jasper:$tomcatVersion"
+ force "org.apache.tomcat.embed:tomcat-embed-websocket:$tomcatVersion"
}
- ]
- configs['jetty9.4'] = [
- servletContainerType: 'jetty',
- servletContainerVersion: { project -> project.ext.jetty94Version },
- servletContainerDescription: { project -> "Jetty ${project.ext.jetty94Version}" },
- servletContainerRunnerConfig: 'grettyRunnerJetty94',
- servletContainerRunnerDependencies: { project ->
- project.dependencies.add servletContainerRunnerConfig, "${runnerGroup}:gretty-runner-jetty94:$grettyVersion"
- addRedirectFilter(project, servletContainerRunnerConfig)
- project.configurations[servletContainerRunnerConfig].resolutionStrategy {
- force "javax.servlet:javax.servlet-api:${project.ext.jetty9ServletApiVersion}"
- def jetty94_version = project.ext.jetty94Version
- force "org.eclipse.jetty:jetty-server:$jetty94_version"
- force "org.eclipse.jetty:jetty-servlet:$jetty94_version"
- force "org.eclipse.jetty:jetty-webapp:$jetty94_version"
- force "org.eclipse.jetty:jetty-security:$jetty94_version"
- force "org.eclipse.jetty:apache-jsp:$jetty94_version"
- force "org.eclipse.jetty:jetty-annotations:$jetty94_version"
- force "org.eclipse.jetty:jetty-plus:$jetty94_version"
- force "org.eclipse.jetty.websocket:javax-websocket-server-impl:$jetty94_version"
- def asm_version = project.ext.asmVersion
- force "org.ow2.asm:asm:$asm_version"
- force "org.ow2.asm:asm-commons:$asm_version"
- }
- },
- servletApiVersion: { project -> project.ext.jetty9ServletApiVersion },
- servletApiDependencies: { project ->
- project.dependencies {
- grettyProvidedCompile "javax.servlet:javax.servlet-api:${project.ext.jetty9ServletApiVersion}"
- grettyProvidedCompile 'javax.websocket:javax.websocket-api:1.0'
- }
- }
- ]
- configs['tomcat9'] = [
- servletContainerType: 'tomcat',
- servletContainerVersion: { project -> project.ext.tomcat9Version },
- servletContainerDescription: { project -> "Tomcat ${project.ext.tomcat9Version}" },
- servletContainerRunnerConfig: 'grettyRunnerTomcat9',
- servletContainerRunnerDependencies: { project ->
- project.dependencies.add servletContainerRunnerConfig, "${runnerGroup}:gretty-runner-tomcat9:$grettyVersion"
- addRedirectFilter(project, servletContainerRunnerConfig)
- project.configurations[servletContainerRunnerConfig].resolutionStrategy {
- force "javax.servlet:javax.servlet-api:${project.ext.tomcat9ServletApiVersion}"
- def tomcat9_version = project.ext.tomcat9Version
- force "org.apache.tomcat.embed:tomcat-embed-core:$tomcat9_version"
- force "org.apache.tomcat.embed:tomcat-embed-el:$tomcat9_version"
- force "org.apache.tomcat.embed:tomcat-embed-jasper:$tomcat9_version"
- force "org.apache.tomcat.embed:tomcat-embed-websocket:$tomcat9_version"
- }
- },
- servletApiVersion: { project -> project.ext.tomcat9ServletApiVersion },
- servletApiDependencies: { project ->
- project.dependencies {
- grettyProvidedCompile "javax.servlet:javax.servlet-api:${project.ext.tomcat9ServletApiVersion}"
- }
+ },
+ servletApiVersion: { project -> project.ext.tomcat10ServletApiVersion },
+ servletApiDependencies: { project ->
+ project.dependencies {
+ grettyProvidedCompile "jakarta.servlet:jakarta.servlet-api:${project.ext.tomcat10ServletApiVersion}"
+ grettyProvidedCompile 'jakarta.websocket:jakarta.websocket-api:2.0.0-M1'
}
- ]
- }
+ }
+ ]
return configs
}
static getConfig(servletContainer) {
- servletContainer = servletContainer ?: 'jetty9.4'
+ servletContainer = servletContainer ?: 'tomcat10'
def result = configs[servletContainer.toString()]
if(!result)
throw new Exception("Unsupported servlet container: $servletContainer")
@@ -278,7 +135,7 @@ class ServletContainerConfig {
}
if(compatibleConfigEntry)
return compatibleConfigEntry.key
- String defaultJettyServletContainer = 'jetty9.4'
+ String defaultJettyServletContainer = 'jetty10'
log.warn 'Cannot find jetty container with compatible servlet-api to {}, defaulting to {}', servletContainer, defaultJettyServletContainer
defaultJettyServletContainer
}
@@ -292,7 +149,7 @@ class ServletContainerConfig {
}
if(compatibleConfigEntry)
return compatibleConfigEntry.key
- String defaultJettyServletContainer = 'tomcat9'
+ String defaultJettyServletContainer = 'tomcat10'
log.warn 'Cannot find tomcat container with compatible servlet-api to {}, defaulting to {}', servletContainer, defaultJettyServletContainer
defaultJettyServletContainer
}
diff --git a/libs/gretty/src/main/groovy/org/akhikhl/gretty/scanner/BaseScannerManager.groovy b/libs/gretty/src/main/groovy/org/akhikhl/gretty/scanner/BaseScannerManager.groovy
index c3de4575c..9e4b4ff13 100644
--- a/libs/gretty/src/main/groovy/org/akhikhl/gretty/scanner/BaseScannerManager.groovy
+++ b/libs/gretty/src/main/groovy/org/akhikhl/gretty/scanner/BaseScannerManager.groovy
@@ -18,8 +18,8 @@ abstract class BaseScannerManager implements ScannerManager {
protected static final webConfigFiles = [
'web.xml', 'web-fragment.xml',
- 'jetty.xml', 'jetty7.xml', 'jetty8.xml', 'jetty9.xml',
- 'jetty-env.xml', 'jetty7-env.xml', 'jetty8-env.xml', 'jetty9-env.xml',
+ 'jetty.xml',
+ 'jetty-env.xml',
'tomcat-users.xml'
] as HashSet
diff --git a/settings.gradle b/settings.gradle
index 18dd1ca24..3bc3a38c8 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -4,21 +4,10 @@ include 'libs:gretty'
include 'libs:gretty-common'
include 'libs:gretty-filter'
include 'libs:gretty-runner'
-include 'libs:gretty-runner-jetty'
-include 'libs:gretty-runner-jetty7'
-include 'libs:gretty-runner-jetty8'
-include 'libs:gretty-runner-jetty9'
-// we don't try to compile gretty-runner-jetty93/4 against jdk prior to 8
-if (JavaVersion.current().isJava8Compatible()) {
- include 'libs:gretty-runner-jetty93'
- include 'libs:gretty-runner-jetty94'
-}
+// FIXME
+// include 'libs:gretty-runner-jetty'
include 'libs:gretty-runner-tomcat'
-include 'libs:gretty-runner-tomcat8plus'
-include 'libs:gretty-runner-tomcat85'
-if (JavaVersion.current().isJava8Compatible()) {
- include 'libs:gretty-runner-tomcat9'
-}
+include 'libs:gretty-runner-tomcat10'
include 'libs:gretty-spock'
include 'libs:gretty-springboot'
include 'libs:gretty-starter'