/** * Adds a new {@link Domain} with seed credentials. * * @param domain the domain. * @param credentials the initial credentials with which to populate the domain. * @return {@code true} if the {@link CredentialsStore} was modified. * @throws java.io.IOException if the change could not be persisted. */ public final boolean addDomain(@NonNull Domain domain, Credentials... credentials) throws IOException { return addDomain(domain, Arrays.asList(credentials)); }
/** * Adds a new {@link Domain} with seed credentials. * * @param domain the domain. * @param credentials the initial credentials with which to populate the domain. * @return {@code true} if the {@link CredentialsStore} was modified. * @throws java.io.IOException if the change could not be persisted. */ public final boolean addDomain(@NonNull Domain domain, Credentials... credentials) throws IOException { return addDomain(domain, Arrays.asList(credentials)); }
private static String createCredentials(String serverAPIUrl, StandardCredentials credentials) throws Exception { List<DomainSpecification> specifications = new ArrayList<DomainSpecification>(2); URI serverUri = new URI(serverAPIUrl); if (serverUri.getPort() > 0) { specifications.add(new HostnamePortSpecification(serverUri.getHost() + ":" + serverUri.getPort(), null)); } else { specifications.add(new HostnameSpecification(serverUri.getHost(), null)); } specifications.add(new SchemeSpecification(serverUri.getScheme())); String path = serverUri.getPath(); if (StringUtils.isEmpty(path)) { path = "/"; } specifications.add(new PathSpecification(path, null, false)); Domain domain = new Domain(serverUri.getHost(), "Auto generated credentials domain", specifications); CredentialsStore provider = new SystemCredentialsProvider.StoreImpl(); provider.addDomain(domain, credentials); return credentials.getId(); }
/** * {@inheritDoc} */ @Override protected int run() throws Exception { store.checkPermission(CredentialsProvider.MANAGE_DOMAINS); Domain domain = (Domain) Items.XSTREAM.unmarshal(safeXmlStreamReader(stdin)); if (store.addDomain(domain)) { return 0; } stderr.println("No change"); return 1; } }
/** * {@inheritDoc} */ @Override protected int run() throws Exception { store.checkPermission(CredentialsProvider.MANAGE_DOMAINS); Domain domain = (Domain) Items.XSTREAM.unmarshal(safeXmlStreamReader(stdin)); if (store.addDomain(domain)) { return 0; } stderr.println("No change"); return 1; } }
@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; }
if (store.addDomain(domain, credential)) { return credential;