类org.apache.commons.httpclient.HttpClientError源码实例Demo

下面列出了怎么用org.apache.commons.httpclient.HttpClientError的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: knopflerfish.org   文件: DigestScheme.java
/**
 * 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;
}
 
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());
    }
}
 
源代码3 项目: oxTrust   文件: EasyCASSLProtocolSocketFactory.java
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());
	}
}
 
源代码4 项目: openemm   文件: EasySSLProtocolSocketFactory.java
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());
	}
}
 
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());
    }
}
 
源代码6 项目: freeacs   文件: EasySSLProtocolSocketFactory.java
/**
 * 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());
  }
}
 
源代码7 项目: MyVirtualDirectory   文件: GetSSLCert.java
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());
    }
}
 
源代码8 项目: http4e   文件: EasySSLProtocolSocketFactory.java
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());
    }
}
 
源代码9 项目: knopflerfish.org   文件: EncodingUtil.java
/**
 * 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");
    }
}
 
源代码10 项目: knopflerfish.org   文件: EncodingUtil.java
/**
 * 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");
    }
}
 
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());
    }
}
 
源代码12 项目: anthelion   文件: DummySSLProtocolSocketFactory.java
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());
  }
}
 
源代码13 项目: sakai   文件: EasySSLProtocolSocketFactory.java
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());
    }
}
 
源代码14 项目: kylin   文件: DefaultSslProtocolSocketFactory.java
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());
    }
}
 
源代码15 项目: olat   文件: EasySSLProtocolSocketFactory.java
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());
    }
}
 
源代码16 项目: olat   文件: EasySSLProtocolSocketFactory.java
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());
    }
}
 
源代码17 项目: Kylin   文件: DefaultSslProtocolSocketFactory.java
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());
    }
}
 
源代码18 项目: Kylin   文件: DefaultSslProtocolSocketFactory.java
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());
    }
}
 
源代码19 项目: sakai   文件: EasySSLProtocolSocketFactory.java
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());
    }
}
 
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());
  }
}
 
源代码21 项目: cloudstack   文件: EasySSLProtocolSocketFactory.java
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());
    }
}
 
源代码22 项目: Spark   文件: EasySSLProtocolSocketFactory.java
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());
    }
}
 
源代码23 项目: knopflerfish.org   文件: EncodingUtil.java
/**
 * 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);
        }
    }
}
 
 类方法
 同包方法