Class Utils

java.lang.Object
eu.webtoolkit.jwt.Utils

public class Utils extends Object
  • Constructor Details

    • Utils

      public Utils()
  • Method Details

    • md5

      public static byte[] md5(String msg)
      Computes an MD5 hash. This utility function computes an MD5 hash, and returns the hash value.
    • sha1

      public static byte[] sha1(String input)
    • urlEncode

      public static String urlEncode(String scope)
      Performs url encoding (aka percentage encoding). This utility function percent encodes a text so that it can be embodied verbatim in a URL (e.g. as a fragment).
      See Also:
    • urlDecode

      public static String urlDecode(String scope)
      Performs url decoding. This utility function percent encodes a text so that it can be embodied verbatim in a URL (e.g. as a fragment).
      See Also:
    • parseFormUrlEncoded

      public static void parseFormUrlEncoded(String s, Map<String,String[]> parameters)
    • base64Encode

      public static String base64Encode(String s)
      Performs Base64-encoding of data.
    • base64Encode

      public static String base64Encode(String s, boolean crlf)
    • base64Encode

      public static String base64Encode(byte[] bytes)
      Performs Base64-encoding of data.
    • base64Encode

      public static String base64Encode(byte[] bytes, boolean crlf)
    • base64Decode

      public static byte[] base64Decode(String s) throws IOException
      Performs Base64-decoding of data.
      Throws:
      IOException
    • base64DecodeS

      public static String base64DecodeS(String s)
    • htmlEncode

      public static String htmlEncode(String text, EnumSet<Utils.HtmlEncodingFlag> flags)
      Performs HTML encoding of text. This utility function escapes characters so that the text can be embodied verbatim in a HTML text block.
    • htmlEncode

      public static String htmlEncode(String text)
    • htmlEncode

      public static String htmlEncode(WString text, EnumSet<Utils.HtmlEncodingFlag> flags)
      Performs HTML encoding of text. This utility function escapes characters so that the text can be embodied verbatim in a HTML text block. By default, newlines are ignored. By passing the Utils.HtmlEncodingFlag.EncodeNewLines flag, these may be encoded as line breaks (<br>).
    • htmlEncode

      public static String htmlEncode(WString text)
    • htmlEncode

      public static String htmlEncode(String value, Utils.HtmlEncodingFlag flag, Utils.HtmlEncodingFlag... flags)
      Performs HTML encoding of text.

      Calls Utils.htmlEncode(text, flags)

    • htmlAttributeValue

      public static String htmlAttributeValue(String text)
      Escape the given text for inclusion in an HTML attribute

      This utility function escapes characters so that the \p text can be used as the value of an HTML attribute between double quotes.

      The double quotes are not included in the output.

      Example usage:

      
       String attribute = "name=\"" + htmlAttributeValue(value) + "\"";
       
    • removeScript

      public static boolean removeScript(CharSequence text)
      Remove tags/attributes from text that are not passive. This removes tags and attributes from XHTML-formatted text that do not simply display something but may trigger scripting, and could have been injected by a malicious user for Cross-Site Scripting (XSS). This method is used by the library to sanitize XHTML-formatted text set in WText, but it may also be useful outside the library to sanitize user content when directly using JavaScript. Modifies the text if needed. When the text is not proper XML, returns false.
    • strip

      public static String strip(String s, String whiteSpaces)
    • assignFontMatch

      public static void assignFontMatch(eu.webtoolkit.jwt.FontSupport.FontMatch fm1, eu.webtoolkit.jwt.FontSupport.FontMatch fm2)
    • copyList

      public static void copyList(List source, List destination)
    • copyList

      public static void copyList(byte[] source, List<Byte> destination)
    • hexToInt

      public static int hexToInt(String s)
    • createDataUrl

      public static String createDataUrl(byte[] data, String mimeType)
    • hmac

      public static byte[] hmac(String msg, String key, String algo)
    • hmac_sha1

      public static byte[] hmac_sha1(String msg, String key)
    • hmac_md5

      public static byte[] hmac_md5(String msg, String key)