Search in sources :

Example 1 with BasicHttpAuthenticationHandler

use of com.atlassian.jira.rest.client.auth.BasicHttpAuthenticationHandler in project jira-plugin by jenkinsci.

the class JiraSite method createSession.

/**
 * Creates a remote access session to this Jira.
 *
 * @return null if remote access is not supported.
 */
private JiraSession createSession(Item item) {
    ItemGroup itemGroup = map(item);
    item = itemGroup instanceof Folder ? ((Folder) itemGroup) : item;
    StandardUsernamePasswordCredentials credentials = resolveCredentials(item);
    if (credentials == null) {
        LOGGER.fine("no Jira credentials available for " + item);
        // remote access not supported
        return null;
    }
    URI uri;
    try {
        uri = url.toURI();
    } catch (URISyntaxException e) {
        LOGGER.warning("convert URL to URI error: " + e.getMessage());
        throw new RuntimeException("failed to create JiraSession due to convert URI error");
    }
    LOGGER.fine("creating Jira Session: " + uri);
    ExtendedJiraRestClient jiraRestClient = new ExtendedAsynchronousJiraRestClientFactory().create(uri, new BasicHttpAuthenticationHandler(credentials.getUsername(), credentials.getPassword().getPlainText()), getHttpClientOptions());
    return new JiraSession(this, new JiraRestService(uri, jiraRestClient, credentials.getUsername(), credentials.getPassword().getPlainText(), readTimeout));
}
Also used : StandardUsernamePasswordCredentials(com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentials) ItemGroup(hudson.model.ItemGroup) BasicHttpAuthenticationHandler(com.atlassian.jira.rest.client.auth.BasicHttpAuthenticationHandler) URISyntaxException(java.net.URISyntaxException) ExtendedJiraRestClient(hudson.plugins.jira.extension.ExtendedJiraRestClient) Folder(com.cloudbees.hudson.plugins.folder.Folder) AbstractFolder(com.cloudbees.hudson.plugins.folder.AbstractFolder) URI(java.net.URI)

Aggregations

BasicHttpAuthenticationHandler (com.atlassian.jira.rest.client.auth.BasicHttpAuthenticationHandler)1 AbstractFolder (com.cloudbees.hudson.plugins.folder.AbstractFolder)1 Folder (com.cloudbees.hudson.plugins.folder.Folder)1 StandardUsernamePasswordCredentials (com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentials)1 ItemGroup (hudson.model.ItemGroup)1 ExtendedJiraRestClient (hudson.plugins.jira.extension.ExtendedJiraRestClient)1 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1