Package org.apache.commons.httpclient.protocol

Examples of org.apache.commons.httpclient.protocol.Protocol


     */
    public static void setup(){
        final String LOOPBACK = "loopback"; // $NON-NLS-1$

        // This ensures tha HttpClient knows about the protocol
        Protocol.registerProtocol(LOOPBACK, new Protocol(LOOPBACK,new LoopbackHttpClientSocketFactory(),1));

        // Now allow the URL handling to work.
        URLStreamHandlerFactory ushf = new URLStreamHandlerFactory(){
            @Override
            public URLStreamHandler createURLStreamHandler(String protocol) {
View Full Code Here


        _client = createHttpClient();
        _client.getParams().setCookiePolicy(CookiePolicy.BROWSER_COMPATIBILITY);
       
        try {            
            // Cast to ProtocolSocketFactory to avoid the deprecated constructor with the SecureProtocolSocketFactory parameter
            Protocol.registerProtocol("https", new Protocol("https", (ProtocolSocketFactory) new TrustingProtocolSocketFactory(), 443));
        } catch (IOException e) {
            s_logger.warn("Failed to register the TrustingProtocolSocketFactory, falling back to default SSLSocketFactory", e);
        }
       
        _gson = new GsonBuilder()
View Full Code Here

    private static Protocol untrustSSL;

    private SSLSocketFactory factory;

    private static boolean isRegistered() {
        Protocol https = Protocol.getProtocol("https");
        boolean isRegistered = https.getSocketFactory() instanceof UntrustedSSLProtocolSocketFactory;

        if (!isRegistered) {
            defaultSSL = https;
        }
View Full Code Here

    public static void register() {
        // make sure to accept self-signed certs

        if (!isRegistered()) {
            if (untrustSSL == null) {
                untrustSSL = new Protocol("https", (ProtocolSocketFactory) new UntrustedSSLProtocolSocketFactory(), 443);
            }

            Protocol.registerProtocol("https", untrustSSL);
        }
    }
View Full Code Here

        } else {
            socketFactory =
                    new ProtocolSocketChannelFactory(connectionTimeout);
        }

        protocol = new Protocol(protocol.getScheme(),
                socketFactory, protocol.getDefaultPort());
       
        return protocol;
    }
View Full Code Here

        HostConfiguration configuration = method.getHostConfiguration();
        if (configuration == null) {
            throw new IllegalStateException("No configuration set on method");
        }

        Protocol originalProtocol = configuration.getProtocol();
        Protocol protocol = updateProtocol(originalProtocol);
        if (protocol != originalProtocol) {
            configuration.setHost(configuration.getHost(),
                    configuration.getVirtualHost(),
                    configuration.getPort(),
                    protocol);
View Full Code Here

        final String path = method.getPath();
        final HostConfiguration hostDetails = method.getHostConfiguration();
        final String host = hostDetails.getHost();
        final int port = hostDetails.getPort();
        final Protocol protocol = hostDetails.getProtocol();
        final boolean isSecure = protocol.isSecure();
        return COOKIE_SPEC.parse(host, port, path, isSecure, header);
    }
View Full Code Here

      if (keystoreData != null)
      {
        IKeystoreManager keystoreManager = KeystoreManagerFactory.make("",keystoreData);
        MeridioSecureSocketFactory secureSocketFactory = new MeridioSecureSocketFactory(keystoreManager.getSecureSocketFactory());
        Protocol myHttpsProtocol = new Protocol("https", (ProtocolSocketFactory)secureSocketFactory, 443);
        myFactory.registerProtocol("https",myHttpsProtocol);
      }

      try
      {
View Full Code Here

   * @return
   */
  public Protocol customizeProtocolWithNotyetCommons(int portNumber)
      throws GeneralSecurityException
  {
    Protocol ssafProtocol = null;
    try
    {
      HttpSecureProtocol httpSecureProtocol = new HttpSecureProtocol();
      // setup keyStore
      File keystore = new File(keyStoreFilePath);
      char[] keyStorePasswordInCharArray = keyStorePassword.toCharArray();
     
      KeyMaterial keyMaterial = new KeyMaterial(keystore,
          keyStorePasswordInCharArray);
     
      // setup trustStore
      File TrustMaterial = new File(trustStoreFilePath);
      char[] trustStorePasswordPasswordInCharArray = trustStorePassword
          .toCharArray();
     
      TrustMaterial trustMaterial = new TrustMaterial(TrustMaterial,
          trustStorePasswordPasswordInCharArray);

      httpSecureProtocol.setKeyMaterial(keyMaterial);
      httpSecureProtocol.setTrustMaterial(trustMaterial);
      httpSecureProtocol.setCheckCRL(true);
      httpSecureProtocol.setCheckExpiry(true);
      httpSecureProtocol.setCheckHostname(true);

      ssafProtocol = new Protocol("https",
          (ProtocolSocketFactory) httpSecureProtocol, portNumber);
    }
    catch (GeneralSecurityException e1)
    {
      log
View Full Code Here

              .createElement("relativePath");
          webServiceRelativePathElement.setTextContent(relativeURL);
          Element webServiceStatusCodeElement = doc
              .createElement("statusCode");

          Protocol ssafProtocol = null;
          try
          {
            ssafProtocol = customizeProtocolWithNotyetCommons(Integer
                .parseInt(portNumber));
          }
View Full Code Here

TOP

Related Classes of org.apache.commons.httpclient.protocol.Protocol

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.