/** * Serializes to a byte stream. * Uses UTF-8 encoding and specifies that in the XML encoding declaration. * @since 1.504 */ public void toXMLUTF8(Object obj, OutputStream out) throws IOException { Writer w = new OutputStreamWriter(out, Charset.forName("UTF-8")); w.write("<?xml version=\"1.1\" encoding=\"UTF-8\"?>\n"); toXML(obj, w); }
public String toXML() { return Jenkins.XSTREAM2.toXML(this); }
public String toXML() { return Jenkins.XSTREAM2.toXML(this); }
/** * Serializes to a byte stream. * Uses UTF-8 encoding and specifies that in the XML encoding declaration. * @since 1.504 */ public void toXMLUTF8(Object obj, OutputStream out) throws IOException { Writer w = new OutputStreamWriter(out, Charset.forName("UTF-8")); w.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"); toXML(obj, w); }
/** * {@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; } Items.XSTREAM2.toXML(domain, new OutputStreamWriter(stdout, "UTF-8")); return 0; }
/** * {@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; } Items.XSTREAM2.toXML(domain, new OutputStreamWriter(stdout, "UTF-8")); return 0; }
@Override public void createNewNode(final Node node) { final String content = Jenkins.XSTREAM2.toXML(node); createNewHistoryEntryAndSaveConfig(node, content, Messages.ConfigHistoryListenerHelper_CREATED(), null, null); }
@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; }
/** * {@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; } CredentialsStoreAction.SECRETS_REDACTED.toXML(existing, new OutputStreamWriter(stdout, "UTF-8")); return 0; }
/** * {@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; } CredentialsStoreAction.SECRETS_REDACTED.toXML(existing, new OutputStreamWriter(stdout, "UTF-8")); return 0; }
private StringParameterValue toStringValue(BuildSelector selector) { return new StringParameterValue( getName(), XSTREAM.toXML(selector).replaceAll("[\n\r]+", ""), getDescription()); }
@Override public void saveNode(final Node node) { final String content = Jenkins.XSTREAM2.toXML(node); if (checkDuplicate(node)) { createNewHistoryEntryAndSaveConfig(node, content, Messages.ConfigHistoryListenerHelper_CHANGED(), null, null); } }
/** * Creates a fingerprint that can be used to track the usage of a specific credential. * * @param c the credential to fingerprint. * @return the Fingerprint. * @throws IOException if the credential's fingerprint hash could not be computed. * @since 2.1.1 */ @NonNull public static Fingerprint getOrCreateFingerprintOf(@NonNull Credentials c) throws IOException { String pseudoFilename = String.format("Credential id=%s name=%s", c instanceof IdCredentials ? ((IdCredentials) c).getId() : "unknown", CredentialsNameProvider.name(c)); try { MessageDigest md5 = MessageDigest.getInstance("MD5"); DigestOutputStream out = new DigestOutputStream(new NullOutputStream(), md5); try { FINGERPRINT_XML.toXML(c, new OutputStreamWriter(out, Charset.forName("UTF-8"))); } finally { IOUtils.closeQuietly(out); } return Jenkins.getActiveInstance().getFingerprintMap().getOrCreate(null, pseudoFilename, md5.digest()); } catch (NoSuchAlgorithmException e) { throw new IllegalStateException("JLS mandates MD5 as a supported digest algorithm"); } }
/** * Retrieves the {@link Fingerprint} for a specific credential. * * @param c the credential. * @return the {@link Fingerprint} or {@code null} if the credential has no fingerprint associated with it. * @throws IOException if the credential's fingerprint hash could not be computed. * @since 2.1.1 */ @CheckForNull public static Fingerprint getFingerprintOf(@NonNull Credentials c) throws IOException { try { MessageDigest md5 = MessageDigest.getInstance("MD5"); DigestOutputStream out = new DigestOutputStream(new NullOutputStream(), md5); try { FINGERPRINT_XML.toXML(c, new OutputStreamWriter(out, Charset.forName("UTF-8"))); } finally { IOUtils.closeQuietly(out); } return Jenkins.getActiveInstance().getFingerprintMap().get(Util.toHexString(md5.digest())); } catch (NoSuchAlgorithmException e) { throw new IllegalStateException("JLS mandates MD5 as a supported digest algorithm"); } }
/** * Retrieves the {@link Fingerprint} for a specific credential. * * @param c the credential. * @return the {@link Fingerprint} or {@code null} if the credential has no fingerprint associated with it. * @throws IOException if the credential's fingerprint hash could not be computed. * @since 2.1.1 */ @CheckForNull public static Fingerprint getFingerprintOf(@NonNull Credentials c) throws IOException { try { MessageDigest md5 = MessageDigest.getInstance("MD5"); DigestOutputStream out = new DigestOutputStream(new NullOutputStream(), md5); try { FINGERPRINT_XML.toXML(c, new OutputStreamWriter(out, Charset.forName("UTF-8"))); } finally { IOUtils.closeQuietly(out); } return Jenkins.getActiveInstance().getFingerprintMap().get(Util.toHexString(md5.digest())); } catch (NoSuchAlgorithmException e) { throw new IllegalStateException("JLS mandates MD5 as a supported digest algorithm"); } }
private synchronized void saveToRunMapXml() { if (!isDirty() || persistenceFile == null) { return; } AtomicFileWriter w = null; try { w = new AtomicFileWriter(persistenceFile); w.write("<?xml version='1.0' encoding='UTF-8'?>\n"); xstream.toXML(this, w); w.commit(); markDirty(false); } catch (Exception ex) { LOGGER.log(Level.SEVERE, "Cannot write RunMap.xml", ex); } finally { if ( w != null) { try { w.abort();} catch (IOException ex) {}; } } }
public void doSubmit(StaplerRequest req, StaplerResponse rsp) throws ServletException, IOException { // stapler-class in form data tells Stapler which Fruit subclass to use Fruit fruit = req.bindJSON(Fruit.class, req.getSubmittedForm().getJSONObject("fruit")); rsp.setContentType("text/plain"); new XStream2().toXML(fruit, rsp.getWriter()); }
public void doSubmit(StaplerRequest req, StaplerResponse rsp) throws ServletException, IOException { // stapler-class in form data tells Stapler which Fruit subclass to use Fruit fruit = req.bindJSON(Fruit.class, req.getSubmittedForm().getJSONObject("fruit")); rsp.setContentType("text/plain"); new XStream2().toXML(fruit, rsp.getWriter()); }
public void doSubmit(StaplerRequest req, StaplerResponse rsp) throws ServletException, IOException { // '$class' in form data tells Stapler which Fruit subclass to use, // older versions of Jenkins/Stapler used 'stapler-class' Fruit fruit = req.bindJSON(Fruit.class, req.getSubmittedForm().getJSONObject("fruit")); rsp.setContentType("text/plain"); new XStream2().toXML(fruit, rsp.getWriter()); }
@Override public FormValidation validateVersion(String name, String version) { if (!Items.XSTREAM2.toXML(scm).contains("${library." + name + ".version}")) { return FormValidation.warningWithMarkup("When using <b>" + getDescriptor().getDisplayName() + "</b>, you will need to include <code>${library." + Util.escape(name) + ".version}</code> in the SCM configuration somewhere."); } return FormValidation.okWithMarkup("Cannot validate default version with legacy SCM plugins via <b>" + getDescriptor().getDisplayName() + "</b>. Use " + Jenkins.getActiveInstance().getDescriptorByType(SCMSourceRetriever.DescriptorImpl.class).getDisplayName() + " if available."); }