|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jets3t.service.security.AWSCredentials
public class AWSCredentials
Class to contain the Amazon Web Services (AWS) credentials of a user. This class also includes utility methods to store credentials to password-encrypted files, and retrieve credentials from these files.
Field Summary | |
---|---|
protected java.lang.String |
awsAccessKey
|
protected java.lang.String |
awsSecretAccessKey
|
static int |
CREDENTIALS_STORAGE_VERSION
|
protected static java.lang.String |
DEVPAY_TYPE_NAME
|
protected java.lang.String |
friendlyName
|
protected static org.apache.commons.logging.Log |
log
|
protected static java.lang.String |
REGULAR_TYPE_NAME
|
protected static java.lang.String |
V2_KEYS_DELIMITER
|
protected static java.lang.String |
V3_KEYS_DELIMITER
|
protected static java.lang.String |
VERSION_PREFIX
|
Constructor Summary | |
---|---|
AWSCredentials(java.lang.String awsAccessKey,
java.lang.String awsSecretAccessKey)
Construct credentials. |
|
AWSCredentials(java.lang.String awsAccessKey,
java.lang.String awsSecretAccessKey,
java.lang.String friendlyName)
Construct credentials, and associate them with a human-friendly name. |
Method Summary | |
---|---|
java.lang.String |
getAccessKey()
|
protected java.lang.String |
getDataToEncrypt()
|
java.lang.String |
getFriendlyName()
|
java.lang.String |
getLogString()
|
java.lang.String |
getSecretKey()
|
protected java.lang.String |
getTypeName()
|
boolean |
hasFriendlyName()
|
static AWSCredentials |
load(java.lang.String password,
java.io.BufferedInputStream inputStream)
Loads encrypted credentials from a data input stream. |
static AWSCredentials |
load(java.lang.String password,
java.io.File file)
Loads encrypted credentials from a file. |
static void |
main(java.lang.String[] args)
Console utility to store AWS credentials information in an encrypted file in the toolkit's default preferences directory. |
void |
save(java.lang.String password,
java.io.File file)
Encrypts AWS Credentials with the given password and saves the encrypted data to a file using the default algorithm EncryptionUtil.DEFAULT_ALGORITHM . |
void |
save(java.lang.String password,
java.io.File file,
java.lang.String algorithm)
Encrypts AWS Credentials with the given password and saves the encrypted data to a file. |
void |
save(java.lang.String password,
java.io.OutputStream outputStream)
Encrypts AWS Credentials with the given password and writes the encrypted data to an output stream using the default algorithm EncryptionUtil.DEFAULT_ALGORITHM . |
void |
save(java.lang.String password,
java.io.OutputStream outputStream,
java.lang.String algorithm)
Encrypts AWS Credentials with the given password and writes the encrypted data to an output stream. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final org.apache.commons.logging.Log log
public static final int CREDENTIALS_STORAGE_VERSION
protected static final java.lang.String V2_KEYS_DELIMITER
protected static final java.lang.String V3_KEYS_DELIMITER
protected static final java.lang.String VERSION_PREFIX
protected static final java.lang.String REGULAR_TYPE_NAME
protected static final java.lang.String DEVPAY_TYPE_NAME
protected java.lang.String awsAccessKey
protected java.lang.String awsSecretAccessKey
protected java.lang.String friendlyName
Constructor Detail |
---|
public AWSCredentials(java.lang.String awsAccessKey, java.lang.String awsSecretAccessKey)
awsAccessKey
- AWS access key for an Amazon S3 account.awsSecretAccessKey
- AWS secret key for an Amazon S3 acount.public AWSCredentials(java.lang.String awsAccessKey, java.lang.String awsSecretAccessKey, java.lang.String friendlyName)
awsAccessKey
- AWS access key for an Amazon S3 account.awsSecretAccessKey
- AWS secret key for an Amazon S3 acount.friendlyName
- a name identifying the owner of the credentials, such as 'James'.Method Detail |
---|
public java.lang.String getAccessKey()
public java.lang.String getSecretKey()
public java.lang.String getFriendlyName()
public boolean hasFriendlyName()
public java.lang.String getLogString()
protected java.lang.String getTypeName()
protected java.lang.String getDataToEncrypt()
public void save(java.lang.String password, java.io.File file, java.lang.String algorithm) throws java.security.InvalidKeyException, java.security.NoSuchAlgorithmException, javax.crypto.NoSuchPaddingException, java.security.spec.InvalidKeySpecException, java.lang.IllegalStateException, javax.crypto.IllegalBlockSizeException, javax.crypto.BadPaddingException, java.security.InvalidAlgorithmParameterException, java.io.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.
java.security.InvalidKeyException
java.security.NoSuchAlgorithmException
javax.crypto.NoSuchPaddingException
java.security.spec.InvalidKeySpecException
java.lang.IllegalStateException
javax.crypto.IllegalBlockSizeException
javax.crypto.BadPaddingException
java.security.InvalidAlgorithmParameterException
java.io.IOException
public void save(java.lang.String password, java.io.File file) throws java.security.InvalidKeyException, java.security.NoSuchAlgorithmException, javax.crypto.NoSuchPaddingException, java.security.spec.InvalidKeySpecException, java.lang.IllegalStateException, javax.crypto.IllegalBlockSizeException, javax.crypto.BadPaddingException, java.security.InvalidAlgorithmParameterException, java.io.IOException
EncryptionUtil.DEFAULT_ALGORITHM
.
password
- the password used to encrypt the credentials.file
- the file to write the encrypted credentials data to.
java.security.InvalidKeyException
java.security.NoSuchAlgorithmException
javax.crypto.NoSuchPaddingException
java.security.spec.InvalidKeySpecException
java.lang.IllegalStateException
javax.crypto.IllegalBlockSizeException
javax.crypto.BadPaddingException
java.security.InvalidAlgorithmParameterException
java.io.IOException
public void save(java.lang.String password, java.io.OutputStream outputStream, java.lang.String algorithm) throws java.security.InvalidKeyException, java.security.NoSuchAlgorithmException, javax.crypto.NoSuchPaddingException, java.security.spec.InvalidKeySpecException, java.lang.IllegalStateException, javax.crypto.IllegalBlockSizeException, javax.crypto.BadPaddingException, java.security.InvalidAlgorithmParameterException, java.io.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.
java.security.InvalidKeyException
java.security.NoSuchAlgorithmException
javax.crypto.NoSuchPaddingException
java.security.spec.InvalidKeySpecException
java.lang.IllegalStateException
javax.crypto.IllegalBlockSizeException
javax.crypto.BadPaddingException
java.security.InvalidAlgorithmParameterException
java.io.IOException
public void save(java.lang.String password, java.io.OutputStream outputStream) throws java.security.InvalidKeyException, java.security.NoSuchAlgorithmException, javax.crypto.NoSuchPaddingException, java.security.spec.InvalidKeySpecException, java.lang.IllegalStateException, javax.crypto.IllegalBlockSizeException, javax.crypto.BadPaddingException, java.security.InvalidAlgorithmParameterException, java.io.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.
java.security.InvalidKeyException
java.security.NoSuchAlgorithmException
javax.crypto.NoSuchPaddingException
java.security.spec.InvalidKeySpecException
java.lang.IllegalStateException
javax.crypto.IllegalBlockSizeException
javax.crypto.BadPaddingException
java.security.InvalidAlgorithmParameterException
java.io.IOException
public static AWSCredentials load(java.lang.String password, java.io.File file) throws S3ServiceException
password
- the password used to decrypt the credentials. If null, the AWS Credentials are not decrypted
and only the version and friendly-name information is loaded.file
- a file containing an encrypted data encoding of an AWSCredentials object.
S3ServiceException
public static AWSCredentials load(java.lang.String password, java.io.BufferedInputStream inputStream) throws S3ServiceException
password
- the password used to decrypt the credentials. If null, the AWS 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 AWSCredentials object.
S3ServiceException
public static void main(java.lang.String[] args) throws java.lang.Exception
This class can be run from the command line as:
java org.jets3t.service.security.AWSCredentials <friendlyName> <credentialsFilename> <algorithm>When run it will prompt for the user's AWS access key,secret key and encryption password. It will then encode into the specified credentials file.
args
-
java.lang.Exception
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |