Skip to content

Commit

Permalink
Merge pull request #5 from valtimo-platform/feature/configure_OkHttpC…
Browse files Browse the repository at this point in the history
…lient

Feature/configure ok http client
  • Loading branch information
paul-ritense authored Nov 22, 2024
2 parents fd57f30 + ee3132e commit 85eb3b1
Show file tree
Hide file tree
Showing 12 changed files with 286 additions and 92 deletions.
6 changes: 6 additions & 0 deletions backend/app/.env.properties
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,9 @@ VALTIMO_OPENKLANT_SECRET=e09b8bc5-5831-4618-ab28-41411304309d
#org.openapitools.client.baseUrl=${BASEURL}
org.openapitools.client.baseUrl=wdwwer

ROTTERDAM_XENTIAL_ACCOUNT_NAME=gzac
ROTTERDAM_XENTIAL_ACCOUNT_PASSWORD=12345

ROTTERDAM_ESB_SERVER_CERTIFICATE_FILENAME=/Users/paul/Documents/rotterdam/xential/test.gemeente-rotterdam.gzac.cloud_20241023.pem
ROTTERDAM_ESB_CLIENT_PRIVATE_KEY_FILENAME=/Users/paul/Documents/rotterdam/xential/private.key
ROTTERDAM_ESB_CLIENT_CERTIFICATE_FILENAME=/Users/paul/Documents/rotterdam/xential/test.gemeente-rotterdam.gzac.cloud_20241023.pem
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,21 @@ package com.ritense.valtimo.xential.autoconfiguration

import com.ritense.documentenapi.client.DocumentenApiClient
import com.ritense.plugin.service.PluginService
import com.ritense.valtimo.contract.authentication.UserManagementService
import com.ritense.valtimo.contract.config.LiquibaseMasterChangeLogLocation
import com.ritense.valtimo.xential.plugin.XentialPluginFactory
import com.ritense.valtimo.xential.repository.XentialTokenRepository
import com.ritense.valtimo.xential.service.DocumentGenerationService
import com.ritense.valueresolver.ValueResolverService
import com.ritense.zakenapi.ZaakUrlProvider
import com.ritense.zakenapi.client.ZakenApiClient
import com.rotterdam.xential.api.DefaultApi
import org.camunda.bpm.engine.RuntimeService
import org.openapitools.client.infrastructure.ApiClient
import org.springframework.beans.factory.annotation.Value
import org.springframework.boot.autoconfigure.AutoConfiguration
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
import org.springframework.boot.autoconfigure.domain.EntityScan
import org.springframework.context.ApplicationEventPublisher
import org.springframework.context.annotation.Bean
import org.springframework.data.jpa.repository.config.EnableJpaRepositories
import org.springframework.web.reactive.function.client.WebClient

@AutoConfiguration
@EnableJpaRepositories(basePackages = ["com.ritense.valtimo.xential.repository"])
Expand All @@ -60,41 +57,27 @@ class XentialAutoConfiguration {
return LiquibaseMasterChangeLogLocation("config/liquibase/xential-plugin-master.xml")
}

@Bean
@ConditionalOnMissingBean
fun defaultApi(): DefaultApi {
return DefaultApi()
}

// @Value("\${plugin.xential.baseurl: }") baseUrl: String

@Bean
@ConditionalOnMissingBean
fun apiClient(
) = ApiClient("http://localhost:1080")

@Bean
@ConditionalOnMissingBean
fun documentGenerationService(
defaultApi: DefaultApi,
xentialTokenRepository: XentialTokenRepository,
pluginService: PluginService,
documentenApiClient: DocumentenApiClient,
applicationEventPublisher: ApplicationEventPublisher,
zaakUrlProvider: ZaakUrlProvider,
zakenApiClient: ZakenApiClient,
runtimeService: RuntimeService,
valueResolverService: ValueResolverService
valueResolverService: ValueResolverService,
userManagementService: UserManagementService
) = DocumentGenerationService(
defaultApi,
xentialTokenRepository,
pluginService,
documentenApiClient,
applicationEventPublisher,
zaakUrlProvider,
zakenApiClient,
runtimeService,
valueResolverService
valueResolverService,
userManagementService
)

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.ritense.valtimo.xential.domain

import java.io.File
import java.net.URI

data class HttpClientProperties(
val applicationName: String,
val applicationPassword: String,
val baseUrl: URI,
val serverCertificateFilename: File,
val clientPrivateKeyFilename: File?,
val clientCertFile: File?
)
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,41 @@ package com.ritense.valtimo.xential.domain

import jakarta.persistence.Column
import jakarta.persistence.Entity
import jakarta.persistence.GeneratedValue
import jakarta.persistence.GenerationType
import jakarta.persistence.Id
import jakarta.persistence.Table
import java.net.URI
import java.util.UUID

@Entity
@Table(name = "xential_tokens")
data class XentialToken (

@Id
@Column(name = "token", nullable = false, updatable = false)
val token: UUID,
@Column(name = "process_id", nullable = false, updatable = false)
val processId: UUID,
@Column(name = "message_name", nullable = false, updatable = false)
val messageName: String,
@Column(name = "resume_url", nullable = true, updatable = false)
val resumeUrl: URI?,
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "token")
val token: UUID = UUID.randomUUID(),

@Column(name = "external_token")
val externalToken: String = "",

@Column(name = "process_id")
val processId: UUID = UUID.randomUUID(),

@Column(name = "message_name")
val messageName: String = "",

@Column(name = "resume_url")
val resumeUrl: String = ""

// @Id
// @Column(name = "token", nullable = false, updatable = false)
// val token: UUID,
// @Column(name = "process_id", nullable = false, updatable = false)
// val processId: UUID,
// @Column(name = "message_name", nullable = false, updatable = false)
// val messageName: String,
// @Column(name = "resume_url", nullable = true, updatable = false)
// val resumeUrl: URI?, @Id
// @Column(name = "token", nullable = false, updatable = false)
)
Original file line number Diff line number Diff line change
Expand Up @@ -22,35 +22,50 @@ import com.ritense.plugin.annotation.PluginAction
import com.ritense.plugin.annotation.PluginActionProperty
import com.ritense.plugin.annotation.PluginProperty
import com.ritense.processlink.domain.ActivityTypeWithEventName
import com.ritense.valtimo.xential.domain.HttpClientProperties
import com.ritense.valtimo.xential.domain.FileFormat
import com.ritense.valtimo.xential.domain.GenerateDocumentProperties
import com.ritense.valtimo.xential.plugin.XentialPlugin.Companion.PLUGIN_KEY
import com.ritense.valtimo.xential.service.DocumentGenerationService
import com.ritense.zakenapi.ZakenApiPlugin
import org.camunda.bpm.engine.delegate.DelegateExecution
import java.io.File
import java.net.URI
import java.util.UUID

@Plugin(
key = PLUGIN_KEY,
title = "Xential Plugin",
description = ""
description = "handle xentail requests"
)
@Suppress("UNUSED")
class XentialPlugin(
val documentGenerationService: DocumentGenerationService
private val documentGenerationService: DocumentGenerationService
) {

@PluginProperty(key = "clientId", secret = false)
private lateinit var clientId: String
@PluginProperty(key = "applicationName", secret = false, required = true)
private lateinit var applicationName: String

@PluginProperty(key = "clientPassword", secret = true)
private lateinit var clientPassword: String
@PluginProperty(key = "applicationPassword", secret = true, required = true)
private lateinit var applicationPassword: String

@PluginProperty(key = "baseUrl", secret = false, required = true)
lateinit var baseUrl: URI

@PluginProperty(key = "documentenApiPluginConfiguration", secret = false)
lateinit var documentenApiPluginConfiguration: DocumentenApiPlugin

@PluginProperty(key = "zakenApiPluginConfiguration", secret = false)
lateinit var zakenApiPluginConfiguration: ZakenApiPlugin

@PluginProperty(key = "serverCertificateFilename", secret = false, required = true)
private lateinit var serverCertificateFilename: String

@PluginProperty(key = "clientPrivateKeyFilename", secret = false, required = false)
var clientPrivateKeyFilename: String? = null

@PluginProperty(key = "clientCertificateFilename", secret = false, required = false)
var clientCertificateFilename: String? = null

@PluginAction(
key = "generate-document",
Expand All @@ -73,11 +88,20 @@ class XentialPlugin(
messageName,
templateData
)

val httpClientProperties = HttpClientProperties(
applicationName,
applicationPassword,
baseUrl,
File(serverCertificateFilename),
clientPrivateKeyFilename?.let{File(it)},
clientCertificateFilename?.let {File(it)}
)

documentGenerationService.generateDocument(
httpClientProperties,
UUID.fromString(execution.processInstanceId),
generateDocumentProperties,
clientId,
clientPassword,
execution
)
}
Expand Down
Loading

0 comments on commit 85eb3b1

Please sign in to comment.