diff --git a/nucleus/core/kernel/src/main/java/com/sun/enterprise/v3/admin/IdmService.java b/nucleus/core/kernel/src/main/java/com/sun/enterprise/v3/admin/IdmService.java index a96ecf40151..5afcc8f4ba9 100644 --- a/nucleus/core/kernel/src/main/java/com/sun/enterprise/v3/admin/IdmService.java +++ b/nucleus/core/kernel/src/main/java/com/sun/enterprise/v3/admin/IdmService.java @@ -37,26 +37,18 @@ * only if the new code is made subject to such option by the copyright * holder. */ -// Portions Copyright 2016 Payara Foundation +// Portions Copyright [2018] [Payara Foundation and/or its affiliates] package com.sun.enterprise.v3.admin; import com.sun.enterprise.glassfish.bootstrap.StartupContextUtil; import com.sun.enterprise.module.bootstrap.StartupContext; import com.sun.enterprise.security.store.IdentityManagement; -import com.sun.enterprise.security.store.PasswordAdapter; -import org.glassfish.hk2.runlevel.RunLevel; -import org.glassfish.internal.api.InitRunLevel; -import org.glassfish.security.common.MasterPassword; import org.glassfish.server.ServerEnvironmentImpl; import javax.inject.Inject; -import javax.inject.Named; - -import org.jvnet.hk2.annotations.Optional; import org.jvnet.hk2.annotations.Service; import org.glassfish.hk2.api.PostConstruct; -import javax.inject.Singleton; import java.io.*; import java.util.Arrays; @@ -105,8 +97,14 @@ public void postConstruct() { if (!success) { masterPassword = "changeit".toCharArray(); //the default; } - System.setProperty("javax.net.ssl.keyStorePassword",new String(masterPassword)); - System.setProperty("javax.net.ssl.trustStorePassword",new String(masterPassword)); + + if (System.getProperty("javax.net.ssl.keyStorePassword") == null) { + System.setProperty("javax.net.ssl.keyStorePassword", new String(masterPassword)); + } + + if (System.getProperty("javax.net.ssl.trustStorePassword") == null) { + System.setProperty("javax.net.ssl.trustStorePassword", new String(masterPassword)); + } } @Override diff --git a/nucleus/security/ssl-impl/src/main/java/com/sun/enterprise/security/ssl/impl/SecuritySupportImpl.java b/nucleus/security/ssl-impl/src/main/java/com/sun/enterprise/security/ssl/impl/SecuritySupportImpl.java index bde0bf2c252..3e6ee075d36 100644 --- a/nucleus/security/ssl-impl/src/main/java/com/sun/enterprise/security/ssl/impl/SecuritySupportImpl.java +++ b/nucleus/security/ssl-impl/src/main/java/com/sun/enterprise/security/ssl/impl/SecuritySupportImpl.java @@ -37,6 +37,7 @@ * only if the new code is made subject to such option by the copyright * holder. */ +// Portions Copyright [2018] [Payara Foundation and/or its affiliates]" package com.sun.enterprise.security.ssl.impl; import com.sun.enterprise.security.ssl.manager.UnifiedX509KeyManager; @@ -87,6 +88,8 @@ import org.jvnet.hk2.annotations.Service; import javax.inject.Singleton; +import org.glassfish.api.admin.ServerEnvironment; +import org.jvnet.hk2.annotations.Optional; /** * This implements SecuritySupport used in PluggableFeatureFactory. @@ -129,6 +132,9 @@ public class SecuritySupportImpl extends SecuritySupport { private ServiceLocator habitat; @Inject private ProcessEnvironment penv; + + @Inject @Optional + private ServerEnvironment senv; public SecuritySupportImpl() { this(true); @@ -164,12 +170,16 @@ private void initJKS() { if (penv == null && habitat != null) { penv = habitat.getService(ProcessEnvironment.class); } + + if (senv == null && habitat != null) { + senv = habitat.getService(ServerEnvironment.class); + } /* * If we don't have a keystore password yet check the properties. * Always do so for the app client case whether the passwords have been * found from master password helper or not. */ - if (keyStorePass == null || isACC()) { + if (keyStorePass == null || isACC() || (senv != null && senv.isMicro())) { final String keyStorePassOverride = System.getProperty(KEYSTORE_PASS_PROP, DEFAULT_KEYSTORE_PASS); if (keyStorePassOverride != null) { keyStorePass = keyStorePassOverride.toCharArray();