/** * Encodes a string using base64 and returns the result as another string. * * @param text String to be encoded. * @return Resulting encoded string. */ public static String encodeAsString(final String text) { return encodeAsString(text.getBytes()); }
/** * Decodes a string using base64 and returns the result as another string. * * @param text String to be decoded. * @return Resulting decoded string. */ public static String decodeAsString(final String text) { return decodeAsString(text.getBytes()); } }
/** * Decodes array of bytes using base64 decoding and returns the result as a string. * * @param buffer Array of bytes to be decoded. * @return Resulting decoded string. */ public static String decodeAsString(final byte[] buffer) { final byte[] result = decode(buffer); try { return new String(result, "ASCII"); } catch (final UnsupportedEncodingException ex) { // should never happen return new String(result); } }
/** * Encodes array of bytes using base64 encoding and returns the result as a string. * * @param buffer Array of bytes to be encoded. * @return Resulting encoded string. */ public static String encodeAsString(final byte[] buffer) { final byte[] result = encode(buffer); try { return new String(result, "ASCII"); } catch (final UnsupportedEncodingException ex) { // should never happen return new String(result); } }
/** * Encodes array of bytes using base64 encoding and returns the result as a string. * * @param buffer Array of bytes to be encoded. * @return Resulting encoded string. */ public static String encodeAsString(final byte[] buffer) { final byte[] result = encode(buffer); try { return new String(result, "ASCII"); } catch (final UnsupportedEncodingException ex) { // should never happen return new String(result); } }
/** * Encodes a string using base64 and returns the result as another string. * * @param text String to be encoded. * @return Resulting encoded string. */ public static String encodeAsString(final String text) { return encodeAsString(text.getBytes()); }
/** * Decodes a string using base64 and returns the result as another string. * * @param text String to be decoded. * @return Resulting decoded string. */ public static String decodeAsString(final String text) { return decodeAsString(text.getBytes()); } }
/** * Encodes array of bytes using base64 encoding and returns the result as a string. * * @param buffer Array of bytes to be encoded. * @return Resulting encoded string. */ public static String encodeAsString(final byte[] buffer) { final byte[] result = encode(buffer); try { return new String(result, "ASCII"); } catch (final UnsupportedEncodingException ex) { // should never happen return new String(result); } }
/** * Decodes array of bytes using base64 decoding and returns the result as a string. * * @param buffer Array of bytes to be decoded. * @return Resulting decoded string. */ public static String decodeAsString(final byte[] buffer) { final byte[] result = decode(buffer); try { return new String(result, "ASCII"); } catch (final UnsupportedEncodingException ex) { // should never happen return new String(result); } }
private static String buildBasicAuthHeader(final String userName, final String password) { return Base64.encodeAsString(userName + ":" + password); }
/** Construct a Builder based upon the "auth" field of the docker client config file. */ public static Builder forAuth(final String auth) { // split with limit=2 to catch case where password contains a colon final String[] authParams = Base64.decodeAsString(auth).split(":", 2); if (authParams.length != 2) { return builder(); } return builder() .username(authParams[0].trim()) .password(authParams[1].trim()); }
/** * Encodes array of bytes using base64 encoding and returns the result as a string. * * @param buffer Array of bytes to be encoded. * @return Resulting encoded string. */ public static String encodeAsString(final byte[] buffer) { final byte[] result = encode(buffer); try { return new String(result, "ASCII"); } catch (final UnsupportedEncodingException ex) { // should never happen return new String(result); } }
/** * Decodes array of bytes using base64 decoding and returns the result as a string. * * @param buffer Array of bytes to be decoded. * @return Resulting decoded string. */ public static String decodeAsString(final byte[] buffer) { final byte[] result = decode(buffer); try { return new String(result, "ASCII"); } catch (final UnsupportedEncodingException ex) { // should never happen return new String(result); } }
private String calculateAuthentication(HttpAuthenticationFilter.Credentials credentials) { String username = credentials.getUsername(); byte[] password = credentials.getPassword(); if (username == null) { username = ""; } if (password == null) { password = new byte[0]; } final byte[] prefix = (username + ":").getBytes(HttpAuthenticationFilter.CHARACTER_SET); final byte[] usernamePassword = new byte[prefix.length + password.length]; System.arraycopy(prefix, 0, usernamePassword, 0, prefix.length); System.arraycopy(password, 0, usernamePassword, prefix.length, password.length); return "Basic " + Base64.encodeAsString(usernamePassword); }
/** * Decodes a string using base64 and returns the result as another string. * * @param text String to be decoded. * @return Resulting decoded string. */ public static String decodeAsString(final String text) { return decodeAsString(text.getBytes()); } }
/** * Encodes array of bytes using base64 encoding and returns the result as a string. * * @param buffer Array of bytes to be encoded. * @return Resulting encoded string. */ public static String encodeAsString(final byte[] buffer) { final byte[] result = encode(buffer); try { return new String(result, "ASCII"); } catch (final UnsupportedEncodingException ex) { // should never happen return new String(result); } }
/** * Decodes array of bytes using base64 decoding and returns the result as a string. * * @param buffer Array of bytes to be decoded. * @return Resulting decoded string. */ public static String decodeAsString(final byte[] buffer) { final byte[] result = decode(buffer); try { return new String(result, "ASCII"); } catch (final UnsupportedEncodingException ex) { // should never happen return new String(result); } }
private String calculateAuthentication(HttpAuthenticationFilter.Credentials credentials) { String username = credentials.getUsername(); byte[] password = credentials.getPassword(); if (username == null) { username = ""; } if (password == null) { password = new byte[0]; } final byte[] prefix = (username + ":").getBytes(HttpAuthenticationFilter.CHARACTER_SET); final byte[] usernamePassword = new byte[prefix.length + password.length]; System.arraycopy(prefix, 0, usernamePassword, 0, prefix.length); System.arraycopy(password, 0, usernamePassword, prefix.length, password.length); return "Basic " + Base64.encodeAsString(usernamePassword); }
/** * Decodes a string using base64 and returns the result as another string. * * @param text String to be decoded. * @return Resulting decoded string. */ public static String decodeAsString(final String text) { return decodeAsString(text.getBytes()); } }
/** * Encodes array of bytes using base64 encoding and returns the result as a string. * * @param buffer Array of bytes to be encoded. * @return Resulting encoded string. */ public static String encodeAsString(final byte[] buffer) { final byte[] result = encode(buffer); try { return new String(result, "ASCII"); } catch (final UnsupportedEncodingException ex) { // should never happen return new String(result); } }