diff --git a/pom.xml b/pom.xml index 9ea9929..fefc6c2 100644 --- a/pom.xml +++ b/pom.xml @@ -21,7 +21,7 @@ - 3.49.0 + 3.51.0 2.17.1 4.2.2 3.1.2-sb-fixed @@ -58,6 +58,20 @@ + maven-assembly-plugin 2.4 @@ -66,6 +80,15 @@ src/assembly/dist-assembly.xml + + + make-assembly + package + + single + + + @@ -184,7 +207,7 @@ com.atlassian.jira jira-rest-java-client-api - 5.2.4 + 5.2.6 com.google.guava @@ -197,7 +220,7 @@ com.atlassian.jira jira-rest-java-client-core - 5.2.4 + 5.2.6 diff --git a/src/main/java/com/smartbear/ready/plugin/jira/factories/JiraPrefsFactory.java b/src/main/java/com/smartbear/ready/plugin/jira/factories/JiraPrefsFactory.java index 82b2555..c45db46 100644 --- a/src/main/java/com/smartbear/ready/plugin/jira/factories/JiraPrefsFactory.java +++ b/src/main/java/com/smartbear/ready/plugin/jira/factories/JiraPrefsFactory.java @@ -20,13 +20,13 @@ @PluginPrefs public class JiraPrefsFactory implements Prefs { public static final String BUG_TRACKER_LOGIN_LABEL = "Email or username:"; - public static final String BUG_TRACKER_PASSWORD = "API Token or Password:"; - public static final String BUG_TRACKER_LOGIN_DESCRIPTION = "Your JIRA user account"; - public static final String BUG_TRACKER_LOGIN_IN_FIELD_DESCRIPTION = "Your JIRA user account"; - public static final String BUG_TRACKER_PASSWORD_DESCRIPTION = "The password for logging in"; + public static final String BUG_TRACKER_LOGIN_DESCRIPTION = "Your profile's e-mail (JIRA Cloud) or your profile's user name (JIRA Server) or empty when using a Private Access Token (PAT)." ; + public static final String BUG_TRACKER_LOGIN_IN_FIELD_DESCRIPTION = BUG_TRACKER_LOGIN_DESCRIPTION; + public static final String BUG_TRACKER_PASSWORD = "Password or Personal Access Token (PAT):"; + public static final String BUG_TRACKER_PASSWORD_DESCRIPTION = "This your password or a Personal Access Token (PAT)."; public static final String BUG_TRACKER_URL = "JIRA server URL:"; - public static final String BUG_TRACKER_URL_DESCRIPTION = "The URL of your JIRA instance, for instance, https://mycompany.atlassian.net"; - public static final String BUG_TRACKER_URL_IN_FIELD_DESCRIPTION = "The URL of your JIRA instance (https://...)"; + public static final String BUG_TRACKER_URL_IN_FIELD_DESCRIPTION = "The URL of your JIRA instance (without the /rest/api/* part)"; + public static final String BUG_TRACKER_URL_DESCRIPTION = BUG_TRACKER_URL_IN_FIELD_DESCRIPTION + ", for instance, https://mycompany.atlassian.net or https://mycompany.net/jira"; public static final String JIRA_PREFS_TITLE = "JIRA"; public static final String SKIP_RELEASED_VERSIONS = "Hide released versions:"; public static final String SKIP_RELEASED_VERSIONS_DESCRIPTION = "Do not show released versions for \"Fixed Version/s\" field"; diff --git a/src/main/java/com/smartbear/ready/plugin/jira/impl/BearerHttpAuthenticationHandler.java b/src/main/java/com/smartbear/ready/plugin/jira/impl/BearerHttpAuthenticationHandler.java new file mode 100644 index 0000000..395c877 --- /dev/null +++ b/src/main/java/com/smartbear/ready/plugin/jira/impl/BearerHttpAuthenticationHandler.java @@ -0,0 +1,19 @@ +package com.smartbear.ready.plugin.jira.impl; + +import com.atlassian.httpclient.api.Request; +import com.atlassian.jira.rest.client.api.AuthenticationHandler; + +public class BearerHttpAuthenticationHandler implements AuthenticationHandler { + + private static final String AUTHORIZATION_HEADER = "Authorization"; + private final String token; + + public BearerHttpAuthenticationHandler(final String token) { + this.token = token; + } + + @Override + public void configure(Request.Builder builder) { + builder.setHeader(AUTHORIZATION_HEADER, "Bearer " + token); + } +} diff --git a/src/main/java/com/smartbear/ready/plugin/jira/impl/JiraProvider.java b/src/main/java/com/smartbear/ready/plugin/jira/impl/JiraProvider.java index a3642e1..67a6e8e 100644 --- a/src/main/java/com/smartbear/ready/plugin/jira/impl/JiraProvider.java +++ b/src/main/java/com/smartbear/ready/plugin/jira/impl/JiraProvider.java @@ -117,7 +117,13 @@ private JiraProvider() { try { String url = bugTrackerSettings.getUrl(); URI uri = new URI(url); - restClient = factory.createWithBasicHttpAuthentication(uri, bugTrackerSettings.getLogin(), bugTrackerSettings.getPassword()); + if (bugTrackerSettings.getLogin() != null && ! bugTrackerSettings.getLogin().isEmpty() && ! bugTrackerSettings.getLogin().isBlank() ) { + restClient = factory.createWithBasicHttpAuthentication(uri, bugTrackerSettings.getLogin(), bugTrackerSettings.getPassword()); + } else { + BearerHttpAuthenticationHandler handler = new BearerHttpAuthenticationHandler(bugTrackerSettings.getPassword()); + restClient = factory.create(uri, handler); + } + logger.info("[JiraProvider].[JiraProvider] restClient", restClient.toString()); } catch (URISyntaxException e) { logger.error(BUG_TRACKER_URI_IS_INCORRECT); @@ -591,7 +597,7 @@ private WsdlProject findActiveElementRootProject(ModelItem activeElement) { public boolean settingsComplete(BugTrackerSettings settings) { return !(settings == null || StringUtils.isNullOrEmpty(settings.getUrl()) || - StringUtils.isNullOrEmpty(settings.getLogin()) || + //StringUtils.isNullOrEmpty(settings.getLogin()) || StringUtils.isNullOrEmpty(settings.getPassword())); }