/** * Get all the ({@link Domain#global()}) credentials. * * @return all the ({@link Domain#global()}) credentials. */ @SuppressWarnings("unused") // used by stapler public List<Credentials> getCredentials() { return domainCredentialsMap.get(Domain.global()); }
/** * Get all the ({@link Domain#global()}) credentials. * * @return all the ({@link Domain#global()}) credentials. */ @SuppressWarnings("unused") // used by stapler public List<Credentials> getCredentials() { return domainCredentialsMap.get(Domain.global()); }
/** * Gets all the user's credentials. * * @return all the user's credentials. */ @SuppressWarnings("unused") // used by stapler public List<Credentials> getCredentials() { checkPermission(CredentialsProvider.VIEW); return domainCredentialsMap.get(Domain.global()); }
/** * Stapler's constructor. * * @param domain the domain. * @param credentials the credentials. */ @DataBoundConstructor public DomainCredentials(Domain domain, List<Credentials> credentials) { this.domain = domain == null ? Domain.global() : domain.resolve(); this.credentials = credentials == null ? new ArrayList<Credentials>() : new ArrayList<Credentials>(credentials); }
/** * Tests if this is the {@link #global()} domain. * * @return {@code true} if and only if this is the {@link #global()} domain. * @since 2.0 */ public boolean isGlobal() { return equals(global()); }
/** * Returns all the {@link com.cloudbees.plugins.credentials.domains.Domain}s that this credential provider has. * Most implementers of {@link CredentialsStore} will probably want to override this method. * * @return the list of domains. */ @NonNull public List<Domain> getDomains() { return Collections.singletonList(Domain.global()); }
/** * Expose a flag to indicate that the wrapped domain is the global domain. * * @return {@code true} if and only if the wrapped domain is the global domain. */ @Exported public boolean isGlobal() { return domain == Domain.global(); }
/** * Returns all the {@link com.cloudbees.plugins.credentials.domains.Domain}s that this credential provider has. * Most implementers of {@link CredentialsStore} will probably want to override this method. * * @return the list of domains. */ @NonNull public List<Domain> getDomains() { return Collections.singletonList(Domain.global()); }
/** * Gets all the folder's credentials. * * @return all the folder's credentials. */ @SuppressWarnings("unused") // used by stapler public List<Credentials> getCredentials() { return getDomainCredentialsMap().get(Domain.global()); }
/** * Gets all the user's credentials. * * @return all the user's credentials. */ @SuppressWarnings("unused") // used by stapler public List<Credentials> getCredentials() { checkPermission(CredentialsProvider.VIEW); return domainCredentialsMap.get(Domain.global()); }
/** * Stapler's constructor. * * @param domain the domain. * @param credentials the credentials. */ @DataBoundConstructor public DomainCredentials(Domain domain, List<Credentials> credentials) { this.domain = domain == null ? Domain.global() : domain.resolve(); this.credentials = credentials == null ? new ArrayList<Credentials>() : new ArrayList<Credentials>(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; }
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; }
/** * Resolve the correct domain instance. * * @return the correct domain instance (i.e. replaces the global domain with {@link #global()}. */ @SuppressWarnings("ConstantConditions") public Domain resolve() { if (Util.fixEmptyAndTrim(name) == null && Util.fixEmptyAndTrim(description) == null && (specifications == null || specifications.isEmpty())) { return global(); } return this; }
@BeforeClass public static void setup() throws Exception { CredentialsStore store = CredentialsProvider.lookupStores(j.jenkins).iterator().next(); store.addCredentials(Domain.global(), globalCred); }
private static void addCredentials(ConduitCredentials credentials) throws IOException { CredentialsStore store = new SystemCredentialsProvider.UserFacingAction().getStore(); store.addCredentials(Domain.global(), credentials); }
@Issue("JENKINS-48380") @Test public void withCredentialsWrapper() throws Exception { final String credentialsId = "creds"; final String username = "bob"; final String passphrase = "s3cr3t"; final String keyContent = "the-key"; SSHUserPrivateKey c = new DummyPrivateKey(credentialsId, username, passphrase, keyContent); CredentialsProvider.lookupStores(j.jenkins).iterator().next().addCredentials(Domain.global(), c); expect("withCredentialsWrapper") .archives("userPass.txt", username + ":" + passphrase) .archives("key.txt", keyContent) .go(); }
@Test public void withDefaults() throws Exception { Folder folder = j.createProject(Folder.class); getFolderStore(folder).addCredentials(Domain.global(), folderCred); getFolderStore(folder).addCredentials(Domain.global(), grandParentCred); folder.addProperty(new FolderConfig("folder_docker", "https://folder.registry", folderCred.getId())); expect("declarativeDockerConfigWithOverride") .inFolder(folder) .runFromRepo(false) .logContains("Docker Label is: other-label", "Registry URL is: https://other.registry", "Registry Creds ID is: " + grandParentCred.getId()).go(); }
@Test public void directParent() throws Exception { Folder folder = j.createProject(Folder.class); getFolderStore(folder).addCredentials(Domain.global(), folderCred); folder.addProperty(new FolderConfig("folder_docker", "https://folder.registry", folderCred.getId())); expect("declarativeDockerConfig") .inFolder(folder) .runFromRepo(false) .logContains("Docker Label is: folder_docker", "Registry URL is: https://folder.registry", "Registry Creds ID is: " + folderCred.getId()).go(); }
@Test public void grandParent() throws Exception { Folder grandParent = j.createProject(Folder.class); getFolderStore(grandParent).addCredentials(Domain.global(), grandParentCred); grandParent.addProperty(new FolderConfig("parent_docker", "https://parent.registry", grandParentCred.getId())); Folder parent = grandParent.createProject(Folder.class, "testParent"); //Can be static since grandParent should be unique expect("declarativeDockerConfig") .inFolder(parent) .runFromRepo(false) .logContains("Docker Label is: parent_docker", "Registry URL is: https://parent.registry", "Registry Creds ID is: " + grandParentCred.getId()).go(); }