|
|||||||||
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 | |
---|---|
static int |
CREDENTIALS_STORAGE_VERSION
|
Constructor Summary | |
---|---|
AWSCredentials(String awsAccessKey,
String awsSecretAccessKey)
Construct credentials. |
|
AWSCredentials(String awsAccessKey,
String awsSecretAccessKey,
String friendlyName)
Construct credentials, and associate them with a human-friendly name. |
Method Summary | |
---|---|
String |
getAccessKey()
|
String |
getFriendlyName()
|
String |
getLogString()
|
String |
getSecretKey()
|
boolean |
hasFriendlyName()
|
static AWSCredentials |
load(String password,
BufferedInputStream inputStream)
Loads encrypted credentials from a data input stream. |
static AWSCredentials |
load(String password,
File file)
Loads encrypted credentials from a file. |
static void |
main(String[] args)
Console utility to store AWS credentials information in an encrypted file in the toolkit's default preferences directory. |
void |
save(String password,
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(String password,
File file,
String algorithm)
Encrypts AWS Credentials with the given password and saves the encrypted data to a file. |
void |
save(String password,
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(String password,
OutputStream outputStream,
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 |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int CREDENTIALS_STORAGE_VERSION
Constructor Detail |
---|
public AWSCredentials(String awsAccessKey, String awsSecretAccessKey)
awsAccessKey
- AWS access key for an Amazon S3 account.awsSecretAccessKey
- AWS secret key for an Amazon S3 acount.public AWSCredentials(String awsAccessKey, String awsSecretAccessKey, 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 String getAccessKey()
public String getSecretKey()
public String getFriendlyName()
public boolean hasFriendlyName()
public String getLogString()
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 AWSCredentials load(String password, 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(String password, 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(String[] args) throws 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
-
Exception
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |