@Nonnull @Override public Set<Attribute<SystemCredentialsProvider, ?>> describe() { return Collections.singleton( new MultivaluedAttribute<SystemCredentialsProvider, DomainCredentials>("domainCredentials", DomainCredentials.class) .setter( (target, value) -> target.setDomainCredentialsMap(DomainCredentials.asMap(value))) ); }
/** * Backwards compatibility. * * @param credentials the credentials. * @deprecated */ @Deprecated public UserCredentialsProperty(List<Credentials> credentials) { domainCredentialsMap = DomainCredentials.migrateListToMap(null, credentials); }
/** * Helper method used by the {@code domainCredentials.jelly} taglib to ensure the list is valid. * * @param list the list. * @return the list with fixes applied. */ @NonNull public static List<DomainCredentials> fixList(@CheckForNull List<DomainCredentials> list) { Map<Domain, List<Credentials>> map = asMap(list); if (!map.containsKey(Domain.global())) { map.put(Domain.global(), new CopyOnWriteArrayList<Credentials>()); } return asList(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>(); }
/** * 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); }
/** * Set all the credentials. * * @param domainCredentialsMap all the credentials. * @since 1.5 */ public synchronized void setDomainCredentialsMap(Map<Domain, List<Credentials>> domainCredentialsMap) { this.domainCredentialsMap = DomainCredentials.toCopyOnWriteMap(domainCredentialsMap); }
/** * Returns the {@link com.cloudbees.plugins.credentials.domains.DomainCredentials} * * @return the {@link com.cloudbees.plugins.credentials.domains.DomainCredentials} * @since 3.10 */ @SuppressWarnings("unused") // used by stapler public List<DomainCredentials> getDomainCredentials() { return DomainCredentials.asList(getDomainCredentialsMap()); }
/** * Converts a {@link Map} keyed by {@link Domain} with {@link List} of {@link Credentials} as values into a * {@link List} of {@link DomainCredentials} into a * * @param map the map. * @return the corresponding list. */ @NonNull public static List<DomainCredentials> asList(Map<Domain, List<Credentials>> map) { List<DomainCredentials> result = new ArrayList<DomainCredentials>(); if (map != null) { for (Map.Entry<Domain, List<Credentials>> entry : map.entrySet()) { result.add(new DomainCredentials(entry.getKey(), entry.getValue())); } } return result; }
/** * Backwards compatibility. * * @param credentials the credentials. * @deprecated */ @Deprecated public UserCredentialsProperty(List<Credentials> credentials) { domainCredentialsMap = DomainCredentials.migrateListToMap(null, credentials); }
/** * Helper method used by the {@code domainCredentials.jelly} taglib to ensure the list is valid. * * @param list the list. * @return the list with fixes applied. */ @NonNull public static List<DomainCredentials> fixList(@CheckForNull List<DomainCredentials> list) { Map<Domain, List<Credentials>> map = asMap(list); if (!map.containsKey(Domain.global())) { map.put(Domain.global(), new CopyOnWriteArrayList<Credentials>()); } return asList(map); }
FolderCredentialsProperty property = folder.getProperties().get(FolderCredentialsProperty.class); if (property != null) { for (C c : DomainCredentials.getCredentials( property.getDomainCredentialsMap(), type,
/** * 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); }
/** * Set all the credentials. * * @param domainCredentialsMap all the credentials. * @since 1.5 */ public synchronized void setDomainCredentialsMap(Map<Domain, List<Credentials>> domainCredentialsMap) { this.domainCredentialsMap = DomainCredentials.toCopyOnWriteMap(domainCredentialsMap); }
/** * Get all the credentials. * * @return all the credentials. * @since 1.5 */ @SuppressWarnings("unused") // used by stapler public List<DomainCredentials> getDomainCredentials() { return DomainCredentials.asList(getDomainCredentialsMap()); }
/** * Converts a {@link Map} keyed by {@link Domain} with {@link List} of {@link Credentials} as values into a * {@link List} of {@link DomainCredentials} into a * * @param map the map. * @return the corresponding list. */ @NonNull public static List<DomainCredentials> asList(Map<Domain, List<Credentials>> map) { List<DomainCredentials> result = new ArrayList<DomainCredentials>(); if (map != null) { for (Map.Entry<Domain, List<Credentials>> entry : map.entrySet()) { result.add(new DomainCredentials(entry.getKey(), entry.getValue())); } } return result; }
/** * Backwards compatibility. * * @param credentials the credentials. * @deprecated */ @Deprecated public FolderCredentialsProperty(List<Credentials> credentials) { domainCredentialsMap = DomainCredentials.migrateListToMap(domainCredentialsMap, credentials); }
/** * Constructor for stapler. * * @param domainCredentials the credentials. * @since 1.5 */ @DataBoundConstructor public UserCredentialsProperty(DomainCredentials[] domainCredentials) { domainCredentialsMap = DomainCredentials.asMap(Arrays.asList(domainCredentials)); }
FolderCredentialsProperty property = folder.getProperties().get(FolderCredentialsProperty.class); if (property != null) { for (C c : DomainCredentials.getCredentials( property.getDomainCredentialsMap(), type,
@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; }
/** * Sets the map of domain credentials. * * @param domainCredentialsMap the map of domain credentials. * @since 3.10 */ public synchronized void setDomainCredentialsMap(Map<Domain, List<Credentials>> domainCredentialsMap) { this.domainCredentialsMap = DomainCredentials.toCopyOnWriteMap(domainCredentialsMap); }