|
@@ -27,19 +27,26 @@ import password.pwm.PwmApplication;
|
|
import password.pwm.PwmApplicationMode;
|
|
import password.pwm.PwmApplicationMode;
|
|
import password.pwm.PwmConstants;
|
|
import password.pwm.PwmConstants;
|
|
import password.pwm.PwmEnvironment;
|
|
import password.pwm.PwmEnvironment;
|
|
|
|
+import password.pwm.bean.SessionLabel;
|
|
import password.pwm.config.Configuration;
|
|
import password.pwm.config.Configuration;
|
|
|
|
+import password.pwm.config.PwmSetting;
|
|
|
|
+import password.pwm.config.StoredValue;
|
|
|
|
+import password.pwm.config.profile.LdapProfile;
|
|
import password.pwm.config.stored.ConfigurationProperty;
|
|
import password.pwm.config.stored.ConfigurationProperty;
|
|
import password.pwm.config.stored.ConfigurationReader;
|
|
import password.pwm.config.stored.ConfigurationReader;
|
|
import password.pwm.config.stored.StoredConfigurationImpl;
|
|
import password.pwm.config.stored.StoredConfigurationImpl;
|
|
|
|
+import password.pwm.config.value.X509CertificateValue;
|
|
import password.pwm.error.ErrorInformation;
|
|
import password.pwm.error.ErrorInformation;
|
|
import password.pwm.error.PwmError;
|
|
import password.pwm.error.PwmError;
|
|
import password.pwm.error.PwmException;
|
|
import password.pwm.error.PwmException;
|
|
|
|
+import password.pwm.error.PwmOperationalException;
|
|
import password.pwm.error.PwmUnrecoverableException;
|
|
import password.pwm.error.PwmUnrecoverableException;
|
|
import password.pwm.util.PropertyConfigurationImporter;
|
|
import password.pwm.util.PropertyConfigurationImporter;
|
|
import password.pwm.util.PwmScheduler;
|
|
import password.pwm.util.PwmScheduler;
|
|
import password.pwm.util.java.JavaHelper;
|
|
import password.pwm.util.java.JavaHelper;
|
|
import password.pwm.util.java.TimeDuration;
|
|
import password.pwm.util.java.TimeDuration;
|
|
import password.pwm.util.logging.PwmLogger;
|
|
import password.pwm.util.logging.PwmLogger;
|
|
|
|
+import password.pwm.util.secure.X509Utils;
|
|
|
|
|
|
import javax.servlet.ServletContext;
|
|
import javax.servlet.ServletContext;
|
|
import javax.servlet.ServletRequest;
|
|
import javax.servlet.ServletRequest;
|
|
@@ -51,11 +58,14 @@ import java.io.InputStream;
|
|
import java.io.Serializable;
|
|
import java.io.Serializable;
|
|
import java.nio.file.Files;
|
|
import java.nio.file.Files;
|
|
import java.nio.file.Path;
|
|
import java.nio.file.Path;
|
|
|
|
+import java.security.cert.X509Certificate;
|
|
import java.time.Instant;
|
|
import java.time.Instant;
|
|
import java.util.Collection;
|
|
import java.util.Collection;
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
|
|
+import java.util.List;
|
|
import java.util.Locale;
|
|
import java.util.Locale;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
|
+import java.util.Set;
|
|
import java.util.concurrent.Executors;
|
|
import java.util.concurrent.Executors;
|
|
import java.util.concurrent.ScheduledExecutorService;
|
|
import java.util.concurrent.ScheduledExecutorService;
|
|
import java.util.concurrent.TimeUnit;
|
|
import java.util.concurrent.TimeUnit;
|
|
@@ -64,8 +74,8 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|
|
|
|
|
public class ContextManager implements Serializable
|
|
public class ContextManager implements Serializable
|
|
{
|
|
{
|
|
-
|
|
|
|
private static final PwmLogger LOGGER = PwmLogger.forClass( ContextManager.class );
|
|
private static final PwmLogger LOGGER = PwmLogger.forClass( ContextManager.class );
|
|
|
|
+ private static final SessionLabel SESSION_LABEL = SessionLabel.CONTEXT_SESSION_LABEL;
|
|
|
|
|
|
private transient ServletContext servletContext;
|
|
private transient ServletContext servletContext;
|
|
private transient ScheduledExecutorService taskMaster;
|
|
private transient ScheduledExecutorService taskMaster;
|
|
@@ -101,8 +111,6 @@ public class ContextManager implements Serializable
|
|
final PwmApplication pwmApplication = getPwmApplication( request.getServletContext() );
|
|
final PwmApplication pwmApplication = getPwmApplication( request.getServletContext() );
|
|
request.setAttribute( PwmConstants.REQUEST_ATTR_PWM_APPLICATION, pwmApplication );
|
|
request.setAttribute( PwmConstants.REQUEST_ATTR_PWM_APPLICATION, pwmApplication );
|
|
return pwmApplication;
|
|
return pwmApplication;
|
|
-
|
|
|
|
-
|
|
|
|
}
|
|
}
|
|
|
|
|
|
public static PwmApplication getPwmApplication( final HttpSession session ) throws PwmUnrecoverableException
|
|
public static PwmApplication getPwmApplication( final HttpSession session ) throws PwmUnrecoverableException
|
|
@@ -241,7 +249,7 @@ public class ContextManager implements Serializable
|
|
|
|
|
|
{
|
|
{
|
|
final String filename = configurationFile == null ? "null" : configurationFile.getAbsoluteFile().getAbsolutePath();
|
|
final String filename = configurationFile == null ? "null" : configurationFile.getAbsoluteFile().getAbsolutePath();
|
|
- LOGGER.debug( () -> "configuration file was loaded from " + ( filename ) );
|
|
|
|
|
|
+ LOGGER.debug( SESSION_LABEL, () -> "configuration file was loaded from " + ( filename ) );
|
|
}
|
|
}
|
|
|
|
|
|
final Collection<PwmEnvironment.ApplicationFlag> applicationFlags = parameterReader.readApplicationFlags();
|
|
final Collection<PwmEnvironment.ApplicationFlag> applicationFlags = parameterReader.readApplicationFlags();
|
|
@@ -288,6 +296,8 @@ public class ContextManager implements Serializable
|
|
}
|
|
}
|
|
|
|
|
|
checkConfigForSaveOnRestart( configReader, pwmApplication );
|
|
checkConfigForSaveOnRestart( configReader, pwmApplication );
|
|
|
|
+
|
|
|
|
+ checkConfigForAutoImportLdapCerts( configReader );
|
|
}
|
|
}
|
|
|
|
|
|
if ( pwmApplication == null || pwmApplication.getApplicationMode() == PwmApplicationMode.NEW )
|
|
if ( pwmApplication == null || pwmApplication.getApplicationMode() == PwmApplicationMode.NEW )
|
|
@@ -295,7 +305,7 @@ public class ContextManager implements Serializable
|
|
taskMaster.scheduleWithFixedDelay( new SilentPropertiesFileWatcher(), fileScanFrequencyMs, fileScanFrequencyMs, TimeUnit.MILLISECONDS );
|
|
taskMaster.scheduleWithFixedDelay( new SilentPropertiesFileWatcher(), fileScanFrequencyMs, fileScanFrequencyMs, TimeUnit.MILLISECONDS );
|
|
}
|
|
}
|
|
|
|
|
|
- LOGGER.trace( () -> "initialization complete (" + TimeDuration.compactFromCurrent( startTime ) + ")" );
|
|
|
|
|
|
+ LOGGER.trace( SESSION_LABEL, () -> "initialization complete (" + TimeDuration.compactFromCurrent( startTime ) + ")" );
|
|
}
|
|
}
|
|
|
|
|
|
private void checkConfigForSaveOnRestart(
|
|
private void checkConfigForSaveOnRestart(
|
|
@@ -308,29 +318,48 @@ public class ContextManager implements Serializable
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
- final String saveConfigOnRestartStrValue = configReader.getStoredConfiguration().readConfigProperty(
|
|
|
|
- ConfigurationProperty.CONFIG_ON_START );
|
|
|
|
-
|
|
|
|
- if ( saveConfigOnRestartStrValue == null || !Boolean.parseBoolean( saveConfigOnRestartStrValue ) )
|
|
|
|
|
|
+ if ( !Boolean.parseBoolean( configReader.getStoredConfiguration().readConfigProperty( ConfigurationProperty.CONFIG_ON_START ) ) )
|
|
{
|
|
{
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
- LOGGER.warn( "configuration file contains property \"" + ConfigurationProperty.CONFIG_ON_START + "\"=true, will save configuration and set property to false." );
|
|
|
|
|
|
+ LOGGER.warn( SESSION_LABEL, "configuration file contains property \""
|
|
|
|
+ + ConfigurationProperty.CONFIG_ON_START.getKey() + "\"=true, will save configuration and set property to false." );
|
|
|
|
|
|
try
|
|
try
|
|
{
|
|
{
|
|
final StoredConfigurationImpl newConfig = StoredConfigurationImpl.copy( configReader.getStoredConfiguration() );
|
|
final StoredConfigurationImpl newConfig = StoredConfigurationImpl.copy( configReader.getStoredConfiguration() );
|
|
newConfig.writeConfigProperty( ConfigurationProperty.CONFIG_ON_START, "false" );
|
|
newConfig.writeConfigProperty( ConfigurationProperty.CONFIG_ON_START, "false" );
|
|
- configReader.saveConfiguration( newConfig, pwmApplication, null );
|
|
|
|
|
|
+ configReader.saveConfiguration( newConfig, pwmApplication, SESSION_LABEL );
|
|
requestPwmApplicationRestart();
|
|
requestPwmApplicationRestart();
|
|
}
|
|
}
|
|
catch ( Exception e )
|
|
catch ( Exception e )
|
|
{
|
|
{
|
|
- LOGGER.error( "error while saving configuration file commanded by property \"" + ConfigurationProperty.CONFIG_ON_START + "\"=true, error: " + e.getMessage() );
|
|
|
|
|
|
+ LOGGER.error( SESSION_LABEL, "error while saving configuration file commanded by property \""
|
|
|
|
+ + ConfigurationProperty.CONFIG_ON_START + "\"=true, error: " + e.getMessage() );
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private void checkConfigForAutoImportLdapCerts(
|
|
|
|
+ final ConfigurationReader configReader
|
|
|
|
+ )
|
|
|
|
+ {
|
|
|
|
+ if ( configReader == null || configReader.getStoredConfiguration() == null )
|
|
|
|
+ {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if ( !Boolean.parseBoolean( configReader.getStoredConfiguration().readConfigProperty( ConfigurationProperty.IMPORT_LDAP_CERTIFICATES ) ) )
|
|
|
|
+ {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ LOGGER.info( SESSION_LABEL, () -> "configuration file contains property \"" + ConfigurationProperty.IMPORT_LDAP_CERTIFICATES.getKey()
|
|
|
|
+ + "\"=true, will import attempt ldap certificate import every 5 seconds until successful" );
|
|
|
|
+ final long secondsDelay = 5;
|
|
|
|
+ taskMaster.scheduleWithFixedDelay( new AutoImportLdapCertJob(), secondsDelay, secondsDelay, TimeUnit.SECONDS );
|
|
|
|
+ }
|
|
|
|
+
|
|
private void handleStartupError( final String msgPrefix, final Throwable throwable )
|
|
private void handleStartupError( final String msgPrefix, final Throwable throwable )
|
|
{
|
|
{
|
|
final String errorMsg;
|
|
final String errorMsg;
|
|
@@ -352,7 +381,7 @@ public class ContextManager implements Serializable
|
|
|
|
|
|
try
|
|
try
|
|
{
|
|
{
|
|
- LOGGER.fatal( startupErrorInformation.getDetailedErrorMsg() );
|
|
|
|
|
|
+ LOGGER.fatal( SESSION_LABEL, startupErrorInformation.getDetailedErrorMsg() );
|
|
}
|
|
}
|
|
catch ( Exception e2 )
|
|
catch ( Exception e2 )
|
|
{
|
|
{
|
|
@@ -404,7 +433,7 @@ public class ContextManager implements Serializable
|
|
{
|
|
{
|
|
if ( configReader.modifiedSinceLoad() )
|
|
if ( configReader.modifiedSinceLoad() )
|
|
{
|
|
{
|
|
- LOGGER.info( () -> "configuration file modification has been detected" );
|
|
|
|
|
|
+ LOGGER.info( SESSION_LABEL, () -> "configuration file modification has been detected" );
|
|
requestPwmApplicationRestart();
|
|
requestPwmApplicationRestart();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -428,19 +457,19 @@ public class ContextManager implements Serializable
|
|
if ( silentPropertiesFile.exists() )
|
|
if ( silentPropertiesFile.exists() )
|
|
{
|
|
{
|
|
boolean success = false;
|
|
boolean success = false;
|
|
- LOGGER.info( () -> "file " + silentPropertiesFile.getAbsolutePath() + " has appeared, will import as configuration" );
|
|
|
|
|
|
+ LOGGER.info( SESSION_LABEL, () -> "file " + silentPropertiesFile.getAbsolutePath() + " has appeared, will import as configuration" );
|
|
try
|
|
try
|
|
{
|
|
{
|
|
final PropertyConfigurationImporter importer = new PropertyConfigurationImporter();
|
|
final PropertyConfigurationImporter importer = new PropertyConfigurationImporter();
|
|
final StoredConfigurationImpl storedConfiguration = importer.readConfiguration( new FileInputStream( silentPropertiesFile ) );
|
|
final StoredConfigurationImpl storedConfiguration = importer.readConfiguration( new FileInputStream( silentPropertiesFile ) );
|
|
- configReader.saveConfiguration( storedConfiguration, pwmApplication, null );
|
|
|
|
- LOGGER.info( () -> "file " + silentPropertiesFile.getAbsolutePath() + " has been successfully imported and saved as configuration file" );
|
|
|
|
|
|
+ configReader.saveConfiguration( storedConfiguration, pwmApplication, SESSION_LABEL );
|
|
|
|
+ LOGGER.info( SESSION_LABEL, () -> "file " + silentPropertiesFile.getAbsolutePath() + " has been successfully imported and saved as configuration file" );
|
|
requestPwmApplicationRestart();
|
|
requestPwmApplicationRestart();
|
|
success = true;
|
|
success = true;
|
|
}
|
|
}
|
|
catch ( Exception e )
|
|
catch ( Exception e )
|
|
{
|
|
{
|
|
- LOGGER.error( "error importing " + silentPropertiesFile.getAbsolutePath() + ", error: " + e.getMessage() );
|
|
|
|
|
|
+ LOGGER.error( SESSION_LABEL, "error importing " + silentPropertiesFile.getAbsolutePath() + ", error: " + e.getMessage() );
|
|
}
|
|
}
|
|
|
|
|
|
final String appendValue = success ? ".imported" : ".error";
|
|
final String appendValue = success ? ".imported" : ".error";
|
|
@@ -450,11 +479,11 @@ public class ContextManager implements Serializable
|
|
try
|
|
try
|
|
{
|
|
{
|
|
Files.move( source, dest );
|
|
Files.move( source, dest );
|
|
- LOGGER.info( () -> "file " + source.toString() + " has been renamed to " + dest.toString() );
|
|
|
|
|
|
+ LOGGER.info( SESSION_LABEL, () -> "file " + source.toString() + " has been renamed to " + dest.toString() );
|
|
}
|
|
}
|
|
catch ( IOException e )
|
|
catch ( IOException e )
|
|
{
|
|
{
|
|
- LOGGER.error( "error renaming file " + source.toString() + " to " + dest.toString() + ", error: " + e.getMessage() );
|
|
|
|
|
|
+ LOGGER.error( SESSION_LABEL, "error renaming file " + source.toString() + " to " + dest.toString() + ", error: " + e.getMessage() );
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -481,7 +510,7 @@ public class ContextManager implements Serializable
|
|
if ( configReader != null && configReader.isSaveInProgress() )
|
|
if ( configReader != null && configReader.isSaveInProgress() )
|
|
{
|
|
{
|
|
final TimeDuration timeDuration = TimeDuration.fromCurrent( startTime );
|
|
final TimeDuration timeDuration = TimeDuration.fromCurrent( startTime );
|
|
- LOGGER.info( () -> "delaying restart request due to in progress file save (" + timeDuration.asCompactString() + ")" );
|
|
|
|
|
|
+ LOGGER.info( SESSION_LABEL, () -> "delaying restart request due to in progress file save (" + timeDuration.asCompactString() + ")" );
|
|
taskMaster.schedule( new RestartFlagWatcher(), 1, TimeUnit.SECONDS );
|
|
taskMaster.schedule( new RestartFlagWatcher(), 1, TimeUnit.SECONDS );
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
@@ -497,7 +526,7 @@ public class ContextManager implements Serializable
|
|
|
|
|
|
{
|
|
{
|
|
final TimeDuration timeDuration = TimeDuration.fromCurrent( startTime );
|
|
final TimeDuration timeDuration = TimeDuration.fromCurrent( startTime );
|
|
- LOGGER.info( () -> "beginning application restart (" + timeDuration.asCompactString() + "), restart count=" + restartCount.incrementAndGet() );
|
|
|
|
|
|
+ LOGGER.info( SESSION_LABEL, () -> "beginning application restart (" + timeDuration.asCompactString() + "), restart count=" + restartCount.incrementAndGet() );
|
|
}
|
|
}
|
|
|
|
|
|
final Instant shutdownStartTime = Instant.now();
|
|
final Instant shutdownStartTime = Instant.now();
|
|
@@ -512,7 +541,7 @@ public class ContextManager implements Serializable
|
|
}
|
|
}
|
|
catch ( Exception e )
|
|
catch ( Exception e )
|
|
{
|
|
{
|
|
- LOGGER.error( "unexpected error attempting to close application: " + e.getMessage() );
|
|
|
|
|
|
+ LOGGER.error( SESSION_LABEL, "unexpected error attempting to close application: " + e.getMessage() );
|
|
}
|
|
}
|
|
}
|
|
}
|
|
catch ( Exception e )
|
|
catch ( Exception e )
|
|
@@ -523,7 +552,7 @@ public class ContextManager implements Serializable
|
|
{
|
|
{
|
|
final TimeDuration timeDuration = TimeDuration.fromCurrent( startTime );
|
|
final TimeDuration timeDuration = TimeDuration.fromCurrent( startTime );
|
|
final TimeDuration shutdownDuration = TimeDuration.fromCurrent( shutdownStartTime );
|
|
final TimeDuration shutdownDuration = TimeDuration.fromCurrent( shutdownStartTime );
|
|
- LOGGER.info( () -> "application restart; shutdown completed, ("
|
|
|
|
|
|
+ LOGGER.info( SESSION_LABEL, () -> "application restart; shutdown completed, ("
|
|
+ shutdownDuration.asCompactString()
|
|
+ shutdownDuration.asCompactString()
|
|
+ ") now starting new application instance ("
|
|
+ ") now starting new application instance ("
|
|
+ timeDuration.asCompactString() + ")" );
|
|
+ timeDuration.asCompactString() + ")" );
|
|
@@ -532,7 +561,7 @@ public class ContextManager implements Serializable
|
|
|
|
|
|
{
|
|
{
|
|
final TimeDuration timeDuration = TimeDuration.fromCurrent( startTime );
|
|
final TimeDuration timeDuration = TimeDuration.fromCurrent( startTime );
|
|
- LOGGER.info( () -> "application restart completed (" + timeDuration.asCompactString() + ")" );
|
|
|
|
|
|
+ LOGGER.info( SESSION_LABEL, () -> "application restart completed (" + timeDuration.asCompactString() + ")" );
|
|
}
|
|
}
|
|
}
|
|
}
|
|
finally
|
|
finally
|
|
@@ -554,14 +583,14 @@ public class ContextManager implements Serializable
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
- LOGGER.trace( () -> "waiting up to " + maxRequestWaitTime.asCompactString()
|
|
|
|
|
|
+ LOGGER.trace( SESSION_LABEL, () -> "waiting up to " + maxRequestWaitTime.asCompactString()
|
|
+ " for " + startingRequestInProgress + " requests to complete." );
|
|
+ " for " + startingRequestInProgress + " requests to complete." );
|
|
maxRequestWaitTime.pause( TimeDuration.of( 10, TimeDuration.Unit.MILLISECONDS ), () -> pwmApplication.getInprogressRequests().get() == 0
|
|
maxRequestWaitTime.pause( TimeDuration.of( 10, TimeDuration.Unit.MILLISECONDS ), () -> pwmApplication.getInprogressRequests().get() == 0
|
|
);
|
|
);
|
|
|
|
|
|
final int requestsInProgress = pwmApplication.getInprogressRequests().get();
|
|
final int requestsInProgress = pwmApplication.getInprogressRequests().get();
|
|
final TimeDuration waitTime = TimeDuration.fromCurrent( startTime );
|
|
final TimeDuration waitTime = TimeDuration.fromCurrent( startTime );
|
|
- LOGGER.trace( () -> "after " + waitTime.asCompactString() + ", " + requestsInProgress
|
|
|
|
|
|
+ LOGGER.trace( SESSION_LABEL, () -> "after " + waitTime.asCompactString() + ", " + requestsInProgress
|
|
+ " requests in progress, proceeding with restart" );
|
|
+ " requests in progress, proceeding with restart" );
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -686,4 +715,68 @@ public class ContextManager implements Serializable
|
|
{
|
|
{
|
|
return contextPath;
|
|
return contextPath;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ private class AutoImportLdapCertJob implements Runnable
|
|
|
|
+ {
|
|
|
|
+ @Override
|
|
|
|
+ public void run()
|
|
|
|
+ {
|
|
|
|
+ try
|
|
|
|
+ {
|
|
|
|
+ importLdapCert();
|
|
|
|
+ }
|
|
|
|
+ catch ( Exception e )
|
|
|
|
+ {
|
|
|
|
+ LOGGER.error( SESSION_LABEL, "error trying to auto-import certs: " + e.getMessage() );
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void importLdapCert() throws PwmUnrecoverableException, IOException, PwmOperationalException
|
|
|
|
+ {
|
|
|
|
+ LOGGER.trace( SESSION_LABEL, () -> "beginning auto-import ldap cert due to config property '"
|
|
|
|
+ + ConfigurationProperty.IMPORT_LDAP_CERTIFICATES.getKey() + "'" );
|
|
|
|
+ final Configuration configuration = new Configuration( configReader.getStoredConfiguration() );
|
|
|
|
+ final StoredConfigurationImpl newStoredConfig = StoredConfigurationImpl.copy( configReader.getStoredConfiguration() );
|
|
|
|
+
|
|
|
|
+ int importedCerts = 0;
|
|
|
|
+ for ( final LdapProfile ldapProfile : configuration.getLdapProfiles().values() )
|
|
|
|
+ {
|
|
|
|
+ final List<String> ldapUrls = ldapProfile.getLdapUrls();
|
|
|
|
+ if ( !JavaHelper.isEmpty( ldapUrls ) )
|
|
|
|
+ {
|
|
|
|
+ final Set<X509Certificate> certs = X509Utils.readCertsForListOfLdapUrls( ldapUrls, configuration );
|
|
|
|
+ if ( !JavaHelper.isEmpty( certs ) )
|
|
|
|
+ {
|
|
|
|
+ importedCerts += certs.size();
|
|
|
|
+ for ( final X509Certificate cert : certs )
|
|
|
|
+ {
|
|
|
|
+ LOGGER.trace( SESSION_LABEL, () -> "imported cert: " + X509Utils.makeDebugText( cert ) );
|
|
|
|
+ }
|
|
|
|
+ final StoredValue storedValue = new X509CertificateValue( certs );
|
|
|
|
+ newStoredConfig.writeSetting( PwmSetting.LDAP_SERVER_CERTS, ldapProfile.getIdentifier(), storedValue, null );
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if ( importedCerts > 0 )
|
|
|
|
+ {
|
|
|
|
+ final int totalImportedCerts = importedCerts;
|
|
|
|
+ LOGGER.trace( SESSION_LABEL, () -> "completed auto-import ldap cert due to config property '"
|
|
|
|
+ + ConfigurationProperty.IMPORT_LDAP_CERTIFICATES.getKey() + "'"
|
|
|
|
+ + ", imported " + totalImportedCerts + " certificates" );
|
|
|
|
+ newStoredConfig.writeConfigProperty( ConfigurationProperty.IMPORT_LDAP_CERTIFICATES, "false" );
|
|
|
|
+ configReader.saveConfiguration( newStoredConfig, pwmApplication, SESSION_LABEL );
|
|
|
|
+ requestPwmApplicationRestart();
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ LOGGER.trace( SESSION_LABEL, () -> "unable to completed auto-import ldap cert due to config property '"
|
|
|
|
+ + ConfigurationProperty.IMPORT_LDAP_CERTIFICATES.getKey() + "'"
|
|
|
|
+ + ", no LDAP urls are configured" );
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|