use of com.sun.enterprise.security.ssl.impl.MasterPasswordImpl in project Payara by payara.
the class AbstractRemoteCertificateManagementCommand method resolveKeyStore.
/**
* Resolves the keystore location and the password required to access it.
*/
protected void resolveKeyStore() {
Config config = servers.getServer(target).getConfig();
if (listener != null) {
// Check if listener is an HTTP listener
List<Protocol> protocols = config.getNetworkConfig().getProtocols().getProtocol();
for (Protocol protocol : protocols) {
if (protocol.getName().equals(listener)) {
Ssl sslConfig = protocol.getSsl();
if (sslConfig != null) {
if (StringUtils.ok(sslConfig.getKeyStore())) {
keystore = new File(TranslatedConfigView.expandConfigValue(sslConfig.getKeyStore()));
keystorePassword = TranslatedConfigView.expandConfigValue(sslConfig.getKeyStorePassword()).toCharArray();
}
}
}
}
if (keystore == null) {
// Check if listener is an IIOP listener
List<IiopListener> listeners = iiopService.getIiopListener();
for (IiopListener listener : listeners) {
if (listener.getId().equals(listener)) {
Ssl sslConfig = listener.getSsl();
if (StringUtils.ok(sslConfig.getKeyStore())) {
keystore = new File(TranslatedConfigView.expandConfigValue(sslConfig.getKeyStore()));
keystorePassword = TranslatedConfigView.expandConfigValue(sslConfig.getKeyStorePassword()).toCharArray();
}
}
}
}
}
// Default to getting it from the JVM options if no non-default value found
if (keystore == null) {
List<String> jvmOptions = config.getJavaConfig().getJvmOptions();
for (String jvmOption : jvmOptions) {
if (jvmOption.startsWith("-Djavax.net.ssl.keyStore")) {
keystore = new File(TranslatedConfigView.expandConfigValue(jvmOption.substring(jvmOption.indexOf("=") + 1)));
}
}
}
// If it's STILL null, just go with default
if (keystore == null) {
keystore = serverEnvironment.getJKS();
}
// If the password hasn't been set, go with master
if (keystorePassword == null) {
MasterPasswordImpl masterPasswordService = serviceLocator.getService(MasterPasswordImpl.class);
keystorePassword = masterPasswordService.getMasterPassword();
}
}
use of com.sun.enterprise.security.ssl.impl.MasterPasswordImpl in project Payara by payara.
the class AbstractRemoteCertificateManagementCommand method resolveTrustStore.
/**
* Resolves the truststore location and the password required to access it.
*/
protected void resolveTrustStore() {
Config config = servers.getServer(target).getConfig();
if (listener != null) {
// Check if listener is an HTTP listener
List<Protocol> protocols = config.getNetworkConfig().getProtocols().getProtocol();
for (Protocol protocol : protocols) {
if (protocol.getName().equals(listener)) {
Ssl sslConfig = protocol.getSsl();
if (sslConfig != null) {
if (StringUtils.ok(sslConfig.getTrustStore())) {
truststore = new File(TranslatedConfigView.expandConfigValue(sslConfig.getTrustStore()));
truststorePassword = TranslatedConfigView.expandConfigValue(sslConfig.getTrustStorePassword()).toCharArray();
}
}
}
}
if (truststore == null) {
// Check if listener is an IIOP listener
List<IiopListener> listeners = iiopService.getIiopListener();
for (IiopListener listener : listeners) {
if (listener.getId().equals(listener)) {
Ssl sslConfig = listener.getSsl();
if (StringUtils.ok(sslConfig.getTrustStore())) {
truststore = new File(TranslatedConfigView.expandConfigValue(sslConfig.getTrustStore()));
truststorePassword = TranslatedConfigView.expandConfigValue(sslConfig.getTrustStorePassword()).toCharArray();
}
}
}
}
}
// Default to getting it from the JVM options if no non-default value found
if (truststore == null) {
List<String> jvmOptions = config.getJavaConfig().getJvmOptions();
for (String jvmOption : jvmOptions) {
if (jvmOption.startsWith("-Djavax.net.ssl.trustStore")) {
truststore = new File(TranslatedConfigView.expandConfigValue(jvmOption.substring(jvmOption.indexOf("=") + 1)));
}
}
}
// If it's STILL null, just go with default
if (truststore == null) {
truststore = serverEnvironment.getTrustStore();
}
// If the password hasn't been set, go with master
if (truststorePassword == null) {
MasterPasswordImpl masterPassword = serviceLocator.getService(MasterPasswordImpl.class);
truststorePassword = masterPassword.getMasterPassword();
}
}
Aggregations