public interface KeySource
A key source can be created from different source types and formats using the provided static methods, such as
string(String), stream(InputStream) or file(File).
| Modifier and Type | Interface and Description |
|---|---|
static interface |
KeySource.KetSourceWithCharset
A
KeySource which can support a charset. |
| Modifier and Type | Method and Description |
|---|---|
static KeySource |
bytes(byte[] source)
Create a key source from an array of bytes.
|
static KeySource |
file(File source)
Create a key source from a
File. |
static KeySource |
file(String fileName)
Create a key source from a file with given file name.
|
byte[] |
getBytes()
Get the key as a byte array.
|
static KeySource |
resource(String name)
Create a key source using a classpath resource using the default ClassLoader.
|
static KeySource |
resource(String name,
ClassLoader classLoader)
Create a key source using a classpath resource.
|
static KeySource |
stream(InputStream source)
Create a key source from a
InputStream. |
static KeySource |
string(String source)
Create a key source from a
String. |
static KeySource |
string(String source,
Charset charset)
Create a key source from a
String using given charset. |
static KeySource |
string(String source,
String charsetName)
Create a key source from a
String using given charset name. |
byte[] getBytes()
throws IOException
IOException - If an error occurredstatic KeySource bytes(byte[] source)
source - Key source (not null)KeySourcestatic KeySource string(String source)
String. The UTF-8 charset is used by default.source - Key source (not null)KeySourcestatic KeySource string(String source, Charset charset)
String using given charset.source - Key source (not null)charset - The charset with which the source was encoded (not null)KeySourcestatic KeySource string(String source, String charsetName)
String using given charset name.source - Key source (not null)charsetName - The charset name with which the source was encoded (not null)KeySourceUnsupportedCharsetException - If given charset name is not supported by the JVMstatic KeySource stream(InputStream source)
InputStream.source - Key source (not null)KeySourcestatic KeySource resource(String name, ClassLoader classLoader)
ClassLoader.getResource(String).name - Key resource name (not null)classLoader - The ClassLoader to use (not null)KeySourcestatic KeySource resource(String name)
ClassLoader.getResource(String).name - Key resource name (not null)KeySourcestatic KeySource file(File source)
File.source - Key source (not null)KeySourceCopyright © 2019 The Holon Platform. All rights reserved.