Merge branch 'master' into jetty-7.6
Conflicts: jetty-client/src/main/java/org/eclipse/jetty/client/HttpConnection.java jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslSelectChannelEndPoint.java
This commit is contained in:
commit
74fd2e8965
|
@ -73,7 +73,7 @@ public class LikeJettyXml
|
|||
SslSelectChannelConnector ssl_connector = new SslSelectChannelConnector();
|
||||
ssl_connector.setPort(8443);
|
||||
SslContextFactory cf = ssl_connector.getSslContextFactory();
|
||||
cf.setKeyStore(jetty_home + "/etc/keystore");
|
||||
cf.setKeyStorePath(jetty_home + "/etc/keystore");
|
||||
cf.setKeyStorePassword("OBF:1vny1zlo1x8e1vnw1vn61x8g1zlu1vn4");
|
||||
cf.setKeyManagerPassword("OBF:1u2u1wml1z7s1z7a1wnl1u2g");
|
||||
cf.setTrustStore(jetty_home + "/etc/keystore");
|
||||
|
|
|
@ -47,7 +47,7 @@ public class ManyConnectors
|
|||
System.setProperty("jetty.home",jetty_home);
|
||||
ssl_connector.setPort(8443);
|
||||
SslContextFactory cf = ssl_connector.getSslContextFactory();
|
||||
cf.setKeyStore(jetty_home + "/etc/keystore");
|
||||
cf.setKeyStorePath(jetty_home + "/etc/keystore");
|
||||
cf.setKeyStorePassword("OBF:1vny1zlo1x8e1vnw1vn61x8g1zlu1vn4");
|
||||
cf.setKeyManagerPassword("OBF:1u2u1wml1z7s1z7a1wnl1u2g");
|
||||
|
||||
|
|
|
@ -698,14 +698,14 @@ public class HttpClient extends HttpBuffers implements Attributes, Dumpable
|
|||
@Deprecated
|
||||
public String getKeyStoreLocation()
|
||||
{
|
||||
return _sslContextFactory.getKeyStore();
|
||||
return _sslContextFactory.getKeyStorePath();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
@Deprecated
|
||||
public void setKeyStoreLocation(String keyStoreLocation)
|
||||
{
|
||||
_sslContextFactory.setKeyStore(keyStoreLocation);
|
||||
_sslContextFactory.setKeyStorePath(keyStoreLocation);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
|
|
|
@ -48,7 +48,7 @@ public class ProxyTunnellingTest
|
|||
SslSelectChannelConnector connector = new SslSelectChannelConnector();
|
||||
String keyStorePath = MavenTestingUtils.getTestResourceFile("keystore").getAbsolutePath();
|
||||
SslContextFactory cf = connector.getSslContextFactory();
|
||||
cf.setKeyStore(keyStorePath);
|
||||
cf.setKeyStorePath(keyStorePath);
|
||||
cf.setKeyStorePassword("storepwd");
|
||||
cf.setKeyManagerPassword("keypwd");
|
||||
startServer(connector, handler);
|
||||
|
|
|
@ -58,7 +58,7 @@ public class SslCertSecuredExchangeTest extends ContentExchangeTest
|
|||
cf.setValidateCerts(true);
|
||||
cf.setCrlPath(_crlpath);
|
||||
cf.setNeedClientAuth(true);
|
||||
cf.setKeyStore(_keypath);
|
||||
cf.setKeyStorePath(_keypath);
|
||||
cf.setKeyStorePassword(_password);
|
||||
cf.setKeyManagerPassword(_password);
|
||||
cf.setTrustStore(_trustpath);
|
||||
|
@ -159,7 +159,7 @@ public class SslCertSecuredExchangeTest extends ContentExchangeTest
|
|||
cf.setCrlPath(_crlpath);
|
||||
|
||||
cf.setCertAlias("client");
|
||||
cf.setKeyStore(_clientpath);
|
||||
cf.setKeyStorePath(_clientpath);
|
||||
cf.setKeyStorePassword(_password);
|
||||
cf.setKeyManagerPassword(_password);
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ public class SslContentExchangeTest
|
|||
SslSelectChannelConnector connector = new SslSelectChannelConnector();
|
||||
File keystore = MavenTestingUtils.getTestResourceFile("keystore");
|
||||
SslContextFactory cf = connector.getSslContextFactory();
|
||||
cf.setKeyStore(keystore.getAbsolutePath());
|
||||
cf.setKeyStorePath(keystore.getAbsolutePath());
|
||||
cf.setKeyStorePassword("storepwd");
|
||||
cf.setKeyManagerPassword("keypwd");
|
||||
cf.setSessionCachingEnabled(true);
|
||||
|
|
|
@ -63,7 +63,7 @@ extends ContentExchangeTest
|
|||
SslSelectChannelConnector connector = new SslSelectChannelConnector();
|
||||
File keystore = MavenTestingUtils.getTestResourceFile("keystore");
|
||||
SslContextFactory cf = connector.getSslContextFactory();
|
||||
cf.setKeyStore(keystore.getAbsolutePath());
|
||||
cf.setKeyStorePath(keystore.getAbsolutePath());
|
||||
cf.setKeyStorePassword("storepwd");
|
||||
cf.setKeyManagerPassword("keypwd");
|
||||
server.addConnector(connector);
|
||||
|
|
|
@ -165,7 +165,7 @@ public class SslSecurityListenerTest
|
|||
|
||||
connector.setPort(0);
|
||||
SslContextFactory cf = connector.getSslContextFactory();
|
||||
cf.setKeyStore(keystore);
|
||||
cf.setKeyStorePath(keystore);
|
||||
cf.setKeyStorePassword("storepwd");
|
||||
cf.setKeyManagerPassword("keypwd");
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ public abstract class SslValidationTestBase extends ContentExchangeTest
|
|||
srvFactory.setCrlPath(_crlpath);
|
||||
srvFactory.setNeedClientAuth(true);
|
||||
|
||||
srvFactory.setKeyStore(_keypath);
|
||||
srvFactory.setKeyStorePath(_keypath);
|
||||
srvFactory.setKeyStorePassword(_password);
|
||||
srvFactory.setKeyManagerPassword(_password);
|
||||
|
||||
|
@ -88,7 +88,7 @@ public abstract class SslValidationTestBase extends ContentExchangeTest
|
|||
cf.setValidateCerts(true);
|
||||
cf.setCrlPath(_crlpath);
|
||||
|
||||
cf.setKeyStore(_clientpath);
|
||||
cf.setKeyStorePath(_clientpath);
|
||||
cf.setKeyStorePassword(_password);
|
||||
cf.setKeyManagerPassword(_password);
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ public abstract class AbstractSslServerAndClientCreator implements ServerAndClie
|
|||
|
||||
connector.setPort(0);
|
||||
SslContextFactory cf = connector.getSslContextFactory();
|
||||
cf.setKeyStore(keystore);
|
||||
cf.setKeyStorePath(keystore);
|
||||
cf.setKeyStorePassword("storepwd");
|
||||
cf.setKeyManagerPassword("keypwd");
|
||||
connector.setAllowRenegotiate(true);
|
||||
|
|
|
@ -178,6 +178,8 @@ public class SslContextFactory extends AbstractLifeCycle
|
|||
|
||||
/** SSL context */
|
||||
private SSLContext _context;
|
||||
|
||||
private boolean _trustAll;
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
|
@ -186,6 +188,17 @@ public class SslContextFactory extends AbstractLifeCycle
|
|||
*/
|
||||
public SslContextFactory()
|
||||
{
|
||||
_trustAll=true;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* Construct an instance of SslContextFactory
|
||||
* Default constructor for use in XmlConfiguration files
|
||||
*/
|
||||
public SslContextFactory(boolean trustAll)
|
||||
{
|
||||
_trustAll=trustAll;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
@ -208,29 +221,36 @@ public class SslContextFactory extends AbstractLifeCycle
|
|||
{
|
||||
if (_context == null)
|
||||
{
|
||||
if (_keyStoreInputStream == null && _keyStorePath == null &&
|
||||
_trustStoreInputStream == null && _trustStorePath == null )
|
||||
if (_keyStore==null && _keyStoreInputStream == null && _keyStorePath == null &&
|
||||
_trustStore==null && _trustStoreInputStream == null && _trustStorePath == null )
|
||||
{
|
||||
LOG.debug("No keystore or trust store configured. ACCEPTING UNTRUSTED CERTIFICATES!!!!!");
|
||||
// Create a trust manager that does not validate certificate chains
|
||||
TrustManager trustAllCerts = new X509TrustManager()
|
||||
TrustManager[] trust_managers=null;
|
||||
|
||||
if (_trustAll)
|
||||
{
|
||||
public java.security.cert.X509Certificate[] getAcceptedIssuers()
|
||||
LOG.info("No keystore or trust store configured. ACCEPTING UNTRUSTED CERTIFICATES!!!!!");
|
||||
// Create a trust manager that does not validate certificate chains
|
||||
TrustManager trustAllCerts = new X509TrustManager()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
public java.security.cert.X509Certificate[] getAcceptedIssuers()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public void checkClientTrusted(java.security.cert.X509Certificate[] certs, String authType)
|
||||
{
|
||||
}
|
||||
|
||||
public void checkServerTrusted(java.security.cert.X509Certificate[] certs, String authType)
|
||||
{
|
||||
}
|
||||
};
|
||||
public void checkClientTrusted(java.security.cert.X509Certificate[] certs, String authType)
|
||||
{
|
||||
}
|
||||
|
||||
public void checkServerTrusted(java.security.cert.X509Certificate[] certs, String authType)
|
||||
{
|
||||
}
|
||||
};
|
||||
trust_managers = new TrustManager[] { trustAllCerts };
|
||||
}
|
||||
|
||||
SecureRandom secureRandom = (_secureRandomAlgorithm == null)?null:SecureRandom.getInstance(_secureRandomAlgorithm);
|
||||
_context = SSLContext.getInstance(_sslProtocol);
|
||||
_context.init(null, new TrustManager[]{trustAllCerts}, null);
|
||||
_context.init(null, trust_managers, secureRandom);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -403,16 +423,36 @@ public class SslContextFactory extends AbstractLifeCycle
|
|||
/**
|
||||
* @return The file or URL of the SSL Key store.
|
||||
*/
|
||||
public String getKeyStore()
|
||||
public String getKeyStorePath()
|
||||
{
|
||||
return _keyStorePath;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
@Deprecated
|
||||
public String getKeyStore()
|
||||
{
|
||||
return _keyStorePath;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @param keyStorePath
|
||||
* The file or URL of the SSL Key store.
|
||||
*/
|
||||
public void setKeyStorePath(String keyStorePath)
|
||||
{
|
||||
checkNotStarted();
|
||||
|
||||
_keyStorePath = keyStorePath;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @param keyStorePath
|
||||
* @deprecated Use {@link #setKeyStorePath(String)}
|
||||
*/
|
||||
@Deprecated
|
||||
public void setKeyStore(String keyStorePath)
|
||||
{
|
||||
checkNotStarted();
|
||||
|
@ -480,7 +520,7 @@ public class SslContextFactory extends AbstractLifeCycle
|
|||
/** Set the keyStoreInputStream.
|
||||
* @param keyStoreInputStream the InputStream to the KeyStore
|
||||
*
|
||||
* @deprecated
|
||||
* @deprecated Use {@link #setKeyStore(KeyStore)}
|
||||
*/
|
||||
@Deprecated
|
||||
public void setKeyStoreInputStream(InputStream keyStoreInputStream)
|
||||
|
@ -843,7 +883,7 @@ public class SslContextFactory extends AbstractLifeCycle
|
|||
{
|
||||
return (_keyManagerFactoryAlgorithm);
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @param algorithm
|
||||
|
@ -865,10 +905,29 @@ public class SslContextFactory extends AbstractLifeCycle
|
|||
return (_trustManagerFactoryAlgorithm);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @return True if all certificates should be trusted if there is no KeyStore or TrustStore
|
||||
*/
|
||||
public boolean isTrustAll()
|
||||
{
|
||||
return _trustAll;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @param trustAll True if all certificates should be trusted if there is no KeyStore or TrustStore
|
||||
*/
|
||||
public void setTrustAll(boolean trustAll)
|
||||
{
|
||||
_trustAll = trustAll;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @param algorithm
|
||||
* The algorithm name (default "SunX509") used by the {@link TrustManagerFactory}
|
||||
* Use the string "TrustAll" to install a trust manager that trusts all.
|
||||
*/
|
||||
public void setTrustManagerFactoryAlgorithm(String algorithm)
|
||||
{
|
||||
|
@ -1040,7 +1099,7 @@ public class SslContextFactory extends AbstractLifeCycle
|
|||
|
||||
/* ------------------------------------------------------------ */
|
||||
protected TrustManager[] getTrustManagers(KeyStore trustStore, Collection<? extends CRL> crls) throws Exception
|
||||
{
|
||||
{
|
||||
TrustManager[] managers = null;
|
||||
if (trustStore != null)
|
||||
{
|
||||
|
|
|
@ -0,0 +1,75 @@
|
|||
package org.eclipse.jetty.http;
|
||||
|
||||
import static junit.framework.Assert.assertTrue;
|
||||
|
||||
import java.io.FileInputStream;
|
||||
import java.security.KeyStore;
|
||||
|
||||
import org.eclipse.jetty.http.ssl.SslContextFactory;
|
||||
import org.junit.Test;
|
||||
|
||||
|
||||
public class SslContextFactoryTest
|
||||
{
|
||||
@Test
|
||||
public void testNoTsFileKs() throws Exception
|
||||
{
|
||||
String keystorePath = System.getProperty("basedir",".") + "/src/test/resources/keystore";
|
||||
SslContextFactory cf = new SslContextFactory(keystorePath);
|
||||
cf.setKeyStorePassword("storepwd");
|
||||
cf.setKeyManagerPassword("keypwd");
|
||||
|
||||
cf.start();
|
||||
|
||||
assertTrue(cf.getSslContext()!=null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNoTsStreamKs() throws Exception
|
||||
{
|
||||
String keystorePath = System.getProperty("basedir",".") + "/src/test/resources/keystore";
|
||||
|
||||
SslContextFactory cf = new SslContextFactory();
|
||||
|
||||
cf.setKeyStoreInputStream(new FileInputStream(keystorePath));
|
||||
cf.setKeyStorePassword("storepwd");
|
||||
cf.setKeyManagerPassword("keypwd");
|
||||
|
||||
cf.start();
|
||||
|
||||
assertTrue(cf.getSslContext()!=null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNoTsSetKs() throws Exception
|
||||
{
|
||||
String keystorePath = System.getProperty("basedir",".") + "/src/test/resources/keystore";
|
||||
|
||||
KeyStore ks = KeyStore.getInstance("JKS");
|
||||
ks.load(new FileInputStream(keystorePath),"storepwd".toCharArray());
|
||||
|
||||
SslContextFactory cf = new SslContextFactory();
|
||||
cf.setKeyStore(ks);
|
||||
cf.setKeyManagerPassword("keypwd");
|
||||
|
||||
cf.start();
|
||||
|
||||
assertTrue(cf.getSslContext()!=null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNoTsNoKs() throws Exception
|
||||
{
|
||||
SslContextFactory cf = new SslContextFactory();
|
||||
cf.start();
|
||||
assertTrue(cf.getSslContext()!=null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTrustAll() throws Exception
|
||||
{
|
||||
SslContextFactory cf = new SslContextFactory();
|
||||
cf.start();
|
||||
assertTrue(cf.getSslContext()!=null);
|
||||
}
|
||||
}
|
Binary file not shown.
|
@ -245,9 +245,9 @@ public class SelectChannelConnector extends AbstractNIOConnector
|
|||
_manager.setMaxIdleTime(getMaxIdleTime());
|
||||
_manager.setLowResourcesConnections(getLowResourcesConnections());
|
||||
_manager.setLowResourcesMaxIdleTime(getLowResourcesMaxIdleTime());
|
||||
_manager.start();
|
||||
|
||||
super.doStart();
|
||||
_manager.start();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
|
|
@ -261,7 +261,7 @@ public class SslSelectChannelConnector extends SelectChannelConnector implements
|
|||
@Deprecated
|
||||
public void setKeystore(String keystore)
|
||||
{
|
||||
_sslContextFactory.setKeyStore(keystore);
|
||||
_sslContextFactory.setKeyStorePath(keystore);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
@ -272,7 +272,7 @@ public class SslSelectChannelConnector extends SelectChannelConnector implements
|
|||
@Deprecated
|
||||
public String getKeystore()
|
||||
{
|
||||
return _sslContextFactory.getKeyStore();
|
||||
return _sslContextFactory.getKeyStorePath();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
|
|
@ -177,7 +177,7 @@ public class SslSocketConnector extends SocketConnector implements SslConnector
|
|||
@Deprecated
|
||||
public String getKeystore()
|
||||
{
|
||||
return _sslContextFactory.getKeyStore();
|
||||
return _sslContextFactory.getKeyStorePath();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
@ -428,7 +428,7 @@ public class SslSocketConnector extends SocketConnector implements SslConnector
|
|||
@Deprecated
|
||||
public void setKeystore(String keystore)
|
||||
{
|
||||
_sslContextFactory.setKeyStore(keystore);
|
||||
_sslContextFactory.setKeyStorePath(keystore);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
|
|
@ -92,12 +92,12 @@ public class RequestTest
|
|||
{
|
||||
//catch the error and check the param map is not null
|
||||
map = request.getParameterMap();
|
||||
System.err.println(map);
|
||||
assertFalse(map == null);
|
||||
assertTrue(map.isEmpty());
|
||||
|
||||
Enumeration names = request.getParameterNames();
|
||||
assertFalse(names.hasMoreElements());
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -111,7 +111,32 @@ public class RequestTest
|
|||
"Content-Type: text/html;charset=utf8\n"+
|
||||
"\n";
|
||||
|
||||
String response = _connector.getResponses(request);
|
||||
String responses=_connector.getResponses(request);
|
||||
assertTrue(responses.startsWith("HTTP/1.1 200"));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBadUtf8ParamExtraction() throws Exception
|
||||
{
|
||||
_handler._checker = new RequestTester()
|
||||
{
|
||||
public boolean check(HttpServletRequest request,HttpServletResponse response)
|
||||
{
|
||||
String value=request.getParameter("param");
|
||||
return value.startsWith("aaa") && value.endsWith("bb");
|
||||
}
|
||||
};
|
||||
|
||||
//Send a request with query string with illegal hex code to cause
|
||||
//an exception parsing the params
|
||||
String request="GET /?param=aaa%E7bbb HTTP/1.1\r\n"+
|
||||
"Host: whatever\r\n"+
|
||||
"Content-Type: text/html;charset=utf8\n"+
|
||||
"\n";
|
||||
|
||||
String responses=_connector.getResponses(request);
|
||||
assertTrue(responses.startsWith("HTTP/1.1 200"));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ public class ConnectHandlerSSLTest extends AbstractConnectHandlerTest
|
|||
|
||||
String keyStorePath = MavenTestingUtils.getTestResourceFile("keystore").getAbsolutePath();
|
||||
SslContextFactory cf = connector.getSslContextFactory();
|
||||
cf.setKeyStore(keyStorePath);
|
||||
cf.setKeyStorePath(keyStorePath);
|
||||
cf.setKeyStorePassword("storepwd");
|
||||
cf.setKeyManagerPassword("keypwd");
|
||||
|
||||
|
|
|
@ -112,7 +112,7 @@ public class SSLEngineTest
|
|||
|
||||
connector.setPort(0);
|
||||
SslContextFactory cf = connector.getSslContextFactory();
|
||||
cf.setKeyStore(keystore);
|
||||
cf.setKeyStorePath(keystore);
|
||||
cf.setKeyStorePassword("storepwd");
|
||||
cf.setKeyManagerPassword("keypwd");
|
||||
connector.setRequestBufferSize(512);
|
||||
|
|
|
@ -45,7 +45,7 @@ public class SSLSelectChannelConnectorLoadTest
|
|||
|
||||
String keystorePath = System.getProperty("basedir", ".") + "/src/test/resources/keystore";
|
||||
SslContextFactory cf = connector.getSslContextFactory();
|
||||
cf.setKeyStore(keystorePath);
|
||||
cf.setKeyStorePath(keystorePath);
|
||||
cf.setKeyStorePassword("storepwd");
|
||||
cf.setKeyManagerPassword("keypwd");
|
||||
cf.setTrustStore(keystorePath);
|
||||
|
|
|
@ -95,7 +95,7 @@ public class SslRenegotiateTest
|
|||
String keystore = MavenTestingUtils.getTestResourceFile("keystore").getAbsolutePath();
|
||||
connector.setPort(0);
|
||||
SslContextFactory cf = connector.getSslContextFactory();
|
||||
cf.setKeyStore(keystore);
|
||||
cf.setKeyStorePath(keystore);
|
||||
cf.setKeyStorePassword("storepwd");
|
||||
cf.setKeyManagerPassword("keypwd");
|
||||
cf.setAllowRenegotiate(reneg);
|
||||
|
|
|
@ -48,7 +48,7 @@ public class SslSelectChannelServerTest extends HttpServerTestBase
|
|||
SslSelectChannelConnector connector = new SslSelectChannelConnector();
|
||||
String keystorePath = System.getProperty("basedir",".") + "/src/test/resources/keystore";
|
||||
SslContextFactory cf = connector.getSslContextFactory();
|
||||
cf.setKeyStore(keystorePath);
|
||||
cf.setKeyStorePath(keystorePath);
|
||||
cf.setKeyStorePassword("storepwd");
|
||||
cf.setKeyManagerPassword("keypwd");
|
||||
cf.setTrustStore(keystorePath);
|
||||
|
|
|
@ -42,7 +42,7 @@ public class SslSelectChannelTimeoutTest extends ConnectorTimeoutTest
|
|||
connector.setMaxIdleTime(MAX_IDLE_TIME); //250 msec max idle
|
||||
String keystorePath = System.getProperty("basedir",".") + "/src/test/resources/keystore";
|
||||
SslContextFactory cf = connector.getSslContextFactory();
|
||||
cf.setKeyStore(keystorePath);
|
||||
cf.setKeyStorePath(keystorePath);
|
||||
cf.setKeyStorePassword("storepwd");
|
||||
cf.setKeyManagerPassword("keypwd");
|
||||
cf.setTrustStore(keystorePath);
|
||||
|
|
|
@ -50,7 +50,7 @@ public class SslSocketServerTest extends HttpServerTestBase
|
|||
SslSocketConnector connector = new SslSocketConnector();
|
||||
String keystorePath = System.getProperty("basedir",".") + "/src/test/resources/keystore";
|
||||
SslContextFactory cf = connector.getSslContextFactory();
|
||||
cf.setKeyStore(keystorePath);
|
||||
cf.setKeyStorePath(keystorePath);
|
||||
cf.setKeyStorePassword("storepwd");
|
||||
cf.setKeyManagerPassword("keypwd");
|
||||
cf.setTrustStore(keystorePath);
|
||||
|
|
|
@ -44,7 +44,7 @@ public class SslSocketTimeoutTest extends ConnectorTimeoutTest
|
|||
connector.setMaxIdleTime(MAX_IDLE_TIME); //250 msec max idle
|
||||
String keystorePath = System.getProperty("basedir",".") + "/src/test/resources/keystore";
|
||||
SslContextFactory cf = connector.getSslContextFactory();
|
||||
cf.setKeyStore(keystorePath);
|
||||
cf.setKeyStorePath(keystorePath);
|
||||
cf.setKeyStorePassword("storepwd");
|
||||
cf.setKeyManagerPassword("keypwd");
|
||||
cf.setTrustStore(keystorePath);
|
||||
|
|
|
@ -84,7 +84,7 @@ public class SslTruncationAttackTest
|
|||
|
||||
String keystorePath = System.getProperty("basedir", ".") + "/src/test/resources/keystore";
|
||||
SslContextFactory sslContextFactory = connector.getSslContextFactory();
|
||||
sslContextFactory.setKeyStore(keystorePath);
|
||||
sslContextFactory.setKeyStorePath(keystorePath);
|
||||
sslContextFactory.setKeyStorePassword("storepwd");
|
||||
sslContextFactory.setKeyManagerPassword("keypwd");
|
||||
sslContextFactory.setTrustStore(keystorePath);
|
||||
|
|
|
@ -58,7 +58,7 @@ public class SslUploadTest
|
|||
|
||||
String keystorePath = System.getProperty("basedir",".") + "/src/test/resources/keystore";
|
||||
SslContextFactory cf = connector.getSslContextFactory();
|
||||
cf.setKeyStore(keystorePath);
|
||||
cf.setKeyStorePath(keystorePath);
|
||||
cf.setKeyStorePassword("storepwd");
|
||||
cf.setKeyManagerPassword("keypwd");
|
||||
cf.setTrustStore(keystorePath);
|
||||
|
|
|
@ -20,6 +20,9 @@ import java.io.UnsupportedEncodingException;
|
|||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.jetty.util.Utf8Appendable.NotUtf8Exception;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/** Handles coding of MIME "x-www-form-urlencoded".
|
||||
|
@ -42,7 +45,7 @@ import java.util.Map;
|
|||
*/
|
||||
public class UrlEncoded extends MultiMap
|
||||
{
|
||||
// private static final Logger LOG = Log.getLogger(UrlEncoded.class);
|
||||
private static final Logger LOG = Log.getLogger(UrlEncoded.class);
|
||||
|
||||
public static final String ENCODING = System.getProperty("org.eclipse.jetty.util.UrlEncoding.charset",StringUtil.__UTF8);
|
||||
|
||||
|
@ -267,50 +270,59 @@ public class UrlEncoded extends MultiMap
|
|||
{
|
||||
String key = null;
|
||||
String value = null;
|
||||
|
||||
|
||||
// TODO cache of parameter names ???
|
||||
int end=offset+length;
|
||||
for (int i=offset;i<end;i++)
|
||||
{
|
||||
byte b=raw[i];
|
||||
switch ((char)(0xff&b))
|
||||
try
|
||||
{
|
||||
case '&':
|
||||
value = buffer.length()==0?"":buffer.toString();
|
||||
buffer.reset();
|
||||
if (key != null)
|
||||
{
|
||||
map.add(key,value);
|
||||
}
|
||||
else if (value!=null&&value.length()>0)
|
||||
{
|
||||
map.add(value,"");
|
||||
}
|
||||
key = null;
|
||||
value=null;
|
||||
break;
|
||||
|
||||
case '=':
|
||||
if (key!=null)
|
||||
{
|
||||
switch ((char)(0xff&b))
|
||||
{
|
||||
case '&':
|
||||
value = buffer.length()==0?"":buffer.toString();
|
||||
buffer.reset();
|
||||
if (key != null)
|
||||
{
|
||||
map.add(key,value);
|
||||
}
|
||||
else if (value!=null&&value.length()>0)
|
||||
{
|
||||
map.add(value,"");
|
||||
}
|
||||
key = null;
|
||||
value=null;
|
||||
break;
|
||||
|
||||
case '=':
|
||||
if (key!=null)
|
||||
{
|
||||
buffer.append(b);
|
||||
break;
|
||||
}
|
||||
key = buffer.toString();
|
||||
buffer.reset();
|
||||
break;
|
||||
|
||||
case '+':
|
||||
buffer.append((byte)' ');
|
||||
break;
|
||||
|
||||
case '%':
|
||||
if (i+2<end)
|
||||
buffer.append((byte)((TypeUtil.convertHexDigit(raw[++i])<<4) + TypeUtil.convertHexDigit(raw[++i])));
|
||||
break;
|
||||
|
||||
default:
|
||||
buffer.append(b);
|
||||
break;
|
||||
}
|
||||
key = buffer.toString();
|
||||
buffer.reset();
|
||||
break;
|
||||
|
||||
case '+':
|
||||
buffer.append((byte)' ');
|
||||
break;
|
||||
|
||||
case '%':
|
||||
if (i+2<end)
|
||||
buffer.append((byte)((TypeUtil.convertHexDigit(raw[++i])<<4) + TypeUtil.convertHexDigit(raw[++i])));
|
||||
break;
|
||||
default:
|
||||
buffer.append(b);
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch(NotUtf8Exception e)
|
||||
{
|
||||
LOG.warn(e.toString());
|
||||
LOG.debug(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -159,6 +159,7 @@ public abstract class Utf8Appendable
|
|||
}
|
||||
else if (_state == UTF8_REJECT)
|
||||
{
|
||||
_codep=0;
|
||||
_state = UTF8_ACCEPT;
|
||||
_appendable.append(REPLACEMENT);
|
||||
throw new NotUtf8Exception();
|
||||
|
|
|
@ -80,12 +80,11 @@ public class Log
|
|||
__log.debug("Logging to {} via {}", __log, log_class.getName());
|
||||
}
|
||||
}
|
||||
catch(NoClassDefFoundError e)
|
||||
{
|
||||
initStandardLogging(e);
|
||||
}
|
||||
catch(Exception e)
|
||||
catch(Throwable e)
|
||||
{
|
||||
if (e instanceof ThreadDeath)
|
||||
throw (ThreadDeath)e;
|
||||
|
||||
initStandardLogging(e);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue