public abstract class ProviderCredentials extends Object
Modifier and Type | Field and Description |
---|---|
protected String |
accessKey |
protected static int |
CREDENTIALS_STORAGE_VERSION |
protected String |
friendlyName |
protected static org.apache.commons.logging.Log |
log |
protected String |
secretKey |
protected static String |
V2_KEYS_DELIMITER |
protected static String |
V3_KEYS_DELIMITER |
Constructor and Description |
---|
ProviderCredentials(String accessKey,
String secretKey)
Construct credentials.
|
ProviderCredentials(String accessKey,
String secretKey,
String friendlyName)
Construct credentials, and associate them with a human-friendly name.
|
Modifier and Type | Method and Description |
---|---|
String |
getAccessKey() |
protected String |
getDataToEncrypt() |
String |
getFriendlyName() |
String |
getLogString() |
String |
getSecretKey() |
protected abstract String |
getTypeName() |
protected abstract String |
getVersionPrefix() |
boolean |
hasFriendlyName() |
static ProviderCredentials |
load(String password,
BufferedInputStream inputStream)
Loads encrypted credentials from a data input stream.
|
static ProviderCredentials |
load(String password,
File file)
Loads encrypted credentials from a file.
|
void |
save(String password,
File file)
Encrypts ProviderCredentials with the given password and saves the encrypted data to a file
using the default algorithm
EncryptionUtil.DEFAULT_ALGORITHM . |
void |
save(String password,
File file,
String algorithm)
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 algorithm
EncryptionUtil.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.
|
protected static final org.apache.commons.logging.Log log
protected static final int CREDENTIALS_STORAGE_VERSION
protected static final String V2_KEYS_DELIMITER
protected static final String V3_KEYS_DELIMITER
protected String accessKey
protected String secretKey
protected String friendlyName
public ProviderCredentials(String accessKey, String secretKey)
accessKey
- Access key for a storage account.secretKey
- Secret key for a storage account.public ProviderCredentials(String accessKey, String secretKey, String friendlyName)
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'.public String getAccessKey()
public String getSecretKey()
public String getFriendlyName()
public boolean hasFriendlyName()
public String getLogString()
protected String getDataToEncrypt()
protected abstract String getTypeName()
protected abstract String getVersionPrefix()
public void save(String password, File file, String algorithm) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeySpecException, IllegalStateException, IllegalBlockSizeException, BadPaddingException, InvalidAlgorithmParameterException, IOException
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.InvalidKeyException
NoSuchAlgorithmException
NoSuchPaddingException
InvalidKeySpecException
IllegalStateException
IllegalBlockSizeException
BadPaddingException
InvalidAlgorithmParameterException
IOException
public void save(String password, File file) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeySpecException, IllegalStateException, IllegalBlockSizeException, BadPaddingException, InvalidAlgorithmParameterException, IOException
EncryptionUtil.DEFAULT_ALGORITHM
.password
- the password used to encrypt the credentials.file
- the file to write the encrypted credentials data to.InvalidKeyException
NoSuchAlgorithmException
NoSuchPaddingException
InvalidKeySpecException
IllegalStateException
IllegalBlockSizeException
BadPaddingException
InvalidAlgorithmParameterException
IOException
public void save(String password, OutputStream outputStream, String algorithm) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeySpecException, IllegalStateException, IllegalBlockSizeException, BadPaddingException, InvalidAlgorithmParameterException, IOException
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.InvalidKeyException
NoSuchAlgorithmException
NoSuchPaddingException
InvalidKeySpecException
IllegalStateException
IllegalBlockSizeException
BadPaddingException
InvalidAlgorithmParameterException
IOException
public void save(String password, OutputStream outputStream) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeySpecException, IllegalStateException, IllegalBlockSizeException, BadPaddingException, InvalidAlgorithmParameterException, IOException
EncryptionUtil.DEFAULT_ALGORITHM
.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.InvalidKeyException
NoSuchAlgorithmException
NoSuchPaddingException
InvalidKeySpecException
IllegalStateException
IllegalBlockSizeException
BadPaddingException
InvalidAlgorithmParameterException
IOException
public static ProviderCredentials load(String password, File file) throws ServiceException
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.ServiceException
public static ProviderCredentials load(String password, BufferedInputStream inputStream) throws ServiceException
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.ServiceException
Copyright © 2006–2018. All rights reserved.