Package eu.webtoolkit.jwt
Class Utils
- java.lang.Object
-
- eu.webtoolkit.jwt.Utils
-
public class Utils extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classUtils.HtmlEncodingFlagAn enumeration for HTML encoding flags.
-
Constructor Summary
Constructors Constructor Description Utils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidassignFontMatch(eu.webtoolkit.jwt.FontSupport.FontMatch fm1, eu.webtoolkit.jwt.FontSupport.FontMatch fm2)static byte[]base32Decode(java.lang.String s)Performs Base32-decoding of data.static java.lang.Stringbase32DecodeS(java.lang.String s)static java.lang.Stringbase32Encode(byte[] bytes)Performs Base32-encoding of data.static java.lang.Stringbase32Encode(byte[] bytes, boolean crlf)static java.lang.Stringbase32Encode(java.lang.String s)Performs Base32-encoding of data.static java.lang.Stringbase32Encode(java.lang.String s, boolean crlf)static byte[]base64Decode(java.lang.String s)Performs Base64-decoding of data.static java.lang.Stringbase64DecodeS(java.lang.String s)static java.lang.Stringbase64Encode(byte[] bytes)Performs Base64-encoding of data.static java.lang.Stringbase64Encode(byte[] bytes, boolean crlf)static java.lang.Stringbase64Encode(java.lang.String s)Performs Base64-encoding of data.static java.lang.Stringbase64Encode(java.lang.String s, boolean crlf)static voidcopyList(byte[] source, java.util.List<java.lang.Byte> destination)static voidcopyList(java.util.List source, java.util.List destination)static java.lang.StringcreateDataUrl(byte[] data, java.lang.String mimeType)static java.util.List<java.lang.String>getWidgetStyleClasses(WWidget widget)static byte[]hexStrToBytes(long value)Converts the long value to a byte array containing the hexstring.static inthexToInt(java.lang.String s)static byte[]hmac(java.lang.String msg, java.lang.String key, java.lang.String algo)static byte[]hmac_md5(java.lang.String msg, java.lang.String key)static byte[]hmac_sha1(java.lang.String msg, java.lang.String key)static java.lang.Stringhmac_sha1WithEncoding(long msg, byte[] key)static java.lang.StringhmacWithEncoding(byte[] msg, byte[] key, java.lang.String algo)static java.lang.StringhtmlAttributeValue(java.lang.String text)Escape the given text for inclusion in an HTML attributestatic java.lang.StringhtmlEncode(WString text)Performs HTML encoding of text.static java.lang.StringhtmlEncode(WString text, java.util.EnumSet<Utils.HtmlEncodingFlag> flags)Performs HTML encoding of text.static java.lang.StringhtmlEncode(java.lang.String text)Performs HTML encoding of text.static java.lang.StringhtmlEncode(java.lang.String value, Utils.HtmlEncodingFlag flag, Utils.HtmlEncodingFlag... flags)Performs HTML encoding of text.static java.lang.StringhtmlEncode(java.lang.String text, java.util.EnumSet<Utils.HtmlEncodingFlag> flags)Performs HTML encoding of text.static byte[]md5(java.lang.String msg)Computes an MD5 hash.static voidparseFormUrlEncoded(java.lang.String s, java.util.Map<java.lang.String,java.lang.String[]> parameters)static booleanremoveScript(java.lang.CharSequence text)Remove tags/attributes from text that are not passive.static byte[]sha1(java.lang.String input)static java.lang.Stringstrip(java.lang.String s, java.lang.String whiteSpaces)static java.lang.StringurlDecode(java.lang.String scope)Performs url decoding.static java.lang.StringurlEncode(java.lang.String scope)Performs url encoding (aka percentage encoding).
-
-
-
Method Detail
-
md5
public static byte[] md5(java.lang.String msg)
Computes an MD5 hash. This utility function computes an MD5 hash, and returns the hash value.
-
sha1
public static byte[] sha1(java.lang.String input)
-
urlEncode
public static java.lang.String urlEncode(java.lang.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(String scope)
-
urlDecode
public static java.lang.String urlDecode(java.lang.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:
urlEncode(String scope)
-
parseFormUrlEncoded
public static void parseFormUrlEncoded(java.lang.String s, java.util.Map<java.lang.String,java.lang.String[]> parameters)
-
base64Encode
public static java.lang.String base64Encode(java.lang.String s)
Performs Base64-encoding of data.
-
base64Encode
public static java.lang.String base64Encode(java.lang.String s, boolean crlf)
-
base64Encode
public static java.lang.String base64Encode(byte[] bytes)
Performs Base64-encoding of data.
-
base64Encode
public static java.lang.String base64Encode(byte[] bytes, boolean crlf)
-
base64Decode
public static byte[] base64Decode(java.lang.String s) throws java.io.IOExceptionPerforms Base64-decoding of data.- Throws:
java.io.IOException
-
base64DecodeS
public static java.lang.String base64DecodeS(java.lang.String s)
-
base32Encode
public static java.lang.String base32Encode(java.lang.String s)
Performs Base32-encoding of data.
-
base32Encode
public static java.lang.String base32Encode(java.lang.String s, boolean crlf)
-
base32Encode
public static java.lang.String base32Encode(byte[] bytes)
Performs Base32-encoding of data.
-
base32Encode
public static java.lang.String base32Encode(byte[] bytes, boolean crlf)
-
base32Decode
public static byte[] base32Decode(java.lang.String s) throws java.io.IOExceptionPerforms Base32-decoding of data.- Throws:
java.io.IOException
-
base32DecodeS
public static java.lang.String base32DecodeS(java.lang.String s)
-
htmlEncode
public static java.lang.String htmlEncode(java.lang.String text, java.util.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 java.lang.String htmlEncode(java.lang.String text)
Performs HTML encoding of text.Calls
Utils.htmlEncode(text, EnumSet.noneOf(HtmlEncodingFlag.class))
-
htmlEncode
public static java.lang.String htmlEncode(WString text, java.util.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 theUtils.HtmlEncodingFlag.EncodeNewLinesflag, these may be encoded as line breaks (<br>).
-
htmlEncode
public static java.lang.String htmlEncode(WString text)
Performs HTML encoding of text.Calls
Utils.htmlEncode(text, EnumSet.noneOf(HtmlEncodingFlag.class))
-
htmlEncode
public static java.lang.String htmlEncode(java.lang.String value, Utils.HtmlEncodingFlag flag, Utils.HtmlEncodingFlag... flags)Performs HTML encoding of text.
-
htmlAttributeValue
public static java.lang.String htmlAttributeValue(java.lang.String text)
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
public static boolean removeScript(java.lang.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 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
public static java.lang.String strip(java.lang.String s, java.lang.String whiteSpaces)
-
assignFontMatch
public static void assignFontMatch(eu.webtoolkit.jwt.FontSupport.FontMatch fm1, eu.webtoolkit.jwt.FontSupport.FontMatch fm2)
-
copyList
public static void copyList(java.util.List source, java.util.List destination)
-
copyList
public static void copyList(byte[] source, java.util.List<java.lang.Byte> destination)
-
hexToInt
public static int hexToInt(java.lang.String s)
-
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
public static java.lang.String createDataUrl(byte[] data, java.lang.String mimeType)
-
hmac
public static byte[] hmac(java.lang.String msg, java.lang.String key, java.lang.String algo)
-
hmacWithEncoding
public static java.lang.String hmacWithEncoding(byte[] msg, byte[] key, java.lang.String algo)
-
hmac_sha1
public static byte[] hmac_sha1(java.lang.String msg, java.lang.String key)
-
hmac_sha1WithEncoding
public static java.lang.String hmac_sha1WithEncoding(long msg, byte[] key)
-
hmac_md5
public static byte[] hmac_md5(java.lang.String msg, java.lang.String key)
-
getWidgetStyleClasses
public static java.util.List<java.lang.String> getWidgetStyleClasses(WWidget widget)
-
-