"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "solr/solrj/src/java/org/apache/solr/client/solrj/embedded/SSLConfig.java" between
solr-8.4.0-src.tgz and solr-8.4.1-src.tgz

About: Solr is the search platform from the Apache Lucene project. Its major features include full-text search, hit highlighting, faceted search, caching, replication, and a web admin interface.

SSLConfig.java  (solr-8.4.0-src.tgz):SSLConfig.java  (solr-8.4.1-src.tgz)
skipping to change at line 27 skipping to change at line 27
package org.apache.solr.client.solrj.embedded; package org.apache.solr.client.solrj.embedded;
import org.eclipse.jetty.util.ssl.SslContextFactory; import org.eclipse.jetty.util.ssl.SslContextFactory;
/** /**
* Encapsulates settings related to SSL Configuration. * Encapsulates settings related to SSL Configuration.
* NOTE: all other settings are ignored if {@link #isSSLMode} is false. * NOTE: all other settings are ignored if {@link #isSSLMode} is false.
* @see #setUseSSL * @see #setUseSSL
*/ */
public class SSLConfig { public class SSLConfig {
private boolean useSsl; private boolean useSsl;
private boolean clientAuth; private boolean clientAuth;
private String keyStore; private String keyStore;
private String keyStorePassword; private String keyStorePassword;
private String trustStore; private String trustStore;
private String trustStorePassword; private String trustStorePassword;
/** NOTE: all other settings are ignored if useSSL is false; trustStore settin gs are ignored if clientAuth is false */ /** NOTE: all other settings are ignored if useSSL is false; trustStore settin gs are ignored if clientAuth is false */
public SSLConfig(boolean useSSL, boolean clientAuth, String keyStore, String k eyStorePassword, String trustStore, String trustStorePassword) { public SSLConfig(boolean useSSL, boolean clientAuth, String keyStore, String k eyStorePassword, String trustStore, String trustStorePassword) {
this.useSsl = useSSL; this.useSsl = useSSL;
skipping to change at line 79 skipping to change at line 78
public String getTrustStore() { public String getTrustStore() {
return trustStore; return trustStore;
} }
public String getTrustStorePassword() { public String getTrustStorePassword() {
return trustStorePassword; return trustStorePassword;
} }
/** /**
* Returns an SslContextFactory that should be used by a jetty server based on the specified * Returns an SslContextFactory.Server that should be used by a jetty server b ased on the specified
* SSLConfig param which may be null. * SSLConfig param which may be null.
* *
* if the SSLConfig param is non-null, then this method will return the result s of * if the SSLConfig param is non-null, then this method will return the result s of
* {@link #createContextFactory()}. * {@link #createContextFactory()}.
* *
* If the SSLConfig param is null, then this method will return null unless th e * If the SSLConfig param is null, then this method will return null unless th e
* <code>tests.jettySsl</code> system property is true, in which case standard "javax.net.ssl.*" * <code>tests.jettySsl</code> system property is true, in which case standard "javax.net.ssl.*"
* system properties will be used instead, along with "tests.jettySsl.clientAu th". * system properties will be used instead, along with "tests.jettySsl.clientAu th".
* *
* @see #createContextFactory() * @see #createContextFactory()
*/ */
public static SslContextFactory createContextFactory(SSLConfig sslConfig) { public static SslContextFactory.Server createContextFactory(SSLConfig sslConfi
g) {
if (sslConfig != null) { if (sslConfig != null) {
return sslConfig.createContextFactory(); return sslConfig.createContextFactory();
} }
// else... // else...
if (Boolean.getBoolean("tests.jettySsl")) { if (Boolean.getBoolean("tests.jettySsl")) {
return configureSslFromSysProps(); return configureSslFromSysProps();
} }
// else... // else...
return null; return null;
} }
/** /**
* Returns an SslContextFactory that should be used by a jetty server based on this SSLConfig instance, * Returns an SslContextFactory.Server that should be used by a jetty server b ased on this SSLConfig instance,
* or null if SSL should not be used. * or null if SSL should not be used.
* *
* The default implementation generates a simple factory according to the keys tore, truststore, * The default implementation generates a simple factory according to the keys tore, truststore,
* and clientAuth properties of this object. * and clientAuth properties of this object.
* *
* @see #getKeyStore * @see #getKeyStore
* @see #getKeyStorePassword * @see #getKeyStorePassword
* @see #isClientAuthMode * @see #isClientAuthMode
* @see #getTrustStore * @see #getTrustStore
* @see #getTrustStorePassword * @see #getTrustStorePassword
*/ */
public SslContextFactory createContextFactory() { public SslContextFactory.Server createContextFactory() {
if (! isSSLMode()) { if (! isSSLMode()) {
return null; return null;
} }
// else... // else...
SslContextFactory factory = new SslContextFactory(false); SslContextFactory.Server factory = new SslContextFactory.Server();
if (getKeyStore() != null) if (getKeyStore() != null)
factory.setKeyStorePath(getKeyStore()); factory.setKeyStorePath(getKeyStore());
if (getKeyStorePassword() != null) if (getKeyStorePassword() != null)
factory.setKeyStorePassword(getKeyStorePassword()); factory.setKeyStorePassword(getKeyStorePassword());
factory.setNeedClientAuth(isClientAuthMode()); factory.setNeedClientAuth(isClientAuthMode());
if (isClientAuthMode()) { if (isClientAuthMode()) {
if (getTrustStore() != null) if (getTrustStore() != null)
factory.setTrustStorePath(getTrustStore()); factory.setTrustStorePath(getTrustStore());
if (getTrustStorePassword() != null) if (getTrustStorePassword() != null)
factory.setTrustStorePassword(getTrustStorePassword()); factory.setTrustStorePassword(getTrustStorePassword());
} }
return factory; return factory;
} }
private static SslContextFactory configureSslFromSysProps() { public SslContextFactory.Client createClientContextFactory() {
if (! isSSLMode()) {
return null;
}
// else...
SslContextFactory.Client factory = new SslContextFactory.Client();
if (getKeyStore() != null) {
factory.setKeyStorePath(getKeyStore());
}
if (getKeyStorePassword() != null) {
factory.setKeyStorePassword(getKeyStorePassword());
}
if (isClientAuthMode()) {
if (getTrustStore() != null)
factory.setTrustStorePath(getTrustStore());
if (getTrustStorePassword() != null)
factory.setTrustStorePassword(getTrustStorePassword());
}
return factory;
}
SslContextFactory sslcontext = new SslContextFactory(false); private static SslContextFactory.Server configureSslFromSysProps() {
SslContextFactory.Server sslcontext = new SslContextFactory.Server();
if (null != System.getProperty("javax.net.ssl.keyStore")) { if (null != System.getProperty("javax.net.ssl.keyStore")) {
sslcontext.setKeyStorePath sslcontext.setKeyStorePath
(System.getProperty("javax.net.ssl.keyStore")); (System.getProperty("javax.net.ssl.keyStore"));
} }
if (null != System.getProperty("javax.net.ssl.keyStorePassword")) { if (null != System.getProperty("javax.net.ssl.keyStorePassword")) {
sslcontext.setKeyStorePassword sslcontext.setKeyStorePassword
(System.getProperty("javax.net.ssl.keyStorePassword")); (System.getProperty("javax.net.ssl.keyStorePassword"));
} }
if (null != System.getProperty("javax.net.ssl.trustStore")) { if (null != System.getProperty("javax.net.ssl.trustStore")) {
 End of changes. 9 change blocks. 
11 lines changed or deleted 31 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)