org.apache.commons.httpclient.HttpClientError Java Examples

The following examples show how to use org.apache.commons.httpclient.HttpClientError. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DigestScheme.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Creates a random cnonce value based on the current time.
 * 
 * @return The cnonce value as String.
 * @throws HttpClientError if MD5 algorithm is not supported.
 */
public static String createCnonce() {
    LOG.trace("enter DigestScheme.createCnonce()");

    String cnonce;
    final String digAlg = "MD5";
    MessageDigest md5Helper;

    try {
        md5Helper = MessageDigest.getInstance(digAlg);
    } catch (NoSuchAlgorithmException e) {
        throw new HttpClientError(
          "Unsupported algorithm in HTTP Digest authentication: "
           + digAlg);
    }

    cnonce = Long.toString(System.currentTimeMillis());
    cnonce = encode(md5Helper.digest(EncodingUtil.getAsciiBytes(cnonce)));

    return cnonce;
}
 
Example #2
Source File: EasyCASSLProtocolSocketFactory.java    From oxTrust with MIT License 6 votes vote down vote up
protected SSLContext createEasySSLContext(AppConfiguration appConfiguration) {
	try {

		String password = appConfiguration.getCaCertsPassphrase();
		char[] passphrase = null;
		if (password != null) {
			passphrase = encryptionService.decrypt(password).toCharArray();
		}
		KeyStore cacerts = null;
		String cacertsFN = appConfiguration.getCaCertsLocation();
		if (cacertsFN != null) {
			cacerts = KeyStore.getInstance(KeyStore.getDefaultType());
			FileInputStream cacertsFile = new FileInputStream(cacertsFN);
			cacerts.load(cacertsFile, passphrase);
			cacertsFile.close();
		}

		SSLContext context = SSLContext.getInstance("SSL");
		context.init(null, new TrustManager[] { new EasyX509TrustManager(cacerts) }, null);
		return context;
	} catch (Exception e) {
		log.error(e.getMessage(), e);
		throw new HttpClientError(e.toString());
	}
}
 
Example #3
Source File: EasySSLProtocolSocketFactory.java    From flex-blazeds with Apache License 2.0 6 votes vote down vote up
private static SSLContext createEasySSLContext()
{
    try
    {
        SSLContext context = SSLContext.getInstance("SSL");
        context.init(null,
                new TrustManager[]{new EasyX509TrustManager(null)},
                null);
        return context;
    }
    catch (Exception e)
    {
        if (Trace.ssl)
        {
            Trace.trace(e.getMessage());
        }
        throw new HttpClientError(e.toString());
    }
}
 
Example #4
Source File: EasySSLProtocolSocketFactory.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
private static SSLContext createEasySSLContext() {
    try {
        SSLContext context = SSLContext.getInstance("SSL");
        context.init(
          null, 
          new TrustManager[] {new EasyX509TrustManager(null)}, 
          null);
        return context;
    } catch (Exception e) {
        log.error(e.getMessage(), e);
        throw new HttpClientError(e.toString());
    }
}
 
Example #5
Source File: EasySSLProtocolSocketFactory.java    From Spark with Apache License 2.0 5 votes vote down vote up
private static SSLContext createEasySSLContext() {
    try {
        SSLContext context = SSLContext.getInstance("SSL");
        context.init(
                null,
                new TrustManager[]{new EasyX509TrustManager(null)},
                null);
        return context;
    }
    catch (Exception e) {
        LOG.error(e.getMessage(), e);
        throw new HttpClientError(e.toString());
    }
}
 
Example #6
Source File: EasySSLProtocolSocketFactory.java    From cloudstack with Apache License 2.0 5 votes vote down vote up
private static SSLContext createEasySSLContext() {
    try {
        SSLContext context = SSLUtils.getSSLContext();
        context.init(null, new TrustManager[] {new EasyX509TrustManager(null)}, null);
        return context;
    } catch (Exception e) {
        LOG.error(e.getMessage(), e);
        throw new HttpClientError(e.toString());
    }
}
 
Example #7
Source File: DummySSLProtocolSocketFactory.java    From nutch-htmlunit with Apache License 2.0 5 votes vote down vote up
private static SSLContext createEasySSLContext() {
  try {
    SSLContext context = SSLContext.getInstance("SSL");
    context.init(null, new TrustManager[] { new DummyX509TrustManager(null) }, null);
    return context;
  } catch (Exception e) {
    if (LOG.isErrorEnabled()) { LOG.error(e.getMessage(), e); }
    throw new HttpClientError(e.toString());
  }
}
 
Example #8
Source File: EasySSLProtocolSocketFactory.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
private static SSLContext createEasySSLContext() {
    try {
        SSLContext context = SSLContext.getInstance("SSL");
        context.init(
          null, 
          new TrustManager[] {new EasyX509TrustManager(null)}, 
          null);
        return context;
    } catch (Exception e) {
        log.error(e.getMessage(), e);
        throw new HttpClientError(e.toString());
    }
}
 
Example #9
Source File: DefaultSslProtocolSocketFactory.java    From Kylin with Apache License 2.0 5 votes vote down vote up
private static SSLContext createEasySSLContext() {
    try {
        SSLContext context = SSLContext.getInstance("TLS");
        context.init(null, new TrustManager[] { new DefaultX509TrustManager(null) }, null);

        return context;
    } catch (Exception e) {
        LOG.error(e.getMessage(), e);
        throw new HttpClientError(e.toString());
    }
}
 
Example #10
Source File: DefaultSslProtocolSocketFactory.java    From Kylin with Apache License 2.0 5 votes vote down vote up
private static SSLContext createEasySSLContext() {
    try {
        SSLContext context = SSLContext.getInstance("TLS");
        context.init(null, new TrustManager[] { new DefaultX509TrustManager(null) }, null);

        return context;
    } catch (Exception e) {
        LOG.error(e.getMessage(), e);
        throw new HttpClientError(e.toString());
    }
}
 
Example #11
Source File: EasySSLProtocolSocketFactory.java    From olat with Apache License 2.0 5 votes vote down vote up
private static SSLContext createEasySSLContext() {
    try {
        SSLContext context = SSLContext.getInstance("SSL");
        context.init(null, new TrustManager[] { new EasyX509TrustManager(null) }, null);
        return context;
    } catch (Exception e) {
        LOG.error(e.getMessage(), e);
        throw new HttpClientError(e.toString());
    }
}
 
Example #12
Source File: EasySSLProtocolSocketFactory.java    From olat with Apache License 2.0 5 votes vote down vote up
private static SSLContext createEasySSLContext() {
    try {
        SSLContext context = SSLContext.getInstance("SSL");
        context.init(null, new TrustManager[] { new EasyX509TrustManager(null) }, null);
        return context;
    } catch (Exception e) {
        LOG.error(e.getMessage(), e);
        throw new HttpClientError(e.toString());
    }
}
 
Example #13
Source File: DefaultSslProtocolSocketFactory.java    From kylin with Apache License 2.0 5 votes vote down vote up
private static SSLContext createEasySSLContext() {
    try {
        SSLContext context = SSLContext.getInstance("TLSv1.3");
        context.init(null, new TrustManager[] { new DefaultX509TrustManager(null) }, null);

        return context;
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
        throw new HttpClientError(e.toString());
    }
}
 
Example #14
Source File: EasySSLProtocolSocketFactory.java    From openemm with GNU Affero General Public License v3.0 5 votes vote down vote up
private static SSLContext createEasySSLContext() {
	try {
		SSLContext context = SSLContext.getInstance("SSL");
		context.init(null, new TrustManager[] { new EasyX509TrustManager(
				null) }, null);
		return context;
	} catch (Exception e) {
		logger.error(e.getMessage(), e);
		throw new HttpClientError(e.toString());
	}
}
 
Example #15
Source File: DummySSLProtocolSocketFactory.java    From anthelion with Apache License 2.0 5 votes vote down vote up
private static SSLContext createEasySSLContext() {
  try {
    SSLContext context = SSLContext.getInstance("SSL");
    context.init(null, new TrustManager[] { new DummyX509TrustManager(null) }, null);
    return context;
  } catch (Exception e) {
    if (LOG.isErrorEnabled()) { LOG.error(e.getMessage(), e); }
    throw new HttpClientError(e.toString());
  }
}
 
Example #16
Source File: EasySSLProtocolSocketFactory.java    From zap-extensions with Apache License 2.0 5 votes vote down vote up
private static SSLContext createEasySSLContext() {
    try {
        SSLContext context = SSLContext.getInstance("SSL");
        context.init(null, new TrustManager[] {new EasyX509TrustManager(null)}, null);
        return context;
    } catch (Exception e) {
        // LOG.error(e.getMessage(), e);
        throw new HttpClientError(e.toString());
    }
}
 
Example #17
Source File: EncodingUtil.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Converts the byte array of ASCII characters to a string. This method is
 * to be used when decoding content of HTTP elements (such as response
 * headers)
 *
 * @param data the byte array to be encoded
 * @param offset the index of the first byte to encode
 * @param length the number of bytes to encode 
 * @return The string representation of the byte array
 * 
 * @since 3.0
 */
public static String getAsciiString(final byte[] data, int offset, int length) {

    if (data == null) {
        throw new IllegalArgumentException("Parameter may not be null");
    }

    try {
        return new String(data, offset, length, "US-ASCII");
    } catch (UnsupportedEncodingException e) {
        throw new HttpClientError("HttpClient requires ASCII support");
    }
}
 
Example #18
Source File: EncodingUtil.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Converts the specified string to byte array of ASCII characters.
 *
 * @param data the string to be encoded
 * @return The string as a byte array.
 * 
 * @since 3.0
 */
public static byte[] getAsciiBytes(final String data) {

    if (data == null) {
        throw new IllegalArgumentException("Parameter may not be null");
    }

    try {
        return data.getBytes("US-ASCII");
    } catch (UnsupportedEncodingException e) {
        throw new HttpClientError("HttpClient requires ASCII support");
    }
}
 
Example #19
Source File: EasySSLProtocolSocketFactory.java    From http4e with Apache License 2.0 5 votes vote down vote up
private static SSLContext createEasySSLContext() {
    try {
        SSLContext context = SSLContext.getInstance("SSL");
        context.init(
          null, 
          new TrustManager[] {new EasyX509TrustManager(null)}, 
          null);
        return context;
    } catch (Exception e) {
        LOG.error(e.getMessage(), e);
        throw new HttpClientError(e.toString());
    }
}
 
Example #20
Source File: GetSSLCert.java    From MyVirtualDirectory with Apache License 2.0 5 votes vote down vote up
private static SSLContext createEasySSLContext() {
    try {
        SSLContext context = SSLContext.getInstance("SSL");
        context.init(
          null, 
          new TrustManager[] {new EasyX509TrustManager(null)}, 
          null);
        return context;
    } catch (Exception e) {
        LOG.error(e.getMessage(), e);
        throw new HttpClientError(e.toString());
    }
}
 
Example #21
Source File: EasySSLProtocolSocketFactory.java    From freeacs with MIT License 5 votes vote down vote up
/**
 * Creates a new EasySSLProtocolSocket object.
 *
 * @return the SSL context
 */
private static SSLContext createEasySSLContext() {
  try {
    SSLContext context = SSLContext.getInstance("SSL");
    context.init(null, new TrustManager[] {new EasyX509TrustManager(null)}, null);
    return context;
  } catch (Exception e) {
    throw new HttpClientError(e.toString());
  }
}
 
Example #22
Source File: DefaultSslProtocolSocketFactory.java    From kylin-on-parquet-v2 with Apache License 2.0 5 votes vote down vote up
private static SSLContext createEasySSLContext() {
    try {
        SSLContext context = SSLContext.getInstance("TLS");
        context.init(null, new TrustManager[] { new DefaultX509TrustManager(null) }, null);

        return context;
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
        throw new HttpClientError(e.toString());
    }
}
 
Example #23
Source File: EncodingUtil.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 3 votes vote down vote up
/**
 * Form-urlencoding routine.
 *
 * The default encoding for all forms is `application/x-www-form-urlencoded'. 
 * A form data set is represented in this media type as follows:
 *
 * The form field names and values are escaped: space characters are replaced 
 * by `+', and then reserved characters are escaped as per [URL]; that is, 
 * non-alphanumeric characters are replaced by `%HH', a percent sign and two 
 * hexadecimal digits representing the ASCII code of the character. Line breaks, 
 * as in multi-line text field values, are represented as CR LF pairs, i.e. `%0D%0A'.
 * 
 * <p>
 * if the given charset is not supported, ISO-8859-1 is used instead.
 * </p>
 * 
 * @param pairs the values to be encoded
 * @param charset the character set of pairs to be encoded
 * 
 * @return the urlencoded pairs
 * 
 * @since 2.0 final
 */
 public static String formUrlEncode(NameValuePair[] pairs, String charset) {
    try {
        return doFormUrlEncode(pairs, charset);
    } catch (UnsupportedEncodingException e) {
        LOG.error("Encoding not supported: " + charset);
        try {
            return doFormUrlEncode(pairs, DEFAULT_CHARSET);
        } catch (UnsupportedEncodingException fatal) {
            // Should never happen. ISO-8859-1 must be supported on all JVMs
            throw new HttpClientError("Encoding not supported: " + 
                DEFAULT_CHARSET);
        }
    }
}