Skip to content

Instantly share code, notes, and snippets.

@mcqueenorama
Created May 25, 2016 16:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mcqueenorama/78ee0bd2cc3d2c993c6ec1585eb30af0 to your computer and use it in GitHub Desktop.
Save mcqueenorama/78ee0bd2cc3d2c993c6ec1585eb30af0 to your computer and use it in GitHub Desktop.
static class QJenkins extends JenkinsHttpClient {
public QJenkins(URI uri, String username, String password) throws KeyManagementException, NoSuchAlgorithmException, KeyStoreException {
super(uri, addAuthentication(HttpClients.custom().setSSLSocketFactory(
new SSLConnectionSocketFactory(
new SSLContextBuilder().loadTrustMaterial(null,
new TrustStrategy() {
@Override
public boolean isTrusted(X509Certificate[] chain, String authType) throws CertificateException {
return true;
}
}).build(),
SSLConnectionSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER)),
uri, username, password));
if (isNotBlank(username)) {
setLocalContext(new BasicHttpContext());
getLocalContext().setAttribute("preemptive-auth", new BasicScheme());
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment