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


Java URIRequirementBuilder类代码示例

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


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

示例1: doFillCredentialsIdItems

import com.cloudbees.plugins.credentials.domains.URIRequirementBuilder; //导入依赖的package包/类
/**
 * Stapler form completion.
 *
 * @param serverUrl the server URL.
 * @return the available credentials.
 */
@Restricted(NoExternalUse.class) // stapler
@SuppressWarnings("unused")
public ListBoxModel doFillCredentialsIdItems(@QueryParameter String serverUrl) {
    Jenkins.getActiveInstance().checkPermission(Jenkins.ADMINISTER);
    StandardListBoxModel result = new StandardListBoxModel();
    serverUrl = GiteaServers.normalizeServerUrl(serverUrl);
    result.includeMatchingAs(
            ACL.SYSTEM,
            Jenkins.getActiveInstance(),
            StandardCredentials.class,
            URIRequirementBuilder.fromUri(serverUrl).build(),
            AuthenticationTokens.matcher(GiteaAuth.class)
    );
    return result;
}
 
开发者ID:jenkinsci,项目名称:gitea-plugin,代码行数:22,代码来源:GiteaServer.java

示例2: doFillCredentialsIdItems

import com.cloudbees.plugins.credentials.domains.URIRequirementBuilder; //导入依赖的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

示例3: newKeyMaterialFactory

import com.cloudbees.plugins.credentials.domains.URIRequirementBuilder; //导入依赖的package包/类
/**
 * Makes the key materials available locally and returns {@link KeyMaterialFactory} that gives you the parameters
 * needed to access it.
 */
public KeyMaterialFactory newKeyMaterialFactory(@Nonnull Item context, @Nonnull VirtualChannel target) throws IOException, InterruptedException {
    // as a build step, your access to credentials are constrained by what the build
    // can access, hence Jenkins.getAuthentication()
    DockerServerCredentials creds=null;
    if (credentialsId!=null) {
        List<DomainRequirement> domainRequirements = URIRequirementBuilder.fromUri(getUri()).build();
        domainRequirements.add(new DockerServerDomainRequirement());
        creds = CredentialsMatchers.firstOrNull(
                CredentialsProvider.lookupCredentials(
                        DockerServerCredentials.class, context, Jenkins.getAuthentication(),
                        domainRequirements),
                CredentialsMatchers.withId(credentialsId)
        );
    }

    // the directory needs to be outside workspace to avoid prying eyes
    FilePath dotDocker = dotDocker(target);
    dotDocker.mkdirs();
    // ServerKeyMaterialFactory.materialize creates a random subdir if one is needed:
    return newKeyMaterialFactory(dotDocker, creds);
}
 
开发者ID:jenkinsci,项目名称:docker-commons-plugin,代码行数:26,代码来源:DockerServerEndpoint.java

示例4: doFillCredentialsIdItems

import com.cloudbees.plugins.credentials.domains.URIRequirementBuilder; //导入依赖的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)
                    );
}
 
开发者ID:bratchenko,项目名称:jenkins-github-pull-request-comments,代码行数:26,代码来源:GhprcGitHubAuth.java

示例5: lookupCredentials

import com.cloudbees.plugins.credentials.domains.URIRequirementBuilder; //导入依赖的package包/类
public static StandardCredentials lookupCredentials(Item context, String credentialId, String uri) {
    String contextName = "(Jenkins.instance)";
    if (context != null) {
        contextName = context.getFullName();
    }
    logger.log(Level.INFO, "Looking up credentials for {0}, using context {1} for url {2}", new Object[] { credentialId, contextName, uri });
    
    List<StandardCredentials> credentials;
    
    if (context == null) {
        credentials = CredentialsProvider.lookupCredentials(StandardCredentials.class, Jenkins.getInstance(), ACL.SYSTEM,
                URIRequirementBuilder.fromUri(uri).build());
    } else {
        credentials = CredentialsProvider.lookupCredentials(StandardCredentials.class, context, ACL.SYSTEM,
                URIRequirementBuilder.fromUri(uri).build());
    }
    
    logger.log(Level.INFO, "Found {0} credentials", new Object[]{credentials.size()});
    
    return (credentialId == null) ? null : CredentialsMatchers.firstOrNull(credentials,
                CredentialsMatchers.withId(credentialId));
}
 
开发者ID:bratchenko,项目名称:jenkins-github-pull-request-comments,代码行数:23,代码来源:Ghprc.java

示例6: doFillCredentialsIdItems

import com.cloudbees.plugins.credentials.domains.URIRequirementBuilder; //导入依赖的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()
                    )
            );

}
 
开发者ID:carlossg,项目名称:jenkins-kubernetes-plugin,代码行数:19,代码来源:KubectlBuildWrapper.java

示例7: doFillCredentialsIdItems

import com.cloudbees.plugins.credentials.domains.URIRequirementBuilder; //导入依赖的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 //
                    ));

}
 
开发者ID:carlossg,项目名称:jenkins-kubernetes-plugin,代码行数:19,代码来源:KubernetesCloud.java

示例8: doFillApiTokenIdItems

import com.cloudbees.plugins.credentials.domains.URIRequirementBuilder; //导入依赖的package包/类
public ListBoxModel doFillApiTokenIdItems(@QueryParameter String name, @QueryParameter String url) {
    if (Jenkins.getInstance().hasPermission(Item.CONFIGURE)) {
        AbstractIdCredentialsListBoxModel<StandardListBoxModel, StandardCredentials> options = new StandardListBoxModel()
            .includeEmptyValue()
            .includeMatchingAs(ACL.SYSTEM,
                               Jenkins.getActiveInstance(),
                               StandardCredentials.class,
                               URIRequirementBuilder.fromUri(url).build(),
                               new GitLabCredentialMatcher());
        if (name != null && connectionMap.containsKey(name)) {
            String apiTokenId = connectionMap.get(name).getApiTokenId();
            options.includeCurrentValue(apiTokenId);
            for (ListBoxModel.Option option : options) {
                if (option.value.equals(apiTokenId)) {
                    option.selected = true;
                }
            }
        }
        return options;
    }
    return new StandardListBoxModel();
}
 
开发者ID:jenkinsci,项目名称:gitlab-plugin,代码行数:23,代码来源:GitLabConnectionConfig.java

示例9: doFillCredentialsIdItems

import com.cloudbees.plugins.credentials.domains.URIRequirementBuilder; //导入依赖的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

示例10: credentialsForScm

import com.cloudbees.plugins.credentials.domains.URIRequirementBuilder; //导入依赖的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 "";
}
 
开发者ID:maxbraun,项目名称:job-profiles,代码行数:18,代码来源:JobContextBuilder.java

示例11: credentials

import com.cloudbees.plugins.credentials.domains.URIRequirementBuilder; //导入依赖的package包/类
public StandardCredentials credentials(SCMSourceOwner owner) {
    return CredentialsMatchers.firstOrNull(
            CredentialsProvider.lookupCredentials(
                    StandardCredentials.class,
                    owner,
                    Jenkins.getAuthentication(),
                    URIRequirementBuilder.fromUri(serverUrl).build()
            ),
            CredentialsMatchers.allOf(
                    AuthenticationTokens.matcher(GiteaAuth.class),
                    CredentialsMatchers.withId(credentialsId)
            )
    );
}
 
开发者ID:jenkinsci,项目名称:gitea-plugin,代码行数:15,代码来源:GiteaSCMNavigator.java

示例12: doFillCredentialsIdItems

import com.cloudbees.plugins.credentials.domains.URIRequirementBuilder; //导入依赖的package包/类
public ListBoxModel doFillCredentialsIdItems(@AncestorInPath SCMSourceOwner 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.includeEmptyValue();
    result.includeMatchingAs(
            context instanceof Queue.Task ?
                    Tasks.getDefaultAuthenticationOf((Queue.Task) context)
                    : ACL.SYSTEM,
            context,
            StandardCredentials.class,
            URIRequirementBuilder.fromUri(serverUrl).build(),
            AuthenticationTokens.matcher(GiteaAuth.class)
    );
    return result;
}
 
开发者ID:jenkinsci,项目名称:gitea-plugin,代码行数:31,代码来源:GiteaSCMNavigator.java

示例13: doCheckCredentialsId

import com.cloudbees.plugins.credentials.domains.URIRequirementBuilder; //导入依赖的package包/类
public FormValidation doCheckCredentialsId(@AncestorInPath SCMSourceOwner context,
                                           @QueryParameter String serverUrl,
                                           @QueryParameter String value)
        throws IOException, InterruptedException {
    if (context == null) {
        if (!Jenkins.getActiveInstance().hasPermission(Jenkins.ADMINISTER)) {
            return FormValidation.ok();
        }
    } else {
        if (!context.hasPermission(Item.EXTENDED_READ)
                && !context.hasPermission(CredentialsProvider.USE_ITEM)) {
            return FormValidation.ok();
        }
    }
    GiteaServer server = GiteaServers.get().findServer(serverUrl);
    if (server == null) {
        return FormValidation.ok();
    }
    if (StringUtils.isBlank(value)) {
        return FormValidation.ok();
    }
    if (CredentialsProvider.listCredentials(
            StandardCredentials.class,
            context,
            context instanceof Queue.Task ?
                    Tasks.getDefaultAuthenticationOf((Queue.Task) context)
                    : ACL.SYSTEM,
            URIRequirementBuilder.fromUri(serverUrl).build(),
            CredentialsMatchers.allOf(
                    CredentialsMatchers.withId(value),
                    AuthenticationTokens.matcher(GiteaAuth.class)

            )).isEmpty()) {
        return FormValidation.error(Messages.GiteaSCMNavigator_selectedCredentialsMissing());
    }
    return FormValidation.ok();
}
 
开发者ID:jenkinsci,项目名称:gitea-plugin,代码行数:38,代码来源:GiteaSCMNavigator.java

示例14: doFillCredentialsIdItems

import com.cloudbees.plugins.credentials.domains.URIRequirementBuilder; //导入依赖的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

示例15: doCheckCredentialsId

import com.cloudbees.plugins.credentials.domains.URIRequirementBuilder; //导入依赖的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


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