當前位置: 首頁>>代碼示例>>Java>>正文


Java CredentialsProvider.lookupCredentials方法代碼示例

本文整理匯總了Java中com.cloudbees.plugins.credentials.CredentialsProvider.lookupCredentials方法的典型用法代碼示例。如果您正苦於以下問題:Java CredentialsProvider.lookupCredentials方法的具體用法?Java CredentialsProvider.lookupCredentials怎麽用?Java CredentialsProvider.lookupCredentials使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.cloudbees.plugins.credentials.CredentialsProvider的用法示例。


在下文中一共展示了CredentialsProvider.lookupCredentials方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: doFillPrincipalCredentialIdItems

import com.cloudbees.plugins.credentials.CredentialsProvider; //導入方法依賴的package包/類
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);
}
 
開發者ID:jenkinsci,項目名稱:azure-cli-plugin,代碼行數:24,代碼來源:AzureCLIBuilder.java

示例2: doFillCredentialsIdItems

import com.cloudbees.plugins.credentials.CredentialsProvider; //導入方法依賴的package包/類
/**
 * Fills in the Login Credentials selection box with applicable connections.
 * 
 * @param context
 *            filter for login credentials
 * @param credentialsId
 *            existing login credentials; can be null
 * @param project
 *            the Jenkins project
 * 
 * @return login credentials selection
 */
public ListBoxModel doFillCredentialsIdItems(@AncestorInPath Jenkins context, @QueryParameter String credentialsId,
		@AncestorInPath Item project)
{
	List<StandardUsernamePasswordCredentials> creds = CredentialsProvider.lookupCredentials(
			StandardUsernamePasswordCredentials.class, project, ACL.SYSTEM,
			Collections.<DomainRequirement> emptyList());

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

	for (StandardUsernamePasswordCredentials c : creds)
	{
		boolean isSelected = false;
		if (credentialsId != null)
		{
			isSelected = credentialsId.matches(c.getId());
		}

		String description = Util.fixEmptyAndTrim(c.getDescription());
		model.add(new Option(c.getUsername() + (description != null ? " (" + description + ')' : StringUtils.EMPTY), //$NON-NLS-1$
				c.getId(), isSelected));
	}

	return model;
}
 
開發者ID:Compuware-Corp,項目名稱:CPWR-CodeCoverage,代碼行數:38,代碼來源:CodeCoverageBuilder.java

示例3: doFillCredentialsIdItems

import com.cloudbees.plugins.credentials.CredentialsProvider; //導入方法依賴的package包/類
/**
 * Fills in the Login Credentials selection box with applicable Jenkins credentials.
 * 
 * @param context
 *            filter for credentials
 * @param credentialsId
 *            existing login credentials; can be null
 * @param project
 *            the Jenkins project
 * 
 * @return credential selections
 */
public ListBoxModel doFillCredentialsIdItems(@AncestorInPath Jenkins context, @QueryParameter String credentialsId, @AncestorInPath Item project)
{
	List<StandardUsernamePasswordCredentials> creds = CredentialsProvider.lookupCredentials(
			StandardUsernamePasswordCredentials.class, project, ACL.SYSTEM,
			Collections.<DomainRequirement> emptyList());

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

	for (StandardUsernamePasswordCredentials c : creds)
	{
		boolean isSelected = false;
		if (credentialsId != null)
		{
			isSelected = credentialsId.matches(c.getId());
		}

		String description = Util.fixEmptyAndTrim(c.getDescription());
		model.add(new Option(c.getUsername() + (description != null ? " (" + description + ')' : StringUtils.EMPTY), //$NON-NLS-1$
				c.getId(), isSelected));
	}

	return model;
}
 
開發者ID:jenkinsci,項目名稱:compuware-scm-downloader-plugin,代碼行數:37,代碼來源:PdsConfiguration.java

示例4: getLoginInformation

import com.cloudbees.plugins.credentials.CredentialsProvider; //導入方法依賴的package包/類
/**
 * Retrieves login information given a credential ID.
 * 
 * @param project
 *            the Jenkins project
 *
 * @return a Jenkins credential with login information
 */
protected StandardUsernamePasswordCredentials getLoginInformation(Item project)
{
	StandardUsernamePasswordCredentials credential = null;

	List<StandardUsernamePasswordCredentials> credentials = CredentialsProvider.lookupCredentials(
			StandardUsernamePasswordCredentials.class, project, ACL.SYSTEM, Collections.<DomainRequirement> emptyList());

	IdMatcher matcher = new IdMatcher(getCredentialsId());
	for (StandardUsernamePasswordCredentials c : credentials)
	{
		if (matcher.matches(c))
		{
			credential = c;
		}
	}

	return credential;
}
 
開發者ID:jenkinsci,項目名稱:compuware-scm-downloader-plugin,代碼行數:27,代碼來源:CpwrScmConfiguration.java

示例5: getLoginInformation

import com.cloudbees.plugins.credentials.CredentialsProvider; //導入方法依賴的package包/類
/**
 * Retrieves login information given a credential ID
 * 
 * @param project
 *            the Jenkins project
 *
 * @return a Jenkins credential with login information
 */
protected StandardUsernamePasswordCredentials getLoginInformation(Item project)
{
	StandardUsernamePasswordCredentials credential = null;

	List<StandardUsernamePasswordCredentials> credentials = CredentialsProvider.lookupCredentials(
			StandardUsernamePasswordCredentials.class, project, ACL.SYSTEM, Collections.<DomainRequirement> emptyList());

	IdMatcher matcher = new IdMatcher(getCredentialsId());
	for (StandardUsernamePasswordCredentials c : credentials)
	{
		if (matcher.matches(c))
		{
			credential = c;
		}
	}

	return credential;
}
 
開發者ID:jenkinsci,項目名稱:compuware-scm-downloader-plugin,代碼行數:27,代碼來源:IspwConfiguration.java

示例6: FigShareNotifier

import com.cloudbees.plugins.credentials.CredentialsProvider; //導入方法依賴的package包/類
/**
 * Constructor called from a Jelly view. The parameters are given by a user.
 *
 * @param credentialsId figshare credential ID, selected out of a combo box
 * @param articleTitle figshare article title
 * @param articleDescription figshare article description
 * @param antPattern an ant-like pattern (e.g. **\/*.png)
 */
@DataBoundConstructor
public FigShareNotifier(String credentialsId, String articleTitle, String articleDescription, String antPattern) {
    this.credentialsId = credentialsId;
    this.articleTitle = articleTitle;
    this.articleDescription = articleDescription;
    this.antPattern = antPattern;

    // Get credential defined by user, using credential ID
    List<FigShareOauthCredentials> credentials = CredentialsProvider.lookupCredentials(
            FigShareOauthCredentials.class, Jenkins.getInstance(), ACL.SYSTEM,
            Collections.<DomainRequirement> emptyList());
    FigShareOauthCredentials credential = CredentialsMatchers.firstOrNull(credentials,
            CredentialsMatchers.allOf(CredentialsMatchers.withId(credentialsId)));

    this.credential = credential;
    if (null == credential) {
        LOGGER.warning(String.format(
                "Could not locate credential with ID %s. figshare integration is disabled for this notifier",
                credentialsId));
    }
}
 
開發者ID:biouno,項目名稱:figshare-plugin,代碼行數:30,代碼來源:FigShareNotifier.java

示例7: lookupCredentials

import com.cloudbees.plugins.credentials.CredentialsProvider; //導入方法依賴的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

示例8: getCredentialsListBox

import com.cloudbees.plugins.credentials.CredentialsProvider; //導入方法依賴的package包/類
/**
 * Helper utility for populating a jelly list box with matching
 * {@link GoogleRobotCredentials} to avoid listing credentials that avoids
 * surfacing those with insufficient permissions.
 *
 * Modeled after:
 *    http://developer-blog.cloudbees.com/2012/10/using-ssh-from-jenkins.html
 *
 * @param clazz The class annotated with @RequiresDomain indicating its scope
 * requirements.
 * @return a list box populated solely with credentials compatible for the
 *         extension being configured.
 */
public static CredentialsListBoxModel getCredentialsListBox(Class<?> clazz) {
  GoogleOAuth2ScopeRequirement requirement =
      DomainRequirementProvider.of(clazz, GoogleOAuth2ScopeRequirement.class);

  if (requirement == null) {
    throw new IllegalArgumentException(
        Messages.GoogleRobotCredentials_NoAnnotation(clazz.getSimpleName()));
  }

  CredentialsListBoxModel listBox = new CredentialsListBoxModel(requirement);
  Iterable<GoogleRobotCredentials> allGoogleCredentials =
      CredentialsProvider.lookupCredentials(
          GoogleRobotCredentials.class, Jenkins.getInstance(), ACL.SYSTEM,
          ImmutableList.<DomainRequirement>of(requirement));

  for (GoogleRobotCredentials credentials : allGoogleCredentials) {
    String name = CredentialsNameProvider.name(credentials);
    listBox.add(name, credentials.getId());
  }
  return listBox;
}
 
開發者ID:jenkinsci,項目名稱:google-oauth-plugin,代碼行數:35,代碼來源:GoogleRobotCredentials.java

示例9: findCredential

import com.cloudbees.plugins.credentials.CredentialsProvider; //導入方法依賴的package包/類
/**
 * Finds a Perforce Credential based on the String id.
 *
 * @param id Credential ID
 * @return a P4StandardCredentials credential or null if not found.
 * @deprecated Use {@link #findCredential(String, ItemGroup)} or {@link #findCredential(String, Item)}
 */
@Deprecated
public static P4BaseCredentials findCredential(String id) {
	Class<P4BaseCredentials> type = P4BaseCredentials.class;
	Jenkins scope = Jenkins.getInstance();
	Authentication acl = ACL.SYSTEM;
	DomainRequirement domain = new DomainRequirement();

	List<P4BaseCredentials> list;
	list = CredentialsProvider.lookupCredentials(type, scope, acl, domain);

	for (P4BaseCredentials c : list) {
		if (c.getId().equals(id)) {
			return c;
		}
	}
	return null;
}
 
開發者ID:p4paul,項目名稱:p4-jenkins,代碼行數:25,代碼來源:ConnectionHelper.java

示例10: testAvailableCredentialsInJob

import com.cloudbees.plugins.credentials.CredentialsProvider; //導入方法依賴的package包/類
@Test
public void testAvailableCredentialsInJob() throws IOException {
	Job job = jenkins.createFreeStyleProject("testAvailableCredentialsInJob");

	P4BaseCredentials systemCredentials = new P4PasswordImpl(
			CredentialsScope.SYSTEM, "idSystem", "desc:passwd", "localhost:1666",
			null, "user", "0", "0", null, "pass");

	P4BaseCredentials globalCredentials = new P4PasswordImpl(
			CredentialsScope.GLOBAL, "idInGlobal", "desc:passwd", "localhost:1666",
			null, "user", "0", "0", null, "pass");

	assertTrue(lookupCredentials().isEmpty());
	SystemCredentialsProvider.getInstance().getCredentials().add(systemCredentials);
	SystemCredentialsProvider.getInstance().getCredentials().add(globalCredentials);
	SystemCredentialsProvider.getInstance().save();
	assertFalse(new SystemCredentialsProvider().getCredentials().isEmpty());

	List<P4BaseCredentials> list = CredentialsProvider.lookupCredentials(P4BaseCredentials.class,
			job, ACL.SYSTEM, Collections.<DomainRequirement>emptyList());
	assertEquals(1, list.size());
	assertEquals(globalCredentials.getId(), list.get(0).getId());
}
 
開發者ID:p4paul,項目名稱:p4-jenkins,代碼行數:24,代碼來源:PerforceCredentialsTest.java

示例11: doFillCredentialIdItems

import com.cloudbees.plugins.credentials.CredentialsProvider; //導入方法依賴的package包/類
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);
}
 
開發者ID:ingenieux,項目名稱:awseb-deployment-plugin,代碼行數:17,代碼來源:AWSEBDeploymentBuilder.java

示例12: lookupNamedCredential

import com.cloudbees.plugins.credentials.CredentialsProvider; //導入方法依賴的package包/類
public static AmazonWebServicesCredentials lookupNamedCredential(String credentialsId)
    throws CredentialNotFoundException {
  List<AmazonWebServicesCredentials> credentialList =
      CredentialsProvider.lookupCredentials(
          AmazonWebServicesCredentials.class, Jenkins.getInstance(), ACL.SYSTEM,
          Collections.<DomainRequirement>emptyList());

  AmazonWebServicesCredentials cred =
      CredentialsMatchers.firstOrNull(credentialList,
                                      CredentialsMatchers.allOf(
                                          CredentialsMatchers.withId(credentialsId)));

  if (cred == null) {
    throw new CredentialNotFoundException(credentialsId);
  }
  return cred;
}
 
開發者ID:ingenieux,項目名稱:awseb-deployment-plugin,代碼行數:18,代碼來源:AWSClientFactory.java

示例13: getCredentials

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

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

    // now we have matchedCredentials.getPassword() and matchedCredentials.getUsername();
    return (UsernamePasswordCredentials) matchedCredentials;
}
 
開發者ID:morficus,項目名稱:Parameterized-Remote-Trigger-Plugin,代碼行數:22,代碼來源:Auth.java

示例14: doFillCredsItems

import com.cloudbees.plugins.credentials.CredentialsProvider; //導入方法依賴的package包/類
public static ListBoxModel doFillCredsItems() {
    StandardUsernameListBoxModel model = new StandardUsernameListBoxModel();

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

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

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

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

    return model;
}
 
開發者ID:morficus,項目名稱:Parameterized-Remote-Trigger-Plugin,代碼行數:21,代碼來源:Auth.java

示例15: doCheckCredentialsId

import com.cloudbees.plugins.credentials.CredentialsProvider; //導入方法依賴的package包/類
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());
}
 
開發者ID:jenkinsci,項目名稱:credentials-binding-plugin,代碼行數:25,代碼來源:ZipFileBinding.java


注:本文中的com.cloudbees.plugins.credentials.CredentialsProvider.lookupCredentials方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。