diff --git a/build.gradle.kts b/build.gradle.kts index 794d2a5d7..e1a4d0ebc 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -28,8 +28,8 @@ plugins { id("com.google.protobuf") version "0.8.12" apply false // Kotlin specific - kotlin("jvm") version "1.4.32" apply false - kotlin("plugin.spring") version "1.4.32" apply false + kotlin("jvm") version "1.5.20" apply false + kotlin("plugin.spring") version "1.5.20" apply false id("com.diffplug.spotless") version "5.11.0" id("com.github.jk1.dependency-license-report") version "1.16" diff --git a/example-route-builder/src/main/kotlin/de/fhg/aisec/ids/ExampleConnector.kt b/example-route-builder/src/main/kotlin/de/fhg/aisec/ids/ExampleConnector.kt index b410f33db..58d656639 100644 --- a/example-route-builder/src/main/kotlin/de/fhg/aisec/ids/ExampleConnector.kt +++ b/example-route-builder/src/main/kotlin/de/fhg/aisec/ids/ExampleConnector.kt @@ -19,8 +19,13 @@ */ package de.fhg.aisec.ids +import org.apache.camel.support.jsse.KeyManagersParameters +import org.apache.camel.support.jsse.KeyStoreParameters +import org.apache.camel.support.jsse.SSLContextParameters +import org.apache.camel.support.jsse.TrustManagersParameters import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication +import java.nio.file.FileSystems @SpringBootApplication open class ExampleConnector : TrustedConnector() { @@ -30,5 +35,23 @@ open class ExampleConnector : TrustedConnector() { fun main(args: Array) { runApplication(*args) } + + fun getSslContext(): SSLContextParameters { + return SSLContextParameters().apply { + certAlias = "1.0.1" + keyManagers = KeyManagersParameters().apply { + keyStore = KeyStoreParameters().apply { + resource = FileSystems.getDefault().getPath("etc", "consumer-keystore.p12").toFile().path + password = "password" + } + } + trustManagers = TrustManagersParameters().apply { + keyStore = KeyStoreParameters().apply { + resource = FileSystems.getDefault().getPath("etc", "truststore.p12").toFile().path + password = "password" + } + } + } + } } } diff --git a/example-route-builder/src/main/kotlin/de/fhg/aisec/ids/ExampleIdscpClient.kt b/example-route-builder/src/main/kotlin/de/fhg/aisec/ids/ExampleIdscpClient.kt index a1c542dee..aae53eaee 100644 --- a/example-route-builder/src/main/kotlin/de/fhg/aisec/ids/ExampleIdscpClient.kt +++ b/example-route-builder/src/main/kotlin/de/fhg/aisec/ids/ExampleIdscpClient.kt @@ -21,34 +21,14 @@ package de.fhg.aisec.ids import org.apache.camel.RoutesBuilder import org.apache.camel.builder.RouteBuilder -import org.apache.camel.support.jsse.KeyManagersParameters -import org.apache.camel.support.jsse.KeyStoreParameters -import org.apache.camel.support.jsse.SSLContextParameters -import org.apache.camel.support.jsse.TrustManagersParameters import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration -import java.nio.file.FileSystems @Configuration open class ExampleIdscpClient { @Bean("clientSslContext") - open fun createSSLContext(): SSLContextParameters { - val ctx = SSLContextParameters() - ctx.certAlias = "1.0.1" - ctx.keyManagers = KeyManagersParameters() - ctx.keyManagers.keyStore = KeyStoreParameters() - ctx.keyManagers.keyStore.resource = - FileSystems.getDefault().getPath("etc", "provider-keystore.p12").toFile().path - ctx.keyManagers.keyStore.password = "password" - ctx.trustManagers = TrustManagersParameters() - ctx.trustManagers.keyStore = KeyStoreParameters() - ctx.trustManagers.keyStore.resource = - FileSystems.getDefault().getPath("etc", "truststore.p12").toFile().path - ctx.trustManagers.keyStore.password = "password" - - return ctx - } + open fun createSSLContext() = ExampleConnector.getSslContext() @Bean open fun client(): RoutesBuilder { diff --git a/example-route-builder/src/main/kotlin/de/fhg/aisec/ids/ExampleIdscpServer.kt b/example-route-builder/src/main/kotlin/de/fhg/aisec/ids/ExampleIdscpServer.kt index 81850711a..3b5863ed6 100644 --- a/example-route-builder/src/main/kotlin/de/fhg/aisec/ids/ExampleIdscpServer.kt +++ b/example-route-builder/src/main/kotlin/de/fhg/aisec/ids/ExampleIdscpServer.kt @@ -21,34 +21,14 @@ package de.fhg.aisec.ids import org.apache.camel.RoutesBuilder import org.apache.camel.builder.RouteBuilder -import org.apache.camel.support.jsse.KeyManagersParameters -import org.apache.camel.support.jsse.KeyStoreParameters -import org.apache.camel.support.jsse.SSLContextParameters -import org.apache.camel.support.jsse.TrustManagersParameters import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration -import java.nio.file.FileSystems @Configuration open class ExampleIdscpServer { @Bean("serverSslContext") - open fun createSSLContext(): SSLContextParameters { - val ctx = SSLContextParameters() - ctx.certAlias = "1.0.1" - ctx.keyManagers = KeyManagersParameters() - ctx.keyManagers.keyStore = KeyStoreParameters() - ctx.keyManagers.keyStore.resource = - FileSystems.getDefault().getPath("etc", "consumer-keystore.p12").toFile().path - ctx.keyManagers.keyStore.password = "password" - ctx.trustManagers = TrustManagersParameters() - ctx.trustManagers.keyStore = KeyStoreParameters() - ctx.trustManagers.keyStore.resource = - FileSystems.getDefault().getPath("etc", "truststore.p12").toFile().path - ctx.trustManagers.keyStore.password = "password" - - return ctx - } + open fun createSSLContext() = ExampleConnector.getSslContext() @Bean open fun server(): RoutesBuilder { diff --git a/ids-connector/src/main/kotlin/de/fhg/aisec/ids/ConnectorConfiguration.kt b/ids-connector/src/main/kotlin/de/fhg/aisec/ids/ConnectorConfiguration.kt index 5a370fb73..1f831371a 100644 --- a/ids-connector/src/main/kotlin/de/fhg/aisec/ids/ConnectorConfiguration.kt +++ b/ids-connector/src/main/kotlin/de/fhg/aisec/ids/ConnectorConfiguration.kt @@ -58,7 +58,7 @@ class ConnectorConfiguration { } @Bean - fun listBeans(ctx: ApplicationContext): CommandLineRunner? { + fun listBeans(ctx: ApplicationContext): CommandLineRunner { return CommandLineRunner { val beans: Array = ctx.beanDefinitionNames @@ -71,7 +71,7 @@ class ConnectorConfiguration { } @Bean - fun listContainers(ctx: ApplicationContext): CommandLineRunner? { + fun listContainers(ctx: ApplicationContext): CommandLineRunner { return CommandLineRunner { val containers = cml?.list(false) @@ -82,7 +82,7 @@ class ConnectorConfiguration { } @Bean - fun showConnectorProfile(ctx: ApplicationContext): CommandLineRunner? { + fun showConnectorProfile(ctx: ApplicationContext): CommandLineRunner { return CommandLineRunner { val connector = im.connector @@ -95,7 +95,7 @@ class ConnectorConfiguration { } @Bean - fun showCamelInfo(ctx: ApplicationContext): CommandLineRunner? { + fun showCamelInfo(ctx: ApplicationContext): CommandLineRunner { return CommandLineRunner { val routes = rm.routes diff --git a/ids-connector/src/main/resources/application.yml b/ids-connector/src/main/resources/application.yml index 5e2db051e..984490be6 100644 --- a/ids-connector/src/main/resources/application.yml +++ b/ids-connector/src/main/resources/application.yml @@ -2,6 +2,9 @@ logging: level: ROOT: INFO de.fhg.aisec: DEBUG + # Use for IDSCP2 debugging +# de.fhg.aisec.ids.idscp2: TRACE +# de.fhg.aisec.ids.camel.idscp2: TRACE spring: resources: diff --git a/ids-container-manager/src/main/kotlin/de/fhg/aisec/ids/cm/impl/docker/DockerCM.kt b/ids-container-manager/src/main/kotlin/de/fhg/aisec/ids/cm/impl/docker/DockerCM.kt index 9bf8fbde3..6d2f3e31d 100644 --- a/ids-container-manager/src/main/kotlin/de/fhg/aisec/ids/cm/impl/docker/DockerCM.kt +++ b/ids-container-manager/src/main/kotlin/de/fhg/aisec/ids/cm/impl/docker/DockerCM.kt @@ -135,14 +135,14 @@ class DockerCM : ContainerManager { for (unit in PERIOD_UNITS) { val elapsed = period[unit] if (elapsed > 0) { - units.add(elapsed.toString() + " " + unit.toString().toLowerCase()) + units.add(elapsed.toString() + " " + unit.toString().lowercase()) } } for (unit in DURATION_UNITS) { val unitDuration = unit.duration.toSeconds() val elapsed = duration / unitDuration if (elapsed > 0) { - units.add(elapsed.toString() + " " + unit.toString().toLowerCase()) + units.add(elapsed.toString() + " " + unit.toString().lowercase()) } duration %= unitDuration } @@ -211,7 +211,7 @@ class DockerCM : ContainerManager { "${humanReadableByteCount((c["SizeRw"] ?: 0).toString().toLong())} RW (data), " + "${humanReadableByteCount((c["SizeRootFs"] ?: 0).toString().toLong())} RO (layers)" app.created = info.getString("Created") - app.status = ContainerStatus.valueOf(state.getString("Status").toUpperCase()) + app.status = ContainerStatus.valueOf(state.getString("Status").uppercase()) app.ports = ports .entries diff --git a/ids-route-manager/src/main/kotlin/de/fhg/aisec/ids/rm/XmlDeployWatcher.kt b/ids-route-manager/src/main/kotlin/de/fhg/aisec/ids/rm/XmlDeployWatcher.kt index b5ae3a82b..b42dfe61f 100644 --- a/ids-route-manager/src/main/kotlin/de/fhg/aisec/ids/rm/XmlDeployWatcher.kt +++ b/ids-route-manager/src/main/kotlin/de/fhg/aisec/ids/rm/XmlDeployWatcher.kt @@ -103,6 +103,8 @@ class XmlDeployWatcher : ApplicationContextAware { LOG.warn("XML watcher stopped by interrupt") break } + // Remember newly created XML files + val createdPaths = mutableSetOf() // Poll the events that happened since last iteration for (watchEvent in key.pollEvents()) { try { @@ -110,6 +112,7 @@ class XmlDeployWatcher : ApplicationContextAware { val xmlPathString = xmlPath.toString() when (watchEvent.kind()) { StandardWatchEventKinds.ENTRY_CREATE -> { + createdPaths += xmlPathString // Must check whether the path represents a valid XML file if (Files.isRegularFile(xmlPath) || xmlPathString.endsWith(".xml")) { startXmlApplicationContext(xmlPathString) @@ -119,7 +122,10 @@ class XmlDeployWatcher : ApplicationContextAware { stopXmlApplicationContext(xmlPathString) } StandardWatchEventKinds.ENTRY_MODIFY -> { - restartXmlApplicationContext(xmlPathString) + // Ignore MODIFY events for newly created XML files + if (xmlPathString !in createdPaths) { + restartXmlApplicationContext(xmlPathString) + } } else -> { LOG.warn("Unhandled WatchEvent: {}", watchEvent) diff --git a/ids-route-manager/src/main/kotlin/de/fhg/aisec/ids/rm/util/NodeData.kt b/ids-route-manager/src/main/kotlin/de/fhg/aisec/ids/rm/util/NodeData.kt index fc2e9fb69..abc6e7944 100644 --- a/ids-route-manager/src/main/kotlin/de/fhg/aisec/ids/rm/util/NodeData.kt +++ b/ids-route-manager/src/main/kotlin/de/fhg/aisec/ids/rm/util/NodeData.kt @@ -194,7 +194,7 @@ class NodeData(var id: String, node: Any?, imagePrefix: String) { url = ( "http://camel.apache.org/" + - nodeType!!.toLowerCase(Locale.ENGLISH).replace(' ', '-') + + nodeType!!.lowercase(Locale.ENGLISH).replace(' ', '-') + ".html" ) } diff --git a/libraryVersions.yaml b/libraryVersions.yaml index f2d8f5921..16b0cce1a 100644 --- a/libraryVersions.yaml +++ b/libraryVersions.yaml @@ -1,11 +1,11 @@ -idscp2: "0.4.3" +idscp2: "0.4.4" ktlint: "0.41.0" # Pinning okhttp: "4.9.1" # Kotlin library/compiler version -kotlin: "1.4.32" +kotlin: "1.5.20" kotlinxCoroutines: "1.4.3" # basically, the first requirement, all other libraries depend on this version karaf: "4.2.10"