Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #774

Merged
merged 13 commits into from
Apr 26, 2023
27 changes: 16 additions & 11 deletions Minio/DataModel/AccessCredentials.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,24 @@ public class AccessCredentials
public AccessCredentials(string accessKey, string secretKey,
string sessionToken, DateTime expiration)
{
if (string.IsNullOrEmpty(accessKey))
throw new ArgumentException($"'{nameof(accessKey)}' cannot be null or empty.", nameof(accessKey));
if (!string.IsNullOrEmpty(accessKey) || !string.IsNullOrEmpty(secretKey) || !string.IsNullOrEmpty(sessionToken))
{
AccessKey = accessKey;
SecretKey = secretKey;
SessionToken = sessionToken;
Expiration = expiration.Equals(default) ? null : Utils.To8601String(expiration);
}
else
{
if (string.IsNullOrEmpty(secretKey))
martijn00 marked this conversation as resolved.
Show resolved Hide resolved
throw new ArgumentException($"'{nameof(accessKey)}' cannot be null or empty.", nameof(accessKey));

if (string.IsNullOrEmpty(secretKey))
throw new ArgumentException($"'{nameof(secretKey)}' cannot be null or empty.", nameof(secretKey));
if (string.IsNullOrEmpty(secretKey))
throw new ArgumentException($"'{nameof(secretKey)}' cannot be null or empty.", nameof(secretKey));

if (string.IsNullOrEmpty(sessionToken))
throw new ArgumentException($"'{nameof(sessionToken)}' cannot be null or empty.", nameof(sessionToken));

AccessKey = accessKey;
SecretKey = secretKey;
SessionToken = sessionToken;
Expiration = expiration.Equals(default) ? null : Utils.To8601String(expiration);
if (string.IsNullOrEmpty(sessionToken))
throw new ArgumentException($"'{nameof(sessionToken)}' cannot be null or empty.", nameof(sessionToken));
}
}

public AccessCredentials()
Expand Down