All Implemented Interfaces:
Describable<Auth2>, Serializable, Cloneable

public class CredentialsAuth extends Auth2
See Also:
  • Field Details

  • Constructor Details

    • CredentialsAuth

      @DataBoundConstructor public CredentialsAuth()
  • Method Details

    • setCredentials

      @DataBoundSetter public void setCredentials(String credentials)
    • getCredentials

      public String getCredentials()
    • getUserName

      public String getUserName(Item item) throws CredentialsNotFoundException
      Tries to find the Jenkins Credential and returns the user name.
      Parameters:
      item - the Item (Job, Pipeline,...) we are currently running in. The item is required to also get Credentials which are defined in the items scope and not Jenkins globally. Value can be null, but Credentials e.g. configured on a Folder will not be found in this case, only globally configured Credentials.
      Returns:
      The user name configured in this Credential
      Throws:
      CredentialsNotFoundException - if credential could not be found.
    • getPassword

      public String getPassword(Item item) throws CredentialsNotFoundException
      Tries to find the Jenkins Credential and returns the password.
      Parameters:
      item - the Item (Job, Pipeline,...) we are currently running in. The item is required to also get Credentials which are defined in the items scope and not Jenkins globally. Value can be null, but Credentials e.g. configured on a Folder will not be found in this case, only globally configured Credentials.
      Returns:
      The password configured in this Credential
      Throws:
      CredentialsNotFoundException - if credential could not be found.
    • toString

      public String toString()
      Specified by:
      toString in class Auth2
    • toString

      public String toString(Item item)
      Description copied from class: Auth2
      Returns a string representing the authorization.
      Specified by:
      toString in class Auth2
      Parameters:
      item - the Item (Job, Pipeline,...) we are currently running in. The item is required to also get Credentials which are defined in the items scope and not Jenkins globally. Value can be null, but Credentials e.g. configured on a Folder will not be found in this case, only globally configured Credentials.
      Returns:
      a string representing the authorization.
    • setAuthorizationHeader

      public void setAuthorizationHeader(URLConnection connection, BuildContext context) throws IOException
      Description copied from class: Auth2
      Depending on the purpose the Auth2 implementation has to override the Authorization header of the connection appropriately. It might also ignore this step or remove an existing Authorization header.
      Specified by:
      setAuthorizationHeader in class Auth2
      Parameters:
      connection - connection between the application and the remote server.
      context - the context of this Builder/BuildStep.
      Throws:
      IOException - if there is an error generating the authorization header.
    • getDescriptor

      public Auth2.Auth2Descriptor getDescriptor()
      Specified by:
      getDescriptor in interface Describable<Auth2>
      Overrides:
      getDescriptor in class AbstractDescribableImpl<Auth2>
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object