use of com.cloudbees.plugins.credentials.Credentials in project blueocean-plugin by jenkinsci.
the class BlueOceanCredentialsProvider method getCredentials.
@Nonnull
public <C extends Credentials> List<C> getCredentials(@Nonnull final Class<C> type, @Nullable ItemGroup itemGroup, @Nullable Authentication authentication, @Nonnull List<DomainRequirement> domainRequirements) {
final List<C> result = new ArrayList<>();
final FolderPropertyImpl prop = propertyOf(itemGroup);
if (prop != null && prop.domain.test(domainRequirements)) {
final User proxyUser = User.get(prop.getUser(), false, Collections.emptyMap());
Authentication proxyAuth = proxyUser == null ? null : proxyUser.impersonate();
if (proxyAuth != null) {
ACL.impersonate(proxyAuth, new Runnable() {
@Override
public void run() {
for (CredentialsStore s : CredentialsProvider.lookupStores(proxyUser)) {
for (Domain d : s.getDomains()) {
if (d.test(PROXY_REQUIREMENT)) {
for (Credentials c : filter(s.getCredentials(d), withId(prop.getId()))) {
if (type.isInstance(c)) {
result.add((C) c);
}
}
}
}
}
}
});
}
}
return result;
}
Aggregations