diff --git a/Jenkinsfile b/Jenkinsfile index 31dacad..79764a9 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,6 +1,6 @@ buildPlugin( useContainerAgent: true, // Set to `false` if you need to use Docker for containerized tests configurations: [ - [platform: 'linux', jdk: 11], + [platform: 'linux', jdk: 17], [platform: 'windows', jdk: 11], ]) \ No newline at end of file diff --git a/aqconnect.iml b/aqconnect.iml index 5ef37ef..f0b4b5c 100644 --- a/aqconnect.iml +++ b/aqconnect.iml @@ -30,7 +30,7 @@ - + diff --git a/core/.classpath b/core/.classpath deleted file mode 100644 index 71f5fef..0000000 --- a/core/.classpath +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/core/.project b/core/.project deleted file mode 100644 index b0930c9..0000000 --- a/core/.project +++ /dev/null @@ -1,34 +0,0 @@ - - - core - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.m2e.core.maven2Builder - - - - - - org.eclipse.jdt.core.javanature - org.eclipse.m2e.core.maven2Nature - - - - 1604395699486 - - 30 - - org.eclipse.core.resources.regexFilterMatcher - node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__ - - - - diff --git a/core/pom.xml b/core/pom.xml deleted file mode 100644 index fd48c90..0000000 --- a/core/pom.xml +++ /dev/null @@ -1,98 +0,0 @@ - - - - 4.0.0 - - aqPluginCore - core - - ${revision}${changelist} - - - core - - http://www.example.com - - - UTF-8 - 1.7 - 1.7 - 1.0 - -SNAPSHOT - - - - - junit - junit - [4.13.1,) - test - - - - commons-codec - commons-codec - 1.10 - - - - org.apache.httpcomponents - httpclient - 4.5.13 - - - - com.googlecode.json-simple - json-simple - 1.1 - - - - - - - - - - maven-clean-plugin - 3.1.0 - - - - maven-resources-plugin - 3.0.2 - - - maven-compiler-plugin - 3.8.0 - - - maven-surefire-plugin - 2.22.1 - - - maven-jar-plugin - 3.0.2 - - - maven-install-plugin - 2.5.2 - - - maven-deploy-plugin - 2.8.2 - - - - maven-site-plugin - 3.7.1 - - - maven-project-info-reports-plugin - 3.0.0 - - - - - diff --git a/core/target/classes/aqPluginCore/AQConstants$TEST_CASE_STATUS.class b/core/target/classes/aqPluginCore/AQConstants$TEST_CASE_STATUS.class deleted file mode 100644 index bfa0713..0000000 Binary files a/core/target/classes/aqPluginCore/AQConstants$TEST_CASE_STATUS.class and /dev/null differ diff --git a/core/target/classes/aqPluginCore/AQConstants$TEST_JOB_STATUS.class b/core/target/classes/aqPluginCore/AQConstants$TEST_JOB_STATUS.class deleted file mode 100644 index d6b0449..0000000 Binary files a/core/target/classes/aqPluginCore/AQConstants$TEST_JOB_STATUS.class and /dev/null differ diff --git a/core/target/classes/aqPluginCore/AQConstants.class b/core/target/classes/aqPluginCore/AQConstants.class deleted file mode 100644 index 240a791..0000000 Binary files a/core/target/classes/aqPluginCore/AQConstants.class and /dev/null differ diff --git a/core/target/classes/aqPluginCore/AQException.class b/core/target/classes/aqPluginCore/AQException.class deleted file mode 100644 index 21a670f..0000000 Binary files a/core/target/classes/aqPluginCore/AQException.class and /dev/null differ diff --git a/core/target/classes/aqPluginCore/AQFormValidate.class b/core/target/classes/aqPluginCore/AQFormValidate.class deleted file mode 100644 index 17997e2..0000000 Binary files a/core/target/classes/aqPluginCore/AQFormValidate.class and /dev/null differ diff --git a/core/target/classes/aqPluginCore/AQRestClient$1.class b/core/target/classes/aqPluginCore/AQRestClient$1.class deleted file mode 100644 index d2ffd2c..0000000 Binary files a/core/target/classes/aqPluginCore/AQRestClient$1.class and /dev/null differ diff --git a/core/target/classes/aqPluginCore/AQRestClient.class b/core/target/classes/aqPluginCore/AQRestClient.class deleted file mode 100644 index 8ee5e4c..0000000 Binary files a/core/target/classes/aqPluginCore/AQRestClient.class and /dev/null differ diff --git a/core/target/classes/aqPluginCore/AQUtils.class b/core/target/classes/aqPluginCore/AQUtils.class deleted file mode 100644 index 4bf6c42..0000000 Binary files a/core/target/classes/aqPluginCore/AQUtils.class and /dev/null differ diff --git a/core/target/core-1.0-SNAPSHOT.jar b/core/target/core-1.0-SNAPSHOT.jar deleted file mode 100644 index 9acfb88..0000000 Binary files a/core/target/core-1.0-SNAPSHOT.jar and /dev/null differ diff --git a/core/target/maven-archiver/pom.properties b/core/target/maven-archiver/pom.properties deleted file mode 100644 index 51ea211..0000000 --- a/core/target/maven-archiver/pom.properties +++ /dev/null @@ -1,4 +0,0 @@ -#Created by Apache Maven 3.6.3 -groupId=aqPluginCore -artifactId=core -version=1.0-SNAPSHOT diff --git a/pom.xml b/pom.xml index e1c10ef..1393c2b 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.jenkins-ci.plugins plugin - 4.16 + 4.72 com.aq @@ -17,9 +17,9 @@ -SNAPSHOT jenkinsci/accelq-ci-connect-plugin jenkinsci/${project.artifactId}-plugin - 2.222.3 - 8 - 2.71 + 2.401.3 + 11 + hpi @@ -75,12 +75,5 @@ json-simple [1.1.1,) - - core - aqCore - 1.0 - system - ${project.basedir}/src/lib/core-1.0-SNAPSHOT.jar - diff --git a/src/lib/core-1.0-SNAPSHOT.jar b/src/lib/core-1.0-SNAPSHOT.jar deleted file mode 100644 index 9acfb88..0000000 Binary files a/src/lib/core-1.0-SNAPSHOT.jar and /dev/null differ diff --git a/core/src/main/java/aqPluginCore/AQConstants.java b/src/main/java/com/aq/aqconnect/AQConstants.java similarity index 98% rename from core/src/main/java/aqPluginCore/AQConstants.java rename to src/main/java/com/aq/aqconnect/AQConstants.java index 9dc6724..deebcc3 100644 --- a/core/src/main/java/aqPluginCore/AQConstants.java +++ b/src/main/java/com/aq/aqconnect/AQConstants.java @@ -1,4 +1,4 @@ -package aqPluginCore; +package com.aq.aqconnect; public class AQConstants { public static final String LOG_DELIMITER = ">>> "; diff --git a/core/src/main/java/aqPluginCore/AQException.java b/src/main/java/com/aq/aqconnect/AQException.java similarity index 86% rename from core/src/main/java/aqPluginCore/AQException.java rename to src/main/java/com/aq/aqconnect/AQException.java index 15393fb..9e27385 100644 --- a/core/src/main/java/aqPluginCore/AQException.java +++ b/src/main/java/com/aq/aqconnect/AQException.java @@ -1,4 +1,5 @@ -package aqPluginCore; +package com.aq.aqconnect; + public class AQException extends RuntimeException{ diff --git a/core/src/main/java/aqPluginCore/AQFormValidate.java b/src/main/java/com/aq/aqconnect/AQFormValidate.java similarity index 85% rename from core/src/main/java/aqPluginCore/AQFormValidate.java rename to src/main/java/com/aq/aqconnect/AQFormValidate.java index e445891..86eedee 100644 --- a/core/src/main/java/aqPluginCore/AQFormValidate.java +++ b/src/main/java/com/aq/aqconnect/AQFormValidate.java @@ -1,4 +1,5 @@ -package aqPluginCore; +package com.aq.aqconnect; + import java.net.URL; import java.util.regex.Pattern; @@ -44,7 +45,8 @@ public String validateAPIKey(String value) { } public String validateUserId(String value) { try { - String emailRegex = "^(([^<>()[\\]\\\\.,;:\\s@\\\"]+(\\.[^<>()[\\]\\\\.,;:\\s@\\\"]+)*)|(\\\".+\\\"))@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\])|(([a-zA-Z\\-0-9]+\\.)+[a-zA-Z]{2,}))$"; + String emailRegex = "^(?=.{1,64}@)[A-Za-z0-9_-]+(\\.[A-Za-z0-9_-]+)*@" + + "[^-][A-Za-z0-9-]+(\\.[A-Za-z0-9-]+)*(\\.[A-Za-z]{2,})$"; Pattern pat = Pattern.compile(emailRegex); if (value == null || value.length() == 0) return "Cannot be empty"; else if (!pat.matcher(value).matches()) return "User ID must be in email format"; diff --git a/src/main/java/com/aq/aqconnect/AQPluginBuilderAction.java b/src/main/java/com/aq/aqconnect/AQPluginBuilderAction.java index 32c9571..11ac418 100644 --- a/src/main/java/com/aq/aqconnect/AQPluginBuilderAction.java +++ b/src/main/java/com/aq/aqconnect/AQPluginBuilderAction.java @@ -20,7 +20,6 @@ import javax.servlet.ServletException; import java.io.IOException; import java.io.PrintStream; -import aqPluginCore.*; import org.kohsuke.stapler.QueryParameter; import org.kohsuke.stapler.verb.POST; import org.json.simple.parser.ParseException; @@ -105,7 +104,7 @@ public void perform(@Nonnull Run run, @Nonnull FilePath workspace, @Nonnul JSONObject summaryObj = null; long realJobPid = 0; try { - aqRestClient = AQRestClient.getInstance(); + aqRestClient = new AQRestClient(); AQUtils aqUtils = new AQUtils(); aqRestClient.setUpBaseURL(this.appURL, this.tenantCode); aqRestClient.disableSSLChecks(this.disableSSLCheck); @@ -300,7 +299,7 @@ public FormValidation doTestConnection(@QueryParameter("appURL") final String ap // make call to backend to validate it AQRestClient aqRestClient = null; AQUtils aqUtils = new AQUtils(); - aqRestClient = AQRestClient.getInstance(); + aqRestClient = new AQRestClient(); String payload = aqUtils.getRunParamJsonPayload(runParamStr); aqRestClient.setUpBaseURL(appURL, tenantCode); aqRestClient.disableSSLChecks(disableSSLCheck); diff --git a/core/src/main/java/aqPluginCore/AQRestClient.java b/src/main/java/com/aq/aqconnect/AQRestClient.java similarity index 90% rename from core/src/main/java/aqPluginCore/AQRestClient.java rename to src/main/java/com/aq/aqconnect/AQRestClient.java index 5bed8a7..17eb546 100644 --- a/core/src/main/java/aqPluginCore/AQRestClient.java +++ b/src/main/java/com/aq/aqconnect/AQRestClient.java @@ -1,4 +1,5 @@ -package aqPluginCore; +package com.aq.aqconnect; + import org.apache.http.HttpHost; import org.apache.http.client.methods.CloseableHttpResponse; @@ -21,27 +22,25 @@ import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; +import java.nio.charset.StandardCharsets; +import java.security.KeyManagementException; +import java.security.KeyStoreException; +import java.security.NoSuchAlgorithmException; import java.security.cert.CertificateException; import java.security.cert.X509Certificate; public class AQRestClient { - private static final AQRestClient aqRESTClient = new AQRestClient(); private final JSONParser jsonParser = new JSONParser(); //Base URL and extensions - private static String BASE_URL; - private static String API_ENDPOINT; - - private static int PROXY_PORT = 80; - private static String PROXY_HOST; - private static Boolean DISABLE_SSL_CHECKS = false; - + private String BASE_URL; + private String API_ENDPOINT; + private int PROXY_PORT = 80; + private String PROXY_HOST; + private Boolean DISABLE_SSL_CHECKS = false; - public static AQRestClient getInstance() { - return aqRESTClient; - } public String getBaseURL() { return BASE_URL; @@ -60,7 +59,7 @@ public void setUpBaseURL(String baseURL, String tenantCode) { API_ENDPOINT = BASE_URL + "awb/api/" + AQConstants.API_VERSION + "/" + tenantCode; } - private CloseableHttpClient getHttpsClient() { + private CloseableHttpClient getHttpsClient(){ try { HttpClientBuilder hcb = null; if (DISABLE_SSL_CHECKS) { @@ -85,7 +84,11 @@ public boolean isTrusted(X509Certificate[] x509Certificates, String s) throws Ce } CloseableHttpClient client = hcb.build(); return client; - } catch(Exception e) { + }catch(NoSuchAlgorithmException e){ + return null; + }catch(KeyStoreException e){ + return null; + }catch(KeyManagementException e){ return null; } } @@ -102,7 +105,7 @@ public JSONObject getJobSummary(long runPid, String apiKey, String userId) { CloseableHttpResponse httpResponse = httpClient.execute(httpGet); BufferedReader reader = new BufferedReader(new InputStreamReader( - httpResponse.getEntity().getContent())); + httpResponse.getEntity().getContent(), StandardCharsets.UTF_8)); String inputLine; StringBuffer response = new StringBuffer(); @@ -134,7 +137,7 @@ public JSONObject triggerJob(String apiKey, String userId, String jobId, String try { CloseableHttpResponse httpResponse = httpClient.execute(httpPut); BufferedReader reader = new BufferedReader(new InputStreamReader( - httpResponse.getEntity().getContent())); + httpResponse.getEntity().getContent(), StandardCharsets.UTF_8)); String inputLine; StringBuffer response = new StringBuffer(); while ((inputLine = reader.readLine()) != null) { diff --git a/core/src/main/java/aqPluginCore/AQUtils.java b/src/main/java/com/aq/aqconnect/AQUtils.java similarity index 99% rename from core/src/main/java/aqPluginCore/AQUtils.java rename to src/main/java/com/aq/aqconnect/AQUtils.java index 07f1b62..d8b272e 100644 --- a/core/src/main/java/aqPluginCore/AQUtils.java +++ b/src/main/java/com/aq/aqconnect/AQUtils.java @@ -1,4 +1,5 @@ -package aqPluginCore; +package com.aq.aqconnect; + import org.apache.http.entity.StringEntity; import org.json.simple.JSONObject; import org.json.simple.parser.JSONParser;