protected static Credentials getCredentialsById(CredentialsStore store, Domain domain, String id) { List<Credentials> credentialsList = store.getCredentials(domain); Set<String> ids = new HashSet<String>(credentialsList.size()); Credentials existing = null; int index = 0; for (Credentials c : credentialsList) { String cid; if (c instanceof IdCredentials) { cid = ((IdCredentials) c).getId(); } else { while (ids.contains("index-" + index)) { index++; } cid = "index-" + index; index++; } if (id.equals(cid)) { existing = c; break; } ids.add(cid); } return existing; }
protected static Credentials getCredentialsById(CredentialsStore store, Domain domain, String id) { List<Credentials> credentialsList = store.getCredentials(domain); Set<String> ids = new HashSet<String>(credentialsList.size()); Credentials existing = null; int index = 0; for (Credentials c : credentialsList) { String cid; if (c instanceof IdCredentials) { cid = ((IdCredentials) c).getId(); } else { while (ids.contains("index-" + index)) { index++; } cid = "index-" + index; index++; } if (id.equals(cid)) { existing = c; break; } ids.add(cid); } return existing; }
@Override protected int run() throws Exception { store.checkPermission(CredentialsProvider.UPDATE); List<DomainCredentials> existing = new ArrayList<>(); List<Domain> domains = store.getDomains(); for (Domain domain : domains) { existing.add(new DomainCredentials(domain, store.getCredentials(domain))); } CredentialsStoreAction.SECRETS_REDACTED.toXML(existing, new OutputStreamWriter(stdout, "UTF-8")); return 0; }
/** * Exposes a map of the wrapped credentials. * * @return a map of the wrapped credentials. */ @NonNull public Map<String, CredentialsWrapper> getCredentials() { Map<String, CredentialsWrapper> result = new LinkedHashMap<String, CredentialsWrapper>(); int index = 0; for (Credentials c : getStore().getCredentials(domain)) { String id; if (c instanceof IdCredentials) { id = ((IdCredentials) c).getId(); } else { while (result.containsKey("index-" + index)) { index++; } id = "index-" + index; index++; } result.put(id, new CredentialsWrapper(this, c, id)); } return result; }
List<Domain> domains = store.getDomains(); for (Domain domain : domains) { List<Credentials> credentials = store.getCredentials(domain); Map<String, String> nameById = new LinkedHashMap<String, String>(credentials.size()); int maxIdLen = "# of Credentials".length(), maxNameLen = 0;
/** * Exposes a map of the wrapped credentials. * * @return a map of the wrapped credentials. */ @NonNull public Map<String, CredentialsWrapper> getCredentials() { Map<String, CredentialsWrapper> result = new LinkedHashMap<String, CredentialsWrapper>(); int index = 0; for (Credentials c : getStore().getCredentials(domain)) { String id; if (c instanceof IdCredentials) { id = ((IdCredentials) c).getId(); } else { while (result.containsKey("index-" + index)) { index++; } id = "index-" + index; index++; } result.put(id, new CredentialsWrapper(this, c, id)); } return result; }
private String url(CredentialsStore store) { for (Domain d: store.getDomains()) { for (Credentials c: store.getCredentials(d)) { if (c instanceof IdCredentials && value.equals(((IdCredentials) c).getId())) { String link = store.getRelativeLinkToAction(); return link == null ? null : link + d.getUrl() + "credential/"+ Util.rawEncode(value); } } } return null; }
List<Domain> domains = store.getDomains(); for (Domain domain : domains) { List<Credentials> credentials = store.getCredentials(domain); Map<String, String> nameById = new LinkedHashMap<String, String>(credentials.size()); int maxIdLen = "# of Credentials".length(), maxNameLen = 0;
private String url(CredentialsStore store) { for (Domain d: store.getDomains()) { for (Credentials c: store.getCredentials(d)) { if (c instanceof IdCredentials && value.equals(((IdCredentials) c).getId())) { String link = store.getRelativeLinkToAction(); return link == null ? null : link + d.getUrl() + "credential/"+ Util.rawEncode(value); } } } return null; }
if (p.hasPermission(CredentialsProvider.VIEW)) { for (Domain domain : p.getDomains()) { for (Credentials c : p.getCredentials(domain)) { CredentialsScope scope = c.getScope(); if (scope != null && !scope.isVisible(context)) {
if (p.hasPermission(CredentialsProvider.VIEW)) { for (Domain domain : p.getDomains()) { for (Credentials c : p.getCredentials(domain)) { CredentialsScope scope = c.getScope(); if (scope != null && !scope.isVisible(context)) {
for (Credentials c : credentialsStore.getCredentials(d)) { if (!(c instanceof StringCredentials)) continue;
@CheckForNull private static FormValidation checkForDuplicates(String value, ModelObject context, ModelObject object) { CredentialsMatcher withId = CredentialsMatchers.withId(value); for (CredentialsStore store : CredentialsProvider.lookupStores(object)) { if (!store.hasPermission(CredentialsProvider.VIEW)) { continue; } ModelObject storeContext = store.getContext(); for (Domain domain : store.getDomains()) { for (Credentials match : CredentialsMatchers.filter(store.getCredentials(domain), withId)) { if (storeContext == context) { return FormValidation.error("This ID is already in use"); } else { CredentialsScope scope = match.getScope(); if (scope != null && !scope.isVisible(context)) { // scope is not exported to child contexts continue; } return FormValidation.warning("The ID ‘%s’ is already in use in %s", value, storeContext instanceof Item ? ((Item) storeContext).getFullDisplayName() : storeContext.getDisplayName()); } } } } return null; }
@CheckForNull private static FormValidation checkForDuplicates(String value, ModelObject context, ModelObject object) { CredentialsMatcher withId = CredentialsMatchers.withId(value); for (CredentialsStore store : CredentialsProvider.lookupStores(object)) { if (!store.hasPermission(CredentialsProvider.VIEW)) { continue; } ModelObject storeContext = store.getContext(); for (Domain domain : store.getDomains()) { for (Credentials match : CredentialsMatchers.filter(store.getCredentials(domain), withId)) { if (storeContext == context) { return FormValidation.error("This ID is already in use"); } else { CredentialsScope scope = match.getScope(); if (scope != null && !scope.isVisible(context)) { // scope is not exported to child contexts continue; } return FormValidation.warning("The ID ‘%s’ is already in use in %s", value, storeContext instanceof Item ? ((Item) storeContext).getFullDisplayName() : storeContext.getDisplayName()); } } } } return null; }