Skip to content

Commit

Permalink
Add support for managing custom federated authenticators.
Browse files Browse the repository at this point in the history
  • Loading branch information
Thisara-Welmilla committed Nov 8, 2024
1 parent 453f02d commit 0c77d92
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -262,23 +262,25 @@ public Authentication build() {
switch (authType) {
case BASIC:
return new Authentication.BasicAuthBuilder(
getProperty(authPropertiesMap, Property.USERNAME.getName()),
getProperty(authPropertiesMap, Property.PASSWORD.getName())).build();
getProperty(Type.BASIC, authPropertiesMap, Property.USERNAME.getName()),
getProperty(Type.BASIC, authPropertiesMap, Property.PASSWORD.getName())).build();
case BEARER:
return new Authentication.BearerAuthBuilder(
getProperty(authPropertiesMap, Property.ACCESS_TOKEN.getName())).build();
getProperty(Type.BEARER, authPropertiesMap, Property.ACCESS_TOKEN.getName())).build();
case API_KEY:
return new Authentication.APIKeyAuthBuilder(
getProperty(authPropertiesMap, Property.HEADER.getName()),
getProperty(authPropertiesMap, Property.VALUE.getName())).build();
getProperty(Type.API_KEY, authPropertiesMap, Property.HEADER.getName()),
getProperty(Type.API_KEY, authPropertiesMap, Property.VALUE.getName())).build();
case NONE:
return new Authentication.NoneAuthBuilder().build();
default:
throw new IllegalArgumentException();
throw new IllegalArgumentException(String.format("An invalid authentication type '%s' is " +
"provided for the authentication configuration of the endpoint.", authType.name()));
}
}

private String getProperty(Map<String, String> actionEndpointProperties, String propertyName) {
private String getProperty(Authentication.Type authType, Map<String, String> actionEndpointProperties,
String propertyName) {

if (actionEndpointProperties != null && actionEndpointProperties.containsKey(propertyName)) {
String propValue = actionEndpointProperties.get(propertyName);
Expand All @@ -288,8 +290,8 @@ private String getProperty(Map<String, String> actionEndpointProperties, String
throw new IllegalArgumentException(String.format("The Property %s cannot be blank.", propertyName));
}

throw new NoSuchElementException(String.format("The Property %s is not found in the authentication " +
"configuration.", propertyName));
throw new NoSuchElementException(String.format("The property %s must be provided as an authentication " +
"property for the %s authentication type.", propertyName, authType.name()));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import java.util.Map;

/**
* The authenticator endpoint configuration model.
* The authenticator endpoint configuration model for the user defined authenticator configurations.
*/
public class UserDefinedAuthenticatorEndpointConfig {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,17 @@ public UserDefinedFederatedAuthenticatorConfig() {
}

/**
* Get the endpoint config of the User defined federated authenticator config.
* Get the endpoint configurations of the User defined federated authenticator config.
*
* @return DefinedByType
* @return UserDefinedAuthenticatorEndpointConfig
*/
public UserDefinedAuthenticatorEndpointConfig getEndpointConfig() {

return endpointConfig;
}

/**
* Set the defined by type of the User defined federated authenticator config.
* Set the endpoint configurations of the User defined federated authenticator config.
*
* @param endpointConfig The endpoint config of the User defined federated authenticator config.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,17 @@ public UserDefinedLocalAuthenticatorConfig(AuthenticationType type) {
}

/**
* Get the endpoint config of the User defined local authenticator config.
* Get the endpoint configurations of the User defined local authenticator config.
*
* @return DefinedByType
* @return UserDefinedAuthenticatorEndpointConfig
*/
public UserDefinedAuthenticatorEndpointConfig getEndpointConfig() {

return endpointConfig;
}

/**
* Set the defined by type of the User defined local authenticator config.
* Set the endpoint configurations of the User defined local authenticator config.
*
* @param endpointConfig The endpoint config of the User defined local authenticator config.
*/
Expand Down

0 comments on commit 0c77d92

Please sign in to comment.