Class GitHubTokenCredentialsCreator
- java.lang.Object
-
- hudson.model.Descriptor<GitHubTokenCredentialsCreator>
-
- org.jenkinsci.plugins.github.config.GitHubTokenCredentialsCreator
-
- All Implemented Interfaces:
Describable<GitHubTokenCredentialsCreator>
,Saveable
,OnMaster
@Extension public class GitHubTokenCredentialsCreator extends Descriptor<GitHubTokenCredentialsCreator> implements Describable<GitHubTokenCredentialsCreator>
Helper class to convert username+password credentials or directly login+password to GH token and save it as token credentials with help of plain-credentials plugin- Since:
- 1.13.0
- Author:
- lanwen (Merkushev Kirill)
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class hudson.model.Descriptor
Descriptor.FormException, Descriptor.PropertyType, Descriptor.Self
-
-
Field Summary
Fields Modifier and Type Field Description static List<String>
GH_PLUGIN_REQUIRED_SCOPE
Default scope required for this plugin.-
Fields inherited from class hudson.model.Descriptor
clazz
-
-
Constructor Summary
Constructors Constructor Description GitHubTokenCredentialsCreator()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description com.cloudbees.plugins.credentials.common.StandardCredentials
createCredentials(String serverAPIUrl, String token, String username)
CreatesStringCredentials
with previously created GH token.org.kohsuke.github.GHAuthorization
createToken(String username, String password, String apiUrl)
Can be used to convert given login and password to GH personal token as more secured way to interact with apiFormValidation
doCreateTokenByCredentials(String apiUrl, String credentialsId)
FormValidation
doCreateTokenByPassword(String apiUrl, String login, String password)
ListBoxModel
doFillCredentialsIdItems(String apiUrl, String credentialsId)
GitHubTokenCredentialsCreator
getDescriptor()
String
getDisplayName()
-
Methods inherited from class hudson.model.Descriptor
addHelpFileRedirect, bindJSON, calcAutoCompleteSettings, calcFillSettings, configure, configure, doHelp, find, find, findByDescribableClassName, findById, getCategory, getCheckMethod, getCheckUrl, getConfigFile, getConfigPage, getCurrentDescriptorByNameUrl, getDescriptorFullUrl, getDescriptorUrl, getGlobalConfigPage, getGlobalPropertyType, getHelpFile, getHelpFile, getHelpFile, getId, getJsonSafeClassName, getKlass, getPlugin, getPossibleViewNames, getPropertyType, getPropertyType, getPropertyTypeOrDie, getRequiredGlobalConfigPagePermission, getT, getViewPage, isInstance, isSubTypeOf, load, newInstance, newInstance, newInstancesFromHeteroList, newInstancesFromHeteroList, save, self, toArray, toList, toMap
-
-
-
-
Method Detail
-
getDescriptor
public GitHubTokenCredentialsCreator getDescriptor()
- Specified by:
getDescriptor
in interfaceDescribable<GitHubTokenCredentialsCreator>
-
getDisplayName
public String getDisplayName()
- Overrides:
getDisplayName
in classDescriptor<GitHubTokenCredentialsCreator>
-
doFillCredentialsIdItems
public ListBoxModel doFillCredentialsIdItems(@QueryParameter String apiUrl, @QueryParameter String credentialsId)
-
doCreateTokenByCredentials
public FormValidation doCreateTokenByCredentials(@QueryParameter String apiUrl, @QueryParameter String credentialsId)
-
doCreateTokenByPassword
public FormValidation doCreateTokenByPassword(@QueryParameter String apiUrl, @QueryParameter String login, @QueryParameter String password)
-
createToken
public org.kohsuke.github.GHAuthorization createToken(@NonNull String username, @NonNull String password, @Nullable String apiUrl) throws IOException
Can be used to convert given login and password to GH personal token as more secured way to interact with api- Parameters:
username
- gh loginpassword
- gh passwordapiUrl
- gh api url. Can be null or empty to default- Returns:
- personal token with requested scope
- Throws:
IOException
- when can't create token with given creds
-
createCredentials
public com.cloudbees.plugins.credentials.common.StandardCredentials createCredentials(@Nullable String serverAPIUrl, String token, String username)
CreatesStringCredentials
with previously created GH token. Adds them to domain extracted from server url (will be generated if no any exists before). Domain will have domain requirements consists of scheme and host from serverAPIUrl arg- Parameters:
serverAPIUrl
- to add to domain with host and scheme requirement from this urltoken
- GH Personal tokenusername
- used to add to description of newly created creds- Returns:
- credentials object
- See Also:
createCredentials(String, StandardCredentials)
-
-