Class Base64Url


  • public class Base64Url
    extends Object
    This is an implementation of Base64Url based on the fast Base64 implementation of Mikael Grev.
    • Constructor Summary

      Constructors 
      Constructor Description
      Base64Url()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static boolean containsOnlyBase64UrlChars​(byte[] bytes, int offset, int len)  
      static byte[] decodeFast​(byte[] sArr)
      Decodes a BASE64Url encoded byte array that is known to be reasonably well formatted.
      static byte[] decodeFast​(char[] sArr)
      Decodes a BASE64Url encoded char array that is known to be reasonably well formatted.
      static byte[] decodeFast​(String s)
      Decodes a BASE64Url encoded string that is known to be reasonably well formatted.
      static byte[] encodeToByte​(byte[] sArr)
      Encodes a raw byte array into a BASE64Url byte[] representation i accordance with RFC 2045.
      static char[] encodeToChar​(byte[] sArr)
      Encodes a raw byte array into a BASE64Url char[] representation i accordance with RFC 2045.
      static String encodeToString​(byte[] sArr)
      Encodes a raw byte array into a BASE64Url String representation i accordance with RFC 2045.
    • Constructor Detail

      • Base64Url

        public Base64Url()
    • Method Detail

      • containsOnlyBase64UrlChars

        public static boolean containsOnlyBase64UrlChars​(byte[] bytes,
                                                         int offset,
                                                         int len)
      • encodeToChar

        public static char[] encodeToChar​(byte[] sArr)
        Encodes a raw byte array into a BASE64Url char[] representation i accordance with RFC 2045.
        Parameters:
        sArr - The bytes to convert. If null or length 0 an empty array will be returned.
        Returns:
        A BASE64Url encoded array. Never null.
      • decodeFast

        public static byte[] decodeFast​(char[] sArr)
        Decodes a BASE64Url encoded char array that is known to be reasonably well formatted. The preconditions are:
        + The array must have no line separators at all (one line).
        + The array may not contain illegal characters within the encoded string
        + The array CAN have illegal characters at the beginning and end, those will be dealt with appropriately.
        Parameters:
        sArr - The source array. Length 0 will return an empty array. null will throw an exception.
        Returns:
        The decoded array of bytes. May be of length 0.
      • encodeToByte

        public static byte[] encodeToByte​(byte[] sArr)
        Encodes a raw byte array into a BASE64Url byte[] representation i accordance with RFC 2045.
        Parameters:
        sArr - The bytes to convert. If null or length 0 an empty array will be returned.
        Returns:
        A BASE64Url encoded array. Never null.
      • decodeFast

        public static byte[] decodeFast​(byte[] sArr)
        Decodes a BASE64Url encoded byte array that is known to be reasonably well formatted. The preconditions are:
        + The array must have no line separators at all (one line).
        + The array may not contain illegal characters within the encoded string
        + The array CAN have illegal characters at the beginning and end, those will be dealt with appropriately.
        Parameters:
        sArr - The source array. Length 0 will return an empty array. null will throw an exception.
        Returns:
        The decoded array of bytes. May be of length 0.
      • encodeToString

        public static String encodeToString​(byte[] sArr)
        Encodes a raw byte array into a BASE64Url String representation i accordance with RFC 2045.
        Parameters:
        sArr - The bytes to convert. If null or length 0 an empty array will be returned.
        Returns:
        A BASE64Url encoded array. Never null.
      • decodeFast

        public static byte[] decodeFast​(String s)
        Decodes a BASE64Url encoded string that is known to be reasonably well formatted. The preconditions are:
        + The array must have no line separators at all (one line).
        + The array may not contain illegal characters within the encoded string
        + The array CAN have illegal characters at the beginning and end, those will be dealt with appropriately.
        Parameters:
        s - The source string. Length 0 will return an empty array. null will throw an exception.
        Returns:
        The decoded array of bytes. May be of length 0.