Skip to content

Commit

Permalink
Add new authenticator configs for user defined auth extensions.
Browse files Browse the repository at this point in the history
  • Loading branch information
Thisara-Welmilla committed Nov 8, 2024
1 parent fa9ca08 commit cc7c884
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> proppertyMap = new HashMap<>();
for (AuthProperty prop: endpointConfig.getAuthentication().getProperties()) {
proppertyMap.put(prop.getName(), prop.getValue());
}
return proppertyMap;
}

/**
* 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 cc7c884

Please sign in to comment.