Skip to content

Commit

Permalink
Merge branch 'master' into pr6064
Browse files Browse the repository at this point in the history
# Conflicts:
#	components/action-mgt/org.wso2.carbon.identity.action.execution/pom.xml
#	components/action-mgt/org.wso2.carbon.identity.action.management/pom.xml
#	components/action-mgt/pom.xml
#	components/api-resource-mgt/org.wso2.carbon.identity.api.resource.collection.mgt/pom.xml
#	components/api-resource-mgt/org.wso2.carbon.identity.api.resource.mgt/pom.xml
#	components/api-resource-mgt/pom.xml
#	components/application-mgt/org.wso2.carbon.identity.application.common/pom.xml
#	components/application-mgt/org.wso2.carbon.identity.application.mgt.ui/pom.xml
#	components/application-mgt/org.wso2.carbon.identity.application.mgt/pom.xml
#	components/application-mgt/pom.xml
#	components/authentication-framework/org.wso2.carbon.identity.application.authentication.endpoint.util/pom.xml
#	components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/pom.xml
#	components/authentication-framework/pom.xml
#	components/captcha-mgt/org.wso2.carbon.captcha.mgt/pom.xml
#	components/captcha-mgt/pom.xml
#	components/carbon-authenticators/pom.xml
#	components/carbon-authenticators/thrift-authenticator/org.wso2.carbon.identity.authenticator.thrift/pom.xml
#	components/carbon-authenticators/thrift-authenticator/pom.xml
#	components/central-logger/org.wso2.carbon.identity.central.log.mgt/pom.xml
#	components/central-logger/pom.xml
#	components/certificate-mgt/org.wso2.carbon.identity.certificate.management/pom.xml
#	components/certificate-mgt/pom.xml
#	components/claim-mgt/org.wso2.carbon.claim.mgt.ui/pom.xml
#	components/claim-mgt/org.wso2.carbon.claim.mgt/pom.xml
#	components/claim-mgt/org.wso2.carbon.identity.claim.metadata.mgt.ui/pom.xml
#	components/claim-mgt/org.wso2.carbon.identity.claim.metadata.mgt/pom.xml
#	components/claim-mgt/pom.xml
#	components/client-attestation-mgt/org.wso2.carbon.identity.client.attestation.mgt/pom.xml
#	components/client-attestation-mgt/pom.xml
#	components/configuration-mgt/org.wso2.carbon.identity.api.server.configuration.mgt/pom.xml
#	components/configuration-mgt/org.wso2.carbon.identity.configuration.mgt.core/pom.xml
#	components/configuration-mgt/org.wso2.carbon.identity.configuration.mgt.endpoint/pom.xml
#	components/configuration-mgt/pom.xml
#	components/consent-mgt/org.wso2.carbon.identity.consent.mgt/pom.xml
#	components/consent-mgt/pom.xml
#	components/consent-server-configs-mgt/org.wso2.carbon.identity.consent.server.configs.mgt/pom.xml
#	components/consent-server-configs-mgt/pom.xml
#	components/cors-mgt/org.wso2.carbon.identity.cors.mgt.core/pom.xml
#	components/cors-mgt/pom.xml
#	components/directory-server-manager/org.wso2.carbon.directory.server.manager.common/pom.xml
#	components/directory-server-manager/org.wso2.carbon.directory.server.manager.ui/pom.xml
#	components/directory-server-manager/org.wso2.carbon.directory.server.manager/pom.xml
#	components/directory-server-manager/pom.xml
#	components/entitlement/org.wso2.carbon.identity.api.server.entitlement/pom.xml
#	components/entitlement/org.wso2.carbon.identity.entitlement.common/pom.xml
#	components/entitlement/org.wso2.carbon.identity.entitlement.endpoint/pom.xml
#	components/entitlement/org.wso2.carbon.identity.entitlement.ui/pom.xml
#	components/entitlement/org.wso2.carbon.identity.entitlement/pom.xml
#	components/entitlement/pom.xml
#	components/extension-mgt/org.wso2.carbon.identity.extension.mgt/pom.xml
#	components/extension-mgt/pom.xml
#	components/functions-library-mgt/org.wso2.carbon.identity.functions.library.mgt.ui/pom.xml
#	components/functions-library-mgt/org.wso2.carbon.identity.functions.library.mgt/pom.xml
#	components/functions-library-mgt/pom.xml
#	components/identity-core/org.wso2.carbon.identity.base/pom.xml
#	components/identity-core/org.wso2.carbon.identity.core.ui/pom.xml
#	components/identity-core/org.wso2.carbon.identity.core/pom.xml
#	components/identity-core/pom.xml
#	components/identity-event/org.wso2.carbon.identity.event/pom.xml
#	components/identity-event/pom.xml
#	components/identity-mgt/org.wso2.carbon.identity.mgt.endpoint.util/pom.xml
#	components/identity-mgt/org.wso2.carbon.identity.mgt.ui/pom.xml
#	components/identity-mgt/org.wso2.carbon.identity.mgt/pom.xml
#	components/identity-mgt/pom.xml
#	components/idp-mgt/org.wso2.carbon.idp.mgt.ui/pom.xml
#	components/idp-mgt/org.wso2.carbon.idp.mgt/pom.xml
#	components/idp-mgt/pom.xml
#	components/input-validation-mgt/org.wso2.carbon.identity.input.validation.mgt/pom.xml
#	components/input-validation-mgt/pom.xml
#	components/multi-attribute-login/org.wso2.carbon.identity.multi.attribute.login.mgt/pom.xml
#	components/multi-attribute-login/org.wso2.carbon.identity.unique.claim.mgt/pom.xml
#	components/multi-attribute-login/pom.xml
#	components/notification-mgt/org.wso2.carbon.identity.notification.mgt/pom.xml
#	components/notification-mgt/pom.xml
#	components/policy-editor/org.wso2.carbon.policyeditor.ui/pom.xml
#	components/policy-editor/org.wso2.carbon.policyeditor/pom.xml
#	components/policy-editor/pom.xml
#	components/provisioning/org.wso2.carbon.identity.provisioning/pom.xml
#	components/provisioning/pom.xml
#	components/role-mgt/org.wso2.carbon.identity.role.mgt.core/pom.xml
#	components/role-mgt/org.wso2.carbon.identity.role.v2.mgt.core/pom.xml
#	components/role-mgt/pom.xml
#	components/secret-mgt/org.wso2.carbon.identity.secret.mgt.core/pom.xml
#	components/secret-mgt/pom.xml
#	components/security-mgt/org.wso2.carbon.security.mgt.ui/pom.xml
#	components/security-mgt/org.wso2.carbon.security.mgt/pom.xml
#	components/security-mgt/pom.xml
#	components/template-mgt/org.wso2.carbon.identity.template.mgt.ui/pom.xml
#	components/template-mgt/org.wso2.carbon.identity.template.mgt/pom.xml
#	components/template-mgt/pom.xml
#	components/trusted-app-mgt/org.wso2.carbon.identity.trusted.app.mgt/pom.xml
#	components/trusted-app-mgt/pom.xml
#	components/user-functionality-mgt/org.wso2.carbon.identity.user.functionality.mgt/pom.xml
#	components/user-functionality-mgt/pom.xml
#	components/user-mgt/org.wso2.carbon.identity.user.profile.ui/pom.xml
#	components/user-mgt/org.wso2.carbon.identity.user.profile/pom.xml
#	components/user-mgt/org.wso2.carbon.identity.user.registration/pom.xml
#	components/user-mgt/org.wso2.carbon.role.mgt.ui/pom.xml
#	components/user-mgt/org.wso2.carbon.user.mgt.common/pom.xml
#	components/user-mgt/org.wso2.carbon.user.mgt.ui/pom.xml
#	components/user-mgt/org.wso2.carbon.user.mgt/pom.xml
#	components/user-mgt/pom.xml
#	components/user-store/org.wso2.carbon.identity.user.store.configuration.deployer/pom.xml
#	components/user-store/org.wso2.carbon.identity.user.store.configuration.ui/pom.xml
#	components/user-store/org.wso2.carbon.identity.user.store.configuration/pom.xml
#	components/user-store/org.wso2.carbon.identity.user.store.count/pom.xml
#	components/user-store/pom.xml
#	features/action-mgt/org.wso2.carbon.identity.action.management.server.feature/pom.xml
#	features/action-mgt/pom.xml
#	features/api-resource-mgt/org.wso2.carbon.identity.api.resource.mgt.server.feature/pom.xml
#	features/api-resource-mgt/pom.xml
#	features/application-mgt/org.wso2.carbon.identity.application.mgt.feature/pom.xml
#	features/application-mgt/org.wso2.carbon.identity.application.mgt.server.feature/pom.xml
#	features/application-mgt/org.wso2.carbon.identity.application.mgt.ui.feature/pom.xml
#	features/application-mgt/pom.xml
#	features/authentication-framework/org.wso2.carbon.identity.application.authentication.framework.server.feature/pom.xml
#	features/authentication-framework/pom.xml
#	features/carbon-authenticators/pom.xml
#	features/carbon-authenticators/thrift-authenticator/org.wso2.carbon.identity.thrift.authentication.feature/pom.xml
#	features/carbon-authenticators/thrift-authenticator/pom.xml
#	features/categories/authorization/pom.xml
#	features/categories/inbound-authentication/pom.xml
#	features/categories/inbound-provisioning/pom.xml
#	features/categories/keystore-mgt/pom.xml
#	features/categories/notification-mgt/pom.xml
#	features/categories/outbound-authentication/pom.xml
#	features/categories/outbound-provisioning/pom.xml
#	features/categories/pom.xml
#	features/categories/user-mgt/pom.xml
#	features/central-logger/org.wso2.carbon.identity.central.log.mgt.server.feature/pom.xml
#	features/central-logger/pom.xml
#	features/certificate-mgt/org.wso2.carbon.identity.certificate.management.server.feature/pom.xml
#	features/certificate-mgt/pom.xml
#	features/claim-mgt/org.wso2.carbon.claim.mgt.feature/pom.xml
#	features/claim-mgt/org.wso2.carbon.claim.mgt.server.feature/pom.xml
#	features/claim-mgt/org.wso2.carbon.claim.mgt.ui.feature/pom.xml
#	features/claim-mgt/pom.xml
#	features/client-attestation-mgt/org.wso2.carbon.identity.client.attestation.mgt.server.feature/pom.xml
#	features/client-attestation-mgt/pom.xml
#	features/configuration-mgt/org.wso2.carbon.identity.configuration.mgt.server.feature/pom.xml
#	features/configuration-mgt/pom.xml
#	features/consent-mgt/org.wso2.carbon.identity.consent.mgt.server.feature/pom.xml
#	features/consent-mgt/pom.xml
#	features/consent-server-configs-mgt/org.wso2.carbon.identity.consent.server.configs.mgt.server.feature/pom.xml
#	features/consent-server-configs-mgt/pom.xml
#	features/cors-mgt/org.wso2.carbon.identity.cors.mgt.server.feature/pom.xml
#	features/cors-mgt/pom.xml
#	features/directory-server-manager/org.wso2.carbon.directory.service.mgr.feature/pom.xml
#	features/directory-server-manager/org.wso2.carbon.directory.service.mgr.server.feature/pom.xml
#	features/directory-server-manager/org.wso2.carbon.directory.service.mgr.ui.feature/pom.xml
#	features/directory-server-manager/pom.xml
#	features/extension-mgt/org.wso2.carbon.identity.extension.mgt.feature/pom.xml
#	features/extension-mgt/pom.xml
#	features/functions-library-mgt/org.wso2.carbon.identity.functions.library.mgt.feature/pom.xml
#	features/functions-library-mgt/org.wso2.carbon.identity.functions.library.mgt.server.feature/pom.xml
#	features/functions-library-mgt/org.wso2.carbon.identity.functions.library.mgt.ui.feature/pom.xml
#	features/functions-library-mgt/pom.xml
#	features/identity-core/org.wso2.carbon.identity.core.feature/pom.xml
#	features/identity-core/org.wso2.carbon.identity.core.server.feature/pom.xml
#	features/identity-core/org.wso2.carbon.identity.core.ui.feature/pom.xml
#	features/identity-core/pom.xml
#	features/identity-event/org.wso2.carbon.identity.event.feature/pom.xml
#	features/identity-event/org.wso2.carbon.identity.event.server.feature/pom.xml
#	features/identity-event/pom.xml
#	features/identity-mgt/org.wso2.carbon.identity.mgt.feature/pom.xml
#	features/identity-mgt/org.wso2.carbon.identity.mgt.server.feature/pom.xml
#	features/identity-mgt/org.wso2.carbon.identity.mgt.ui.feature/pom.xml
#	features/identity-mgt/pom.xml
#	features/idp-mgt/org.wso2.carbon.idp.mgt.feature/pom.xml
#	features/idp-mgt/org.wso2.carbon.idp.mgt.server.feature/pom.xml
#	features/idp-mgt/org.wso2.carbon.idp.mgt.ui.feature/pom.xml
#	features/idp-mgt/pom.xml
#	features/input-validation-mgt/org.wso2.carbon.identity.input.validation.mgt.server.feature/pom.xml
#	features/input-validation-mgt/pom.xml
#	features/multi-attribute-login/org.wso2.carbon.identity.multi.attribute.login.mgt.server.feature/pom.xml
#	features/multi-attribute-login/org.wso2.carbon.identity.unique.claim.mgt.server.feature/pom.xml
#	features/multi-attribute-login/pom.xml
#	features/notification-mgt/org.wso2.carbon.identity.notification.mgt.feature/pom.xml
#	features/notification-mgt/org.wso2.carbon.identity.notification.mgt.server.feature/pom.xml
#	features/notification-mgt/pom.xml
#	features/provisioning/org.wso2.carbon.identity.provisioning.server.feature/pom.xml
#	features/provisioning/pom.xml
#	features/role-mgt/org.wso2.carbon.identity.role.mgt.core.server.feature/pom.xml
#	features/role-mgt/org.wso2.carbon.identity.role.v2.mgt.core.server.feature/pom.xml
#	features/role-mgt/pom.xml
#	features/secret-mgt/org.wso2.carbon.identity.secret.mgt.core.server.feature/pom.xml
#	features/secret-mgt/pom.xml
#	features/security-mgt/org.wso2.carbon.security.mgt.feature/pom.xml
#	features/security-mgt/org.wso2.carbon.security.mgt.server.feature/pom.xml
#	features/security-mgt/org.wso2.carbon.security.mgt.ui.feature/pom.xml
#	features/security-mgt/pom.xml
#	features/template-mgt/org.wso2.carbon.identity.template.mgt.feature/pom.xml
#	features/template-mgt/org.wso2.carbon.identity.template.mgt.server.feature/pom.xml
#	features/template-mgt/org.wso2.carbon.identity.template.mgt.ui.feature/pom.xml
#	features/template-mgt/pom.xml
#	features/trusted-app-mgt/org.wso2.carbon.identity.trusted.app.mgt.server.feature/pom.xml
#	features/trusted-app-mgt/pom.xml
#	features/user-functionality-mgt/org.wso2.carbon.identity.user.functionality.mgt.feature/pom.xml
#	features/user-functionality-mgt/org.wso2.carbon.identity.user.functionality.mgt.server.feature/pom.xml
#	features/user-functionality-mgt/pom.xml
#	features/user-mgt/org.wso2.carbon.identity.user.profile.feature/pom.xml
#	features/user-mgt/org.wso2.carbon.identity.user.profile.server.feature/pom.xml
#	features/user-mgt/org.wso2.carbon.identity.user.profile.ui.feature/pom.xml
#	features/user-mgt/org.wso2.carbon.identity.user.registration.feature/pom.xml
#	features/user-mgt/org.wso2.carbon.identity.user.registration.server.feature/pom.xml
#	features/user-mgt/org.wso2.carbon.identity.user.registration.ui.feature/pom.xml
#	features/user-mgt/org.wso2.carbon.role.mgt.ui.feature/pom.xml
#	features/user-mgt/org.wso2.carbon.user.mgt.feature/pom.xml
#	features/user-mgt/org.wso2.carbon.user.mgt.server.feature/pom.xml
#	features/user-mgt/org.wso2.carbon.user.mgt.ui.feature/pom.xml
#	features/user-mgt/pom.xml
#	features/user-store/org.wso2.carbon.identity.user.store.configuration.server.feature/pom.xml
#	features/user-store/pom.xml
#	features/xacml/org.wso2.carbon.identity.xacml.feature/pom.xml
#	features/xacml/org.wso2.carbon.identity.xacml.server.feature/pom.xml
#	features/xacml/org.wso2.carbon.identity.xacml.ui.feature/pom.xml
#	features/xacml/pom.xml
#	pom.xml
#	service-stubs/identity/org.wso2.carbon.claim.mgt.stub/pom.xml
#	service-stubs/identity/org.wso2.carbon.directory.server.manager.stub/pom.xml
#	service-stubs/identity/org.wso2.carbon.identity.application.authentication.framework.stub/pom.xml
#	service-stubs/identity/org.wso2.carbon.identity.application.default.authentication.sequence.mgt.stub/pom.xml
#	service-stubs/identity/org.wso2.carbon.identity.application.mgt.stub/pom.xml
#	service-stubs/identity/org.wso2.carbon.identity.claim.metadata.mgt.stub/pom.xml
#	service-stubs/identity/org.wso2.carbon.identity.entitlement.stub/pom.xml
#	service-stubs/identity/org.wso2.carbon.identity.functions.library.mgt.stub/pom.xml
#	service-stubs/identity/org.wso2.carbon.identity.governance.stub/pom.xml
#	service-stubs/identity/org.wso2.carbon.identity.mgt.stub/pom.xml
#	service-stubs/identity/org.wso2.carbon.identity.user.profile.stub/pom.xml
#	service-stubs/identity/org.wso2.carbon.identity.user.registration.stub/pom.xml
#	service-stubs/identity/org.wso2.carbon.identity.user.store.configuration.stub/pom.xml
#	service-stubs/identity/org.wso2.carbon.identity.user.store.count.stub/pom.xml
#	service-stubs/identity/org.wso2.carbon.idp.mgt.stub/pom.xml
#	service-stubs/identity/org.wso2.carbon.security.mgt.stub/pom.xml
#	service-stubs/identity/org.wso2.carbon.user.mgt.stub/pom.xml
#	service-stubs/identity/pom.xml
#	test-utils/org.wso2.carbon.identity.testutil/pom.xml
  • Loading branch information
malithie committed Nov 8, 2024
2 parents a214ba1 + 2aea6ad commit e97f740
Show file tree
Hide file tree
Showing 12 changed files with 488 additions and 62 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -437,29 +437,11 @@ private EndpointConfig getActionEndpointConfigById(String actionUUID, Integer te

Authentication authentication = null;
if (actionEndpointProperties.containsKey(ActionMgtConstants.AUTHN_TYPE_ATTRIBUTE)) {
Authentication.Type authnType = Authentication.Type.valueOf(
actionEndpointProperties.get(ActionMgtConstants.AUTHN_TYPE_ATTRIBUTE));
switch (authnType) {
case BASIC:
authentication = new Authentication.BasicAuthBuilder(
actionEndpointProperties.get(Authentication.Property.USERNAME.getName()),
actionEndpointProperties.get(Authentication.Property.PASSWORD.getName())).build();
break;
case BEARER:
authentication = new Authentication.BearerAuthBuilder(
actionEndpointProperties.get(Authentication.Property.ACCESS_TOKEN.getName())).build();
break;
case API_KEY:
authentication = new Authentication.APIKeyAuthBuilder(
actionEndpointProperties.get(Authentication.Property.HEADER.getName()),
actionEndpointProperties.get(Authentication.Property.VALUE.getName())).build();
break;
case NONE:
authentication = new Authentication.NoneAuthBuilder().build();
break;
default:
break;
}
authentication = new Authentication.AuthenticationBuilder()
.type(Authentication.Type.valueOf(
actionEndpointProperties.get(ActionMgtConstants.AUTHN_TYPE_ATTRIBUTE)))
.properties(actionEndpointProperties)
.build();
} else {
throw ActionManagementUtil.handleServerException(
ActionMgtConstants.ErrorMessages.ERROR_NO_AUTHENTICATION_TYPE, null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package org.wso2.carbon.identity.action.management.model;

import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.wso2.carbon.identity.action.management.ActionSecretProcessor;
import org.wso2.carbon.identity.action.management.constant.ActionMgtConstants;
import org.wso2.carbon.identity.action.management.exception.ActionMgtException;
Expand All @@ -27,6 +28,8 @@

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.NoSuchElementException;

/**
* Authentication class which hold supported authentication types and their properties.
Expand Down Expand Up @@ -233,4 +236,62 @@ public Authentication build() {
return new Authentication(this);
}
}

/**
* This builder build endpoint by taking the authentication type and properties as input.
*/
public static class AuthenticationBuilder {

private Type authType;
private Map<String, String> authPropertiesMap;

public AuthenticationBuilder type(Type type) {

this.authType = type;
return this;
}

public AuthenticationBuilder properties(Map<String, String> authPropertiesMap) {

this.authPropertiesMap = authPropertiesMap;
return this;
}

public Authentication build() {

switch (authType) {
case BASIC:
return new Authentication.BasicAuthBuilder(
getProperty(Type.BASIC, authPropertiesMap, Property.USERNAME.getName()),
getProperty(Type.BASIC, authPropertiesMap, Property.PASSWORD.getName())).build();
case BEARER:
return new Authentication.BearerAuthBuilder(
getProperty(Type.BEARER, authPropertiesMap, Property.ACCESS_TOKEN.getName())).build();
case API_KEY:
return new Authentication.APIKeyAuthBuilder(
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(String.format("An invalid authentication type '%s' is " +
"provided for the authentication configuration of the endpoint.", authType.name()));
}
}

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

if (actionEndpointProperties != null && actionEndpointProperties.containsKey(propertyName)) {
String propValue = actionEndpointProperties.get(propertyName);
if (StringUtils.isNotBlank(propValue)) {
return propValue;
}
throw new IllegalArgumentException(String.format("The Property %s cannot be blank.", 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 @@ -67,6 +67,11 @@ public class FederatedAuthenticatorConfig implements Serializable {
@XmlElement(name = "DefinedBy")
protected DefinedByType definedByType;

public FederatedAuthenticatorConfig() {

definedByType = DefinedByType.SYSTEM;
}

public static FederatedAuthenticatorConfig build(OMElement federatedAuthenticatorConfigOM) {

if (federatedAuthenticatorConfigOM == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ public class LocalAuthenticatorConfig implements Serializable {
@XmlElement(name = "DefinedBy")
protected DefinedByType definedByType;

public LocalAuthenticatorConfig() {

definedByType = DefinedByType.SYSTEM;
}

/*
* <LocalAuthenticatorConfig> <Name></Name> <DisplayName></DisplayName> <IsEnabled></IsEnabled>
* <Properties></Properties> </LocalAuthenticatorConfig>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
/*
* Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com).
*
* WSO2 LLC. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

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;

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

private final EndpointConfig endpointConfig;

private UserDefinedAuthenticatorEndpointConfig(UserDefinedAuthenticatorEndpointConfigBuilder builder) {

endpointConfig = builder.endpointConfig;
}

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.
*/
public static class UserDefinedAuthenticatorEndpointConfigBuilder {

private String uri;
private String authenticationType;
private Map<String, String> authenticationProperties;
private EndpointConfig endpointConfig;

public UserDefinedAuthenticatorEndpointConfigBuilder() {
}

public UserDefinedAuthenticatorEndpointConfigBuilder uri(String uri) {

this.uri = uri;
return this;
}

public UserDefinedAuthenticatorEndpointConfigBuilder authenticationProperties(
Map<String, String> authentication) {

this.authenticationProperties = authentication;
return this;
}

public UserDefinedAuthenticatorEndpointConfigBuilder authenticationType(String authenticationType) {

this.authenticationType = authenticationType;
return this;
}

public UserDefinedAuthenticatorEndpointConfig build() {

EndpointConfig.EndpointConfigBuilder endpointConfigBuilder = new EndpointConfig.EndpointConfigBuilder();
endpointConfigBuilder.uri(uri);
endpointConfigBuilder.authentication(new Authentication.AuthenticationBuilder()
.type(Authentication.Type.valueOf(authenticationType))
.properties(authenticationProperties)
.build());
endpointConfig = endpointConfigBuilder.build();

return new UserDefinedAuthenticatorEndpointConfig(this);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com).
*
* WSO2 LLC. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

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

import org.wso2.carbon.identity.base.AuthenticatorPropertyConstants.DefinedByType;

/**
* The user defined federated authenticator configuration model.
*/
public class UserDefinedFederatedAuthenticatorConfig extends FederatedAuthenticatorConfig {

private static final String TAG_CUSTOM = "CUSTOM";

protected UserDefinedAuthenticatorEndpointConfig endpointConfig;

public UserDefinedFederatedAuthenticatorConfig() {

definedByType = DefinedByType.USER;
setTags(new String[]{TAG_CUSTOM});
}

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

return endpointConfig;
}

/**
* Set the endpoint configurations of the User defined federated authenticator config.
*
* @param endpointConfig The endpoint config of the User defined federated authenticator config.
*/
public void setEndpointConfig(UserDefinedAuthenticatorEndpointConfig endpointConfig) {

this.endpointConfig = endpointConfig;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com).
*
* WSO2 LLC. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

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

import org.wso2.carbon.identity.base.AuthenticatorPropertyConstants.AuthenticationType;
import org.wso2.carbon.identity.base.AuthenticatorPropertyConstants.DefinedByType;

/**
* The user defined local authenticator configuration model.
*/
public class UserDefinedLocalAuthenticatorConfig extends LocalAuthenticatorConfig {

private static final String TAG_2FA = "2FA";
private static final String TAG_CUSTOM = "CUSTOM";

protected UserDefinedAuthenticatorEndpointConfig endpointConfig;

public UserDefinedLocalAuthenticatorConfig(AuthenticationType type) {

definedByType = DefinedByType.USER;
if (AuthenticationType.VERIFICATION == type) {
setTags(new String[]{TAG_CUSTOM, TAG_2FA});
} else {
setTags(new String[]{TAG_CUSTOM});
}
}

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

return endpointConfig;
}

/**
* Set the endpoint configurations of the User defined local authenticator config.
*
* @param endpointConfig The endpoint config of the User defined local authenticator config.
*/
public void setEndpointConfig(UserDefinedAuthenticatorEndpointConfig endpointConfig) {

this.endpointConfig = endpointConfig;
}
}
Loading

0 comments on commit e97f740

Please sign in to comment.