mirror of
https://github.com/pcvolkmer/etl-processor.git
synced 2025-04-20 17:56:50 +00:00
refactor: extract custom SSL gPAS rest template creation
This commit is contained in:
parent
0f5a68660d
commit
959f6889d4
@ -88,6 +88,47 @@ class AppConfiguration {
|
|||||||
@ConditionalOnProperty(value = ["app.pseudonymize.generator"], havingValue = "GPAS")
|
@ConditionalOnProperty(value = ["app.pseudonymize.generator"], havingValue = "GPAS")
|
||||||
@Bean
|
@Bean
|
||||||
fun gpasPseudonymGenerator(configProperties: GPasConfigProperties, retryTemplate: RetryTemplate, restTemplate: RestTemplate): Generator {
|
fun gpasPseudonymGenerator(configProperties: GPasConfigProperties, retryTemplate: RetryTemplate, restTemplate: RestTemplate): Generator {
|
||||||
|
try {
|
||||||
|
if (!configProperties.sslCaLocation.isNullOrBlank()) {
|
||||||
|
return GpasPseudonymGenerator(
|
||||||
|
configProperties,
|
||||||
|
retryTemplate,
|
||||||
|
createCustomGpasRestTemplate(configProperties)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
} catch (e: Exception) {
|
||||||
|
throw RuntimeException(e)
|
||||||
|
}
|
||||||
|
|
||||||
|
return GpasPseudonymGenerator(configProperties, retryTemplate, restTemplate)
|
||||||
|
}
|
||||||
|
|
||||||
|
@ConditionalOnProperty(value = ["app.pseudonymize.generator"], havingValue = "BUILDIN", matchIfMissing = true)
|
||||||
|
@Bean
|
||||||
|
fun buildinPseudonymGenerator(): Generator {
|
||||||
|
return AnonymizingGenerator()
|
||||||
|
}
|
||||||
|
|
||||||
|
@ConditionalOnProperty(value = ["app.pseudonymizer"], havingValue = "GPAS")
|
||||||
|
@ConditionalOnMissingBean
|
||||||
|
@Bean
|
||||||
|
fun gpasPseudonymGeneratorOnDeprecatedProperty(configProperties: GPasConfigProperties, retryTemplate: RetryTemplate, restTemplate: RestTemplate): Generator {
|
||||||
|
try {
|
||||||
|
if (!configProperties.sslCaLocation.isNullOrBlank()) {
|
||||||
|
return GpasPseudonymGenerator(
|
||||||
|
configProperties,
|
||||||
|
retryTemplate,
|
||||||
|
createCustomGpasRestTemplate(configProperties)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
} catch (e: Exception) {
|
||||||
|
throw RuntimeException(e)
|
||||||
|
}
|
||||||
|
|
||||||
|
return GpasPseudonymGenerator(configProperties, retryTemplate, restTemplate)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun createCustomGpasRestTemplate(configProperties: GPasConfigProperties): RestTemplate {
|
||||||
fun getSslContext(certificateLocation: String): SSLContext? {
|
fun getSslContext(certificateLocation: String): SSLContext? {
|
||||||
val ks = KeyStore.getInstance(KeyStore.getDefaultType())
|
val ks = KeyStore.getInstance(KeyStore.getDefaultType())
|
||||||
|
|
||||||
@ -137,31 +178,14 @@ class AppConfiguration {
|
|||||||
)
|
)
|
||||||
|
|
||||||
if (customSslContext != null) {
|
if (customSslContext != null) {
|
||||||
return GpasPseudonymGenerator(
|
return getCustomRestTemplate(customSslContext)
|
||||||
configProperties,
|
|
||||||
retryTemplate,
|
|
||||||
getCustomRestTemplate(customSslContext)
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
throw RuntimeException(e)
|
throw RuntimeException(e)
|
||||||
}
|
}
|
||||||
|
|
||||||
return GpasPseudonymGenerator(configProperties, retryTemplate, restTemplate)
|
throw RuntimeException("Custom SSL configuration for gPAS not usable")
|
||||||
}
|
|
||||||
|
|
||||||
@ConditionalOnProperty(value = ["app.pseudonymize.generator"], havingValue = "BUILDIN", matchIfMissing = true)
|
|
||||||
@Bean
|
|
||||||
fun buildinPseudonymGenerator(): Generator {
|
|
||||||
return AnonymizingGenerator()
|
|
||||||
}
|
|
||||||
|
|
||||||
@ConditionalOnProperty(value = ["app.pseudonymizer"], havingValue = "GPAS")
|
|
||||||
@ConditionalOnMissingBean
|
|
||||||
@Bean
|
|
||||||
fun gpasPseudonymGeneratorOnDeprecatedProperty(configProperties: GPasConfigProperties, retryTemplate: RetryTemplate, restTemplate: RestTemplate): Generator {
|
|
||||||
return gpasPseudonymGenerator(configProperties, retryTemplate, restTemplate)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ConditionalOnProperty(value = ["app.pseudonymizer"], havingValue = "BUILDIN")
|
@ConditionalOnProperty(value = ["app.pseudonymizer"], havingValue = "BUILDIN")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user