Class CredentialsHelper

java.lang.Object
com.parallels.jenkins.CredentialsHelper

public final class CredentialsHelper extends Object
Centralised credential lookup for the Parallels DevOps plugin.

All calls to CredentialsProvider.lookupCredentials(java.lang.Class<C>) are funnelled through this class so that no inline lookups are scattered across PrlDevopsCloud or PrlDevopsComputerLauncher.

Methods prefixed find return null when the credential is absent; methods prefixed require throw CredentialsNotFoundException instead of returning null, preventing silent NullPointerExceptions.

  • Method Details

    • findStringCredential

      @CheckForNull public static org.jenkinsci.plugins.plaincredentials.StringCredentials findStringCredential(@NonNull String credentialsId, @NonNull ItemGroup<?> context)
      Looks up a StringCredentials by ID.
      Returns:
      the credential, or null if not found
    • requireStringCredential

      @NonNull public static org.jenkinsci.plugins.plaincredentials.StringCredentials requireStringCredential(@NonNull String credentialsId, @NonNull ItemGroup<?> context) throws CredentialsNotFoundException
      Looks up a StringCredentials by ID, throwing if absent.
      Throws:
      CredentialsNotFoundException - if the credential cannot be resolved
    • findUsernamePasswordCredential

      @CheckForNull public static com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentials findUsernamePasswordCredential(@NonNull String credentialsId, @NonNull ItemGroup<?> context)
      Looks up a StandardUsernamePasswordCredentials by ID.
      Returns:
      the credential, or null if not found
    • requireUsernamePasswordCredential

      @NonNull public static com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentials requireUsernamePasswordCredential(@NonNull String credentialsId, @NonNull ItemGroup<?> context) throws CredentialsNotFoundException
      Looks up a StandardUsernamePasswordCredentials by ID, throwing if absent.
      Throws:
      CredentialsNotFoundException - if the credential cannot be resolved
    • requireSshCredential

      @NonNull public static com.cloudbees.plugins.credentials.common.StandardUsernameCredentials requireSshCredential(@NonNull String credentialsId, @NonNull ItemGroup<?> context) throws CredentialsNotFoundException
      Looks up an SSH credential (StandardUsernameCredentials) by ID, throwing if absent.

      StandardUsernameCredentials is the common supertype for both StandardUsernamePasswordCredentials (username + password) and BasicSSHUserPrivateKey (username + private key), so a single lookup covers all SSH authentication modes.

      Throws:
      CredentialsNotFoundException - if the credential cannot be resolved