@Override public byte[] decode(final String base64) { return codec.decode(base64); }
public Object fromString(String str) { return base64.decode(str); } }
public Object fromString(String str) { return base64.decode(str); } }
public byte[] convert(String inputData) { return base64Encoder.decode(inputData.trim()); } }
public static byte[] base64ToByteArray(String s) { return new Base64Encoder().decode(s); } }
public static byte[] base64Decode(String data) { return new Base64Encoder().decode(data); }
/** * Decrypt with AES algorithm * * @param encrypted Ciphered text * @param passphrase Password for decryption * @param encoding Encoding * @return Decrypted text */ public String decrypt(String encrypted, String passphrase, String encoding) { if (encrypted.length() == 0) { return null; } try { byte[] decoded = base64Encoder.decode(encrypted); byte[] iv = Arrays.copyOfRange(decoded, 0, GCM_IV_LENGTH); Cipher cipher = generateCipher(iv, passphrase, Cipher.DECRYPT_MODE); if (cipher != null) { byte[] ciphertext = cipher.doFinal(decoded, GCM_IV_LENGTH, decoded.length - GCM_IV_LENGTH); return new String(ciphertext, encoding); } } catch (IllegalBlockSizeException | BadPaddingException | UnsupportedEncodingException exc) { logger.error("Error decoding string {0}", encrypted, exc); } return null; } }
public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) { String data = reader.getValue(); // needs to be called before hasMoreChildren. if (!reader.hasMoreChildren()) { return base64.decode(data); } else { // backwards compatability ... try to unmarshal byte arrays that haven't been encoded return unmarshalIndividualByteElements(reader, context); } }
public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) { String data = reader.getValue(); // needs to be called before hasMoreChildren. if (!reader.hasMoreChildren()) { return base64.decode(data); } else { // backwards compatability ... try to unmarshal byte arrays that haven't been encoded return unmarshalIndividualByteElements(reader, context); } }
/** * {@inheritDoc} */ public ObjectId legacyUnmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) { reader.moveDown(); ObjectId sha1 = ObjectId.fromRaw(base64.decode(reader.getValue())); reader.moveUp(); return sha1; } }
public Object unmarshal(HierarchicalStreamReader reader,UnmarshallingContext context) { Field4Rest toReturn = null; String name = reader.getAttribute("name"); String type = reader.getAttribute("type"); Byte typeId; if (type.equalsIgnoreCase("numeric")) typeId = DataTypes.DOUBLE; else if (type.equalsIgnoreCase("string")) typeId = DataTypes.VARCHAR; else typeId = DataTypes.BINARY; Boolean isNull = false; if (reader.getAttribute("is-null")!=null) isNull = Boolean.valueOf(reader.getAttribute("is-null")); Serializable value = null; if (!isNull) { if (type.equalsIgnoreCase("string")) value = reader.getValue(); else if (type.equalsIgnoreCase("numeric")) value = Double.parseDouble(reader.getValue()); else value = (byte[]) base64.decode(reader.getValue()); } toReturn = new Field4Rest(name,typeId,value); return toReturn; }
/** * Legacy unmarshalling of object id * * @param reader stream reader * @param context usage context of reader * @return object id */ protected Object legacyUnmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) { reader.moveDown(); ObjectId sha1 = ObjectId.fromRaw(base64.decode(reader.getValue())); reader.moveUp(); return sha1; }