Class CredentialsHelper


  • public final class CredentialsHelper
    extends Object
    Helper for dealing with credentials.
    Author:
    Fritz Elfert
    • Constructor Detail

      • CredentialsHelper

        public CredentialsHelper()
    • 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 - The ContextBuilder 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)
      • getPassword

        public static String getPassword​(Secret s)