当前位置: 首页>>代码示例>>Java>>正文


Java StandardUsernameCredentials类代码示例

本文整理汇总了Java中com.cloudbees.plugins.credentials.common.StandardUsernameCredentials的典型用法代码示例。如果您正苦于以下问题:Java StandardUsernameCredentials类的具体用法?Java StandardUsernameCredentials怎么用?Java StandardUsernameCredentials使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


StandardUsernameCredentials类属于com.cloudbees.plugins.credentials.common包,在下文中一共展示了StandardUsernameCredentials类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: doFillCredentialsIdItems

import com.cloudbees.plugins.credentials.common.StandardUsernameCredentials; //导入依赖的package包/类
public ListBoxModel doFillCredentialsIdItems(
    @AncestorInPath Item context,
    @QueryParameter String remote,
    @QueryParameter String credentialsId) {
  if (context == null && !Jenkins.getActiveInstance().hasPermission(Jenkins.ADMINISTER)
      || context != null && !context.hasPermission(Item.EXTENDED_READ)) {
    return new StandardListBoxModel().includeCurrentValue(credentialsId);
  }
  return new StandardListBoxModel()
      .includeEmptyValue()
      .includeMatchingAs(
          context instanceof Queue.Task
              ? Tasks.getAuthenticationOf((Queue.Task) context)
              : ACL.SYSTEM,
          context,
          StandardUsernameCredentials.class,
          URIRequirementBuilder.fromUri(remote).build(),
          GitClient.CREDENTIALS_MATCHER)
      .includeCurrentValue(credentialsId);
}
 
开发者ID:GerritForge,项目名称:gerrit-plugin,代码行数:21,代码来源:GerritSCMSource.java

示例2: doFillCheckoutCredentialsIdItems

import com.cloudbees.plugins.credentials.common.StandardUsernameCredentials; //导入依赖的package包/类
@Restricted(NoExternalUse.class)
public ListBoxModel doFillCheckoutCredentialsIdItems(@AncestorInPath SCMSourceOwner context, @QueryParameter String connectionName, @QueryParameter String checkoutCredentialsId) {
    if (context == null && !Jenkins.getInstance().hasPermission(Jenkins.ADMINISTER) ||
            context != null && !context.hasPermission(Item.EXTENDED_READ)) {
        return new StandardListBoxModel().includeCurrentValue(checkoutCredentialsId);
    }

    StandardListBoxModel result = new StandardListBoxModel();
    result.add("- anonymous -", CHECKOUT_CREDENTIALS_ANONYMOUS);
    return result.includeMatchingAs(
            context instanceof Queue.Task
                    ? Tasks.getDefaultAuthenticationOf((Queue.Task) context)
                    : ACL.SYSTEM,
            context,
            StandardUsernameCredentials.class,
            SettingsUtils.gitLabConnectionRequirements(connectionName),
            GitClient.CREDENTIALS_MATCHER
    );
}
 
开发者ID:Argelbargel,项目名称:gitlab-branch-source-plugin,代码行数:20,代码来源:GitLabSCMSourceSettings.java

示例3: doFillCredentialsIdItems

import com.cloudbees.plugins.credentials.common.StandardUsernameCredentials; //导入依赖的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;
}
 
开发者ID:hpcloud,项目名称:cloudfoundry-jenkins,代码行数:19,代码来源:CloudFoundryPushPublisher.java

示例4: doFillCredentialsIdItems

import com.cloudbees.plugins.credentials.common.StandardUsernameCredentials; //导入依赖的package包/类
public static ListBoxModel doFillCredentialsIdItems(@AncestorInPath ItemGroup context) {

            AccessControlled ac = (context instanceof AccessControlled ? (AccessControlled) context : Jenkins.getInstance());
            if (!ac.hasPermission(Jenkins.ADMINISTER)) {
                return new ListBoxModel();
            }

            return new SSHUserListBoxModel().withMatching(
                    SSHAuthenticator.matcher(Connection.class),
                    CredentialsProvider.lookupCredentials(
                            StandardUsernameCredentials.class,
                            context,
                            ACL.SYSTEM,
                            SSHLauncher.SSH_SCHEME)
            );
        }
 
开发者ID:jenkinsci,项目名称:docker-plugin,代码行数:17,代码来源:DockerTemplateBase.java

示例5: getCredentials

import com.cloudbees.plugins.credentials.common.StandardUsernameCredentials; //导入依赖的package包/类
/**
 * Looks up the credentialsID attached to this object in the Global Credentials plugin datastore
 * @return the matched credentials
 */
private UsernamePasswordCredentials getCredentials() {
    String credetialId = this.getCreds();
    StandardUsernameCredentials matchedCredentials = null;
    Item item = null;

    List<StandardUsernameCredentials> listOfCredentials = CredentialsProvider.lookupCredentials(
            StandardUsernameCredentials.class, item, ACL.SYSTEM, Collections.<DomainRequirement> emptyList());
    for (StandardUsernameCredentials cred : listOfCredentials) {
        if (credetialId.equals(cred.getId())) {
            matchedCredentials = cred;
            break;
        }
    }

    // now we have matchedCredentials.getPassword() and matchedCredentials.getUsername();
    return (UsernamePasswordCredentials) matchedCredentials;
}
 
开发者ID:morficus,项目名称:Parameterized-Remote-Trigger-Plugin,代码行数:22,代码来源:Auth.java

示例6: doFillCredsItems

import com.cloudbees.plugins.credentials.common.StandardUsernameCredentials; //导入依赖的package包/类
public static ListBoxModel doFillCredsItems() {
    StandardUsernameListBoxModel model = new StandardUsernameListBoxModel();

    Item item = Stapler.getCurrentRequest().findAncestorObject(Item.class);

    List<StandardUsernameCredentials> listOfAllCredentails = CredentialsProvider.lookupCredentials(
            StandardUsernameCredentials.class, item, ACL.SYSTEM, Collections.<DomainRequirement> emptyList());

    List<StandardUsernameCredentials> listOfSandardUsernameCredentials = new ArrayList<StandardUsernameCredentials>();

    // since we only care about 'UsernamePasswordCredentials' objects, lets seek those out and ignore the rest.
    for (StandardUsernameCredentials c : listOfAllCredentails) {
        if (c instanceof UsernamePasswordCredentials) {
            listOfSandardUsernameCredentials.add(c);
        }
    }
    model.withAll(listOfSandardUsernameCredentials);

    return model;
}
 
开发者ID:morficus,项目名称:Parameterized-Remote-Trigger-Plugin,代码行数:21,代码来源:Auth.java

示例7: doFillCredentialsIdItems

import com.cloudbees.plugins.credentials.common.StandardUsernameCredentials; //导入依赖的package包/类
/**
 * Populates the list of credentials in the select box in CodeScene API configuration section
 * Inspired by git plugin:
 * https://github.com/jenkinsci/git-plugin/blob/f58648e9005293ab07b2389212603ff9a460b80a/src/main/java/jenkins/plugins/git/GitSCMSource.java#L239
 */
public ListBoxModel doFillCredentialsIdItems(@AncestorInPath Jenkins context, @QueryParameter String credentialsId) {
    if (context == null || !context.hasPermission(Item.CONFIGURE)) {
        return new StandardListBoxModel().includeCurrentValue(credentialsId);
    }
    return new StandardListBoxModel()
            .includeEmptyValue()
            .includeMatchingAs(
                    context instanceof Queue.Task ? Tasks.getAuthenticationOf((Queue.Task)context) : ACL.SYSTEM,
                    context,
                    StandardUsernameCredentials.class,
                    Collections.<DomainRequirement>emptyList(),
                    CredentialsMatchers.always())
            .includeCurrentValue(credentialsId);
}
 
开发者ID:empear-analytics,项目名称:codescene-jenkins-plugin,代码行数:20,代码来源:CodeSceneBuilder.java

示例8: doFillCredentialsIdItems

import com.cloudbees.plugins.credentials.common.StandardUsernameCredentials; //导入依赖的package包/类
@Restricted(NoExternalUse.class)
@SuppressWarnings("unused") // stapler form binding
public ListBoxModel doFillCredentialsIdItems(@CheckForNull @AncestorInPath Item context,
                                             @QueryParameter String serverUrl,
                                             @QueryParameter String credentialsId) {
    StandardListBoxModel result = new StandardListBoxModel();
    if (context == null) {
        if (!Jenkins.getActiveInstance().hasPermission(Jenkins.ADMINISTER)) {
            // must have admin if you want the list without a context
            result.includeCurrentValue(credentialsId);
            return result;
        }
    } else {
        if (!context.hasPermission(Item.EXTENDED_READ)
                && !context.hasPermission(CredentialsProvider.USE_ITEM)) {
            // must be able to read the configuration or use the item credentials if you want the list
            result.includeCurrentValue(credentialsId);
            return result;
        }
    }
    result.add(Messages.SSHCheckoutTrait_useAgentKey(), "");
    result.includeMatchingAs(
            context instanceof Queue.Task ?
                    Tasks.getDefaultAuthenticationOf((Queue.Task) context)
                    : ACL.SYSTEM,
            context,
            StandardUsernameCredentials.class,
            URIRequirementBuilder.fromUri(serverUrl).build(),
            CredentialsMatchers.instanceOf(SSHUserPrivateKey.class)
    );
    return result;
}
 
开发者ID:jenkinsci,项目名称:gitea-plugin,代码行数:33,代码来源:SSHCheckoutTrait.java

示例9: doCheckCredentialsId

import com.cloudbees.plugins.credentials.common.StandardUsernameCredentials; //导入依赖的package包/类
/**
 * Validation for checkout credentials.
 *
 * @param context   the context.
 * @param serverUrl the server url.
 * @param value     the current selection.
 * @return the validation results
 */
@Restricted(NoExternalUse.class)
@SuppressWarnings("unused") // stapler form binding
public FormValidation doCheckCredentialsId(@CheckForNull @AncestorInPath Item context,
                                           @QueryParameter String serverUrl,
                                           @QueryParameter String value) {
    if (context == null
            ? !Jenkins.getActiveInstance().hasPermission(Jenkins.ADMINISTER)
            : !context.hasPermission(Item.EXTENDED_READ)) {
        return FormValidation.ok();
    }
    if (StringUtils.isBlank(value)) {
        // use agent key
        return FormValidation.ok();
    }
    if (CredentialsMatchers.firstOrNull(CredentialsProvider
                    .lookupCredentials(SSHUserPrivateKey.class, context, context instanceof Queue.Task
                            ? Tasks.getDefaultAuthenticationOf((Queue.Task) context)
                            : ACL.SYSTEM, URIRequirementBuilder.fromUri(serverUrl).build()),
            CredentialsMatchers.withId(value)) != null) {
        return FormValidation.ok();
    }
    if (CredentialsMatchers.firstOrNull(CredentialsProvider
                    .lookupCredentials(StandardUsernameCredentials.class, context, context instanceof Queue.Task
                            ? Tasks.getDefaultAuthenticationOf((Queue.Task) context)
                            : ACL.SYSTEM, URIRequirementBuilder.fromUri(serverUrl).build()),
            CredentialsMatchers.withId(value)) != null) {
        return FormValidation.error(Messages.SSHCheckoutTrait_incompatibleCredentials());
    }
    return FormValidation.warning(Messages.SSHCheckoutTrait_missingCredentials());
}
 
开发者ID:jenkinsci,项目名称:gitea-plugin,代码行数:39,代码来源:SSHCheckoutTrait.java

示例10: doFillCredentialsIdItems

import com.cloudbees.plugins.credentials.common.StandardUsernameCredentials; //导入依赖的package包/类
/**
 * This method is called to populate the credentials list on the Jenkins config page.
 */
public ListBoxModel doFillCredentialsIdItems(@AncestorInPath ItemGroup context,
                                             @QueryParameter("target") final String target) {
    StandardListBoxModel result = new StandardListBoxModel();
    result.includeEmptyValue();
    result.withMatching(CredentialsMatchers.instanceOf(StandardUsernamePasswordCredentials.class),
            CredentialsProvider.lookupCredentials(
                    StandardUsernameCredentials.class,
                    context,
                    ACL.SYSTEM,
                    URIRequirementBuilder.fromUri(target).build()
            )
    );
    return result;
}
 
开发者ID:IBM,项目名称:ibm-cloud-devops,代码行数:18,代码来源:PublishSQ.java

示例11: doFillCredentialsIdItems

import com.cloudbees.plugins.credentials.common.StandardUsernameCredentials; //导入依赖的package包/类
/**
 * This method is called to populate the credentials list on the Jenkins
 * config page.
 */
public ListBoxModel doFillCredentialsIdItems(@AncestorInPath ItemGroup context,
		@QueryParameter("target") final String target) {
	StandardListBoxModel result = new StandardListBoxModel();
	result.includeEmptyValue();
	result.withMatching(CredentialsMatchers.instanceOf(StandardUsernamePasswordCredentials.class),
			CredentialsProvider.lookupCredentials(StandardUsernameCredentials.class, context, ACL.SYSTEM,
					URIRequirementBuilder.fromUri(target).build()));
	return result;
}
 
开发者ID:IBM,项目名称:ibm-cloud-devops,代码行数:14,代码来源:PublishDeploy.java

示例12: doCheckCredentialsId

import com.cloudbees.plugins.credentials.common.StandardUsernameCredentials; //导入依赖的package包/类
public FormValidation doCheckCredentialsId(
    @AncestorInPath Item context, @QueryParameter String remote, @QueryParameter String value) {
  if (context == null && !Jenkins.getActiveInstance().hasPermission(Jenkins.ADMINISTER)
      || context != null && !context.hasPermission(Item.EXTENDED_READ)) {
    return FormValidation.ok();
  }

  value = Util.fixEmptyAndTrim(value);
  if (value == null) {
    return FormValidation.ok();
  }

  remote = Util.fixEmptyAndTrim(remote);
  if (remote == null)
  // not set, can't check
  {
    return FormValidation.ok();
  }

  for (ListBoxModel.Option o :
      CredentialsProvider.listCredentials(
          StandardUsernameCredentials.class,
          context,
          context instanceof Queue.Task
              ? Tasks.getAuthenticationOf((Queue.Task) context)
              : ACL.SYSTEM,
          URIRequirementBuilder.fromUri(remote).build(),
          GitClient.CREDENTIALS_MATCHER)) {
    if (StringUtils.equals(value, o.value)) {
      // TODO check if this type of credential is acceptable to the Git client or does it merit warning
      // NOTE: we would need to actually lookup the credential to do the check, which may require
      // fetching the actual credential instance from a remote credentials store. Perhaps this is
      // not required
      return FormValidation.ok();
    }
  }
  // no credentials available, can't check
  return FormValidation.warning("Cannot find any credentials with id " + value);
}
 
开发者ID:GerritForge,项目名称:gerrit-plugin,代码行数:40,代码来源:GerritSCMSource.java

示例13: apply

import com.cloudbees.plugins.credentials.common.StandardUsernameCredentials; //导入依赖的package包/类
@Override
public String apply(@Nullable Entry<String, StandardUsernameCredentials> entry) {
    if (entry == null)
        return null;
    String mavenServerId = entry.getKey();
    StandardUsernameCredentials credentials = entry.getValue();
    return "[" +
            "mavenServerId: '" + mavenServerId + "', " +
            "jenkinsCredentials: '" + credentials.getId() + "', " +
            "username: '" + credentials.getUsername() + "', " +
            "type: '" + ClassUtils.getShortName(credentials.getClass()) +
            "']";
}
 
开发者ID:jenkinsci,项目名称:pipeline-maven-plugin,代码行数:14,代码来源:WithMavenStepExecution.java

示例14: perform

import com.cloudbees.plugins.credentials.common.StandardUsernameCredentials; //导入依赖的package包/类
@Override
public void perform(@Nonnull Run<?, ?> run, @Nonnull FilePath ws, @Nonnull Launcher launcher, @Nonnull TaskListener listener) throws InterruptedException, IOException {
    try {
        CLIRunner runner = new CLIRunner(run, ws, launcher, listener);
        Computer computer = Computer.currentComputer();
        if (computer == null) {
            throw new AbortException("The ansible playbook build step requires to be launched on a node");
        }
        String exe = AnsibleInstallation.getExecutable(ansibleName, AnsibleCommand.ANSIBLE, computer.getNode(), listener, run.getEnvironment(listener));
        AnsibleAdHocCommandInvocation invocation = new AnsibleAdHocCommandInvocation(exe, run, ws, listener);
        invocation.setHostPattern(hostPattern);
        invocation.setInventory(inventory);
        invocation.setModule(module);
        invocation.setModuleCommand(command);
        invocation.setSudo(sudo, sudoUser);
        invocation.setForks(forks);
        invocation.setCredentials(StringUtils.isNotBlank(credentialsId) ?
                CredentialsProvider.findCredentialById(credentialsId, StandardUsernameCredentials.class, run) :
                null);
        invocation.setAdditionalParameters(additionalParameters);
        invocation.setHostKeyCheck(hostKeyChecking);
        invocation.setUnbufferedOutput(unbufferedOutput);
        invocation.setColorizedOutput(colorizedOutput);
        if (!invocation.execute(runner)) {
            throw new AbortException("Ansible Ad-Hoc command execution failed");
        }
    } catch (IOException ioe) {
        Util.displayIOException(ioe, listener);
        ioe.printStackTrace(listener.fatalError(hudson.tasks.Messages.CommandInterpreter_CommandFailed()));
        throw ioe;
    } catch (AnsibleInvocationException aie) {
        listener.fatalError(aie.getMessage());
        throw new AbortException(aie.getMessage());
    }
}
 
开发者ID:jcsirot,项目名称:ansible-plugin,代码行数:36,代码来源:AnsibleAdHocCommandBuilder.java

示例15: doFillCredentialsIdItems

import com.cloudbees.plugins.credentials.common.StandardUsernameCredentials; //导入依赖的package包/类
public ListBoxModel doFillCredentialsIdItems(@AncestorInPath Project project) {
    return new StandardListBoxModel()
        .withEmptySelection()
        .withMatching(anyOf(
            instanceOf(SSHUserPrivateKey.class),
            instanceOf(UsernamePasswordCredentials.class)),
            CredentialsProvider.lookupCredentials(StandardUsernameCredentials.class, project));
}
 
开发者ID:jcsirot,项目名称:ansible-plugin,代码行数:9,代码来源:AnsiblePlaybookStep.java


注:本文中的com.cloudbees.plugins.credentials.common.StandardUsernameCredentials类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。