/** * Converts a {@link Collection} of {@link DomainCredentials} into a {@link Map} keyed by {@link Domain} with * {@link List} of {@link Credentials} as values. * * @param collection the collection. * @return the corresponding map. */ @NonNull public static Map<Domain, List<Credentials>> asMap(@CheckForNull Collection<DomainCredentials> collection) { Map<Domain, List<Credentials>> map = new LinkedHashMap<Domain, List<Credentials>>(); if (collection != null) { for (DomainCredentials item : collection) { List<Credentials> existing = map.get(item.getDomain()); if (existing == null) { map.put(item.getDomain(), new CopyOnWriteArrayList<Credentials>(item.getCredentials())); } else { // allow combining for malformed requests existing.addAll(item.getCredentials()); } } } return new CopyOnWriteMap.Hash<Domain, List<Credentials>>(map); }
/** * Converts a {@link Collection} of {@link DomainCredentials} into a {@link Map} keyed by {@link Domain} with * {@link List} of {@link Credentials} as values. * * @param collection the collection. * @return the corresponding map. */ @NonNull public static Map<Domain, List<Credentials>> asMap(@CheckForNull Collection<DomainCredentials> collection) { Map<Domain, List<Credentials>> map = new LinkedHashMap<Domain, List<Credentials>>(); if (collection != null) { for (DomainCredentials item : collection) { List<Credentials> existing = map.get(item.getDomain()); if (existing == null) { map.put(item.getDomain(), new CopyOnWriteArrayList<Credentials>(item.getCredentials())); } else { // allow combining for malformed requests existing.addAll(item.getCredentials()); } } } return new CopyOnWriteMap.Hash<Domain, List<Credentials>>(map); }
/** * {@inheritDoc} */ @NonNull @Override public <C extends Credentials> List<C> getCredentials(@NonNull Class<C> type, @NonNull Item item, @Nullable Authentication authentication, @NonNull List<DomainRequirement> domainRequirements) { if (ACL.SYSTEM.equals(authentication)) { return DomainCredentials.getCredentials(SystemCredentialsProvider.getInstance() .getDomainCredentialsMap(), type, domainRequirements, not(withScope(SYSTEM))); } return new ArrayList<C>(); }
FolderCredentialsProperty property = folder.getProperties().get(FolderCredentialsProperty.class); if (property != null) { for (C c : DomainCredentials.getCredentials( property.getDomainCredentialsMap(), type,
FolderCredentialsProperty property = folder.getProperties().get(FolderCredentialsProperty.class); if (property != null) { for (C c : DomainCredentials.getCredentials( property.getDomainCredentialsMap(), type,
/** * {@inheritDoc} */ @NonNull @Override public <C extends Credentials> List<C> getCredentials(@NonNull Class<C> type, @NonNull Item item, @Nullable Authentication authentication, @NonNull List<DomainRequirement> domainRequirements) { if (ACL.SYSTEM.equals(authentication)) { return DomainCredentials.getCredentials(SystemCredentialsProvider.getInstance() .getDomainCredentialsMap(), type, domainRequirements, not(withScope(SYSTEM))); } return new ArrayList<C>(); }
@Override protected int run() throws Exception { store.checkPermission(CredentialsProvider.CREATE); store.checkPermission(CredentialsProvider.MANAGE_DOMAINS); List<DomainCredentials> replacement = (List<DomainCredentials>) Items.XSTREAM.unmarshal(safeXmlStreamReader(stdin)); for (DomainCredentials domain : replacement) { for (Credentials credentials : domain.getCredentials()) { store.addDomain(domain.getDomain(), credentials); } } return 0; }
/** * {@inheritDoc} */ @NonNull @Override public <C extends Credentials> List<C> getCredentials(@NonNull Class<C> type, @Nullable ItemGroup itemGroup, @Nullable Authentication authentication, @NonNull List<DomainRequirement> domainRequirements) { if (ACL.SYSTEM.equals(authentication)) { CredentialsMatcher matcher = Jenkins.getInstance() == itemGroup ? always() : not(withScope(SYSTEM)); return DomainCredentials.getCredentials(SystemCredentialsProvider.getInstance() .getDomainCredentialsMap(), type, domainRequirements, matcher); } return new ArrayList<C>(); }
/** * {@inheritDoc} */ @NonNull @Override public <C extends Credentials> List<C> getCredentials(@NonNull Class<C> type, @Nullable ItemGroup itemGroup, @Nullable Authentication authentication, @NonNull List<DomainRequirement> domainRequirements) { if (ACL.SYSTEM.equals(authentication)) { CredentialsMatcher matcher = Jenkins.getInstance() == itemGroup ? always() : not(withScope(SYSTEM)); return DomainCredentials.getCredentials(SystemCredentialsProvider.getInstance() .getDomainCredentialsMap(), type, domainRequirements, matcher); } return new ArrayList<C>(); }
try { return DomainCredentials .getCredentials(property.getDomainCredentialsMap(), type, domainRequirements, always()); } finally { if (needImpersonation) {
try { return DomainCredentials .getCredentials(property.getDomainCredentialsMap(), type, domainRequirements, always()); } finally { if (needImpersonation) {
FolderCredentialsProperty property = folder.getProperties().get(FolderCredentialsProperty.class); if (property != null) { for (C c : DomainCredentials.getCredentials( property.getDomainCredentialsMap(), type,
FolderCredentialsProperty property = folder.getProperties().get(FolderCredentialsProperty.class); if (property != null) { for (C c : DomainCredentials.getCredentials( property.getDomainCredentialsMap(), type,