什麼是可用於將第三方應用程序與jira 4.3集成的身份驗證方案。顯然,從客戶那裏獲取用戶名和密碼聽起來很荒唐。另外,我得到的oauth身份驗證僅適用於版本5.請讓我知道。謝謝。JIRA集成
PS。我不想要開發插件或使用其他版本5。我只是想使用rest api版本4.4.1從jira中提取數據。
什麼是可用於將第三方應用程序與jira 4.3集成的身份驗證方案。顯然,從客戶那裏獲取用戶名和密碼聽起來很荒唐。另外,我得到的oauth身份驗證僅適用於版本5.請讓我知道。謝謝。JIRA集成
PS。我不想要開發插件或使用其他版本5。我只是想使用rest api版本4.4.1從jira中提取數據。
您可以隨時使用一個登錄名(例如匿名用戶)在幕後與Jira進行連接,而無需詢問用戶輸入密碼。 您也可以allow user to create issues anonymously。 或安裝項目public browsing。
如果它是本地Jira(安裝在您的系統上),您可以調用任何客戶端API來提取數據,只需提供url和編碼auth(使用用戶名和密碼)即可。
String getUrl = applicationProperties.getjURL() + "/rest/api/1.0/XXX";
String jiraUser = applicationProperties.getJiraUser().trim();
String jiraPwd = applicationProperties.getJiraPassword().trim();
String auth = new String(Base64.encode(jiraUser + ":" + jiraPwd));
HttpGet get = new HttpGet(getUrl);
StringEntity postingString = new StringEntity(gson.toJson(descrptionBean));
post.setEntity(postingString);
post.setHeader("Authorization", "Basic " + auth);
post.setHeader("Content-type", "application/json");
HttpClient httpClient = new org.apache.http.impl.client.DefaultHttpClient();
HttpResponse response = httpClient.execute(get);
... 但如果是SSL/HTTPS安全,那麼你需要(如果使用Java作爲技術的情況下)來設定信任,密鑰庫,keyStorePassword等系統屬性。您可以使用API JiraRestClientFactory創建一個jira客戶端,如下所示。
public JiraRestClient getRestClient() {
System.setProperty("javax.net.ssl.trustStore", Constants.KEYSTORE);
System.setProperty("javax.net.ssl.keyStore", Constants.KEYSTORE);
System.setProperty("javax.net.ssl.keyStorePassword", "changeit");
String trustStore = System.getProperty("javax.net.ssl.trustStore");
System.setProperty("-Dlog4j.configuration", "log4j.properties");
if (trustStore == null) {
Constants.REPORT.info("javax.net.ssl.trustStore is not defined, Please generate \"KeyStore.jks\" of JIRA Instance");
}
final JiraRestClientFactory jiraRestClientFactory = new AsynchronousJiraRestClientFactory();
final HttpClientOptions options = new HttpClientOptions();
options.setConnectionTimeout(15, TimeUnit.MINUTES);
options.setSocketTimeout(15, TimeUnit.MINUTES);
options.setConnectionPoolTimeToLive(15, TimeUnit.MINUTES);
options.setRequestPreparer(new Effect<Request>() {
@Override
public void apply(final Request request) {
new BasicHttpAuthenticationHandler(applicationProperties.getJiraUser().trim(), applicationProperties.getJiraPassword().trim()).configure(request);
}
});
try {
URI serverUri = new URI(applicationProperties.getjURL().trim());
defaultHttpClient = new DefaultHttpClient<>(new NoOpEventPublisher(), new RestClientApplicationProperties(serverUri), ThreadLocalContextManagers.noop(), options);
return jiraRestClientFactory.create(serverUri, defaultHttpClient);
} catch (Exception e) {
String msg = "Terminating the application while connecting to RestClient : " + e.getMessage();
Constants.REPORT.info("javax.net.ssl.trustStore is not defined, Please generate \"KeyStore.jks\" of JIRA Instance");
Constants.REPORT.info(msg);
Constants.ERROR.info(msg);
Constants.ERROR.info(Level.SEVERE, e);
System.exit(-1);
}
return null;
}