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

项目:gitea-plugin    文件:GiteaServer.java   
/**
 * 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;
}
项目:gitea-plugin    文件:PersonalAccessTokenImpl.java   
/**
 * Sanity check for a Gitea access token.
 *
 * @param value the token.
 * @return the resulst of the sanity check.
 */
@Restricted(NoExternalUse.class) // stapler
@SuppressWarnings("unused") // stapler
public FormValidation doCheckToken(@QueryParameter String value) {
    Secret secret = Secret.fromString(value);
    if (secret == null) {
        return FormValidation.error(Messages.PersonalAccessTokenImpl_tokenRequired());
    }
    if (StringUtils.equals(value, secret.getPlainText())) {
        if (value.length() != 40) {
            return FormValidation.error(Messages.PersonalAccessTokenImpl_tokenWrongLength());
        }
    } else if (secret.getPlainText().length() != 40) {
        return FormValidation.warning(Messages.PersonalAccessTokenImpl_tokenWrongLength());
    }
    return FormValidation.ok();
}
项目: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);
}
项目:aws-codecommit-trigger-plugin    文件:SQSTrigger.java   
public FormValidation doCheckQueueUuid(@QueryParameter final String value) {
    if (this.getSqsQueues().size() == 0) {
        return FormValidation.error(Messages.errorQueueUnavailable());
    }

    if (StringUtils.isEmpty(value)) {
        return FormValidation.ok(Messages.infoQueueDefault());
    }

    final SQSQueue queue = this.getSqsQueue(value);

    if (queue == null) {
        return FormValidation.error(Messages.errorQueueUuidUnknown());
    }

    return FormValidation.ok();
}
项目:mirrorgate-jenkins-builds-collector    文件:MirrorGatePublisher.java   
public FormValidation doTestConnection(
        @QueryParameter("mirrorGateAPIUrl") final String mirrorGateAPIUrl,
        @QueryParameter("mirrorgateCredentialsId") final String credentialsId)
        throws Descriptor.FormException {
    MirrorGateService testMirrorGateService = getMirrorGateService();
    if (testMirrorGateService != null) {
        MirrorGateResponse response
                = testMirrorGateService.testConnection();
        return response.getResponseCode() == HttpStatus.SC_OK
                ? FormValidation.ok("Success")
                : FormValidation.error("Failure<"
                        + response.getResponseCode() + ">");
    } else {
        return FormValidation.error("Failure");
    }
}
项目: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;
}
项目:vsts-jenkins-build-integration-sample    文件:TfsBuildNotifier.java   
public ListBoxModel doFillProjectItems(@QueryParameter String serverUrl, @QueryParameter String username,
                                       @QueryParameter Secret password) throws URISyntaxException {
    ListBoxModel items = new ListBoxModel();

    if (validInputs(serverUrl, username, password)) {
        try {
            TfsClient client = getTfsClientFactory().getValidatedClient(serverUrl, username, password);
            List<TeamProjectReference> references = client.getProjectClient().getProjects();

            for (TeamProjectReference ref : references) {
                items.add(ref.getName(), String.valueOf(ref.getId()));
            }
        } catch (VssServiceException vse) {
            return items;
        }
    }

    return items;
}
项目:vsts-jenkins-build-integration-sample    文件:TfsBuildNotifier.java   
public ListBoxModel doFillBuildDefinitionItems(@QueryParameter String serverUrl,  @QueryParameter String username,
                                               @QueryParameter Secret password, @QueryParameter String project) throws URISyntaxException {
    ListBoxModel items = new ListBoxModel();

    if (validInputs(serverUrl, username, password, project)) {
        try {
            TfsClient client = getTfsClientFactory().getValidatedClient(serverUrl, username, password);
            List<DefinitionReference> definitions = client.getBuildClient().getDefinitions(UUID.fromString(project));

            for (DefinitionReference definition : definitions) {
                items.add(definition.getName(), String.valueOf(definition.getId()));
            }
        } catch (VssServiceException vse) {
            return items;
        }
    }

    return items;
}
项目:embeddable-badges-plugin    文件:PublicBadgeAction.java   
/**
    * Serves the testCoverage badge image. TO DO
    * @param req
    * @param rsp
    * @param job
    * @return
    */
   @SuppressWarnings("rawtypes")
public HttpResponse doTestIcon(StaplerRequest req, StaplerResponse rsp, @QueryParameter String job) {
       Job<?, ?> project = getProject(job);
       Integer testPass = null;
       Integer testTotal = null;

       if (project.getLastCompletedBuild() != null) {
        AbstractTestResultAction testAction =  project.getLastCompletedBuild().getAction(AbstractTestResultAction.class);
        if(testAction != null){
            int total = testAction.getTotalCount();
            int pass = total - testAction.getFailCount() - testAction.getSkipCount();

            testTotal = total;
            testPass = pass;
        }
       }
       return iconResolver.getTestResultImage(testPass, testTotal);
   }
项目:rocket-chat-notifier    文件:RocketChatNotifier.java   
public FormValidation doTestConnection(
         @QueryParameter("url") final String url,
         @QueryParameter("user") final String user,
         @QueryParameter("password") final String password,
         @QueryParameter("room") final String room
        )  {
    try {
        RocketChatClient rcClient = new RocketChatClient(url, user, password);
        Set<Room> publicRooms = rcClient.getPublicRooms();
        StringBuilder message = new StringBuilder("available rooms are: ");
        boolean comma = false;
        for (Room r : publicRooms) {
            if(r.name.equals(room))
                return FormValidation.ok("Server version is "+rcClient.getRocketChatVersion());
            if(comma) message.append(", ");                         
            comma = true;
            message.append("'"+r.name+"'");
        }
        return FormValidation.error("available rooms are "+message);
    } catch (Exception e) {
        return FormValidation.error(e.getMessage());
    }
}
项目:jenkins-artifactory-polling-plugin    文件:ArtifactoryRepository.java   
/** 
 * Function that does form validation for the artifactID field in the UI
 * @param value The value of the field
 * @return The form state depending on the value
 */
public FormValidation doCheckArtifactID(@QueryParameter String value, @QueryParameter String groupID, @QueryParameter String repo)
{

    if (value != "") 
    {   
        if (checkIfArtifactExists(repo, groupID, value))
        {
            return FormValidation.ok();
        }
        else
        {
            return FormValidation.error("Could not find artifact: " + groupID + ":" + value + " in repo " + repo);
        }
    }
    else
    {
        return FormValidation.error("Artifact ID cannot be empty");
    }

}
项目:sap-hcp-deployer-plugin    文件:HcpDeploymentBuilder.java   
public FormValidation doValidateInput(@QueryParameter("host") final String host, @QueryParameter("account") final String account, @QueryParameter("user") final String user,
                                      @QueryParameter("password") final String password, @QueryParameter("appname") final String appname,
                                      @QueryParameter("packageLocation") final String packageLocation) {
    if (host == null || host.equals(""))
        return FormValidation.error("hostname is null or empty");
    if (account == null || account.equals(""))
        return FormValidation.error("accountname is null or empty");
    if (user == null || user.equals(""))
        return FormValidation.error("username is null or empty");
    if (password == null || password.equals(""))
        return FormValidation.error("password is null or empty");
    if (appname == null || appname.equals(""))
        return FormValidation.error("application name is null or empty");

    return FormValidation.ok();
}
项目: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;
}
项目:ec2-spot-jenkins-plugin    文件:EC2FleetCloud.java   
public ListBoxModel doFillRegionItems(@QueryParameter final String credentialsId,
                                      @QueryParameter final String region)
        throws IOException, ServletException {
    final List<Region> regionList;

    try {
        final AmazonEC2 client = connect(credentialsId, null);
        final DescribeRegionsResult regions=client.describeRegions();
        regionList=regions.getRegions();
    } catch(final Exception ex) {
        //Ignore bad exceptions
        return new ListBoxModel();
    }

    final ListBoxModel model = new ListBoxModel();
    for(final Region reg : regionList) {
        model.add(new ListBoxModel.Option(reg.getRegionName(), reg.getRegionName()));
    }
    return model;
}
项目:impersonation-plugin    文件:ImpersonationAction.java   
@RequirePOST
public HttpResponse doImpersonate(StaplerRequest req, @QueryParameter String name) {
    Authentication auth = Jenkins.getAuthentication();
    GrantedAuthority[] authorities = auth.getAuthorities();
    if (authorities == null || StringUtils.isBlank(name)) {
        return HttpResponses.redirectToContextRoot();
    }
    GrantedAuthority authority = null;
    for (GrantedAuthority a : authorities) {
        if (a.getAuthority().equals(name)) {
            authority = a;
            break;
        }
    }
    if (authority == null) {
        return HttpResponses.redirectToContextRoot();
    }
    if (!SecurityRealm.AUTHENTICATED_AUTHORITY.equals(authority)) {
        ACL.impersonate(new ImpersonationAuthentication(auth, authority, SecurityRealm.AUTHENTICATED_AUTHORITY));
    } else {
        ACL.impersonate(new ImpersonationAuthentication(auth, SecurityRealm.AUTHENTICATED_AUTHORITY));
    }
    return HttpResponses.redirectToContextRoot();
}
项目:aptly-plugin    文件:AptlyPublisher.java   
/**
* This method validates the current entered Aptly site configuration data.
* @param request the current {@link javax.servlet.http.HttpServletRequest}
*/
public FormValidation doLoginCheck(
                                   @QueryParameter("aptly.profileName") final String sitename,
                                   @QueryParameter("aptly.url") final String url,
                                   @QueryParameter("aptly.enableSelfSigned") final String enableselfsigned,
                                   @QueryParameter("aptly.timeOut") final String timeout,
                                   @QueryParameter("aptly.username") final String username,
                                   @QueryParameter("aptly.password") final String password)
{
    LOG.info("Login check for " + sitename);
    PrintStream logstream = new PrintStream(new LogOutputStream(), true);
    try {
        AptlySite site = new AptlySite(url,enableselfsigned,timeout,username,password);
        AptlyRestClient client =  new AptlyRestClient(logstream, site);
        final String ver = client.getAptlyServerVersion();
        LOG.info("got version " + ver);
        return FormValidation.ok("Success, Aptly version: " + ver);
    } catch (Exception e) {
        return FormValidation.error(e.getMessage());
    }
}
项目:jira-ext-plugin    文件:UpdateField.java   
public HttpResponse doQueryJiraFields(@QueryParameter String issueKey)
{
    try
    {
        if (!Config.getGlobalConfig().isJiraConfigComplete())
        {
            return FormValidation.error("JIRA settings are not set in global config");
        }
        final Map<String, String> jiraFields = getJiraClientSvc().getJiraFields(issueKey);
        return new ForwardToView(this, "/org/jenkinsci/plugins/jiraext/view/UpdateField/jiraFields.jelly")
                .with("jiraFieldMap", jiraFields);
    }
    catch (Throwable t)
    {
        String message =  "Error finding FieldIds for issueKey: " + issueKey;
        logger.log(Level.WARNING, message, t);
        return FormValidation.error(t, message);
    }
}
项目:aws-codebuild-jenkins-plugin    文件:CodeBuildCredentials.java   
public FormValidation doCheckSecretKey(@QueryParameter("proxyHost") final String proxyHost,
                                       @QueryParameter("proxyPort") final String proxyPort,
                                       @QueryParameter("accessKey") final String accessKey,
                                       @QueryParameter("secretKey") final String secretKey) {

    try {
        AWSCredentials initialCredentials = AWSClientFactory.getBasicCredentialsOrDefaultChain(accessKey, secretKey).getCredentials();
        new AWSCodeBuildClient(initialCredentials, getClientConfiguration(proxyHost, proxyPort)).listProjects(new ListProjectsRequest());

    } catch (Exception e) {
        String errorMessage = e.getMessage();
        if(errorMessage.length() >= ERROR_MESSAGE_MAX_LENGTH) {
            errorMessage = errorMessage.substring(ERROR_MESSAGE_MAX_LENGTH);
        }
        return FormValidation.error("Authorization failed: " + errorMessage);
    }
    return FormValidation.ok("AWS access and secret key authorization successful.");
}
项目:vmware-vrealize-orchestrator    文件:OrchestratorBuilder.java   
public FormValidation doCheckTenant(@QueryParameter final boolean ssoEnabled,
                                    @QueryParameter final String tenant) {

    if (ssoEnabled) {
        String tenantVal = Util.fixEmptyAndTrim(tenant);
        if (tenantVal == null) {
            return FormValidation.error("Please enter tenant.");
        }

        if (tenantVal.indexOf('$') >= 0) {
            // set by variable, can't validate
            return FormValidation.ok();
        }
    }

    return FormValidation.ok();
}
项目: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);
}
项目: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.");
}
项目:codescene-jenkins-plugin    文件:CodeSceneBuilder.java   
public FormValidation doCheckBaseRevision(@QueryParameter boolean analyzeBranchDiff,
                                          @QueryParameter String baseRevision) throws IOException, ServletException {
    if (analyzeBranchDiff && (baseRevision == null || baseRevision.isEmpty())) {
        return FormValidation.error("Base revision cannot be empty.");
    } else {
        return FormValidation.ok();
    }
}
项目:codescene-jenkins-plugin    文件:CodeSceneBuilder.java   
public FormValidation doCheckRiskThreshold(@QueryParameter int riskThreshold, @QueryParameter boolean markBuildAsUnstable) {
    if (markBuildAsUnstable && (riskThreshold < 1 || riskThreshold > 10)) {
        return FormValidation.error("Risk threshold must be a number between 1 and 10. The value %d is invalid.", riskThreshold);
    } else {
        return FormValidation.ok();
    }
}
项目:codescene-jenkins-plugin    文件:CodeSceneBuilder.java   
public FormValidation doCheckCredentialsId(@QueryParameter String credentialsId) {
    if (credentialsId == null || credentialsId.isEmpty()) {
        return FormValidation.error("CodeScene API credentials must be set.");
    } else {
        return FormValidation.ok();
    }
}
项目:codescene-jenkins-plugin    文件:CodeSceneBuilder.java   
public FormValidation doCheckDeltaAnalysisUrl(@QueryParameter String deltaAnalysisUrl) {
    if (deltaAnalysisUrl == null || deltaAnalysisUrl.isEmpty()) {
        return FormValidation.error("CodeScene delta analysis URL cannot be blank.");
    } else {
        try {
            new URL(deltaAnalysisUrl);
            return FormValidation.ok();
        } catch (MalformedURLException e) {
            return FormValidation.error("Invalid URL");
        }
    }
}
项目:codescene-jenkins-plugin    文件:CodeSceneBuilder.java   
public FormValidation doCheckRepository(@QueryParameter String repository) {
    if (repository == null || repository.isEmpty()) {
        return FormValidation.error("CodeScene repository cannot be blank.");
    } else {
        return FormValidation.ok();
    }
}
项目:codescene-jenkins-plugin    文件:CodeSceneBuilder.java   
public FormValidation doCheckCouplingThresholdPercent(@QueryParameter int couplingThresholdPercent) {
    if (couplingThresholdPercent < 1 || couplingThresholdPercent > 100) {
        return FormValidation.error("Temporal coupling threshold is percentage and must be a number between 1 and 100." +
                "The value %d is invalid.", couplingThresholdPercent);
    } else {
        return FormValidation.ok();
    }
}
项目: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;
}