Package org.jets3t.service.security
Class ProviderCredentials
java.lang.Object
org.jets3t.service.security.ProviderCredentials
- Direct Known Subclasses:
AWSCredentials
,GSCredentials
Abstract class to contain the credentials of a user.
- Author:
- James Murty, Nikolas Coukouma, Google developers
-
Constructor Summary
ConstructorsConstructorDescriptionProviderCredentials
(String accessKey, String secretKey) Construct credentials.ProviderCredentials
(String accessKey, String secretKey, String friendlyName) Construct credentials, and associate them with a human-friendly name. -
Method Summary
Modifier and TypeMethodDescriptionboolean
static ProviderCredentials
load
(String password, BufferedInputStream inputStream) Loads encrypted credentials from a data input stream.static ProviderCredentials
Loads encrypted credentials from a file.void
Encrypts ProviderCredentials with the given password and saves the encrypted data to a file using the default algorithmEncryptionUtil.DEFAULT_ALGORITHM
.void
Encrypts ProviderCredentials with the given password and saves the encrypted data to a file.void
save
(String password, OutputStream outputStream) Encrypts ProviderCredentials with the given password and writes the encrypted data to an output stream using the default algorithmEncryptionUtil.DEFAULT_ALGORITHM
.void
save
(String password, OutputStream outputStream, String algorithm) Encrypts ProviderCredentials with the given password and writes the encrypted data to an output stream.
-
Constructor Details
-
ProviderCredentials
Construct credentials.- Parameters:
accessKey
- Access key for a storage account.secretKey
- Secret key for a storage account.
-
ProviderCredentials
Construct credentials, and associate them with a human-friendly name.- Parameters:
accessKey
- Access key for a storage account.secretKey
- Secret key for a storage account.friendlyName
- a name identifying the owner of the credentials, such as 'James'.
-
-
Method Details
-
getAccessKey
- Returns:
- the Access Key.
-
getSecretKey
- Returns:
- the Secret Key.
-
getFriendlyName
- Returns:
- the friendly name associated with a storage account, if available.
-
hasFriendlyName
public boolean hasFriendlyName()- Returns:
- true if there is a non-null and non-empty friendly name associated with this account.
-
getLogString
- Returns:
- a string summarizing these credentials
-
save
public void save(String password, File file, String algorithm) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeySpecException, IllegalStateException, IllegalBlockSizeException, BadPaddingException, InvalidAlgorithmParameterException, IOException Encrypts ProviderCredentials with the given password and saves the encrypted data to a file.- Parameters:
password
- the password used to encrypt the credentials.file
- the file to write the encrypted credentials data to.algorithm
- the algorithm used to encrypt the output stream.- Throws:
InvalidKeyException
NoSuchAlgorithmException
NoSuchPaddingException
InvalidKeySpecException
IllegalStateException
IllegalBlockSizeException
BadPaddingException
InvalidAlgorithmParameterException
IOException
-
save
public void save(String password, File file) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeySpecException, IllegalStateException, IllegalBlockSizeException, BadPaddingException, InvalidAlgorithmParameterException, IOException Encrypts ProviderCredentials with the given password and saves the encrypted data to a file using the default algorithmEncryptionUtil.DEFAULT_ALGORITHM
.- Parameters:
password
- the password used to encrypt the credentials.file
- the file to write the encrypted credentials data to.- Throws:
InvalidKeyException
NoSuchAlgorithmException
NoSuchPaddingException
InvalidKeySpecException
IllegalStateException
IllegalBlockSizeException
BadPaddingException
InvalidAlgorithmParameterException
IOException
-
save
public void save(String password, OutputStream outputStream, String algorithm) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeySpecException, IllegalStateException, IllegalBlockSizeException, BadPaddingException, InvalidAlgorithmParameterException, IOException Encrypts ProviderCredentials with the given password and writes the encrypted data to an output stream.- Parameters:
password
- the password used to encrypt the credentials.outputStream
- the output stream to write the encrypted credentials data to, this stream must be closed by the caller.algorithm
- the algorithm used to encrypt the output stream.- Throws:
InvalidKeyException
NoSuchAlgorithmException
NoSuchPaddingException
InvalidKeySpecException
IllegalStateException
IllegalBlockSizeException
BadPaddingException
InvalidAlgorithmParameterException
IOException
-
save
public void save(String password, OutputStream outputStream) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeySpecException, IllegalStateException, IllegalBlockSizeException, BadPaddingException, InvalidAlgorithmParameterException, IOException Encrypts ProviderCredentials with the given password and writes the encrypted data to an output stream using the default algorithmEncryptionUtil.DEFAULT_ALGORITHM
.- Parameters:
password
- the password used to encrypt the credentials.outputStream
- the output stream to write the encrypted credentials data to, this stream must be closed by the caller.- Throws:
InvalidKeyException
NoSuchAlgorithmException
NoSuchPaddingException
InvalidKeySpecException
IllegalStateException
IllegalBlockSizeException
BadPaddingException
InvalidAlgorithmParameterException
IOException
-
load
Loads encrypted credentials from a file.- Parameters:
password
- the password used to decrypt the credentials. If null, the credentials are not decrypted and only the version and friendly-name information is loaded.file
- a file containing an encrypted data encoding of an ProviderCredentials object.- Returns:
- the decrypted credentials in an object.
- Throws:
ServiceException
-
load
public static ProviderCredentials load(String password, BufferedInputStream inputStream) throws ServiceException Loads encrypted credentials from a data input stream.- Parameters:
password
- the password used to decrypt the credentials. If null, the credentials are not decrypted and only the version and friendly-name information is loaded.inputStream
- an input stream containing an encrypted data encoding of an ProviderCredentials object.- Returns:
- the decrypted credentials in an object.
- Throws:
ServiceException
-