Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

restore broken functionality #143

Merged
merged 3 commits into from
May 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,11 @@
<artifactId>camel-cxf-soap</artifactId>
<version>${camel-version}</version>
</dependency>
<dependency>
<groupId>com.sun.xml.messaging.saaj</groupId>
<artifactId>saaj-impl</artifactId>
<version>1.5.3</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-core</artifactId>
Expand Down
38 changes: 21 additions & 17 deletions src/main/java/ch/bfh/ti/i4mi/mag/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -245,17 +245,20 @@ public class Config {
havingValue = "true",
matchIfMissing = false)
public SSLContextParameters getPixSSLContext() throws IOException, CertificateException, NoSuchAlgorithmException, KeyStoreException {

KeyStoreParameters ksp = new KeyStoreParameters();
// Keystore file may be found at src/main/resources
//ksp.setResource(keystore);
//ksp.setPassword(keystorePassword);


// https://www.baeldung.com/java-keystore
KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType());
log.info("keystore base64 valued: " + (keystoreBase64 != null && !keystoreBase64.trim().isEmpty()));
ks.load(ReadCertificateStream(), keystorePassword.toCharArray());
ksp.setKeyStore(ks);
if (keystoreBase64 != null && !keystoreBase64.trim().isEmpty()) {
ks.load(ReadCertificateStream(), keystorePassword.toCharArray());
ksp.setKeyStore(ks);
} else {
// Keystore file may be found at src/main/resources
ksp.setResource(keystore);
ksp.setPassword(keystorePassword);
}

KeyManagersParameters kmp = new KeyManagersParameters();
kmp.setKeyStore(ksp);
Expand All @@ -280,14 +283,18 @@ public SSLContextParameters getPixSSLContext() throws IOException, CertificateEx

public SSLContextParameters getAuditSSLContext() throws KeyStoreException, IOException, CertificateException, NoSuchAlgorithmException {
KeyStoreParameters ksp = new KeyStoreParameters();
// Keystore file may be found at src/main/resources
//ksp.setResource(keystore);
//ksp.setPassword(keystorePassword);


// https://www.baeldung.com/java-keystore
KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType());
ks.load(ReadCertificateStream(), keystorePassword.toCharArray());
ksp.setKeyStore(ks);
log.info("keystore base64 valued: " + (keystoreBase64 != null && !keystoreBase64.trim().isEmpty()));
if (keystoreBase64 != null && !keystoreBase64.trim().isEmpty()) {
ks.load(ReadCertificateStream(), keystorePassword.toCharArray());
ksp.setKeyStore(ks);
} else {
// Keystore file may be found at src/main/resources
ksp.setResource(keystore);
ksp.setPassword(keystorePassword);
}

KeyManagersParameters kmp = new KeyManagersParameters();
kmp.setKeyStore(ksp);
Expand Down Expand Up @@ -348,10 +355,7 @@ public FilterRegistrationBean<Filter> corsFilterRegistration() {
return frb;
}

private InputStream ReadCertificateStream () throws FileNotFoundException {
if (keystoreBase64 == null || keystoreBase64.trim().isEmpty()){
return new FileInputStream(keystore);
}
private InputStream ReadCertificateStream () throws FileNotFoundException {
byte[] decodedBytes = Base64.getDecoder().decode(keystoreBase64);
return new ByteArrayInputStream(decodedBytes);
}
Expand Down
Loading