/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
using Amazon.Runtime.Internal.Util;
using Amazon.Util;
using System;
namespace Amazon.Runtime
{
///
/// Session credentials consisting of AccessKey, SecretKey and Token
///
public class SessionAWSCredentials : AWSCredentials
{
#region Public constructors
///
/// Constructs a SessionAWSCredentials object for the specified accessKey, secretKey.
///
///
///
///
public SessionAWSCredentials(string awsAccessKeyId, string awsSecretAccessKey, string token)
{
if (string.IsNullOrEmpty(awsAccessKeyId)) throw new ArgumentNullException("awsAccessKeyId");
if (string.IsNullOrEmpty(awsSecretAccessKey)) throw new ArgumentNullException("awsSecretAccessKey");
if (string.IsNullOrEmpty(token)) throw new ArgumentNullException("token");
_lastCredentials = new ImmutableCredentials(awsAccessKeyId, awsSecretAccessKey, token);
}
#endregion
#region Credentials data
private ImmutableCredentials _lastCredentials;
#endregion
#region Abstract class overrides
///
/// Returns an instance of ImmutableCredentials for this instance
///
///
public override ImmutableCredentials GetCredentials()
{
return _lastCredentials.Copy();
}
#endregion
public override bool Equals(object obj)
{
if (object.ReferenceEquals(this, obj))
return true;
var sac = obj as SessionAWSCredentials;
if (sac == null)
return false;
return AWSSDKUtils.AreEqual(
new object[] { _lastCredentials },
new object[] { sac._lastCredentials });
}
public override int GetHashCode()
{
return Hashing.Hash(_lastCredentials);
}
}
}