Package jenkins.plugins.jclouds.internal
Class CredentialsHelper
- java.lang.Object
-
- jenkins.plugins.jclouds.internal.CredentialsHelper
-
public final class CredentialsHelper extends Object
Helper for dealing with credentials.- Author:
- Fritz Elfert
-
-
Constructor Summary
Constructors Constructor Description CredentialsHelper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static String
convertCredentials(String description, String identity, Secret credential)
Converts old identity/credential new UsernamePassword credential-plugin record.static com.cloudbees.plugins.credentials.common.StandardUsernameCredentials
getCredentialsById(String id)
Use the ssh-slaves-plugin to retrieve a credentials object by its Id.static String
getPassword(Secret s)
static String
getPrivateKey(com.cloudbees.jenkins.plugins.sshcredentials.SSHUserPrivateKey supk)
static ContextBuilder
setCredentials(ContextBuilder cb, String id)
Populates the credential of a JClouds ContextBuilder from a credentials record.static void
setProject(String id, Properties overrides)
Handles new OpenstackKeystoneV3 credentials and sets jclouds overrides accordingly.static String
storeCredentials(com.cloudbees.plugins.credentials.common.StandardUsernameCredentials u)
Stores a new credentials record (Used only during migration).
-
-
-
Method Detail
-
storeCredentials
public static String storeCredentials(com.cloudbees.plugins.credentials.common.StandardUsernameCredentials u) throws IOException
Stores a new credentials record (Used only during migration).- Parameters:
u
- The new credentials to store;- Returns:
- The Id of the new record or
null
on failure. - Throws:
IOException
- on error.
-
getCredentialsById
public static com.cloudbees.plugins.credentials.common.StandardUsernameCredentials getCredentialsById(String id)
Use the ssh-slaves-plugin to retrieve a credentials object by its Id.- Parameters:
id
- The Id of the credentials object.- Returns:
- The StandardUsernameCredentials or null if not found.
-
convertCredentials
public static String convertCredentials(String description, String identity, Secret credential)
Converts old identity/credential new UsernamePassword credential-plugin record.- Parameters:
description
- The for the credentials record.identity
- The old identity (AKA username).credential
- The old credential (AKA password).- Returns:
- The Id of the newly created credential-plugin record.
-
setProject
public static void setProject(String id, Properties overrides)
Handles new OpenstackKeystoneV3 credentials and sets jclouds overrides accordingly.
-
setCredentials
public static ContextBuilder setCredentials(ContextBuilder cb, String id)
Populates the credential of a JClouds ContextBuilder from a credentials record.- Parameters:
cb
- TheContextBuilder
which should get the credential.id
- The Id of the credentials object.- Returns:
- The modified
ContextBuilder
-
getPrivateKey
public static String getPrivateKey(com.cloudbees.jenkins.plugins.sshcredentials.SSHUserPrivateKey supk)
-
-