- // Create all-trusting host name verifier
- hostnameVerifier = new HostnameVerifier() {
- @Override
- public boolean verify(String hostname, SSLSession session) {
- return true;
- }
- };
- // Create a trust manager that does not validate certificate chains
- trustAll = new TrustManager[] {new X509TrustManager() {
- @Override
- public X509Certificate[] getAcceptedIssuers() {
- return null; // Not relevant.
- }
-
- @Override
- public void checkClientTrusted(X509Certificate[] certs, String authType) {
- // Do nothing. Just allow them all.
- }
-
- @Override
- public void checkServerTrusted(X509Certificate[] certs, String authType) {
- // Do nothing. Just allow them all.
- }
- }};
- }
-
- public static synchronized JenkinsExecutorClient getInstance(@Nonnull String newUser, @Nonnull String newPassword,
- @Nonnull String newBaseurl) throws MalformedURLException {
- new URL(newBaseurl);
- for (JenkinsExecutorClient client : JENKINS_CLIENTS) {
- if (client.getBaseUrl().equals(newBaseurl) && client.getUser().equals(newUser)
- && client.getPassword().equals(newPassword)) {
- return client;
- }
- }
- JenkinsExecutorClient client = new JenkinsExecutorClient(newUser, newPassword, newBaseurl);
- JENKINS_CLIENTS.add(client);
- return client;