public class Utils extends Object
Modifier and Type | Field and Description |
---|---|
static String |
LOG_CLIENT |
static String |
LOG_SECURITY |
static String |
LOG_SERVER |
Constructor and Description |
---|
Utils() |
Modifier and Type | Method and Description |
---|---|
static void |
closeQuietly(Closeable x) |
static String |
createFaultMessage(String message,
Throwable cause) |
static byte[] |
createKey()
create a new symmetric key
|
static byte[] |
decodeBase64(String base64) |
static String |
encodeBase64(byte[] data) |
static void |
finishWriting(OutputStream target)
properly flush the stream, which may be compressed and/or encrypted
|
static OutputStream |
getCompressStream(OutputStream sink)
returns a stream that compresses data
|
static InputStream |
getDecompressStream(InputStream source)
returns a stream that compresses data
|
static InputStream |
getDecryptStream(InputStream source,
byte[] key)
returns a stream that decrypts data
|
static String |
getDetailMessage(Throwable throwable) |
static OutputStream |
getEncryptStream(OutputStream sink,
byte[] key)
returns a stream that encrypts data
|
static ScheduledExecutorService |
getExecutor() |
static FileAccess |
getFileAccess(org.apache.log4j.Logger logger) |
static org.apache.log4j.Logger |
getLogger(String prefix,
Class<?> clazz) |
static Set<String> |
getWhiteList() |
static String |
hexString(byte[] bytes)
converts the byte-array into a more user-friendly hex string
|
static String |
hexString(MessageDigest digest)
converts the message digest into a user-friendly hex string
|
static Cipher |
makeDecryptionCipher(byte[] encodedKey)
create a
Cipher for decryption |
static Cipher |
makeEncryptionCipher(byte[] encodedKey)
create a
Cipher for encryption |
static String |
md5(byte[] data) |
static String |
md5(File file) |
static List<String> |
parseLine(String line) |
static String |
trim(String s)
this removes leading and trailing \" characters
|
static void |
writeToFile(String content,
File target) |
public static final String LOG_SERVER
public static final String LOG_CLIENT
public static final String LOG_SECURITY
public static InputStream getDecryptStream(InputStream source, byte[] key) throws IOException
source
- - the underlying physical streamkey
- - encoded keyIOException
public static OutputStream getEncryptStream(OutputStream sink, byte[] key) throws IOException
sink
- - the underlying physical streamkey
- - encoded keyIOException
public static OutputStream getCompressStream(OutputStream sink) throws IOException
sink
- - the underlying physical streamkey
- - encoded keyIOException
public static InputStream getDecompressStream(InputStream source) throws IOException
sink
- - the underlying physical streamkey
- - encoded keyIOException
public static String encodeBase64(byte[] data)
public static byte[] decodeBase64(String base64)
public static Cipher makeEncryptionCipher(byte[] encodedKey) throws Exception
Cipher
for encryptionencodedKey
- - encoded keyException
public static Cipher makeDecryptionCipher(byte[] encodedKey) throws Exception
Cipher
for decryptionencodedKey
- - encoded keyException
public static byte[] createKey() throws InvalidKeySpecException, NoSuchAlgorithmException, NoSuchProviderException
InvalidKeySpecException
NoSuchAlgorithmException
NoSuchProviderException
public static String md5(byte[] data)
public static void writeToFile(String content, File target) throws IOException
IOException
public static String hexString(MessageDigest digest)
digest
- public static String hexString(byte[] bytes)
bytes
- public static ScheduledExecutorService getExecutor()
public static String trim(String s)
s
- public static FileAccess getFileAccess(org.apache.log4j.Logger logger)
public static void finishWriting(OutputStream target) throws IOException
target
- IOException
public static void closeQuietly(Closeable x)
Copyright © 2010–2016 UNICORE. All rights reserved.