Tabnine Logo
CredentialsStore.getDomains
Code IndexAdd Tabnine to your IDE (free)

How to use
getDomains
method
in
com.cloudbees.plugins.credentials.CredentialsStore

Best Java code snippets using com.cloudbees.plugins.credentials.CredentialsStore.getDomains (Showing top 20 results out of 315)

origin: jenkinsci/gitlab-plugin

  @Initializer(after = InitMilestone.PLUGINS_STARTED)
  public static void migrate() throws IOException {
    GitLabConnectionConfig descriptor = (GitLabConnectionConfig) Jenkins.getInstance().getDescriptor(GitLabConnectionConfig.class);
    for (GitLabConnection connection : descriptor.getConnections()) {
      if (connection.apiTokenId == null && connection.apiToken != null) {
        for (CredentialsStore credentialsStore : CredentialsProvider.lookupStores(Jenkins.getInstance())) {
          if (credentialsStore instanceof SystemCredentialsProvider.StoreImpl) {
            List<Domain> domains = credentialsStore.getDomains();
            connection.apiTokenId = UUID.randomUUID().toString();
            credentialsStore.addCredentials(domains.get(0),
              new GitLabApiTokenImpl(CredentialsScope.SYSTEM, connection.apiTokenId, "GitLab API Token", Secret.fromString(connection.apiToken)));
          }
        }
      }
    }
    descriptor.save();
  }
}
origin: org.jenkins-ci.plugins/credentials

protected static Domain getDomainByName(CredentialsStore store, String domain) {
  if (StringUtils.equals("_", domain) || StringUtils.isBlank(domain) || "(global)".equals(domain)) {
    return Domain.global();
  } else {
    for (Domain d : store.getDomains()) {
      if (domain.equals(d.getName())) {
        return d;
      }
    }
  }
  return null;
}
origin: jenkinsci/credentials-plugin

protected static Domain getDomainByName(CredentialsStore store, String domain) {
  if (StringUtils.equals("_", domain) || StringUtils.isBlank(domain) || "(global)".equals(domain)) {
    return Domain.global();
  } else {
    for (Domain d : store.getDomains()) {
      if (domain.equals(d.getName())) {
        return d;
      }
    }
  }
  return null;
}
origin: jenkinsci/credentials-plugin

@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;
}
origin: org.jenkins-ci.plugins/credentials

/**
 * Retrieves the domain with the matching name.
 *
 * @param name the name (or {@code null} to match {@link Domain#global()} as that is the domain with a null name)
 * @return the domain or {@code null} if there is no domain with the supplied name.
 * @since 2.1.1
 */
@CheckForNull
public Domain getDomainByName(@CheckForNull String name) {
  for (Domain d : getDomains()) {
    if (StringUtils.equals(name, d.getName())) {
      return d;
    }
  }
  return null;
}
origin: jenkinsci/credentials-plugin

/**
 * Retrieves the domain with the matching name.
 *
 * @param name the name (or {@code null} to match {@link Domain#global()} as that is the domain with a null name)
 * @return the domain or {@code null} if there is no domain with the supplied name.
 * @since 2.1.1
 */
@CheckForNull
public Domain getDomainByName(@CheckForNull String name) {
  for (Domain d : getDomains()) {
    if (StringUtils.equals(name, d.getName())) {
      return d;
    }
  }
  return null;
}
origin: org.jenkins-ci.plugins/credentials

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;
}
origin: jenkinsci/credentials-plugin

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;
}
origin: org.jenkins-ci.plugins/credentials

for (Domain d : action.getStore().getDomains()) {
  if (wrapper != null && wrapper.domain == d) {
    continue;
origin: jenkinsci/credentials-plugin

for (Domain d : action.getStore().getDomains()) {
  if (wrapper != null && wrapper.domain == d) {
    continue;
origin: org.jenkins-ci.plugins/credentials

/**
 * Returns the map of {@link DomainWrapper} instances.
 *
 * @return the map of {@link DomainWrapper} instances.
 */
@Exported
@NonNull
public Map<String, DomainWrapper> getDomains() {
  Map<String, DomainWrapper> result = new TreeMap<String, DomainWrapper>();
  for (Domain d : getStore().getDomains()) {
    String name;
    if (d.isGlobal()) {
      name = "_";
    } else {
      name = d.getName();
    }
    result.put(name, new DomainWrapper(this, d));
  }
  return result;
}
origin: jenkinsci/credentials-plugin

/**
 * Returns the map of {@link DomainWrapper} instances.
 *
 * @return the map of {@link DomainWrapper} instances.
 */
@Exported
@NonNull
public Map<String, DomainWrapper> getDomains() {
  Map<String, DomainWrapper> result = new TreeMap<String, DomainWrapper>();
  for (Domain d : getStore().getDomains()) {
    String name;
    if (d.isGlobal()) {
      name = "_";
    } else {
      name = d.getName();
    }
    result.put(name, new DomainWrapper(this, d));
  }
  return result;
}
origin: org.jenkins-ci.plugins/credentials

for (CredentialsStore p : CredentialsProvider.lookupStores(context)) {
  if (p.hasPermission(CredentialsProvider.VIEW)) {
    for (Domain domain : p.getDomains()) {
      for (Credentials c : p.getCredentials(domain)) {
        CredentialsScope scope = c.getScope();
origin: jenkinsci/credentials-plugin

for (CredentialsStore p : CredentialsProvider.lookupStores(context)) {
  if (p.hasPermission(CredentialsProvider.VIEW)) {
    for (Domain domain : p.getDomains()) {
      for (Credentials c : p.getCredentials(domain)) {
        CredentialsScope scope = c.getScope();
origin: org.jenkins-ci.plugins/credentials

@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;
}
origin: org.jenkins-ci.plugins/credentials

/**
 * Stapler web binding for adding credentials to the domain.
 *
 * @param req the request.
 * @param rsp the response.
 * @throws IOException      if something goes wrong.
 * @throws ServletException if something goes wrong.
 */
@RequirePOST
public void doAddCredentials(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException {
  if (!store.isDomainsModifiable()) {
    hudson.util.HttpResponses.status(400).generateResponse(req, rsp, null);
    FormApply.applyResponse("window.alert('Domain is read-only')").generateResponse(req, rsp, null);
  }
  store.checkPermission(CredentialsStoreAction.CREATE);
  JSONObject data = req.getSubmittedForm();
  String domainName = data.getString("domain");
  CredentialsStoreAction.DomainWrapper wrapper = getWrappers().get(domainName);
  if (!store.getDomains().contains(wrapper.getDomain())) {
    hudson.util.HttpResponses.status(400).generateResponse(req, rsp, null);
    FormApply.applyResponse("window.alert('Store does not have selected domain')")
        .generateResponse(req, rsp, null);
  }
  store.checkPermission(CredentialsStoreAction.CREATE);
  Credentials credentials = req.bindJSON(Credentials.class, data.getJSONObject("credentials"));
  store.addCredentials(wrapper.getDomain(), credentials);
  FormApply.applyResponse("window.credentials.refreshAll();").generateResponse(req, rsp, null);
}
origin: jenkinsci/credentials-plugin

@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;
}
origin: org.jenkins-ci.plugins/credentials

/**
 * Creates the children context menu with the supplied prefix to all URLs.
 *
 * @param prefix the prefix to prepend to relative urls.
 * @return the {@link ContextMenu} or {@code null}
 * @since 2.0
 */
@CheckForNull
public ContextMenu getChildrenContextMenu(String prefix) {
  ContextMenu menu = new ContextMenu();
  for (Domain d : getStore().getDomains()) {
    MenuItem item =
        new MenuItem(d.getUrl(), getMenuItemIconUrlByClassSpec("icon-credentials-domain icon-md"),
            d.isGlobal()
                ? Messages.CredentialsStoreAction_GlobalDomainDisplayName()
                : d.getName()
        );
    item.subMenu = new DomainWrapper(this, d).getContextMenu(ContextMenuIconUtils.buildUrl(prefix, d.getUrl()));
    menu.add(item);
  }
  return menu.items.isEmpty() ? null : menu;
}
origin: jenkinsci/credentials-plugin

/**
 * Creates the children context menu with the supplied prefix to all URLs.
 *
 * @param prefix the prefix to prepend to relative urls.
 * @return the {@link ContextMenu} or {@code null}
 * @since 2.0
 */
@CheckForNull
public ContextMenu getChildrenContextMenu(String prefix) {
  ContextMenu menu = new ContextMenu();
  for (Domain d : getStore().getDomains()) {
    MenuItem item =
        new MenuItem(d.getUrl(), getMenuItemIconUrlByClassSpec("icon-credentials-domain icon-md"),
            d.isGlobal()
                ? Messages.CredentialsStoreAction_GlobalDomainDisplayName()
                : d.getName()
        );
    item.subMenu = new DomainWrapper(this, d).getContextMenu(ContextMenuIconUtils.buildUrl(prefix, d.getUrl()));
    menu.add(item);
  }
  return menu.items.isEmpty() ? null : menu;
}
origin: jenkinsci/credentials-plugin

/**
 * Stapler web binding for adding credentials to the domain.
 *
 * @param req the request.
 * @param rsp the response.
 * @throws IOException      if something goes wrong.
 * @throws ServletException if something goes wrong.
 */
@RequirePOST
public void doAddCredentials(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException {
  if (!store.isDomainsModifiable()) {
    hudson.util.HttpResponses.status(400).generateResponse(req, rsp, null);
    FormApply.applyResponse("window.alert('Domain is read-only')").generateResponse(req, rsp, null);
  }
  store.checkPermission(CredentialsStoreAction.CREATE);
  JSONObject data = req.getSubmittedForm();
  String domainName = data.getString("domain");
  CredentialsStoreAction.DomainWrapper wrapper = getWrappers().get(domainName);
  if (!store.getDomains().contains(wrapper.getDomain())) {
    hudson.util.HttpResponses.status(400).generateResponse(req, rsp, null);
    FormApply.applyResponse("window.alert('Store does not have selected domain')")
        .generateResponse(req, rsp, null);
  }
  store.checkPermission(CredentialsStoreAction.CREATE);
  Credentials credentials = req.bindJSON(Credentials.class, data.getJSONObject("credentials"));
  store.addCredentials(wrapper.getDomain(), credentials);
  FormApply.applyResponse("window.credentials.refreshAll();").generateResponse(req, rsp, null);
}
com.cloudbees.plugins.credentialsCredentialsStoregetDomains

Javadoc

Returns all the com.cloudbees.plugins.credentials.domains.Domains that this credential provider has. Most implementers of CredentialsStore will probably want to override this method.

Popular methods of CredentialsStore

  • addCredentials
    Adds the specified Credentials within the specified Domain for this CredentialsStore.
  • addDomain
    Adds a new Domain with seed credentials.
  • getContext
    Returns the context within which this store operates. Credentials in this store will be available to
  • getProvider
    Returns the CredentialsProvider.
  • getCredentials
    Returns an unmodifiable list of credentials for the specified domain.
  • isDomainsModifiable
    Identifies whether this CredentialsStore supports making changes to the list of domains or whether i
  • updateCredentials
    Updates the specified Credentials from the specified Domain for this CredentialsStore with the suppl
  • _isApplicable
    CredentialsStore subtypes can override this method to veto some Descriptors from being available fro
  • checkPermission
    Checks if the current security principal has this permission. Note: This is just a convenience funct
  • getACL
  • getContextDisplayName
    Returns the display name of the #getContext() of this CredentialsStore. The default implementation c
  • getCredentialsDescriptors
    Returns the list of CredentialsDescriptor instances that are applicable within this CredentialsStore
  • getContextDisplayName,
  • getCredentialsDescriptors,
  • getRelativeLinkToAction,
  • getRelativeLinkToContext,
  • getScopes,
  • getStoreAction,
  • hasPermission,
  • isOverridden,
  • removeCredentials

Popular in Java

  • Making http requests using okhttp
  • notifyDataSetChanged (ArrayAdapter)
  • getResourceAsStream (ClassLoader)
  • putExtra (Intent)
  • FileInputStream (java.io)
    An input stream that reads bytes from a file. File file = ...finally if (in != null) in.clos
  • Format (java.text)
    The base class for all formats. This is an abstract base class which specifies the protocol for clas
  • Collection (java.util)
    Collection is the root of the collection hierarchy. It defines operations on data collections and t
  • GregorianCalendar (java.util)
    GregorianCalendar is a concrete subclass of Calendarand provides the standard calendar used by most
  • StringTokenizer (java.util)
    Breaks a string into tokens; new code should probably use String#split.> // Legacy code: StringTo
  • TimeUnit (java.util.concurrent)
    A TimeUnit represents time durations at a given unit of granularity and provides utility methods to
  • Github Copilot alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now