Java 类org.kohsuke.stapler.AncestorInPath 实例源码

项目:ibm-cloud-devops    文件:EvaluateGate.java   
/**
 * This method is called to populate the policy list on the Jenkins config page.
 * @param context
 * @param orgName
 * @param credentialsId
 * @return
 */
public ListBoxModel doFillPolicyNameItems(@AncestorInPath ItemGroup context,
                                          @QueryParameter final String orgName,
                                          @QueryParameter final String toolchainName,
                                          @QueryParameter final String credentialsId) {
    String targetAPI = chooseTargetAPI(environment);
    try {
        // if user changes to a different credential, need to get a new token
        if (!credentialsId.equals(preCredentials) || Util.isNullOrEmpty(bluemixToken)) {
            bluemixToken = getBluemixToken(context, credentialsId, targetAPI);
            preCredentials = credentialsId;
        }
    } catch (Exception e) {
        return new ListBoxModel();
    }
    if(debug_mode){
        LOGGER.info("#######GATE : calling getPolicyList#######");
    }
    return getPolicyList(bluemixToken, orgName, toolchainName, environment, debug_mode);

}
项目:azure-cli-plugin    文件:AzureCLIBuilder.java   
public ListBoxModel doFillPrincipalCredentialIdItems(
        @AncestorInPath Item item,
        @QueryParameter String credentialsId) {
    StandardListBoxModel result = new StandardListBoxModel();
    if (item == null) {
        if (!Jenkins.getActiveInstance().hasPermission(Jenkins.ADMINISTER)) {
            return result.includeCurrentValue(credentialsId);
        }
    } else {
        if (!item.hasPermission(Item.EXTENDED_READ)
                && !item.hasPermission(CredentialsProvider.USE_ITEM)) {
            return result.includeCurrentValue(credentialsId);
        }
    }
    List<AzureCredentials> creds = CredentialsProvider.lookupCredentials(AzureCredentials.class, item, ACL.SYSTEM, Collections.<DomainRequirement>emptyList());
    for (AzureCredentials cred
            :
            creds) {
        result.add(cred.getId());
    }
    return result.includeEmptyValue()
            .includeCurrentValue(credentialsId);
}
项目:mirrorgate-jenkins-builds-collector    文件:MirrorGatePublisher.java   
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);
}
项目:mirrorgate-jenkins-builds-collector    文件:MirrorGatePublisher.java   
public FormValidation doCheckMirrorgateCredentialsId(
        @AncestorInPath Item item,
        @QueryParameter("mirrorgateCredentialsId") String credentialsId) {

    if (item == null) {
        if (!Jenkins.getInstance().hasPermission(Jenkins.ADMINISTER)) {
            return FormValidation.ok();
        }
    } else if (!item.hasPermission(Item.EXTENDED_READ)
            && !item.hasPermission(CredentialsProvider.USE_ITEM)) {
        return FormValidation.ok();
    }
    if (StringUtils.isBlank(credentialsId)) {
        return FormValidation.ok();
    }
    if (credentialsId.startsWith("${") && credentialsId.endsWith("}")) {
        return FormValidation.warning(
                "Cannot validate expression based credentials");
    }
    return FormValidation.ok();
}
项目:gitlab-branch-source-plugin    文件:GitLabSCMSourceSettings.java   
@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
    );
}
项目:CPWR-CodeCoverage    文件:CodeCoverageBuilder.java   
/**
 * Fills in the Host Connection selection box with applicable connections.
 * 
 * @param context
 *            filter for host connections
 * @param connectionId
 *            an existing host connection identifier; can be null
 * @param project
 *            the Jenkins project
 * 
 * @return host connection selections
 */
public ListBoxModel doFillConnectionIdItems(@AncestorInPath Jenkins context, @QueryParameter String connectionId,
        @AncestorInPath Item project)
{
    CpwrGlobalConfiguration globalConfig = CpwrGlobalConfiguration.get();
    HostConnection[] hostConnections = globalConfig.getHostConnections();

    ListBoxModel model = new ListBoxModel();
    model.add(new Option(StringUtils.EMPTY, StringUtils.EMPTY, false));

    for (HostConnection connection : hostConnections)
    {
        boolean isSelected = false;
        if (connectionId != null)
        {
            isSelected = connectionId.matches(connection.getConnectionId());
        }

        model.add(new Option(connection.getDescription() + " [" + connection.getHostPort() + ']', //$NON-NLS-1$
                connection.getConnectionId(), isSelected));
    }

    return model;
}
项目:CPWR-CodeCoverage    文件:CodeCoverageBuilder.java   
/**
 * 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;
}
项目:compuware-scm-downloader-plugin    文件:PdsConfiguration.java   
/**
 * Fills in the Host Connection selection box with applicable connections.
 * 
 * @param context
 *            filter for host connections
 * @param connectionId
 *            an existing host connection identifier; can be null
 * @param project
 *            the Jenkins project
 * 
 * @return host connection selections
 */
public ListBoxModel doFillConnectionIdItems(@AncestorInPath Jenkins context, @QueryParameter String connectionId,
        @AncestorInPath Item project)
{
    CpwrGlobalConfiguration globalConfig = CpwrGlobalConfiguration.get();
    HostConnection[] hostConnections = globalConfig.getHostConnections();

    ListBoxModel model = new ListBoxModel();
    model.add(new Option(StringUtils.EMPTY, StringUtils.EMPTY, false));

    for (HostConnection connection : hostConnections)
    {
        boolean isSelected = false;
        if (connectionId != null)
        {
            isSelected = connectionId.matches(connection.getConnectionId());
        }

        model.add(new Option(connection.getDescription() + " [" + connection.getHostPort() + ']', //$NON-NLS-1$
                connection.getConnectionId(), isSelected));
    }

    return model;
}
项目:compuware-scm-downloader-plugin    文件:PdsConfiguration.java   
/**
 * 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;
}
项目:compuware-scm-downloader-plugin    文件:EndevorConfiguration.java   
/**
 * Fills in the Host Connection selection box with applicable connections.
 * 
 * @param context
 *            filter for host connections
 * @param connectionId
 *            an existing host connection identifier; can be null
 * @param project
 *            the Jenkins project
 * 
 * @return host connection selections
 */
public ListBoxModel doFillConnectionIdItems(@AncestorInPath Jenkins context, @QueryParameter String connectionId,
        @AncestorInPath Item project)
{
    CpwrGlobalConfiguration globalConfig = CpwrGlobalConfiguration.get();
    HostConnection[] hostConnections = globalConfig.getHostConnections();

    ListBoxModel model = new ListBoxModel();
    model.add(new Option(StringUtils.EMPTY, StringUtils.EMPTY, false));

    for (HostConnection connection : hostConnections)
    {
        boolean isSelected = false;
        if (connectionId != null)
        {
            isSelected = connectionId.matches(connection.getConnectionId());
        }

        model.add(new Option(connection.getDescription() + " [" + connection.getHostPort() + ']', //$NON-NLS-1$
                connection.getConnectionId(), isSelected));
    }

    return model;
}
项目:compuware-scm-downloader-plugin    文件:EndevorConfiguration.java   
/**
 * 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;
}
项目:compuware-scm-downloader-plugin    文件:IspwConfiguration.java   
/**
 * Fills in the Host Connection selection box with applicable connections.
 * 
 * @param context
 *            filter for host connections
 * @param connectionId
 *            an existing host connection identifier; can be null
 * @param project
 *            the Jenkins project
 * 
 * @return host connection selections
 */
public ListBoxModel doFillConnectionIdItems(@AncestorInPath Jenkins context, @QueryParameter String connectionId,
        @AncestorInPath Item project)
{
    CpwrGlobalConfiguration globalConfig = CpwrGlobalConfiguration.get();
    HostConnection[] hostConnections = globalConfig.getHostConnections();

    ListBoxModel model = new ListBoxModel();
    model.add(new Option(StringUtils.EMPTY, StringUtils.EMPTY, false));

    for (HostConnection connection : hostConnections)
    {
        boolean isSelected = false;
        if (connectionId != null)
        {
            isSelected = connectionId.matches(connection.getConnectionId());
        }

        model.add(new Option(connection.getDescription() + " [" + connection.getHostPort() + ']', //$NON-NLS-1$
                connection.getConnectionId(), isSelected));
    }

    return model;
}
项目:browserstack-integration-plugin    文件:BrowserStackBuildWrapperDescriptor.java   
public FormValidation doCheckLocalPath(@AncestorInPath final AbstractProject project,
                                       @QueryParameter final String localPath) {
    final String path = Util.fixEmptyAndTrim(localPath);
    if (StringUtils.isBlank(path)) {
        return FormValidation.ok();
    }

    try {
        File f = resolvePath(project, localPath);
        if (f != null) {
            return FormValidation.ok();
        }
    } catch (Exception e) {
        return FormValidation.error(e.getMessage());
    }

    return FormValidation.error("Invalid path.");
}
项目:bitbucket-build-status-notifier-plugin    文件:BitbucketBuildStatusNotifier.java   
public FormValidation doCheckCredentialsId(@QueryParameter final String credentialsId,
                                           @AncestorInPath final Job<?,?> owner) {
    String globalCredentialsId = this.getGlobalCredentialsId();

    if (credentialsId == null || credentialsId.isEmpty()) {
        if (globalCredentialsId == null || globalCredentialsId.isEmpty()) {
            return FormValidation.error("Please enter Bitbucket OAuth credentials");
        } else {
            return this.doCheckGlobalCredentialsId(this.getGlobalCredentialsId());
        }
    }

    UsernamePasswordCredentials credentials = BitbucketBuildStatusHelper.getCredentials(credentialsId, owner);

    return this.checkCredentials(credentials);
}
项目:compuware-scm-downloader-plugin    文件:PdsConfiguration.java   
/**
 * Fills in the Host Connection selection box with applicable connections.
 * 
 * @param context
 *            filter for host connections
 * @param connectionId
 *            an existing host connection identifier; can be null
 * @param project
 *            the Jenkins project
 * 
 * @return host connection selections
 */
public ListBoxModel doFillConnectionIdItems(@AncestorInPath Jenkins context, @QueryParameter String connectionId,
        @AncestorInPath Item project)
{
    CpwrGlobalConfiguration globalConfig = CpwrGlobalConfiguration.get();
    HostConnection[] hostConnections = globalConfig.getHostConnections();

    ListBoxModel model = new ListBoxModel();
    model.add(new Option(StringUtils.EMPTY, StringUtils.EMPTY, false));

    for (HostConnection connection : hostConnections)
    {
        boolean isSelected = false;
        if (connectionId != null)
        {
            isSelected = connectionId.matches(connection.getConnectionId());
        }

        model.add(new Option(connection.getDescription() + " [" + connection.getHostPort() + ']', //$NON-NLS-1$
                connection.getConnectionId(), isSelected));
    }

    return model;
}
项目:compuware-scm-downloader-plugin    文件:PdsConfiguration.java   
/**
 * 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;
}
项目:compuware-scm-downloader-plugin    文件:EndevorConfiguration.java   
/**
 * Fills in the Host Connection selection box with applicable connections.
 * 
 * @param context
 *            filter for host connections
 * @param connectionId
 *            an existing host connection identifier; can be null
 * @param project
 *            the Jenkins project
 * 
 * @return host connection selections
 */
public ListBoxModel doFillConnectionIdItems(@AncestorInPath Jenkins context, @QueryParameter String connectionId,
        @AncestorInPath Item project)
{
    CpwrGlobalConfiguration globalConfig = CpwrGlobalConfiguration.get();
    HostConnection[] hostConnections = globalConfig.getHostConnections();

    ListBoxModel model = new ListBoxModel();
    model.add(new Option(StringUtils.EMPTY, StringUtils.EMPTY, false));

    for (HostConnection connection : hostConnections)
    {
        boolean isSelected = false;
        if (connectionId != null)
        {
            isSelected = connectionId.matches(connection.getConnectionId());
        }

        model.add(new Option(connection.getDescription() + " [" + connection.getHostPort() + ']', //$NON-NLS-1$
                connection.getConnectionId(), isSelected));
    }

    return model;
}
项目:compuware-scm-downloader-plugin    文件:EndevorConfiguration.java   
/**
 * 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;
}
项目:compuware-scm-downloader-plugin    文件:IspwConfiguration.java   
/**
 * Fills in the Host Connection selection box with applicable connections.
 * 
 * @param context
 *            filter for host connections
 * @param connectionId
 *            an existing host connection identifier; can be null
 * @param project
 *            the Jenkins project
 * 
 * @return host connection selections
 */
public ListBoxModel doFillConnectionIdItems(@AncestorInPath Jenkins context, @QueryParameter String connectionId,
        @AncestorInPath Item project)
{
    CpwrGlobalConfiguration globalConfig = CpwrGlobalConfiguration.get();
    HostConnection[] hostConnections = globalConfig.getHostConnections();

    ListBoxModel model = new ListBoxModel();
    model.add(new Option(StringUtils.EMPTY, StringUtils.EMPTY, false));

    for (HostConnection connection : hostConnections)
    {
        boolean isSelected = false;
        if (connectionId != null)
        {
            isSelected = connectionId.matches(connection.getConnectionId());
        }

        model.add(new Option(connection.getDescription() + " [" + connection.getHostPort() + ']', //$NON-NLS-1$
                connection.getConnectionId(), isSelected));
    }

    return model;
}
项目:phabricator-jenkins-plugin    文件:ConduitCredentialsDescriptor.java   
public static ListBoxModel doFillCredentialsIDItems(@AncestorInPath Jenkins context) {
    if (context == null || !context.hasPermission(Item.CONFIGURE)) {
        return new StandardListBoxModel();
    }

    List<DomainRequirement> domainRequirements = new ArrayList<DomainRequirement>();
    return new StandardListBoxModel()
            .withEmptySelection()
            .withMatching(
                    CredentialsMatchers.anyOf(
                            CredentialsMatchers.instanceOf(ConduitCredentials.class)),
                    CredentialsProvider.lookupCredentials(
                            StandardCredentials.class,
                            context,
                            ACL.SYSTEM,
                            domainRequirements));
}
项目:docker-commons-plugin    文件:DockerRegistryEndpoint.java   
public ListBoxModel doFillCredentialsIdItems(@AncestorInPath Item item) {
    if (item == null && !Jenkins.getActiveInstance().hasPermission(Jenkins.ADMINISTER) ||
        item != null && !item.hasPermission(Item.EXTENDED_READ)) {
        return new StandardListBoxModel();
    }
    // TODO may also need to specify a specific authentication and domain requirements
    return new StandardListBoxModel()
            .withEmptySelection()
            .withMatching(AuthenticationTokens.matcher(DockerRegistryToken.class),
                    CredentialsProvider.lookupCredentials(
                            StandardCredentials.class,
                            item,
                            null,
                            Collections.<DomainRequirement>emptyList()
                    )
            );
}
项目:latch-plugin-jenkins    文件:LatchAccountProperty.java   
public FormValidation doLatchPairConnection(@QueryParameter("pairToken") final String pairToken,
                                            @AncestorInPath User user,
                                            @QueryParameter("csrf") final String csrf) throws IOException {
    if (validCSRF(csrf)) {
        if (pairToken != null && !pairToken.isEmpty()) {
            LatchApp latchApp = LatchSDK.getInstance();
            if (latchApp != null) {
                LatchResponse pairResponse = latchApp.pair(pairToken);

                if (pairResponse == null) {
                    return FormValidation.error(Messages.LatchAccountProperty_UnreachableConnection());
                } else if (pairResponse.getError() != null && pairResponse.getError().getCode() != 205) {
                    return FormValidation.error(Messages.LatchAccountProperty_Invalid_Token());
                } else {
                    LatchAccountProperty lap = newInstance(user);
                    lap.accountId = pairResponse.getData().get("accountId").getAsString();
                    user.addProperty(lap);
                    return FormValidation.ok(Messages.LatchAccountProperty_Pair());
                }
            }
            return FormValidation.ok(Messages.LatchAccountProperty_PluginDisabled());
        }
        return FormValidation.error(Messages.LatchAccountProperty_Invalid_Token());
    }
    return FormValidation.error(Messages.LatchAccountProperty_Csrf());
}
项目:latch-plugin-jenkins    文件:LatchAccountProperty.java   
public FormValidation doLatchUnpairConnection(@AncestorInPath User user,
                                              @QueryParameter("csrf") final String csrf) throws IOException {
    if (validCSRF(csrf)) {
        LatchAccountProperty lap = user.getProperty(LatchAccountProperty.class);
        LatchApp latchApp = LatchSDK.getInstance();
        if (latchApp != null) {
            LatchResponse unpairResponse = latchApp.unpair(lap.getAccountId());

            if (unpairResponse == null) {
                return FormValidation.error(Messages.LatchAccountProperty_UnreachableConnection());
            } else if (unpairResponse.getError() != null && unpairResponse.getError().getCode() != 201) {
                return FormValidation.error(unpairResponse.getError().getMessage());
            } else {
                lap.accountId = null;
                lap.user.save();
                return FormValidation.ok(Messages.LatchAccountProperty_Unpair());
            }
        }
        return FormValidation.ok(Messages.LatchAccountProperty_PluginDisabled());
    }
    return FormValidation.error(Messages.LatchAccountProperty_Csrf());
}
项目:jenkins-github-pull-request-comments    文件:GhprcGitHubAuth.java   
/**
 * 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)
                    );
}
项目:jenkins-kubernetes-plugin    文件:KubectlBuildWrapper.java   
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()
                    )
            );

}
项目:ravello-jenkins-plugin    文件:RavelloBlueprintPublisher.java   
public ListBoxModel doFillPreferredRegionItems(@QueryParameter String preferredCloud, @AncestorInPath ItemGroup context) {
    ListBoxModel box = new ListBoxModel();

    if (preferredCloud.equals("GOOGLE")){
        box.add("us-central1", "us-central1");
        box.add("europe-west1", "europe-west1");

    }else if(preferredCloud.equals("AMAZON")){
        box.add("Virginia", "Virginia");
        box.add("Oregon", "Oregon");
        box.add("Ireland", "Ireland");
        box.add("Sao Paulo", "Sao Paulo");
        box.add("Singapore", "Singapore");
        box.add("Sydney", "Sydney");
        box.add("Tokyo", "Tokyo");
    }

    return box;
}
项目:cloudfoundry-jenkins    文件:CloudFoundryPushPublisher.java   
/**
 * 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;
}
项目:docker-plugin    文件:DockerTemplateBase.java   
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)
            );
        }
项目:xldeploy-plugin    文件:DeployitNotifier.java   
public AutoCompletionCandidates doAutoCompleteApplication(@QueryParameter final String value, @AncestorInPath AbstractProject project) {
    String resolvedApplicationName = expandValue(value, project);
    final AutoCompletionCandidates applicationCadidates = new AutoCompletionCandidates();

    final String applicationName = DeployitServerFactory.getNameFromId(resolvedApplicationName);
    DeployitNotifier deployitNotifier = RepositoryUtils.retrieveDeployitNotifierFromProject(project);
    if (deployitNotifier != null) {
        Credential overridingcredential = RepositoryUtils.retrieveOverridingCredentialFromProject(project);

        DeployitServer deployitServer = RepositoryUtils.getDeployitServer(deployitNotifier.credential, overridingcredential);
        if (null != deployitServer) {
            List<String> applicationSuggestions = deployitServer.search(DeployitDescriptorRegistry.UDM_APPLICATION, applicationName + "%");
            for (String applicationSuggestion : applicationSuggestions) {
                applicationCadidates.add(applicationSuggestion);
            }
        }

    }
    return applicationCadidates;
}
项目:xldeploy-plugin    文件:DeployitNotifier.java   
public FormValidation doCheckApplication(@QueryParameter String credential, @QueryParameter final String value, @AncestorInPath AbstractProject project)
{
    if ("Applications/".equals(value))
        return ok("Fill in the application ID, eg Applications/PetClinic");

    String resolvedName = expandValue(value, project);
    final String applicationName = DeployitServerFactory.getNameFromId(resolvedName);

    Credential overridingcredential = RepositoryUtils.retrieveOverridingCredentialFromProject(project);
    DeployitServer deployitServer = RepositoryUtils.getDeployitServer(credential, overridingcredential);
    List<String> candidates = deployitServer.search(DeployitDescriptorRegistry.UDM_APPLICATION, applicationName + "%");
    for (String candidate : candidates) {
        if (candidate.endsWith("/" + applicationName)) {
            return ok();
        }
    }
    if (!candidates.isEmpty()) {
        return warning("Application does not exist, but will be created upon package import. Did you mean to type one of the following: %s?",
            candidates);
    }
    return warning("Application does not exist, but will be created upon package import.");
}
项目:awseb-deployment-plugin    文件:AWSEBDeploymentBuilder.java   
public AbstractIdCredentialsListBoxModel<?, ?> doFillCredentialIdItems(
        @AncestorInPath Item owner) {
    if (owner == null || !owner.hasPermission(Item.CONFIGURE)) {
        return new AWSCredentialsListBoxModel();
    }

    List<AmazonWebServicesCredentials>
            creds =
            CredentialsProvider
                    .lookupCredentials(AmazonWebServicesCredentials.class, owner, ACL.SYSTEM,
                            Collections.<DomainRequirement>emptyList());

    return new AWSCredentialsListBoxModel()
            .withEmptySelection()
            .withAll(creds);
}
项目:credentials-binding-plugin    文件:ZipFileBinding.java   
public FormValidation doCheckCredentialsId(@AncestorInPath Item owner, @QueryParameter String value) {
    for (FileCredentials c : CredentialsProvider.lookupCredentials(FileCredentials.class, owner, null, Collections.<DomainRequirement>emptyList())) {
        if (c.getId().equals(value)) {
            InputStream is = null;
            try {
                is = c.getContent();
                byte[] data = new byte[4];
                if (is.read(data) == 4 && data[0] == 'P' && data[1] == 'K' && data[2] == 3 && data[3] == 4) {
                    return FormValidation.ok();
                } else {
                    return FormValidation.error(Messages.ZipFileBinding_NotZipFile());
                }
            } catch (IOException x) {
                return FormValidation.warning(Messages.ZipFileBinding_CouldNotVerifyFileFormat());
            }
            finally {
                if (is != null) {
                    IOUtils.closeQuietly(is);
                }
            }
        }
    }
    return FormValidation.error(Messages.ZipFileBinding_NoSuchCredentials());
}
项目:jenkins-scala-plugin    文件:ForkedScalaBuilder.java   
public FormValidation doCheckPort(final StaplerRequest req,
    @AncestorInPath final AbstractProject context,
    @QueryParameter final String value) {

    FormValidation validationResult;
    try {
        final int port = Integer.parseInt(value);
        if(port < 1 || port > 65535) {
            validationResult = FormValidation.error("The entered TCP Port must be between 1 and 65,535 inclusive! Please enter a valid TCP Port number...");
        } else {
            validationResult = FormValidation.ok();
        }
    } catch(final NumberFormatException nfe) {
        validationResult = FormValidation.error("The entered TCP Port is not a valid number! Please enter a valid TCP Port number...");
    }
    return validationResult;
}
项目:jenkins-scala-plugin    文件:FileScriptSource.java   
public FormValidation doCheckScriptFile(final StaplerRequest req,
    @AncestorInPath final AbstractProject context,
    @QueryParameter final String value) {

    FormValidation validationResult;
    try {
        if(new FilePath(new File(value)).exists()) {
            validationResult = FormValidation.ok();
        } else {
           validationResult = FormValidation.error(String.format("The file '%s' does not exist!", value)); 
        }
    } catch(final IOException ioe) {
        validationResult = FormValidation.error(String.format("The entered File path is invalid: %s", ioe.getMessage()));
    } catch(final InterruptedException ie) {
        validationResult = FormValidation.error(String.format("Could not process the entered File path: %s", ie.getMessage()));
    }
    return validationResult;
}
项目:codescene-jenkins-plugin    文件:CodeSceneBuilder.java   
/**
 * 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);
}
项目:gitea-plugin    文件:GiteaSCMNavigator.java   
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;
}
项目:gitea-plugin    文件:GiteaSCMNavigator.java   
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();
}
项目:gitea-plugin    文件:SSHCheckoutTrait.java   
@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;
}
项目:gitea-plugin    文件:SSHCheckoutTrait.java   
/**
 * 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());
}
项目:gitea-plugin    文件:GiteaSCMSource.java   
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;
}