Class Utils
java.lang.Object
org.mozilla.jss.netscape.security.util.Utils
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic byte[]base64decode(String string) Converts a Base-64 encoded string into a byte array.static Stringbase64encode(byte[] bytes, boolean chunked) Converts a byte array into a Base-64 encoded string.static Stringbase64encodeMultiLine(byte[] bytes) Converts a byte array into a multi-line Base-64 encoded string.static Stringbase64encodeSingleLine(byte[] bytes) Converts a byte array into a single-line Base-64 encoded string.static booleanbyteArraysAreEqual(byte[] a, byte[] b) compares contents two byte arrays returning true if exactly same.static voidstatic voidstatic voidcopyStream(BufferedReader in, OutputStreamWriter out) static voidcopyStream(InputStream in, OutputStream out) static booleanstatic StringUtility method to execute system commandsstatic String[]returns an array of strings from a vector of Strings there'll be trouble if the Vector contains something other than just Stringsstatic StringHexEncode(byte[] data) static booleanisNT()Checks if this is NT.static booleanisUnix()static Stringstatic StringnormalizeString(String string) Normalize B64 input Stringstatic StringnormalizeString(String string, Boolean keepSpace) Normalize B64 input Stringstatic StringreadFromStream(InputStream inputStream) static voidsortStrings(String[] strings) static byte[]static StringSpecialEncode(byte[] data) static Stringstatic Stringstrips out double quotes around String parameterstatic voidwriteToStream(OutputStream outputStream, String input)
-
Field Details
-
logger
private static final org.slf4j.Logger logger
-
-
Constructor Details
-
Utils
public Utils()
-
-
Method Details
-
isNT
public static boolean isNT()Checks if this is NT. -
isUnix
public static boolean isUnix() -
exec
-
readFromStream
- Throws:
IOException
-
writeToStream
- Throws:
IOException
-
exec
Utility method to execute system commands- Parameters:
cmd- The command to be executed and its argumentsinput- The stdin input to be passed to the cmd- Returns:
- stdout or stderr of the command executed
- Throws:
IOExceptionInterruptedException
-
SpecialURLDecode
-
SpecialDecode
-
SpecialEncode
-
HexEncode
-
checkHost
- Throws:
UnknownHostException
-
copy
- Throws:
Exception
-
copyStream
- Throws:
IOException
-
copyStream
- Throws:
IOException
-
sortStrings
-
lsDateStr
-
byteArraysAreEqual
public static boolean byteArraysAreEqual(byte[] a, byte[] b) compares contents two byte arrays returning true if exactly same. -
stripQuotes
strips out double quotes around String parameter- Parameters:
s- the string potentially bracketed with double quotes- Returns:
- string stripped of surrounding double quotes
-
getStringArrayFromVector
returns an array of strings from a vector of Strings there'll be trouble if the Vector contains something other than just Strings -
base64encode
Converts a byte array into a Base-64 encoded string. If the chunked option is true, the output will be split into multiple lines. Otherwise, the output will be a single line.- Parameters:
bytes- byte arraychunked- generate chunked output- Returns:
- base-64 encoded data
-
base64encodeMultiLine
Converts a byte array into a multi-line Base-64 encoded string. Each line is at most 64-character long and terminated with CRLF.- Parameters:
bytes- byte array- Returns:
- base-64 encoded data
-
base64encodeSingleLine
Converts a byte array into a single-line Base-64 encoded string. The line is not terminated with CRLF.- Parameters:
bytes- byte array- Returns:
- base-64 encoded data
-
base64decode
Converts a Base-64 encoded string into a byte array.- Parameters:
string- base-64 encoded data- Returns:
- byte array
-
normalizeString
Normalize B64 input String- Parameters:
string- base-64 string- Returns:
- normalized string
-
normalizeString
Normalize B64 input String- Parameters:
string- base-64 stringkeepSpace- a boolean variable to control whether to keep spaces or not- Returns:
- normalized string
-