Skip to content

Commit

Permalink
Introduce new property AuthenticationType.
Browse files Browse the repository at this point in the history
  • Loading branch information
Thisara-Welmilla committed Oct 1, 2024
1 parent a8f8170 commit 2a2c971
Show file tree
Hide file tree
Showing 19 changed files with 547 additions and 386 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@

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

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.identity.application.common.model.FederatedAuthenticatorConfig;
import org.wso2.carbon.identity.application.common.model.LocalAuthenticatorConfig;
import org.wso2.carbon.identity.application.common.model.RequestPathAuthenticatorConfig;
Expand All @@ -33,7 +31,6 @@
public class ApplicationAuthenticatorService {

private static volatile ApplicationAuthenticatorService instance;
private static final Log LOG = LogFactory.getLog(ApplicationAuthenticatorService.class);

private List<LocalAuthenticatorConfig> localAuthenticators = new ArrayList<>();
private List<FederatedAuthenticatorConfig> federatedAuthenticators = new ArrayList<>();
Expand Down Expand Up @@ -91,9 +88,6 @@ public RequestPathAuthenticatorConfig getRequestPathAuthenticatorByName(String n

public void addLocalAuthenticator(LocalAuthenticatorConfig authenticator) {
if (authenticator != null) {
if (authenticator.getDefinedByType() == null) {
LOG.debug("The defined by type is not set for the : " + authenticator.getName());
}
localAuthenticators.add(authenticator);
}
}
Expand All @@ -106,9 +100,6 @@ public void removeLocalAuthenticator(LocalAuthenticatorConfig authenticator) {

public void addFederatedAuthenticator(FederatedAuthenticatorConfig authenticator) {
if (authenticator != null) {
if (authenticator.getDefinedByType() == null) {
LOG.debug("The defined by type is not set for the : " + authenticator.getName());
}
federatedAuthenticators.add(authenticator);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ public class FederatedAuthenticatorConfig implements Serializable {
@XmlElement(name = "DefinedBy")
protected IdentityConstants.DefinedByType definedByType;

@XmlElement(name = "AuthenticationType")
protected IdentityConstants.AuthenticationType authenticationType;

public static FederatedAuthenticatorConfig build(OMElement federatedAuthenticatorConfigOM) {

if (federatedAuthenticatorConfigOM == null) {
Expand Down Expand Up @@ -114,11 +117,11 @@ public static FederatedAuthenticatorConfig build(OMElement federatedAuthenticato
}
}

// TODO: Remove warn log, once feature is ready.
if (federatedAuthenticatorConfig.getDefinedByType() == null) {
federatedAuthenticatorConfig.setDefinedByType(IdentityConstants.DefinedByType.SYSTEM);
LOG.debug("The defined by type is not set for the : " + federatedAuthenticatorConfig.getName());

Check warning on line 122 in components/application-mgt/org.wso2.carbon.identity.application.common/src/main/java/org/wso2/carbon/identity/application/common/model/FederatedAuthenticatorConfig.java

View check run for this annotation

Codecov / codecov/patch

components/application-mgt/org.wso2.carbon.identity.application.common/src/main/java/org/wso2/carbon/identity/application/common/model/FederatedAuthenticatorConfig.java#L121-L122

Added lines #L121 - L122 were not covered by tests
}
federatedAuthenticatorConfig.setAuthenticationType(IdentityConstants.AuthenticationType.EXTERNAL_ACCOUNT);

Check warning on line 124 in components/application-mgt/org.wso2.carbon.identity.application.common/src/main/java/org/wso2/carbon/identity/application/common/model/FederatedAuthenticatorConfig.java

View check run for this annotation

Codecov / codecov/patch

components/application-mgt/org.wso2.carbon.identity.application.common/src/main/java/org/wso2/carbon/identity/application/common/model/FederatedAuthenticatorConfig.java#L124

Added line #L124 was not covered by tests

return federatedAuthenticatorConfig;
}
Expand Down Expand Up @@ -248,22 +251,42 @@ public void setTags(String[] tagList) {
}

/**
* Get the tag list of the Local authenticator.
* Get the defined by type of the federated authenticator config.
*
* @return String[]
* @return IdentityConstants.DefinedByType
*/
public IdentityConstants.DefinedByType getDefinedByType() {

return definedByType;

Check warning on line 260 in components/application-mgt/org.wso2.carbon.identity.application.common/src/main/java/org/wso2/carbon/identity/application/common/model/FederatedAuthenticatorConfig.java

View check run for this annotation

Codecov / codecov/patch

components/application-mgt/org.wso2.carbon.identity.application.common/src/main/java/org/wso2/carbon/identity/application/common/model/FederatedAuthenticatorConfig.java#L260

Added line #L260 was not covered by tests
}

/**
* Set the tag list for Local authenticator config.
* Set the defined by type of the federated authenticator config.
*
* @param type authenticator.
* @param type The defined by type of the authenticator config.
*/
public void setDefinedByType(IdentityConstants.DefinedByType type) {

definedByType = type;
}

Check warning on line 271 in components/application-mgt/org.wso2.carbon.identity.application.common/src/main/java/org/wso2/carbon/identity/application/common/model/FederatedAuthenticatorConfig.java

View check run for this annotation

Codecov / codecov/patch

components/application-mgt/org.wso2.carbon.identity.application.common/src/main/java/org/wso2/carbon/identity/application/common/model/FederatedAuthenticatorConfig.java#L270-L271

Added lines #L270 - L271 were not covered by tests

/**
* Get the authentication type of the federated authenticator config.
*
* @return IdentityConstants.AuthenticationType
*/
public IdentityConstants.AuthenticationType getAuthenticationType() {

return authenticationType;

Check warning on line 280 in components/application-mgt/org.wso2.carbon.identity.application.common/src/main/java/org/wso2/carbon/identity/application/common/model/FederatedAuthenticatorConfig.java

View check run for this annotation

Codecov / codecov/patch

components/application-mgt/org.wso2.carbon.identity.application.common/src/main/java/org/wso2/carbon/identity/application/common/model/FederatedAuthenticatorConfig.java#L280

Added line #L280 was not covered by tests
}

/**
* Set the authentication type of the federated authenticator config.
*
* @param type The authentication type.
*/
public void setAuthenticationType(IdentityConstants.AuthenticationType type) {

authenticationType = type;
}

Check warning on line 291 in components/application-mgt/org.wso2.carbon.identity.application.common/src/main/java/org/wso2/carbon/identity/application/common/model/FederatedAuthenticatorConfig.java

View check run for this annotation

Codecov / codecov/patch

components/application-mgt/org.wso2.carbon.identity.application.common/src/main/java/org/wso2/carbon/identity/application/common/model/FederatedAuthenticatorConfig.java#L290-L291

Added lines #L290 - L291 were not covered by tests
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@
public class IdentityProvider implements Serializable {

private static final long serialVersionUID = 2199048941051702943L;
private static final Log LOG = LogFactory.getLog(IdentityProvider.class);

private static final Log log = LogFactory.getLog(IdentityProvider.class);
private static final String FILE_ELEMENT_IDENTITY_PROVIDER_NAME = "IdentityProviderName";
Expand Down Expand Up @@ -420,13 +419,6 @@ public void setFederatedAuthenticatorConfigs(
if (federatedAuthenticatorConfigs == null) {
return;
}

// TODO: Remove warn log, once feature is ready.
for (FederatedAuthenticatorConfig config: federatedAuthenticatorConfigs) {
if (config.getDefinedByType() == null) {
LOG.debug("The defined by type is not set for the : " + config.getName());
}
}
Set<FederatedAuthenticatorConfig> propertySet =
new HashSet<FederatedAuthenticatorConfig>(Arrays.asList(federatedAuthenticatorConfigs));
this.federatedAuthenticatorConfigs = propertySet.toArray(new FederatedAuthenticatorConfig[propertySet.size()]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;

import static org.wso2.carbon.identity.base.IdentityConstants.TAG_2FA;

/**
* Local authenticator configuration of an application.
*/
Expand Down Expand Up @@ -69,6 +71,9 @@ public class LocalAuthenticatorConfig implements Serializable {
@XmlElement(name = "DefinedBy")
protected IdentityConstants.DefinedByType definedByType;

@XmlElement(name = "AuthenticationType")
protected IdentityConstants.AuthenticationType authenticationType;

/*
* <LocalAuthenticatorConfig> <Name></Name> <DisplayName></DisplayName> <IsEnabled></IsEnabled>
* <Properties></Properties> </LocalAuthenticatorConfig>
Expand Down Expand Up @@ -119,12 +124,27 @@ public static LocalAuthenticatorConfig build(OMElement localAuthenticatorConfigO
}
} else if ("DefinedBy".equals(member.getLocalName())) {
localAuthenticatorConfig.setDefinedByType(IdentityConstants.DefinedByType.valueOf(member.getText()));

Check warning on line 126 in components/application-mgt/org.wso2.carbon.identity.application.common/src/main/java/org/wso2/carbon/identity/application/common/model/LocalAuthenticatorConfig.java

View check run for this annotation

Codecov / codecov/patch

components/application-mgt/org.wso2.carbon.identity.application.common/src/main/java/org/wso2/carbon/identity/application/common/model/LocalAuthenticatorConfig.java#L126

Added line #L126 was not covered by tests
} else if ("AuthenticationType".equals(member.getLocalName())) {
localAuthenticatorConfig.setAuthenticationType(
IdentityConstants.AuthenticationType.valueOf(member.getText()));

Check warning on line 129 in components/application-mgt/org.wso2.carbon.identity.application.common/src/main/java/org/wso2/carbon/identity/application/common/model/LocalAuthenticatorConfig.java

View check run for this annotation

Codecov / codecov/patch

components/application-mgt/org.wso2.carbon.identity.application.common/src/main/java/org/wso2/carbon/identity/application/common/model/LocalAuthenticatorConfig.java#L128-L129

Added lines #L128 - L129 were not covered by tests
}
}

Check warning on line 131 in components/application-mgt/org.wso2.carbon.identity.application.common/src/main/java/org/wso2/carbon/identity/application/common/model/LocalAuthenticatorConfig.java

View check run for this annotation

Codecov / codecov/patch

components/application-mgt/org.wso2.carbon.identity.application.common/src/main/java/org/wso2/carbon/identity/application/common/model/LocalAuthenticatorConfig.java#L131

Added line #L131 was not covered by tests

if (localAuthenticatorConfig.getDefinedByType() == null) {
localAuthenticatorConfig.setDefinedByType(IdentityConstants.DefinedByType.SYSTEM);
LOG.debug("The defined by type is not set for the : " + localAuthenticatorConfig.getName());
LOG.debug("The defined by type is not set for the {}. Hence setting default SYSTEM value.",
localAuthenticatorConfig.getName());

Check warning on line 136 in components/application-mgt/org.wso2.carbon.identity.application.common/src/main/java/org/wso2/carbon/identity/application/common/model/LocalAuthenticatorConfig.java

View check run for this annotation

Codecov / codecov/patch

components/application-mgt/org.wso2.carbon.identity.application.common/src/main/java/org/wso2/carbon/identity/application/common/model/LocalAuthenticatorConfig.java#L134-L136

Added lines #L134 - L136 were not covered by tests
}
if (localAuthenticatorConfig.getAuthenticationType() == null && localAuthenticatorConfig.getTags() != null) {
if (localAuthenticatorConfig.getTags() != null &&
Arrays.stream(localAuthenticatorConfig.getTags()).anyMatch(s -> s.equalsIgnoreCase(TAG_2FA))) {
localAuthenticatorConfig.setAuthenticationType(

Check warning on line 141 in components/application-mgt/org.wso2.carbon.identity.application.common/src/main/java/org/wso2/carbon/identity/application/common/model/LocalAuthenticatorConfig.java

View check run for this annotation

Codecov / codecov/patch

components/application-mgt/org.wso2.carbon.identity.application.common/src/main/java/org/wso2/carbon/identity/application/common/model/LocalAuthenticatorConfig.java#L141

Added line #L141 was not covered by tests
IdentityConstants.AuthenticationType.FACTOR_VERIFICATION);
} else {
localAuthenticatorConfig.setAuthenticationType(IdentityConstants.AuthenticationType.INTERNAL_ACCOUNT);

Check warning on line 144 in components/application-mgt/org.wso2.carbon.identity.application.common/src/main/java/org/wso2/carbon/identity/application/common/model/LocalAuthenticatorConfig.java

View check run for this annotation

Codecov / codecov/patch

components/application-mgt/org.wso2.carbon.identity.application.common/src/main/java/org/wso2/carbon/identity/application/common/model/LocalAuthenticatorConfig.java#L144

Added line #L144 was not covered by tests
}
LOG.debug("The defined by type is not set for the: {}. Hence setting value based on the factor for the: {}",
localAuthenticatorConfig.getName(), localAuthenticatorConfig.getAuthenticationType().toString());

Check warning on line 147 in components/application-mgt/org.wso2.carbon.identity.application.common/src/main/java/org/wso2/carbon/identity/application/common/model/LocalAuthenticatorConfig.java

View check run for this annotation

Codecov / codecov/patch

components/application-mgt/org.wso2.carbon.identity.application.common/src/main/java/org/wso2/carbon/identity/application/common/model/LocalAuthenticatorConfig.java#L146-L147

Added lines #L146 - L147 were not covered by tests
}

return localAuthenticatorConfig;
Expand Down Expand Up @@ -240,22 +260,42 @@ public void setTags(String[] tagList) {
}

/**
* Get the tag list of the Local authenticator.
* Get the defined by type of the Local authenticator config.
*
* @return String[]
* @return IdentityConstants.DefinedByType
*/
public IdentityConstants.DefinedByType getDefinedByType() {

return definedByType;

Check warning on line 269 in components/application-mgt/org.wso2.carbon.identity.application.common/src/main/java/org/wso2/carbon/identity/application/common/model/LocalAuthenticatorConfig.java

View check run for this annotation

Codecov / codecov/patch

components/application-mgt/org.wso2.carbon.identity.application.common/src/main/java/org/wso2/carbon/identity/application/common/model/LocalAuthenticatorConfig.java#L269

Added line #L269 was not covered by tests
}

/**
* Set the tag list for Local authenticator config.
* Set the defined by type of the Local authenticator config.
*
* @param type authenticator.
* @param type The defined by type of the authenticator config.
*/
public void setDefinedByType(IdentityConstants.DefinedByType type) {

definedByType = type;
}

Check warning on line 280 in components/application-mgt/org.wso2.carbon.identity.application.common/src/main/java/org/wso2/carbon/identity/application/common/model/LocalAuthenticatorConfig.java

View check run for this annotation

Codecov / codecov/patch

components/application-mgt/org.wso2.carbon.identity.application.common/src/main/java/org/wso2/carbon/identity/application/common/model/LocalAuthenticatorConfig.java#L279-L280

Added lines #L279 - L280 were not covered by tests

/**
* Get the authentication type of the Local authenticator config .
*
* @return IdentityConstants.AuthenticationType
*/
public IdentityConstants.AuthenticationType getAuthenticationType() {

return authenticationType;

Check warning on line 289 in components/application-mgt/org.wso2.carbon.identity.application.common/src/main/java/org/wso2/carbon/identity/application/common/model/LocalAuthenticatorConfig.java

View check run for this annotation

Codecov / codecov/patch

components/application-mgt/org.wso2.carbon.identity.application.common/src/main/java/org/wso2/carbon/identity/application/common/model/LocalAuthenticatorConfig.java#L289

Added line #L289 was not covered by tests
}

/**
* Set the authentication type of the Local authenticator config.
*
* @param type The authentication type.
*/
public void setAuthenticationType(IdentityConstants.AuthenticationType type) {

authenticationType = type;
}

Check warning on line 300 in components/application-mgt/org.wso2.carbon.identity.application.common/src/main/java/org/wso2/carbon/identity/application/common/model/LocalAuthenticatorConfig.java

View check run for this annotation

Codecov / codecov/patch

components/application-mgt/org.wso2.carbon.identity.application.common/src/main/java/org/wso2/carbon/identity/application/common/model/LocalAuthenticatorConfig.java#L299-L300

Added lines #L299 - L300 were not covered by tests
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ private ApplicationConstants() {
public static final String IDP_AUTHENTICATOR_NAME = "authenticatorName";
public static final String IDP_AUTHENTICATOR_DISPLAY_NAME = "authenticatorDisplayName";
public static final String IDP_AUTHENTICATOR_DEFINED_BY_TYPE = "definedByType";
public static final String IDP_AUTHENTICATOR_AUTHENTICATION_TYPE = "authenticationType";
public static final String APPLICATION_DOMAIN = "Application";
// Regex for validating application name.
public static final String APP_NAME_VALIDATING_REGEX = "^[a-zA-Z0-9 ._-]*$";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3100,6 +3100,8 @@ private LocalAndOutboundAuthenticationConfig getLocalAndOutboundAuthenticationCo
.get(ApplicationConstants.IDP_AUTHENTICATOR_DISPLAY_NAME));
localAuthenticator.setDefinedByType(IdentityConstants.DefinedByType.valueOf(
authenticatorInfo.get(ApplicationConstants.IDP_AUTHENTICATOR_DEFINED_BY_TYPE)));
localAuthenticator.setAuthenticationType(IdentityConstants.AuthenticationType.valueOf(
authenticatorInfo.get(ApplicationConstants.IDP_AUTHENTICATOR_AUTHENTICATION_TYPE)));

Check warning on line 3104 in components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java

View check run for this annotation

Codecov / codecov/patch

components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/dao/impl/ApplicationDAOImpl.java#L3101-L3104

Added lines #L3101 - L3104 were not covered by tests
stepLocalAuth.get(step).add(localAuthenticator);
} else {
Map<String, List<FederatedAuthenticatorConfig>> stepFedIdps = stepFedIdPAuthenticators
Expand All @@ -3120,6 +3122,7 @@ private LocalAndOutboundAuthenticationConfig getLocalAndOutboundAuthenticationCo
.get(ApplicationConstants.IDP_AUTHENTICATOR_DISPLAY_NAME));
fedAuthenticator.setDefinedByType(IdentityConstants.DefinedByType.valueOf(
authenticatorInfo.get(ApplicationConstants.IDP_AUTHENTICATOR_DEFINED_BY_TYPE)));
fedAuthenticator.setAuthenticationType(IdentityConstants.AuthenticationType.EXTERNAL_ACCOUNT);
idpAuths.add(fedAuthenticator);
}

Expand Down Expand Up @@ -5031,7 +5034,7 @@ private Map<String, String> getAuthenticatorInfo(Connection conn, int tenantId,
returnData
.put(ApplicationConstants.IDP_AUTHENTICATOR_DISPLAY_NAME, rs.getString(3));
}
// TODO: Read from database and set the DefinedBy property to the authenticator.
// TODO: Read from database and set the DefinedBy and authenticationType properties to the authenticator.
returnData.put(ApplicationConstants.IDP_AUTHENTICATOR_DEFINED_BY_TYPE,
IdentityConstants.DefinedByType.SYSTEM.toString());
} finally {
Expand Down Expand Up @@ -5068,6 +5071,7 @@ private int addAuthenticator(Connection conn, int tenantId, String idpName,
prepStmt.setString(5, "1");
prepStmt.setString(6, authenticatorDispalyName);
//TODO: prepStmt.setString(7, IdentityConstants.DefinedByType.SYSTEM.toString());
//TODO: prepStmt.setString(8, IdentityConstants.AuthenticationType.<TYPE>.toString());
prepStmt.execute();
rs = prepStmt.getGeneratedKeys();
if (rs.next()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@
import java.util.List;
import java.util.Map;


import static java.lang.Boolean.FALSE;
import static java.lang.Boolean.TRUE;
import static org.mockito.ArgumentMatchers.any;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,4 +181,14 @@ default IdentityConstants.DefinedByType getDefinedByType() {

return IdentityConstants.DefinedByType.SYSTEM;

Check warning on line 182 in components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/main/java/org/wso2/carbon/identity/application/authentication/framework/ApplicationAuthenticator.java

View check run for this annotation

Codecov / codecov/patch

components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/main/java/org/wso2/carbon/identity/application/authentication/framework/ApplicationAuthenticator.java#L182

Added line #L182 was not covered by tests
}

/**
* Get the authenticator type. Default value will be SYSTEM.
*
* @return Authenticator Type.
*/
default IdentityConstants.AuthenticationType getAuthenticationType() {

return null;

Check warning on line 192 in components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/main/java/org/wso2/carbon/identity/application/authentication/framework/ApplicationAuthenticator.java

View check run for this annotation

Codecov / codecov/patch

components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/main/java/org/wso2/carbon/identity/application/authentication/framework/ApplicationAuthenticator.java#L192

Added line #L192 was not covered by tests
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,17 @@

package org.wso2.carbon.identity.application.authentication.framework;

import org.wso2.carbon.identity.base.IdentityConstants;

/**
* Federated application authenticator.
*/
public interface FederatedApplicationAuthenticator extends ApplicationAuthenticator {

@Override
default IdentityConstants.AuthenticationType getAuthenticationType() {

return IdentityConstants.AuthenticationType.EXTERNAL_ACCOUNT;

Check warning on line 31 in components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/main/java/org/wso2/carbon/identity/application/authentication/framework/FederatedApplicationAuthenticator.java

View check run for this annotation

Codecov / codecov/patch

components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/main/java/org/wso2/carbon/identity/application/authentication/framework/FederatedApplicationAuthenticator.java#L31

Added line #L31 was not covered by tests
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,24 @@

package org.wso2.carbon.identity.application.authentication.framework;

import org.wso2.carbon.identity.base.IdentityConstants;

import java.util.Arrays;

import static org.wso2.carbon.identity.base.IdentityConstants.TAG_2FA;

/**
* Local authenticator for applications.
*/
public interface LocalApplicationAuthenticator extends ApplicationAuthenticator {

@Override
default IdentityConstants.AuthenticationType getAuthenticationType() {

if (getTags() != null && Arrays.stream(getTags()).anyMatch(s -> s.equalsIgnoreCase(TAG_2FA))) {
return IdentityConstants.AuthenticationType.FACTOR_VERIFICATION;

Check warning on line 36 in components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/main/java/org/wso2/carbon/identity/application/authentication/framework/LocalApplicationAuthenticator.java

View check run for this annotation

Codecov / codecov/patch

components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/main/java/org/wso2/carbon/identity/application/authentication/framework/LocalApplicationAuthenticator.java#L36

Added line #L36 was not covered by tests
}

return IdentityConstants.AuthenticationType.INTERNAL_ACCOUNT;

Check warning on line 39 in components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/main/java/org/wso2/carbon/identity/application/authentication/framework/LocalApplicationAuthenticator.java

View check run for this annotation

Codecov / codecov/patch

components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/main/java/org/wso2/carbon/identity/application/authentication/framework/LocalApplicationAuthenticator.java#L39

Added line #L39 was not covered by tests
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,16 @@
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;

import javax.servlet.Servlet;

import static org.wso2.carbon.identity.application.authentication.framework.util.FrameworkUtils.promptOnLongWait;
import static org.wso2.carbon.identity.base.IdentityConstants.AuthenticationType;
import static org.wso2.carbon.identity.base.IdentityConstants.TAG_2FA;
import static org.wso2.carbon.identity.base.IdentityConstants.TRUE;

/**
Expand Down Expand Up @@ -508,6 +511,12 @@ protected void setAuthenticator(ApplicationAuthenticator authenticator) {
localAuthenticatorConfig.setDisplayName(authenticator.getFriendlyName());
localAuthenticatorConfig.setTags(getTags(authenticator));
localAuthenticatorConfig.setDefinedByType(IdentityConstants.DefinedByType.SYSTEM);

Check warning on line 513 in components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/main/java/org/wso2/carbon/identity/application/authentication/framework/internal/FrameworkServiceComponent.java

View check run for this annotation

Codecov / codecov/patch

components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/main/java/org/wso2/carbon/identity/application/authentication/framework/internal/FrameworkServiceComponent.java#L513

Added line #L513 was not covered by tests
if (localAuthenticatorConfig.getTags() != null &&
Arrays.stream(localAuthenticatorConfig.getTags()).anyMatch(s -> s.equalsIgnoreCase(TAG_2FA))) {
localAuthenticatorConfig.setAuthenticationType(AuthenticationType.FACTOR_VERIFICATION);

Check warning on line 516 in components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/main/java/org/wso2/carbon/identity/application/authentication/framework/internal/FrameworkServiceComponent.java

View check run for this annotation

Codecov / codecov/patch

components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/main/java/org/wso2/carbon/identity/application/authentication/framework/internal/FrameworkServiceComponent.java#L516

Added line #L516 was not covered by tests
} else {
localAuthenticatorConfig.setAuthenticationType(AuthenticationType.INTERNAL_ACCOUNT);

Check warning on line 518 in components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/main/java/org/wso2/carbon/identity/application/authentication/framework/internal/FrameworkServiceComponent.java

View check run for this annotation

Codecov / codecov/patch

components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/main/java/org/wso2/carbon/identity/application/authentication/framework/internal/FrameworkServiceComponent.java#L518

Added line #L518 was not covered by tests
}
AuthenticatorConfig fileBasedConfig = getAuthenticatorConfig(authenticator.getName());
localAuthenticatorConfig.setEnabled(fileBasedConfig.isEnabled());
ApplicationAuthenticatorService.getInstance().addLocalAuthenticator(localAuthenticatorConfig);
Expand All @@ -518,6 +527,7 @@ protected void setAuthenticator(ApplicationAuthenticator authenticator) {
federatedAuthenticatorConfig.setDisplayName(authenticator.getFriendlyName());
federatedAuthenticatorConfig.setTags(getTags(authenticator));
federatedAuthenticatorConfig.setDefinedByType(IdentityConstants.DefinedByType.SYSTEM);
federatedAuthenticatorConfig.setAuthenticationType(IdentityConstants.AuthenticationType.EXTERNAL_ACCOUNT);

Check warning on line 530 in components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/main/java/org/wso2/carbon/identity/application/authentication/framework/internal/FrameworkServiceComponent.java

View check run for this annotation

Codecov / codecov/patch

components/authentication-framework/org.wso2.carbon.identity.application.authentication.framework/src/main/java/org/wso2/carbon/identity/application/authentication/framework/internal/FrameworkServiceComponent.java#L529-L530

Added lines #L529 - L530 were not covered by tests
ApplicationAuthenticatorService.getInstance().addFederatedAuthenticator(federatedAuthenticatorConfig);
} else if (authenticator instanceof RequestPathApplicationAuthenticator) {
RequestPathAuthenticatorConfig reqPathAuthenticatorConfig = new RequestPathAuthenticatorConfig();
Expand Down
Loading

0 comments on commit 2a2c971

Please sign in to comment.