@Override public void write(OutputNode node, String raw) throws Exception { if (encryptedFields.contains(node.getName())) { node.setValue(TransferSettings.encrypt(raw)); node.setAttribute("encrypted", Boolean.TRUE.toString()); } else { node.setValue(raw); } }
@Override public String read(InputNode node) throws Exception { InputNode encryptedAttribute = node.getAttribute("encrypted"); if (encryptedAttribute != null && encryptedAttribute.getValue().equals(Boolean.TRUE.toString())) { return TransferSettings.decrypt(node.getValue()); } return node.getValue(); }
@Override public void write(OutputNode node, FileContent.FileChecksum value) throws Exception { node.setValue(value.toString()); } }
@Override public PartialFileHistory.FileHistoryId read(InputNode node) throws Exception { return PartialFileHistory.FileHistoryId.parseFileId(node.getValue()); }
/** * This is used to create an <code>InputNode</code> that can be * used to read XML from the specified stream. The stream will * be positioned at the root element in the XML document. * * @param source this contains the contents of the XML source * * @throws Exception thrown if there is an I/O exception */ public static InputNode read(InputStream source) throws Exception { return read(PROVIDER.provide(source)); }
private byte[] getPlaintextStorageXml() throws Exception { ByteArrayOutputStream plaintextByteArrayOutputStream = new ByteArrayOutputStream(); DataOutputStream plaintextOutputStream = new DataOutputStream(plaintextByteArrayOutputStream); plaintextOutputStream.writeInt(transferSettings.getType().getBytes().length); plaintextOutputStream.write(transferSettings.getType().getBytes()); GZIPOutputStream plaintextGzipOutputStream = new GZIPOutputStream(plaintextOutputStream); new Persister(new Format(0)).write(transferSettings, plaintextGzipOutputStream); plaintextGzipOutputStream.close(); return plaintextByteArrayOutputStream.toByteArray(); } }
public void write(OutputNode node, SaltedSecretKey saltedSecretKey) { node.setAttribute("salt", StringUtil.toHex(saltedSecretKey.getSalt())); node.setAttribute("key", StringUtil.toHex(saltedSecretKey.getEncoded())); } }
/** * Constructor for the <code>HyphenStyle</code> object. This is * used to create a style that will hyphenate XML attributes * and elements allowing a consistent format for generated XML. */ public HyphenStyle() { this.style = new HyphenBuilder(); this.builder = new Builder(style); }
/** * Returns the <code>OutputNode</code> object at the cursor * position. If the cursor has reached the start of the list * then this returns null instead of the first output node. * * @return this returns the node from the cursor position */ public OutputNode next() { if(hasNext()) { return get(--cursor); } return null; }
public SaltedSecretKey read(InputNode node) throws Exception { byte[] saltBytes = StringUtil.fromHex(node.getAttribute("salt").getValue()); byte[] keyBytes = StringUtil.fromHex(node.getAttribute("key").getValue()); return new SaltedSecretKey(new SecretKeySpec(keyBytes, CipherParams.MASTER_KEY_DERIVATION_FUNCTION), saltBytes); }
@Override public FileContent.FileChecksum read(InputNode node) throws Exception { return FileContent.FileChecksum.parseFileChecksum(node.getValue()); }
@Override public void write(OutputNode node, PartialFileHistory.FileHistoryId value) throws Exception { node.setValue(value.toString()); } }
/** * This is used to create an <code>InputNode</code> that can be * used to read XML from the specified reader. The reader will * be positioned at the root element in the XML document. * * @param source this contains the contents of the XML source * * @throws Exception thrown if there is an I/O exception */ public static InputNode read(Reader source) throws Exception { return read(PROVIDER.provide(source)); }
/** * Constructor for the <code>HyphenStyle</code> object. This is * used to create a style that will hyphenate XML attributes * and elements allowing a consistent format for generated XML. */ public HyphenStyle() { this.style = new HyphenBuilder(); this.builder = new Builder(style); }
@Override public VectorClock read(InputNode node) throws Exception { return VectorClock.parseVectorClock(node.getValue()); }
@Override public void write(OutputNode node, VectorClock value) throws Exception { node.setValue(value.toString()); } }
/** * This is used to create an <code>InputNode</code> that can be * used to read XML from the specified stream. The stream will * be positioned at the root element in the XML document. * * @param source this contains the contents of the XML source * * @throws Exception thrown if there is an I/O exception */ public static InputNode read(InputStream source) throws Exception { return read(PROVIDER.provide(source)); }
/** * This is used to create an <code>InputNode</code> that can be * used to read XML from the specified reader. The reader will * be positioned at the root element in the XML document. * * @param source this contains the contents of the XML source * * @throws Exception thrown if there is an I/O exception */ public static InputNode read(Reader source) throws Exception { return read(PROVIDER.provide(source)); }
/** * This is used to create an <code>InputNode</code> that can be * used to read XML from the specified stream. The stream will * be positioned at the root element in the XML document. * * @param source this contains the contents of the XML source * * @throws Exception thrown if there is an I/O exception */ public static InputNode read(InputStream source) throws Exception { return read(PROVIDER.provide(source)); }
/** * This is used to create an <code>InputNode</code> that can be * used to read XML from the specified reader. The reader will * be positioned at the root element in the XML document. * * @param source this contains the contents of the XML source * * @throws Exception thrown if there is an I/O exception */ public static InputNode read(Reader source) throws Exception { return read(PROVIDER.provide(source)); }