com.example.CustomCryptoSettings Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of glue-examples Show documentation
Show all versions of glue-examples Show documentation
SDCri is a set of Java libraries that implements a network communication framework conforming
with the IEEE 11073 SDC specifications. This project implements examples for using the glue package.
package com.example;
import org.somda.sdc.dpws.crypto.CryptoSettings;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.util.Base64;
import java.util.Optional;
import java.util.regex.Pattern;
public class CustomCryptoSettings implements CryptoSettings {
private static final String keyStorePath = "crypto/sdcparticipant.jks";
private static final String trustStorePath = "crypto/root.jks";
private static final String keyStorePassword = "whatever";
private static final String trustStorePassword = "whatever";
@Override
public Optional getKeyStoreFile() {
return Optional.empty();
}
@Override
public Optional getKeyStoreStream() {
return Optional.ofNullable(getClass().getClassLoader().getResourceAsStream(keyStorePath));
}
@Override
public String getKeyStorePassword() {
return keyStorePassword;
}
@Override
public Optional getTrustStoreFile() {
return Optional.empty();
}
@Override
public Optional getTrustStoreStream() {
return Optional.ofNullable(getClass().getClassLoader().getResourceAsStream(trustStorePath));
}
@Override
public String getTrustStorePassword() {
return trustStorePassword;
}
}