当前位置: 首页>>代码示例>>Java>>正文


Java SecureProtocolSocketFactory类代码示例

本文整理汇总了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());
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:26,代码来源:HttpClientTransmitterImplTest.java

示例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;
}
 
开发者ID:xushjie1987,项目名称:es-hadoop-v2.2.0,代码行数:23,代码来源:CommonsHttpTransport.java

示例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;
}
 
开发者ID:elastic,项目名称:elasticsearch-hadoop,代码行数:23,代码来源:CommonsHttpTransport.java

示例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;
}
 
开发者ID:jenkinsci,项目名称:lib-commons-httpclient,代码行数:53,代码来源:HttpConnection.java

示例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;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:9,代码来源:HttpClientBuilder.java

示例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;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:9,代码来源:HttpClientBuilder.java


注:本文中的org.apache.commons.httpclient.protocol.SecureProtocolSocketFactory类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。