本文整理汇总了Java中org.apache.commons.httpclient.protocol.SecureProtocolSocketFactory类的典型用法代码示例。如果您正苦于以下问题:Java SecureProtocolSocketFactory类的具体用法?Java SecureProtocolSocketFactory怎么用?Java SecureProtocolSocketFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SecureProtocolSocketFactory类属于org.apache.commons.httpclient.protocol包,在下文中一共展示了SecureProtocolSocketFactory类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testSuccessfulVerifyTargetOverHttps
import org.apache.commons.httpclient.protocol.SecureProtocolSocketFactory; //导入依赖的package包/类
public void testSuccessfulVerifyTargetOverHttps() throws Exception
{
//Stub HttpClient so that executeMethod returns a 200 response
when(mockedHttpClient.executeMethod(any(HostConfiguration.class), any(HttpMethod.class),
any(HttpState.class))).thenReturn(200);
target.setEndpointProtocol(HTTPS_PROTOCOL);
target.setEndpointPort(HTTPS_PORT);
//Call verifyTarget
transmitter.verifyTarget(target);
ArgumentCaptor<HostConfiguration> hostConfig = ArgumentCaptor.forClass(HostConfiguration.class);
ArgumentCaptor<HttpMethod> httpMethod = ArgumentCaptor.forClass(HttpMethod.class);
ArgumentCaptor<HttpState> httpState = ArgumentCaptor.forClass(HttpState.class);
verify(mockedHttpClient).executeMethod(hostConfig.capture(), httpMethod.capture(), httpState.capture());
assertEquals("port", HTTPS_PORT, hostConfig.getValue().getPort());
assertTrue("socket factory",
hostConfig.getValue().getProtocol().getSocketFactory() instanceof SecureProtocolSocketFactory);
assertEquals("protocol", HTTPS_PROTOCOL.toLowerCase(),
hostConfig.getValue().getProtocol().getScheme().toLowerCase());
}
示例2: setupSSLIfNeeded
import org.apache.commons.httpclient.protocol.SecureProtocolSocketFactory; //导入依赖的package包/类
private HostConfiguration setupSSLIfNeeded(Settings settings, HostConfiguration hostConfig) {
if (!sslEnabled) {
return hostConfig;
}
// we actually have a socks proxy, let's start the setup
if (log.isDebugEnabled()) {
log.debug("SSL Connection enabled");
}
//
// switch protocol
// due to how HttpCommons work internally this dance is best to be kept as is
//
String schema = "https";
int port = 443;
SecureProtocolSocketFactory sslFactory = new SSLSocketFactory(settings);
replaceProtocol(hostConfig, sslFactory, schema, port);
return hostConfig;
}
示例3: setupSSLIfNeeded
import org.apache.commons.httpclient.protocol.SecureProtocolSocketFactory; //导入依赖的package包/类
private HostConfiguration setupSSLIfNeeded(Settings settings, HostConfiguration hostConfig) {
if (!sslEnabled) {
return hostConfig;
}
// we actually have a socks proxy, let's start the setup
if (log.isDebugEnabled()) {
log.debug("SSL Connection enabled");
}
//
// switch protocol
// due to how HttpCommons work internally this dance is best to be kept as is
//
String schema = "https";
int port = 443;
SecureProtocolSocketFactory sslFactory = new SSLSocketFactory(settings);
replaceProtocol(sslFactory, schema, port);
return hostConfig;
}
示例4: tunnelCreated
import org.apache.commons.httpclient.protocol.SecureProtocolSocketFactory; //导入依赖的package包/类
/**
* Instructs the proxy to establish a secure tunnel to the host. The socket will
* be switched to the secure socket. Subsequent communication is done via the secure
* socket. The method can only be called once on a proxied secure connection.
*
* @throws IllegalStateException if connection is not secure and proxied or
* if the socket is already secure.
* @throws IOException if an attempt to establish the secure tunnel results in an
* I/O error.
*/
public void tunnelCreated() throws IllegalStateException, IOException {
LOG.trace("enter HttpConnection.tunnelCreated()");
if (!isSecure() || !isProxied()) {
throw new IllegalStateException(
"Connection must be secure "
+ "and proxied to use this feature");
}
if (usingSecureSocket) {
throw new IllegalStateException("Already using a secure socket");
}
if (LOG.isDebugEnabled()) {
LOG.debug("Secure tunnel to " + this.hostName + ":" + this.portNumber);
}
SecureProtocolSocketFactory socketFactory =
(SecureProtocolSocketFactory) protocolInUse.getSocketFactory();
socket = socketFactory.createSocket(socket, hostName, portNumber, true);
int sndBufSize = this.params.getSendBufferSize();
if (sndBufSize >= 0) {
socket.setSendBufferSize(sndBufSize);
}
int rcvBufSize = this.params.getReceiveBufferSize();
if (rcvBufSize >= 0) {
socket.setReceiveBufferSize(rcvBufSize);
}
int outbuffersize = socket.getSendBufferSize();
if (outbuffersize > 2048) {
outbuffersize = 2048;
}
int inbuffersize = socket.getReceiveBufferSize();
if (inbuffersize > 2048) {
inbuffersize = 2048;
}
inputStream = new BufferedInputStream(socket.getInputStream(), inbuffersize);
outputStream = new BufferedOutputStream(socket.getOutputStream(), outbuffersize);
usingSecureSocket = true;
tunnelEstablished = true;
}
示例5: getHttpsProtocolSocketFactory
import org.apache.commons.httpclient.protocol.SecureProtocolSocketFactory; //导入依赖的package包/类
/**
* Gets the protocol socket factory used for the https scheme.
*
* @return protocol socket factory used for the https scheme
*/
public SecureProtocolSocketFactory getHttpsProtocolSocketFactory() {
return httpsProtocolSocketFactory;
}
示例6: setHttpsProtocolSocketFactory
import org.apache.commons.httpclient.protocol.SecureProtocolSocketFactory; //导入依赖的package包/类
/**
* Sets the protocol socket factory used for the https scheme.
*
* @param factory the httpsProtocolSocketFactory to set
*/
public void setHttpsProtocolSocketFactory(SecureProtocolSocketFactory factory) {
httpsProtocolSocketFactory = factory;
}