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


Java CredentialsProvider.track方法代碼示例

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


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

示例1: findCredential

import com.cloudbees.plugins.credentials.CredentialsProvider; //導入方法依賴的package包/類
/**
 * Finds a Perforce Credential based on credentials ID and {@link Item}.
 * This also tracks usage of the credentials.
 *
 * @param credentialsId Credential ID
 * @param item          The {@link Item}
 * @return a P4StandardCredentials credential or null if not found.
 */
public static P4BaseCredentials findCredential(String credentialsId, Item item) {
	if (credentialsId == null) {
		return null;
	}
	if (item == null) {
		return findCredential(credentialsId);
	}
	P4BaseCredentials credentials = CredentialsMatchers.firstOrNull(
			CredentialsProvider.lookupCredentials(P4BaseCredentials.class, item,
					ACL.SYSTEM, Collections.<DomainRequirement>emptyList()),
			CredentialsMatchers.allOf(
					CredentialsMatchers.withId(credentialsId),
					CredentialsMatchers.instanceOf(P4BaseCredentials.class)));
	CredentialsProvider.track(item, credentials);
	return credentials;
}
 
開發者ID:p4paul,項目名稱:p4-jenkins,代碼行數:25,代碼來源:ConnectionHelper.java

示例2: getCredentials

import com.cloudbees.plugins.credentials.CredentialsProvider; //導入方法依賴的package包/類
/**
 * Looks up the actual credentials.
 * @param build the build.
 * @return the credentials
 * @throws FileNotFoundException if the credentials could not be found (for convenience, rather than returning null)
 */
protected final @Nonnull C getCredentials(@Nonnull Run<?,?> build) throws IOException {
    IdCredentials cred = CredentialsProvider.findCredentialById(credentialsId, IdCredentials.class, build);
    if (cred==null)
        throw new CredentialNotFoundException(credentialsId);

    if (type().isInstance(cred)) {
        CredentialsProvider.track(build, cred);
        return type().cast(cred);
    }

    
    Descriptor expected = Jenkins.getActiveInstance().getDescriptor(type());
    throw new CredentialNotFoundException("Credentials '"+credentialsId+"' is of type '"+
            cred.getDescriptor().getDisplayName()+"' where '"+
            (expected!=null ? expected.getDisplayName() : type().getName())+
            "' was expected");
}
 
開發者ID:jenkinsci,項目名稱:credentials-binding-plugin,代碼行數:24,代碼來源:MultiBinding.java

示例3: gitea

import com.cloudbees.plugins.credentials.CredentialsProvider; //導入方法依賴的package包/類
private Gitea gitea(SCMSourceOwner owner) throws AbortException {
    GiteaServer server = GiteaServers.get().findServer(serverUrl);
    if (server == null) {
        throw new AbortException("Unknown server: " + serverUrl);
    }
    StandardCredentials credentials = credentials(owner);
    CredentialsProvider.track(owner, credentials);
    return Gitea.server(serverUrl)
            .as(AuthenticationTokens.convert(GiteaAuth.class, credentials));
}
 
開發者ID:jenkinsci,項目名稱:gitea-plugin,代碼行數:11,代碼來源:GiteaSCMNavigator.java

示例4: gitea

import com.cloudbees.plugins.credentials.CredentialsProvider; //導入方法依賴的package包/類
Gitea gitea() throws AbortException {
    GiteaServer server = GiteaServers.get().findServer(serverUrl);
    if (server == null) {
        throw new AbortException("Unknown server: " + serverUrl);
    }
    StandardCredentials credentials = credentials();
    SCMSourceOwner owner = getOwner();
    if (owner != null) {
        CredentialsProvider.track(owner, credentials);
    }
    return Gitea.server(serverUrl)
            .as(AuthenticationTokens.convert(GiteaAuth.class, credentials));
}
 
開發者ID:jenkinsci,項目名稱:gitea-plugin,代碼行數:14,代碼來源:GiteaSCMSource.java

示例5: getCredentialById

import com.cloudbees.plugins.credentials.CredentialsProvider; //導入方法依賴的package包/類
public AzureKeyVaultCredential getCredentialById(String _credentialID, Run<?, ?> build) throws CredentialNotFoundException, CredentialException
{
    AzureKeyVaultCredential credential = new AzureKeyVaultCredential();
    IdCredentials cred = CredentialsProvider.findCredentialById(_credentialID, IdCredentials.class, build);
    
    if (cred==null)
    {
        throw new CredentialNotFoundException(_credentialID);
    }
    
    if(StringCredentials.class.isInstance(cred))
    {
        // Secret Text object
        LOGGER.log(Level.INFO, String.format("Fetched %s as StringCredentials", _credentialID));
        CredentialsProvider.track(build, cred);
        credential.setApplicationSecret(StringCredentials.class.cast(cred).getSecret());
        return credential;
    }
    else if(StandardUsernamePasswordCredentials.class.isInstance(cred))
    {
        // Username/Password Object
        LOGGER.log(Level.INFO, String.format("Fetched %s as StandardUsernamePasswordCredentials", _credentialID));
        CredentialsProvider.track(build, cred);
        credential.setApplicationID(StandardUsernamePasswordCredentials.class.cast(cred).getUsername());
        credential.setApplicationSecret(StandardUsernamePasswordCredentials.class.cast(cred).getPassword());
        return credential;
    }
    else
    {
        throw new CredentialException("Could not determine the type for Secret id " + _credentialID + " only 'Secret Text' and 'Username/Password' are supported");
    }
}
 
開發者ID:mbearup,項目名稱:azure-keyvault-plugin,代碼行數:33,代碼來源:AzureKeyVaultBuildWrapper.java

示例6: build

import com.cloudbees.plugins.credentials.CredentialsProvider; //導入方法依賴的package包/類
@Override
public SCMFileSystem build(@NonNull SCMSource source, @NonNull SCMHead head, @CheckForNull SCMRevision rev)
        throws IOException, InterruptedException {
    GiteaSCMSource src = (GiteaSCMSource) source;
    String repoOwner;
    String repository;
    String ref;
    if (head instanceof PullRequestSCMHead) {
        repoOwner = ((PullRequestSCMHead) head).getOriginOwner();
        repository = ((PullRequestSCMHead) head).getOriginRepository();
        ref = ((PullRequestSCMHead) head).getOriginName();
    } else if (head instanceof BranchSCMHead) {
        repoOwner = src.getRepoOwner();
        repository = src.getRepository();
        ref = head.getName();
    } else {
        return null;
    }
    SCMSourceOwner owner = source.getOwner();
    String serverUrl = src.getServerUrl();
    String credentialsId = src.getCredentialsId();
    StandardCredentials credentials = StringUtils.isBlank(credentialsId)
            ? null
            : CredentialsMatchers.firstOrNull(
            CredentialsProvider.lookupCredentials(
                    StandardCredentials.class,
                    owner,
                    Jenkins.getAuthentication(),
                    URIRequirementBuilder.fromUri(serverUrl).build()
            ),
            CredentialsMatchers.allOf(
                    AuthenticationTokens.matcher(GiteaAuth.class),
                    CredentialsMatchers.withId(credentialsId)
            )
    );
    if (owner != null) {
        CredentialsProvider.track(owner, credentials);
    }
    GiteaConnection connection = Gitea.server(serverUrl)
            .as(AuthenticationTokens.convert(GiteaAuth.class, credentials))
            .open();
    try {
        return new GiteaSCMFileSystem(connection, connection.fetchRepository(repoOwner, repository), ref, rev);
    } catch (IOException | InterruptedException e) {
        try {
            connection.close();
        } catch (IOException ioe) {
            e.addSuppressed(ioe);
        }
        throw e;
    }
}
 
開發者ID:jenkinsci,項目名稱:gitea-plugin,代碼行數:53,代碼來源:GiteaSCMFileSystem.java


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