Package eu.webtoolkit.jwt
Class Utils
java.lang.Object
eu.webtoolkit.jwt.Utils
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
An enumeration for HTML encoding flags. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
assignFontMatch
(eu.webtoolkit.jwt.FontSupport.FontMatch fm1, eu.webtoolkit.jwt.FontSupport.FontMatch fm2) static byte[]
Performs Base32-decoding of data.static String
static String
base32Encode
(byte[] bytes) Performs Base32-encoding of data.static String
base32Encode
(byte[] bytes, boolean crlf) static String
Performs Base32-encoding of data.static String
base32Encode
(String s, boolean crlf) static byte[]
Performs Base64-decoding of data.static String
static String
base64Encode
(byte[] bytes) Performs Base64-encoding of data.static String
base64Encode
(byte[] bytes, boolean crlf) static String
Performs Base64-encoding of data.static String
base64Encode
(String s, boolean crlf) static void
static void
static String
createDataUrl
(byte[] data, String mimeType) static byte[]
hexStrToBytes
(long value) Converts the long value to a byte array containing the hexstring.static int
static byte[]
static byte[]
static byte[]
static String
hmac_sha1WithEncoding
(long msg, byte[] key) static String
hmacWithEncoding
(byte[] msg, byte[] key, String algo) static String
htmlAttributeValue
(String text) Escape the given text for inclusion in an HTML attributestatic String
htmlEncode
(WString text) Performs HTML encoding of text.static String
htmlEncode
(WString text, EnumSet<Utils.HtmlEncodingFlag> flags) Performs HTML encoding of text.static String
htmlEncode
(String text) Performs HTML encoding of text.static String
htmlEncode
(String value, Utils.HtmlEncodingFlag flag, Utils.HtmlEncodingFlag... flags) Performs HTML encoding of text.static String
htmlEncode
(String text, EnumSet<Utils.HtmlEncodingFlag> flags) Performs HTML encoding of text.static byte[]
Computes an MD5 hash.static void
parseFormUrlEncoded
(String s, Map<String, String[]> parameters) static boolean
removeScript
(CharSequence text) Remove tags/attributes from text that are not passive.static byte[]
static String
static String
Performs url decoding.static String
Performs url encoding (aka percentage encoding).
-
Constructor Details
-
Utils
public Utils()
-
-
Method Details
-
md5
Computes an MD5 hash. This utility function computes an MD5 hash, and returns the hash value. -
sha1
-
urlEncode
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
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
-
base64Encode
Performs Base64-encoding of data. -
base64Encode
-
base64Encode
Performs Base64-encoding of data. -
base64Encode
-
base64Decode
Performs Base64-decoding of data.- Throws:
IOException
-
base64DecodeS
-
base32Encode
Performs Base32-encoding of data. -
base32Encode
-
base32Encode
Performs Base32-encoding of data. -
base32Encode
-
base32Decode
Performs Base32-decoding of data.- Throws:
IOException
-
base32DecodeS
-
htmlEncode
Performs HTML encoding of text. This utility function escapes characters so that the text can be embodied verbatim in a HTML text block. -
htmlEncode
Performs HTML encoding of text.Calls
Utils.htmlEncode(text, EnumSet.noneOf(HtmlEncodingFlag.class))
-
htmlEncode
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 theUtils.HtmlEncodingFlag.EncodeNewLines
flag, these may be encoded as line breaks (<br>). -
htmlEncode
Performs HTML encoding of text.Calls
Utils.htmlEncode(text, EnumSet.noneOf(HtmlEncodingFlag.class))
-
htmlEncode
public static String htmlEncode(String value, Utils.HtmlEncodingFlag flag, Utils.HtmlEncodingFlag... flags) Performs HTML encoding of text. -
htmlAttributeValue
Escape the given text for inclusion in an HTML attributeThis 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
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 inWText
, 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
-
assignFontMatch
public static void assignFontMatch(eu.webtoolkit.jwt.FontSupport.FontMatch fm1, eu.webtoolkit.jwt.FontSupport.FontMatch fm2) -
copyList
-
copyList
-
hexToInt
-
hexStrToBytes
public static byte[] hexStrToBytes(long value) Converts the long value to a byte array containing the hexstring.The hexstring of a long value is simple its hexadecimal representation in string format. i.e. 12 would be C. The string will always be then converted to be 16 bytes long.
The string is then converted to an array of bytes.
-
createDataUrl
-
hmac
-
hmacWithEncoding
-
hmac_sha1
-
hmac_sha1WithEncoding
-
hmac_md5
-