本文整理匯總了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;
}