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 String
base64encode
(byte[] bytes, boolean chunked) Converts a byte array into a Base-64 encoded string.static String
base64encodeMultiLine
(byte[] bytes) Converts a byte array into a multi-line Base-64 encoded string.static String
base64encodeSingleLine
(byte[] bytes) Converts a byte array into a single-line Base-64 encoded string.static boolean
byteArraysAreEqual
(byte[] a, byte[] b) compares contents two byte arrays returning true if exactly same.static void
static void
static void
copyStream
(BufferedReader in, OutputStreamWriter out) static void
copyStream
(InputStream in, OutputStream out) static boolean
static String
Utility 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 String
HexEncode
(byte[] data) static boolean
isNT()
Checks if this is NT.static boolean
isUnix()
static String
static String
normalizeString
(String string) Normalize B64 input Stringstatic String
normalizeString
(String string, Boolean keepSpace) Normalize B64 input Stringstatic String
readFromStream
(InputStream inputStream) static void
sortStrings
(String[] strings) static byte[]
static String
SpecialEncode
(byte[] data) static String
static String
strips out double quotes around String parameterstatic void
writeToStream
(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:
IOException
InterruptedException
-
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
-