/** * Decodes data from Base64 notation, automatically detecting gzip-compressed data and decompressing it. * * @param s * the string to decode * @return the decoded data * @since 1.4 */ public static byte[] decode(final String s) { return decode(s, NO_OPTIONS); }
/** * Decodes data from Base64 notation, automatically detecting gzip-compressed data and decompressing it. * * @param s * the string to decode * @return the decoded data * @since 1.4 */ public static byte[] decode(final String s) { return decode(s, NO_OPTIONS); }
/** * Decodes data from Base64 notation, automatically detecting gzip-compressed * data and decompressing it. * * @param s * the string to decode * @return the decoded data * @since 1.4 */ public static byte[] decode(String s) { return decode(s, NO_OPTIONS); }
public static byte[] base64DecodeAndGather(final String encodedString) throws IOException { final String[] encodedFragments = encodedString.split(BASE64_BYTES_FRAGMENT_SEPARATOR); final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); for (final String encodedFragment : encodedFragments) { final byte[] decodedFragment = Base64.decode(encodedFragment); byteArrayOutputStream.write(decodedFragment); } final byte[] decodedBytes = byteArrayOutputStream.toByteArray(); byteArrayOutputStream.close(); return decodedBytes; }
public static byte[] base64DecodeAndGather(final String encodedString) throws IOException { final String[] encodedFragments = encodedString.split(BASE64_BYTES_FRAGMENT_SEPARATOR); final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); for (final String encodedFragment : encodedFragments) { final byte[] decodedFragment = Base64.decode(encodedFragment); byteArrayOutputStream.write(decodedFragment); } final byte[] decodedBytes = byteArrayOutputStream.toByteArray(); byteArrayOutputStream.close(); return decodedBytes; }
/** * Attempts to decode Base64 data and deserialize a Java Object within. Returns <tt>null</tt> if there was an error. * * @param encodedObject * The Base64 data to decode * @param options * Specified options * @return The decoded and deserialized object * @since 1.5 */ public static Object decodeToObject(final String encodedObject, final int options) { // Decode and gunzip if necessary final byte[] objBytes = decode(encodedObject, options); ByteArrayInputStream bais = null; ObjectInputStream ois = null; Object obj = null; try { bais = new ByteArrayInputStream(objBytes); ois = new ObjectInputStream(bais); obj = ois.readObject(); } catch (final IOException e) { e.printStackTrace(); } catch (final ClassNotFoundException e) { e.printStackTrace(); } finally { Misc.close(bais); Misc.close(ois); } // end finally return obj; } // end decodeObject
/** * Attempts to decode Base64 data and deserialize a Java Object within. Returns <tt>null</tt> if there was an error. * * @param encodedObject * The Base64 data to decode * @param options * Specified options * @return The decoded and deserialized object * @since 1.5 */ public static Object decodeToObject(final String encodedObject, final int options) { // Decode and gunzip if necessary final byte[] objBytes = decode(encodedObject, options); ByteArrayInputStream bais = null; ObjectInputStream ois = null; Object obj = null; try { bais = new ByteArrayInputStream(objBytes); ois = new ObjectInputStream(bais); obj = ois.readObject(); } catch (final IOException e) { e.printStackTrace(); } catch (final ClassNotFoundException e) { e.printStackTrace(); } finally { Misc.close(bais); Misc.close(ois); } // end finally return obj; } // end decodeObject
byte[] objBytes = decode(encodedObject, options);
bytes = decode(bytes, 0, bytes.length, options);
bytes = decode(bytes, 0, bytes.length, options);
bytes = decode(bytes, 0, bytes.length, options);
final String usernameAndPassword = new String(Base64.decode(encodedUserPassword));