/** * {@inheritDoc} */ @Override protected int run() throws Exception { store.checkPermission(CredentialsProvider.UPDATE); Domain domain = getDomainByName(store, this.domain); if (domain == null) { stderr.println("No such domain"); return 2; } Credentials existing = getCredentialsById(store, domain, id); if (existing == null) { stderr.println("No such credential"); return 3; } Credentials replacement = (Credentials) Items.XSTREAM.unmarshal(safeXmlStreamReader(stdin)); if (store.updateCredentials(domain, existing, replacement)) { return 0; } stderr.println("No change"); return 1; } }
/** * {@inheritDoc} */ @Override protected int run() throws Exception { store.checkPermission(CredentialsProvider.UPDATE); Domain domain = getDomainByName(store, this.domain); if (domain == null) { stderr.println("No such domain"); return 2; } Credentials existing = getCredentialsById(store, domain, id); if (existing == null) { stderr.println("No such credential"); return 3; } Credentials replacement = (Credentials) Items.XSTREAM.unmarshal(safeXmlStreamReader(stdin)); if (store.updateCredentials(domain, existing, replacement)) { return 0; } stderr.println("No change"); return 1; } }
/** * Updates a {@link Credentials} by its XML definition. * * @param source source of the Item's new definition. * The source should be either a <code>StreamSource</code> or a <code>SAXSource</code>, other * sources may not be handled. * @throws IOException if things go wrong * @since 2.1.1 */ @Restricted(NoExternalUse.class) public void updateByXml(Source source) throws IOException { getStore().checkPermission(UPDATE); final StringWriter out = new StringWriter(); try { XMLUtils.safeTransform(source, new StreamResult(out)); out.close(); } catch (TransformerException e) { throw new IOException("Failed to parse credential", e); } catch (SAXException e) { throw new IOException("Failed to parse credential", e); } Credentials credentials = (Credentials) Items.XSTREAM.unmarshal(new XppDriver().createReader(new StringReader(out.toString()))); getStore().updateCredentials(domain.getDomain(), this.credentials, credentials); }
/** * Updates a {@link Credentials} by its XML definition. * * @param source source of the Item's new definition. * The source should be either a <code>StreamSource</code> or a <code>SAXSource</code>, other * sources may not be handled. * @throws IOException if things go wrong * @since 2.1.1 */ @Restricted(NoExternalUse.class) public void updateByXml(Source source) throws IOException { getStore().checkPermission(UPDATE); final StringWriter out = new StringWriter(); try { XMLUtils.safeTransform(source, new StreamResult(out)); out.close(); } catch (TransformerException e) { throw new IOException("Failed to parse credential", e); } catch (SAXException e) { throw new IOException("Failed to parse credential", e); } Credentials credentials = (Credentials) Items.XSTREAM.unmarshal(new XppDriver().createReader(new StringReader(out.toString()))); getStore().updateCredentials(domain.getDomain(), this.credentials, credentials); }
final boolean wasUpdated = credentialsStore.updateCredentials(d, c, creds); if (!wasUpdated) { LOGGER.warning("Updating Token credential failed during update call.");
/** * Updates the credentials. * * @param req the request. * @return the response. * @throws ServletException if something goes wrong. * @throws IOException if something goes wrong. */ @RequirePOST @Restricted(NoExternalUse.class) @SuppressWarnings("unused") // stapler web method public HttpResponse doUpdateSubmit(StaplerRequest req) throws ServletException, IOException { getStore().checkPermission(UPDATE); JSONObject data = req.getSubmittedForm(); Credentials credentials = req.bindJSON(Credentials.class, data); if (!getStore().updateCredentials(this.domain.domain, this.credentials, credentials)) { return HttpResponses.redirectTo("concurrentModification"); } return HttpResponses.redirectToDot(); }
/** * Updates the credentials. * * @param req the request. * @return the response. * @throws ServletException if something goes wrong. * @throws IOException if something goes wrong. */ @RequirePOST @Restricted(NoExternalUse.class) @SuppressWarnings("unused") // stapler web method public HttpResponse doUpdateSubmit(StaplerRequest req) throws ServletException, IOException { getStore().checkPermission(UPDATE); JSONObject data = req.getSubmittedForm(); Credentials credentials = req.bindJSON(Credentials.class, data); if (!getStore().updateCredentials(this.domain.domain, this.credentials, credentials)) { return HttpResponses.redirectTo("concurrentModification"); } return HttpResponses.redirectToDot(); }