public class CredentialsAuth extends Auth2
Modifier and Type | Class and Description |
---|---|
static class |
CredentialsAuth.CredentialsAuthDescriptor |
Auth2.Auth2Descriptor
Modifier and Type | Field and Description |
---|---|
static Auth2.Auth2Descriptor |
DESCRIPTOR |
Constructor and Description |
---|
CredentialsAuth() |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object obj) |
String |
getCredentials() |
Auth2.Auth2Descriptor |
getDescriptor() |
String |
getPassword(Item item)
Tries to find the Jenkins Credential and returns the password.
|
String |
getUserName(Item item)
Tries to find the Jenkins Credential and returns the user name.
|
int |
hashCode() |
void |
setAuthorizationHeader(URLConnection connection,
BuildContext context)
Depending on the purpose the Auth2 implementation has to override the
Authorization header of the connection appropriately. |
void |
setCredentials(String credentials) |
String |
toString() |
String |
toString(Item item)
Returns a string representing the authorization.
|
@Extension public static final Auth2.Auth2Descriptor DESCRIPTOR
@DataBoundSetter public void setCredentials(String credentials)
public String getCredentials()
public String getUserName(Item item) throws CredentialsNotFoundException
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.CredentialsNotFoundException
- if credential could not be found.public String getPassword(Item item) throws CredentialsNotFoundException
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.CredentialsNotFoundException
- if credential could not be found.public String toString(Item item)
Auth2
toString
in class Auth2
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.public void setAuthorizationHeader(URLConnection connection, BuildContext context) throws IOException
Auth2
Authorization
header of the connection appropriately. It might also ignore this
step or remove an existing Authorization
header.setAuthorizationHeader
in class Auth2
connection
- connection between the application and the remote server.context
- the context of this Builder/BuildStep.IOException
- if there is an error generating the authorization header.public Auth2.Auth2Descriptor getDescriptor()
getDescriptor
in interface Describable<Auth2>
getDescriptor
in class AbstractDescribableImpl<Auth2>
Copyright © 2016–2023. All rights reserved.