generated from telekom/reuse-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added global truststore configuration
- Loading branch information
Showing
7 changed files
with
57 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
...re/src/main/java/de/telekom/eni/pandora/horizon/security/config/TruststoreProperties.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Copyright 2024 Deutsche Telekom IT GmbH | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package de.telekom.eni.pandora.horizon.security.config; | ||
|
||
import lombok.Getter; | ||
import lombok.Setter; | ||
import org.springframework.boot.context.properties.ConfigurationProperties; | ||
|
||
@Getter | ||
@Setter | ||
@ConfigurationProperties("horizon.truststore") | ||
public class TruststoreProperties { | ||
|
||
private String location; | ||
|
||
private String password; | ||
|
||
private boolean enabled = false; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
...n/java/de/telekom/eni/pandora/horizon/autoconfigure/security/TruststoreConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package de.telekom.eni.pandora.horizon.autoconfigure.security; | ||
|
||
import de.telekom.eni.pandora.horizon.security.config.TruststoreProperties; | ||
import org.springframework.boot.autoconfigure.web.ServerProperties; | ||
import org.springframework.boot.context.properties.EnableConfigurationProperties; | ||
import org.springframework.boot.web.server.Ssl; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
; | ||
|
||
@Configuration | ||
@EnableConfigurationProperties({TruststoreProperties.class}) | ||
public class TruststoreConfiguration { | ||
|
||
@Bean | ||
public ServerProperties serverProperties(TruststoreProperties truststoreProperties) { | ||
final ServerProperties serverProperties = new ServerProperties(); | ||
|
||
if (truststoreProperties.isEnabled()) { | ||
final Ssl ssl = new Ssl(); | ||
ssl.setTrustStore(truststoreProperties.getLocation()); | ||
ssl.setTrustStorePassword(truststoreProperties.getPassword()); | ||
serverProperties.setSsl(ssl); | ||
} | ||
|
||
return serverProperties; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters