1 /*
2  * Copyright 2010-2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License").
5  * You may not use this file except in compliance with the License.
6  * A copy of the License is located at
7  *
8  *  http://aws.amazon.com/apache2.0
9  *
10  * or in the "license" file accompanying this file. This file is distributed
11  * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12  * express or implied. See the License for the specific language governing
13  * permissions and limitations under the License.
14  */

15 package com.amazonaws.auth;
16
17 /**
18  * Basic implementation of the AWSCredentials interface that allows callers to
19  * pass in the AWS access key and secret access in the constructor.
20  */

21 public class BasicAWSCredentials implements AWSCredentials {
22
23     private final String accessKey;
24     private final String secretKey;
25
26     /**
27      * Constructs a new BasicAWSCredentials object, with the specified AWS
28      * access key and AWS secret key.
29      *
30      * @param accessKey
31      *            The AWS access key.
32      * @param secretKey
33      *            The AWS secret access key.
34      */

35     public BasicAWSCredentials(String accessKey, String secretKey) {
36         if (accessKey == null) {
37             throw new IllegalArgumentException("Access key cannot be null.");
38         }
39         if (secretKey == null) {
40             throw new IllegalArgumentException("Secret key cannot be null.");
41         }
42
43         this.accessKey = accessKey;
44         this.secretKey = secretKey;
45     }
46
47     /* (non-Javadoc)
48      * @see com.amazonaws.auth.AWSCredentials#getAWSAccessKeyId()
49      */

50     public String getAWSAccessKeyId() {
51         return accessKey;
52     }
53
54     /* (non-Javadoc)
55      * @see com.amazonaws.auth.AWSCredentials#getAWSSecretKey()
56      */

57     public String getAWSSecretKey() {
58         return secretKey;
59     }
60
61 }
62