public class SSHUserListBoxModel extends com.cloudbees.plugins.credentials.common.AbstractIdCredentialsListBoxModel<SSHUserListBoxModel,com.cloudbees.plugins.credentials.common.StandardUsernameCredentials>
ListBoxModel with StandardUsernameCredentials support.
This class is convenient for providing the config.groovy/.jelly fragment for a collection of StandardUsernameCredentials objects.
If you want to let the user configure an StandardUsernameCredentials object, do the following:
First, create a field that stores the credential ID and defines a corresponding parameter in the constructor:
private String credentialId;
@DataBoundConstructor
public MyModel( .... , String credentialId) {
this.credentialId = credentialId;
...
}
Your config.groovy should have the following entry to render a drop-down list box:
f.entry(title:_("Credentials"), field:"credentialId") {
f.select()
}
Finally, your Descriptor implementation should have the doFillCredentialsIdItems method, which
lists up the credentials available in this context:
public SSHUserListBoxModel doFillCredentialsIdItems() {
return new SSHUserListBoxModel()
.addCollection(CredentialsProvider.lookupCredentials(SSHUser.class,...));
}
Exactly which overloaded version of the CredentialsProvider.lookupCredentials(Class) depends on
the context in which your model operates. Here are a few common examples:
Jenkins
(such as slaves), or do not have any ancestors serving as the context, then use addSystemScopeCredentials().
Item (such as its major subtype Job),
then use that Item as the context and call CredentialsProvider.lookupCredentials(Class, Item)
See below:
public SSHUserListBoxModel doFillCredentialsIdItems(@AncestorInPath AbstractProject context) {
return new SSHUserListBoxModel().addCollection(
CredentialsProvider.lookupCredentials(StandardUsernameCredentials.class, context, auth, domainRequirements)));
}
modCount| Constructor and Description |
|---|
SSHUserListBoxModel() |
| Modifier and Type | Method and Description |
|---|---|
SSHUserListBoxModel |
add(com.cloudbees.plugins.credentials.common.StandardUsernameCredentials u)
Deprecated.
use
AbstractIdCredentialsListBoxModel.with(com.cloudbees.plugins.credentials.common.IdCredentials) |
SSHUserListBoxModel |
addCollection(Collection<? extends com.cloudbees.plugins.credentials.common.StandardUsernameCredentials> col)
Deprecated.
use
AbstractIdCredentialsListBoxModel.withMatching(CredentialsMatcher, Iterable) or AbstractIdCredentialsListBoxModel.withAll(Iterable) |
SSHUserListBoxModel |
addSystemScopeCredentials()
Deprecated.
|
protected String |
describe(com.cloudbees.plugins.credentials.common.StandardUsernameCredentials c) |
SSHUserListBoxModel |
withSystemScopeCredentials()
Adds all the system-scoped credentials (they will be filtered with
SSHAuthenticator.matcher()
implicitly). |
SSHUserListBoxModel |
withSystemScopeCredentials(com.cloudbees.plugins.credentials.CredentialsMatcher matcher,
com.cloudbees.plugins.credentials.domains.DomainRequirement... domainRequirements)
Adds all the system-scoped credentials.
|
SSHUserListBoxModel |
withSystemScopeCredentials(com.cloudbees.plugins.credentials.CredentialsMatcher matcher,
List<com.cloudbees.plugins.credentials.domains.DomainRequirement> domainRequirements)
Adds all the system-scoped credentials.
|
SSHUserListBoxModel |
withSystemScopeCredentials(com.cloudbees.plugins.credentials.domains.DomainRequirement... domainRequirements)
Adds all the system-scoped credentials (they will be filtered with
SSHAuthenticator.matcher()
implicitly). |
SSHUserListBoxModel |
withSystemScopeCredentials(List<com.cloudbees.plugins.credentials.domains.DomainRequirement> domainRequirements)
Adds all the system-scoped credentials (they will be filtered with
SSHAuthenticator.matcher()
implicitly). |
with, withAll, withAll, withAll, withEmptySelection, withMatching, withMatching, withMatchingadd, add, add, generateResponse, values, writeToadd, add, addAll, addAll, clear, clone, contains, ensureCapacity, get, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeRange, retainAll, set, size, subList, toArray, toArray, trimToSizeequals, hashCodecontainsAll, toStringfinalize, getClass, notify, notifyAll, wait, wait, waitcontainsAll, equals, hashCode@NonNull protected String describe(@NonNull com.cloudbees.plugins.credentials.common.StandardUsernameCredentials c)
describe in class com.cloudbees.plugins.credentials.common.AbstractIdCredentialsListBoxModel<SSHUserListBoxModel,com.cloudbees.plugins.credentials.common.StandardUsernameCredentials>@Deprecated public SSHUserListBoxModel add(com.cloudbees.plugins.credentials.common.StandardUsernameCredentials u)
AbstractIdCredentialsListBoxModel.with(com.cloudbees.plugins.credentials.common.IdCredentials)@Deprecated public SSHUserListBoxModel addCollection(Collection<? extends com.cloudbees.plugins.credentials.common.StandardUsernameCredentials> col)
AbstractIdCredentialsListBoxModel.withMatching(CredentialsMatcher, Iterable) or AbstractIdCredentialsListBoxModel.withAll(Iterable)SSHAuthenticator.matcher() implicitly).col - the collection of credentials.this for method chaining.@Deprecated public SSHUserListBoxModel addSystemScopeCredentials()
withSystemScopeCredentials()SSHAuthenticator.matcher()
implicitly).
These credentials are meant to be used for system configuration and other things scoped to the Jenkins
object,
such as slaves.this for method chaining.public SSHUserListBoxModel withSystemScopeCredentials()
SSHAuthenticator.matcher()
implicitly).
These credentials are meant to be used for system configuration and other things scoped to the Jenkins
object,
such as slaves.this for method chaining.public SSHUserListBoxModel withSystemScopeCredentials(com.cloudbees.plugins.credentials.domains.DomainRequirement... domainRequirements)
SSHAuthenticator.matcher()
implicitly).
These credentials are meant to be used for system configuration and other things scoped to the Jenkins
object,
such as slaves.domainRequirements - the domain requirementsthis for method chaining.public SSHUserListBoxModel withSystemScopeCredentials(com.cloudbees.plugins.credentials.CredentialsMatcher matcher, com.cloudbees.plugins.credentials.domains.DomainRequirement... domainRequirements)
Jenkins
object,
such as slaves.matcher - a matcher to filter the credentialsdomainRequirements - the domain requirementsthis for method chaining.public SSHUserListBoxModel withSystemScopeCredentials(List<com.cloudbees.plugins.credentials.domains.DomainRequirement> domainRequirements)
SSHAuthenticator.matcher()
implicitly).
These credentials are meant to be used for system configuration and other things scoped to the Jenkins
object,
such as slaves.domainRequirements - the domain requirementsthis for method chaining.public SSHUserListBoxModel withSystemScopeCredentials(com.cloudbees.plugins.credentials.CredentialsMatcher matcher, List<com.cloudbees.plugins.credentials.domains.DomainRequirement> domainRequirements)
Jenkins
object,
such as slaves.matcher - a matcher to filter the credentialsdomainRequirements - the domain requirementsthis for method chaining.Copyright © 2004-2013. All Rights Reserved.