Skip to content

Commit

Permalink
Update JavaDoc
Browse files Browse the repository at this point in the history
  • Loading branch information
ting-lan-wang committed Dec 6, 2024
1 parent c52336e commit 6e099f1
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 54 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,22 +67,18 @@
public final class AwsCredentialsFactory
implements ResourceFactory<AwsCredentials> {

/** Method of authentication supported by the Azure SDK */
/** Method of authentication supported by the AWS SDK */
public static final Parameter<AwsAuthenticationMethod>
AUTHENTICATION_METHOD = Parameter.create(REQUIRED);

public static final Parameter<String> ACCESS_KEY_ID = Parameter.create(REQUIRED);

public static final Parameter<String> SECRET_ACCESS_KEY = Parameter.create(SENSITIVE, REQUIRED);

private static final AwsCredentialsFactory INSTANCE
= new AwsCredentialsFactory();

private AwsCredentialsFactory() { }

/**
* Returns a singleton of {@code TokenCredentialFactory}.
* @return a singleton of {@code TokenCredentialFactory}
* Returns a singleton of {@code AwsCredentialsFactory}.
* @return a singleton of {@code AwsCredentialsFactory}
*/
public static AwsCredentialsFactory getInstance() {
return INSTANCE;
Expand All @@ -98,7 +94,7 @@ public Resource<AwsCredentials> request(ParameterSet parameterSet) {

/**
* Returns credentials for requesting an access token. The type of credentials
* used are configured by the parameters of the given {@code parameters}.
* used are configured by the parameters of the given {@code parameterSet}.
* Supported parameters are defined by the class variables in
* {@link AwsCredentialsFactory}.
* @param parameterSet parameters that configure credentials. Not null.
Expand All @@ -111,7 +107,7 @@ private static AwsCredentials getCredential(ParameterSet parameterSet) {

switch (authenticationMethod) {
case DEFAULT:
return defaultCredentials(parameterSet);
return defaultCredentials();
default :
throw new IllegalArgumentException(
"Unrecognized authentication method: " + authenticationMethod);
Expand All @@ -120,53 +116,11 @@ private static AwsCredentials getCredential(ParameterSet parameterSet) {

/**
* Returns credentials resolved by {@link AppConfigDataClient}.
* @param parameterSet
* @return
*/
private static AwsCredentials defaultCredentials(ParameterSet parameterSet) {
private static AwsCredentials defaultCredentials() {
return DefaultCredentialsProvider
.builder()
.build().resolveCredentials();
}

/**
* Returns the value of a required parameter that may be configured by a
* provider or an SDK environment variable.
* @param parameters Parameters provided by the provider. Not null
* @param parameter Parameter that may be configured by the provider. Not null
* @param sdkName Name of the SDK environment variable, or null if there is
* none.
* @return The configured value of the parameter. Not null.
* @throws IllegalStateException If the parameter is not configured by the
* provider or the SDK.
*/
private static String requireParameter(
ParameterSet parameters, Parameter<String> parameter, String sdkName) {
try {
return parameters.getRequired(parameter);
}
catch (IllegalStateException parameterNotConfigured) {
throw new IllegalArgumentException(format(
"No value is configured for parameter \"%s\"," +
" or SDK variable \"%s\"",
parameters.getName(parameter), sdkName), parameterNotConfigured);
}
}

/**
* Returns the value of an optional parameter which may be configured by a
* provider or an SDK environment variable.
* @param parameters Parameters provided by the provider. Not null
* @param parameter Parameter that may be configured by the provider. Not null
* @param sdkName Name of the SDK environment variable, or null if there is
* none.
* @return The configured value of the parameter, or null if not configured.
*/
private static String optionalParameter(
ParameterSet parameters, Parameter<String> parameter, String sdkName) {
String value = parameters.getOptional(parameter);

return value != null ? value : null;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,27 @@

public class AwsJsonSecretsManagerProvider
implements OracleConfigurationJsonSecretProvider {
/**
* {@inheritDoc}
* <p>
* Returns the password of the Secret that is retrieved from AWS Secrets
* Manager secret.
* </p>
* <p>
* The {@code jsonObject} has the following form:
* </p>
*
* <pre>{@code
* "password": {
* "type": "awssecretsmanager",
* "value": "<secret-name>"
* }
* }</pre>
*
* @param jsonObject json object to be parsed
* @return encoded char array in base64 format that represents the retrieved
* Secret.
*/
@Override
public char[] getSecret(OracleJsonObject jsonObject) {
ParameterSet parameterSet =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,21 @@
import java.net.URISyntaxException;
import java.sql.SQLException;

/**
* A provider for JSON payload which contains configuration from AWS S3.
* See {@link #getJson(String)} for the spec of the JSON payload.
**/
public class AwsS3ConfigurationProvider extends OracleConfigurationJsonProvider {

/**
* {@inheritDoc}
* <p>
* Returns the JSON payload stored in AWS S3.
* </p>
*
* @param s3Url URI of the object stored in AWS S3
* @return JSON payload
*/
@Override
public InputStream getJson(String s3Url) throws SQLException {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
import java.util.HashMap;
import java.util.Map;

/**
* A provider for JSON payload which contains configuration from AWS Secrets
* Manager.
* See {@link #getJson(String)} for the spec of the JSON payload.
**/
public class AwsSecretsManagerConfigurationProvider extends OracleConfigurationJsonProvider {

/**
Expand All @@ -24,11 +29,20 @@ public class AwsSecretsManagerConfigurationProvider extends OracleConfigurationJ
.addParameter("key_name", SecretsManagerFactory.KEY_NAME))
.build();

/**
* {@inheritDoc}
* <p>
* Returns the JSON payload stored in AWS Secrets Manager secret.
* </p>
*
* @param secretName name of the secret
* @return JSON payload
*/
@Override
public InputStream getJson(String secretId) {
public InputStream getJson(String secretName) {
final String valueFieldName = "value";
Map<String, String> optionsWithSecret = new HashMap<>(options);
optionsWithSecret.put(valueFieldName, secretId);
optionsWithSecret.put(valueFieldName, secretName);

ParameterSet parameters = PARAMETER_SET_PARSER.parseNamedValues(optionsWithSecret);

Expand Down

0 comments on commit 6e099f1

Please sign in to comment.