Package net.wedjaa.ansible.vault.crypto
Class VaultHandler
- java.lang.Object
-
- net.wedjaa.ansible.vault.crypto.VaultHandler
-
public class VaultHandler extends Object
Created by mrwho on 03/06/15.
-
-
Field Summary
Fields Modifier and Type Field Description static StringCHAR_ENCODINGstatic intDEFAULT_BUFFER_SIZEThe default buffer size (8192) to use in copy methods.static StringDEFAULT_CYPHERstatic intEOFRepresents the end-of-file (or stream).
-
Constructor Summary
Constructors Constructor Description VaultHandler()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static byte[]decrypt(byte[] encrypted, String password)static voiddecrypt(InputStream encryptedVault, OutputStream decryptedVault, String password)static byte[]encrypt(byte[] cleartext, String password)static byte[]encrypt(byte[] cleartext, String password, String cypher)static voidencrypt(InputStream clearText, OutputStream cipherText, String password)static voidencrypt(InputStream clearText, OutputStream cipherText, String password, String cypher)static byte[]toByteArray(InputStream input)Gets the contents of anInputStreamas abyte[].
-
-
-
Field Detail
-
DEFAULT_CYPHER
public static final String DEFAULT_CYPHER
- See Also:
- Constant Field Values
-
CHAR_ENCODING
public static final String CHAR_ENCODING
- See Also:
- Constant Field Values
-
EOF
public static final int EOF
Represents the end-of-file (or stream).- See Also:
- Constant Field Values
-
DEFAULT_BUFFER_SIZE
public static final int DEFAULT_BUFFER_SIZE
The default buffer size (8192) to use in copy methods.- See Also:
- Constant Field Values
-
-
Method Detail
-
encrypt
public static byte[] encrypt(byte[] cleartext, String password, String cypher) throws IOException- Throws:
IOException
-
encrypt
public static byte[] encrypt(byte[] cleartext, String password) throws IOException- Throws:
IOException
-
encrypt
public static void encrypt(InputStream clearText, OutputStream cipherText, String password, String cypher) throws IOException
- Throws:
IOException
-
encrypt
public static void encrypt(InputStream clearText, OutputStream cipherText, String password) throws IOException
- Throws:
IOException
-
decrypt
public static void decrypt(InputStream encryptedVault, OutputStream decryptedVault, String password) throws IOException
- Throws:
IOException
-
decrypt
public static byte[] decrypt(byte[] encrypted, String password) throws IOException- Throws:
IOException
-
toByteArray
public static byte[] toByteArray(InputStream input) throws IOException
Gets the contents of anInputStreamas abyte[].This method buffers the input internally, so there is no need to use a
BufferedInputStream.- Parameters:
input- theInputStreamto read from- Returns:
- the requested byte array
- Throws:
NullPointerException- if the input is nullIOException- if an I/O error occurs
-
-