本文整理汇总了Java中com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentials类的典型用法代码示例。如果您正苦于以下问题:Java StandardUsernamePasswordCredentials类的具体用法?Java StandardUsernamePasswordCredentials怎么用?Java StandardUsernamePasswordCredentials使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
StandardUsernamePasswordCredentials类属于com.cloudbees.plugins.credentials.common包,在下文中一共展示了StandardUsernamePasswordCredentials类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doFillMirrorgateCredentialsIdItems
import com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentials; //导入依赖的package包/类
public ListBoxModel doFillMirrorgateCredentialsIdItems(
@AncestorInPath Item item,
@QueryParameter("mirrorgateCredentialsId") String credentialsId) {
StandardListBoxModel result = new StandardListBoxModel();
if (item == null) {
if (!Jenkins.getInstance().hasPermission(Jenkins.ADMINISTER)) {
return result.includeCurrentValue(credentialsId);
}
} else if (!item.hasPermission(Item.EXTENDED_READ)
&& !item.hasPermission(CredentialsProvider.USE_ITEM)) {
return result.includeCurrentValue(credentialsId);
}
return result
.includeEmptyValue()
.includeAs(ACL.SYSTEM, item, StandardUsernamePasswordCredentials.class);
}
示例2: doFillCredentialsIdItems
import com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentials; //导入依赖的package包/类
/**
* Fills in the Login Credentials selection box with applicable connections.
*
* @param context
* filter for login credentials
* @param credentialsId
* existing login credentials; can be null
* @param project
* the Jenkins project
*
* @return login credentials selection
*/
public ListBoxModel doFillCredentialsIdItems(@AncestorInPath Jenkins context, @QueryParameter String credentialsId,
@AncestorInPath Item project)
{
List<StandardUsernamePasswordCredentials> creds = CredentialsProvider.lookupCredentials(
StandardUsernamePasswordCredentials.class, project, ACL.SYSTEM,
Collections.<DomainRequirement> emptyList());
ListBoxModel model = new ListBoxModel();
model.add(new Option(StringUtils.EMPTY, StringUtils.EMPTY, false));
for (StandardUsernamePasswordCredentials c : creds)
{
boolean isSelected = false;
if (credentialsId != null)
{
isSelected = credentialsId.matches(c.getId());
}
String description = Util.fixEmptyAndTrim(c.getDescription());
model.add(new Option(c.getUsername() + (description != null ? " (" + description + ')' : StringUtils.EMPTY), //$NON-NLS-1$
c.getId(), isSelected));
}
return model;
}
示例3: doFillCredentialsIdItems
import com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentials; //导入依赖的package包/类
/**
* Fills in the Login Credentials selection box with applicable Jenkins credentials.
*
* @param context
* filter for credentials
* @param credentialsId
* existing login credentials; can be null
* @param project
* the Jenkins project
*
* @return credential selections
*/
public ListBoxModel doFillCredentialsIdItems(@AncestorInPath Jenkins context, @QueryParameter String credentialsId, @AncestorInPath Item project)
{
List<StandardUsernamePasswordCredentials> creds = CredentialsProvider.lookupCredentials(
StandardUsernamePasswordCredentials.class, project, ACL.SYSTEM,
Collections.<DomainRequirement> emptyList());
StandardListBoxModel model = new StandardListBoxModel();
model.add(new Option(StringUtils.EMPTY, StringUtils.EMPTY, false));
for (StandardUsernamePasswordCredentials c : creds)
{
boolean isSelected = false;
if (credentialsId != null)
{
isSelected = credentialsId.matches(c.getId());
}
String description = Util.fixEmptyAndTrim(c.getDescription());
model.add(new Option(c.getUsername() + (description != null ? " (" + description + ')' : StringUtils.EMPTY), //$NON-NLS-1$
c.getId(), isSelected));
}
return model;
}
示例4: getLoginInformation
import com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentials; //导入依赖的package包/类
/**
* Retrieves login information given a credential ID.
*
* @param project
* the Jenkins project
*
* @return a Jenkins credential with login information
*/
protected StandardUsernamePasswordCredentials getLoginInformation(Item project)
{
StandardUsernamePasswordCredentials credential = null;
List<StandardUsernamePasswordCredentials> credentials = CredentialsProvider.lookupCredentials(
StandardUsernamePasswordCredentials.class, project, ACL.SYSTEM, Collections.<DomainRequirement> emptyList());
IdMatcher matcher = new IdMatcher(getCredentialsId());
for (StandardUsernamePasswordCredentials c : credentials)
{
if (matcher.matches(c))
{
credential = c;
}
}
return credential;
}
示例5: getLoginInformation
import com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentials; //导入依赖的package包/类
/**
* Retrieves login information given a credential ID
*
* @param project
* the Jenkins project
*
* @return a Jenkins credential with login information
*/
protected StandardUsernamePasswordCredentials getLoginInformation(Item project)
{
StandardUsernamePasswordCredentials credential = null;
List<StandardUsernamePasswordCredentials> credentials = CredentialsProvider.lookupCredentials(
StandardUsernamePasswordCredentials.class, project, ACL.SYSTEM, Collections.<DomainRequirement> emptyList());
IdMatcher matcher = new IdMatcher(getCredentialsId());
for (StandardUsernamePasswordCredentials c : credentials)
{
if (matcher.matches(c))
{
credential = c;
}
}
return credential;
}
示例6: doFillCredentialsIdItems
import com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentials; //导入依赖的package包/类
public ListBoxModel doFillCredentialsIdItems(@AncestorInPath Item item, @QueryParameter String credentialsId) {
StandardListBoxModel result = new StandardListBoxModel();
if (item == null) {
if (!Jenkins.getInstance().hasPermission(Jenkins.ADMINISTER)) {
return result.add(credentialsId);
}
} else {
if (!item.hasPermission(Item.EXTENDED_READ)
&& !item.hasPermission(CredentialsProvider.USE_ITEM)) {
return result.add(credentialsId);
}
}
return result
.withEmptySelection()
.withAll(CredentialsProvider.lookupCredentials(StandardUsernamePasswordCredentials.class, item, null, Collections.<DomainRequirement>emptyList()))
.withMatching(CredentialsMatchers.withId(credentialsId));
}
示例7: doFillCredentialsIdItems
import com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentials; //导入依赖的package包/类
/**
* Stapler helper method.
*
* @param context
* the context.
* @param remoteBase
* the remote base.
* @return list box model.
* @throws URISyntaxException
*/
public ListBoxModel doFillCredentialsIdItems(@AncestorInPath Item context, @QueryParameter String serverAPIUrl) throws URISyntaxException {
List<DomainRequirement> domainRequirements = URIRequirementBuilder.fromUri(serverAPIUrl).build();
return new StandardListBoxModel()
.withEmptySelection()
.withMatching(
CredentialsMatchers.anyOf(
CredentialsMatchers.instanceOf(StandardUsernamePasswordCredentials.class),
CredentialsMatchers.instanceOf(StringCredentials.class)),
CredentialsProvider.lookupCredentials(StandardCredentials.class,
context,
ACL.SYSTEM,
domainRequirements)
);
}
示例8: doFillCredentialsIdItems
import com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentials; //导入依赖的package包/类
public ListBoxModel doFillCredentialsIdItems(@AncestorInPath Item item, @QueryParameter String serverUrl) {
return new StandardListBoxModel()
.withEmptySelection()
.withMatching(
CredentialsMatchers.anyOf(
CredentialsMatchers.instanceOf(StandardUsernamePasswordCredentials.class),
CredentialsMatchers.instanceOf(TokenProducer.class),
CredentialsMatchers.instanceOf(StandardCertificateCredentials.class)
),
CredentialsProvider.lookupCredentials(
StandardCredentials.class,
item,
null,
URIRequirementBuilder.fromUri(serverUrl).build()
)
);
}
示例9: doFillCredentialsIdItems
import com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentials; //导入依赖的package包/类
public ListBoxModel doFillCredentialsIdItems(@QueryParameter String serverUrl) {
return new StandardListBoxModel().withEmptySelection() //
.withMatching( //
CredentialsMatchers.anyOf(
CredentialsMatchers.instanceOf(StandardUsernamePasswordCredentials.class),
CredentialsMatchers.instanceOf(TokenProducer.class),
CredentialsMatchers.instanceOf(
org.jenkinsci.plugins.kubernetes.credentials.TokenProducer.class),
CredentialsMatchers.instanceOf(StandardCertificateCredentials.class),
CredentialsMatchers.instanceOf(StringCredentials.class)), //
CredentialsProvider.lookupCredentials(StandardCredentials.class, //
Jenkins.getInstance(), //
ACL.SYSTEM, //
serverUrl != null ? URIRequirementBuilder.fromUri(serverUrl).build()
: Collections.EMPTY_LIST //
));
}
示例10: init
import com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentials; //导入依赖的package包/类
public <T extends ApiClient.HttpClientFactory> void init(ApiClient client, T httpFactory) {
this.trigger = this.builder.getTrigger();
if (client == null) {
String username = trigger.getUsername();
String password = trigger.getPassword();
StandardUsernamePasswordCredentials credentials = getCredentials(trigger.getCredentialsId());
if (credentials != null) {
username = credentials.getUsername();
password = credentials.getPassword().getPlainText();
}
this.client = new ApiClient(
username,
password,
trigger.getRepositoryOwner(),
trigger.getRepositoryName(),
trigger.getCiKey(),
trigger.getCiName(),
httpFactory
);
} else this.client = client;
}
示例11: doTestConnection
import com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentials; //导入依赖的package包/类
public FormValidation doTestConnection(@QueryParameter("serverUrl") final String serverUrl,
@QueryParameter("proxyUrl") final String proxyUrl,
@QueryParameter("credentialsId") final String credentialsId
) {
try {
if (credentialsId == null || credentialsId.isEmpty()) {
return FormValidation.error("No credentials specified");
}
StandardUsernamePasswordCredentials credentials = XLTestView.lookupSystemCredentials(credentialsId);
if (credentials == null) {
return FormValidation.error(String.format("Could not find credential with id '%s'", credentialsId));
}
if (serverUrl == null || serverUrl.isEmpty()) {
return FormValidation.error("No server URL specified");
}
// see if we can create a new instance
XLTestServer srv = XLTestServerFactory.newInstance(serverUrl, proxyUrl, credentials);
srv.checkConnection();
return FormValidation.ok("Success");
} catch (RuntimeException e) {
return FormValidation.error("Client error : " + e.getMessage());
}
}
示例12: prebuild
import com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentials; //导入依赖的package包/类
@Override
public boolean prebuild(AbstractBuild<?, ?> build, BuildListener listener) {
checkArgument(build instanceof SpoonBuild, requireInstanceOf("build", SpoonBuild.class));
try {
SpoonBuild spoonBuild = (SpoonBuild) build;
Optional<StandardUsernamePasswordCredentials> credentials = this.getCredentials();
if (credentials.isPresent()) {
spoonBuild.setCredentials(credentials.get());
}
EnvVars env = this.getEnvironment(build, listener);
spoonBuild.setEnv(env);
FilePath scriptPath = this.resolveScriptFilePath(build, env, listener);
spoonBuild.setScript(scriptPath);
this.checkMountSettings();
return super.prebuild(build, listener);
} catch (IllegalStateException ex) {
TaskListeners.logFatalError(listener, ex);
return false;
}
}
示例13: perform
import com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentials; //导入依赖的package包/类
@Override
public boolean perform(AbstractBuild abstractBuild, Launcher launcher, BuildListener listener) throws IOException, InterruptedException {
try {
SpoonBuild build = (SpoonBuild) abstractBuild;
SpoonClient client = SpoonClient.builder(build).launcher(launcher).listener(listener).build();
checkSpoonPluginIsRunning(client);
Optional<StandardUsernamePasswordCredentials> credentials = build.getCredentials();
if (credentials.isPresent()) {
login(client, credentials.get());
}
String outputImage = build(client, build.getScript().get());
build.setBuiltImage(outputImage);
return true;
} catch (IllegalStateException ex) {
TaskListeners.logFatalError(listener, ex);
return false;
}
}
示例14: doFillCredentialsIdItems
import com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentials; //导入依赖的package包/类
/**
* This method is called to populate the credentials list on the Jenkins config page.
*/
@SuppressWarnings("unused")
public ListBoxModel doFillCredentialsIdItems(@AncestorInPath ItemGroup context,
@QueryParameter("target") final String target) {
StandardListBoxModel result = new StandardListBoxModel();
result.withEmptySelection();
result.withMatching(CredentialsMatchers.instanceOf(StandardUsernamePasswordCredentials.class),
CredentialsProvider.lookupCredentials(
StandardUsernameCredentials.class,
context,
ACL.SYSTEM,
URIRequirementBuilder.fromUri(target).build()
)
);
return result;
}
示例15: credentialsForScm
import com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentials; //导入依赖的package包/类
private String credentialsForScm(ScmNode scm) {
String url;
if (scm == null) {
url = JobProfilesConfiguration.get().getProfileRootDir();
} else {
url = scm.uri();
}
List<DomainRequirement> domainRequirements = URIRequirementBuilder.fromUri(url).build();
Item item = null;
StandardUsernamePasswordCredentials credentials = CredentialsMatchers.firstOrNull(
CredentialsProvider.lookupCredentials(StandardUsernamePasswordCredentials.class, item, ACL.SYSTEM, domainRequirements),
CredentialsMatchers.always());
if (credentials != null) {
return credentials.getId();
}
return "";
}