public static void save() throws IOException { SystemCredentialsProvider.getInstance().save(); } }
/** * {@inheritDoc} */ @Override public void save() throws IOException { if (BulkChange.contains(this)) { return; } SystemCredentialsProvider.getInstance().save(); } }
/** * {@inheritDoc} */ @Override public void save() throws IOException { if (BulkChange.contains(this)) { return; } SystemCredentialsProvider.getInstance().save(); } }
private static String checkLocalKubernetesToken() { File file = new File(KUBE_TOKEN_PATH); if (file.exists() && file.canRead() ) { try { String token = IOUtils.toString(file.toURI() ); TokenCredentialsImpl kubeServiceToken = new TokenCredentialsImpl(CredentialsScope.SYSTEM, KUBE_SERVICE_TOKEN_ID, "Local Kubernetes service token", Secret.fromString(token) ); SystemCredentialsProvider.getInstance().getCredentials().add(kubeServiceToken); SystemCredentialsProvider.getInstance().save(); return KUBE_SERVICE_TOKEN_ID; } catch (IOException excep) { LOGGER.warning("Unable to read Kubernetes service token file: " + excep); } } return StringUtils.EMPTY; }
public static String setCredentials(final String hostName, String username, String password) { List<DomainSpecification> domainSpecifications = new ArrayList<>(); domainSpecifications.add(new HostnameSpecification(hostName, null)); Domain domain = new Domain("Generated for " + hostName, "", domainSpecifications); SystemCredentialsProvider.getInstance().getDomainCredentialsMap().put(domain, new ArrayList<Credentials>()); String credentialsId; StandardUsernamePasswordCredentials newCredential = new UsernamePasswordCredentialsImpl( CredentialsScope.GLOBAL, credentialsId = UUID.randomUUID().toString(), "Generated for " + username, username, password ); SystemCredentialsProvider.getInstance().getDomainCredentialsMap().get(domain).add(newCredential); try { SystemCredentialsProvider.getInstance().save(); } catch (IOException ex) { LOGGER.log(Level.WARNING, "SystemCredentialsProvider instance save failed: ", ex); } return credentialsId; }
credentialsProvider.save();
SystemCredentialsProvider.getInstance().getCredentials().add(newCredentials); try { SystemCredentialsProvider.getInstance().save(); LOGGER.log(Level.INFO, "Provided username and password were successfully migrated and stored as {0}", newCredentials.getId()); } catch (IOException e) {
/** * Short-cut method that redundantly checks the specified permission (to catch any typos) and then escalates * authentication in order to save the {@link CredentialsStore}. * * @param p the permissions of the operation being performed. * @throws IOException if something goes wrong. */ private void checkedSave(Permission p) throws IOException { checkPermission(p); Authentication old = SecurityContextHolder.getContext().getAuthentication(); SecurityContextHolder.getContext().setAuthentication(ACL.SYSTEM); try { save(); } finally { SecurityContextHolder.getContext().setAuthentication(old); } }
/** * Short-cut method that redundantly checks the specified permission (to catch any typos) and then escalates * authentication in order to save the {@link CredentialsStore}. * * @param p the permissions of the operation being performed. * @throws IOException if something goes wrong. */ private void checkedSave(Permission p) throws IOException { checkPermission(p); Authentication old = SecurityContextHolder.getContext().getAuthentication(); SecurityContextHolder.getContext().setAuthentication(ACL.SYSTEM); try { save(); } finally { SecurityContextHolder.getContext().setAuthentication(old); } }