Skip to content

Commit

Permalink
Merge pull request #6114 from Thisara-Welmilla/improve-UserDefinedAut…
Browse files Browse the repository at this point in the history
…henticatorEndpointConfig

Add new authenticator configs for user defined auth extensions.
  • Loading branch information
Thisara-Welmilla authored Nov 8, 2024
2 parents c2ab82b + 3cbde60 commit c801b6b
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@

package org.wso2.carbon.identity.application.common.model;

import org.wso2.carbon.identity.action.management.model.AuthProperty;
import org.wso2.carbon.identity.action.management.model.Authentication;
import org.wso2.carbon.identity.action.management.model.EndpointConfig;

import java.util.HashMap;
import java.util.Map;

/**
Expand All @@ -40,6 +42,40 @@ public EndpointConfig getEndpointConfig() {
return endpointConfig;
}

/**
* Get the URI of the authenticator endpoint of the user defined authenticator.
*
* @return URI of the authenticator endpoint.
*/
public String getAuthenticatorEndpointUri() {

return endpointConfig.getUri();
}

/**
* Get the authentication type of the authenticator endpoint of the user defined authenticator.
*
* @return Authentication type of the authenticator endpoint.
*/
public String getAuthenticatorEndpointAuthenticationType() {

return endpointConfig.getAuthentication().getType().getName();
}

/**
* Get the authentication properties of the authenticator endpoint of the user defined authenticator.
*
* @return Authentication properties of the authenticator endpoint.
*/
public Map<String, String> getAuthenticatorEndpointAuthenticationProperties() {

Map<String, String> propertyMap = new HashMap<>();
for (AuthProperty prop: endpointConfig.getAuthentication().getProperties()) {
propertyMap.put(prop.getName(), prop.getValue());
}
return propertyMap;
}

/**
* UserDefinedAuthenticatorEndpointConfig builder.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,9 @@ public void createEndpointConfigurationTest(String uri, String authenticationTyp
endpointConfigBuilder.authenticationProperties(endpointConfig);
UserDefinedAuthenticatorEndpointConfig authEndpointConfig = endpointConfigBuilder.build();

assertEquals(authEndpointConfig.getEndpointConfig().getUri(), uri);
assertEquals(authEndpointConfig.getEndpointConfig().getAuthentication().getType().getName(),
authenticationType);
assertEquals(authEndpointConfig.getEndpointConfig().getAuthentication().getProperties().size(),
endpointConfig.size());
assertEquals(authEndpointConfig.getAuthenticatorEndpointUri(), uri);
assertEquals(authEndpointConfig.getAuthenticatorEndpointAuthenticationType(), authenticationType);
assertEquals(authEndpointConfig.getAuthenticatorEndpointAuthenticationProperties(), endpointConfig);
}

@DataProvider(name = "invalidEndpointConfig")
Expand Down

0 comments on commit c801b6b

Please sign in to comment.