diff --git a/components/application-mgt/org.wso2.carbon.identity.application.common/src/main/java/org/wso2/carbon/identity/application/common/ApplicationAuthenticatorService.java b/components/application-mgt/org.wso2.carbon.identity.application.common/src/main/java/org/wso2/carbon/identity/application/common/ApplicationAuthenticatorService.java index 68574cc78645..3bc2cfe778c2 100644 --- a/components/application-mgt/org.wso2.carbon.identity.application.common/src/main/java/org/wso2/carbon/identity/application/common/ApplicationAuthenticatorService.java +++ b/components/application-mgt/org.wso2.carbon.identity.application.common/src/main/java/org/wso2/carbon/identity/application/common/ApplicationAuthenticatorService.java @@ -213,7 +213,6 @@ public UserDefinedLocalAuthenticatorConfig addUserDefinedLocalAuthenticator( } authenticatorValidator.validateAuthenticatorName(authenticatorConfig.getName()); authenticatorValidator.validateForBlank(DISPLAY_NAME, authenticatorConfig.getDisplayName()); - authenticatorValidator.validateDefinedByType(authenticatorConfig.getDefinedByType()); return dao.addUserDefinedLocalAuthenticator( authenticatorConfig, IdentityTenantUtil.getTenantId(tenantDomain)); @@ -233,7 +232,6 @@ public UserDefinedLocalAuthenticatorConfig updateUserDefinedLocalAuthenticator( UserDefinedLocalAuthenticatorConfig existingConfig = resolveExistingAuthenticator( authenticatorConfig.getName(), tenantDomain); - authenticatorValidator.validateDefinedByType(existingConfig.getDefinedByType()); authenticatorValidator.validateForBlank(DISPLAY_NAME, authenticatorConfig.getDisplayName()); return dao.updateUserDefinedLocalAuthenticator( @@ -252,7 +250,6 @@ public void deleteUserDefinedLocalAuthenticator(String authenticatorName, String UserDefinedLocalAuthenticatorConfig existingConfig = resolveExistingAuthenticator( authenticatorName, tenantDomain); - authenticatorValidator.validateDefinedByType(existingConfig.getDefinedByType()); dao.deleteUserDefinedLocalAuthenticator(authenticatorName, existingConfig, IdentityTenantUtil.getTenantId(tenantDomain)); diff --git a/components/application-mgt/org.wso2.carbon.identity.application.common/src/main/java/org/wso2/carbon/identity/application/common/dao/impl/AuthenticatorManagementDAOImpl.java b/components/application-mgt/org.wso2.carbon.identity.application.common/src/main/java/org/wso2/carbon/identity/application/common/dao/impl/AuthenticatorManagementDAOImpl.java index 97c6704cc61a..3d459eaec35e 100644 --- a/components/application-mgt/org.wso2.carbon.identity.application.common/src/main/java/org/wso2/carbon/identity/application/common/dao/impl/AuthenticatorManagementDAOImpl.java +++ b/components/application-mgt/org.wso2.carbon.identity.application.common/src/main/java/org/wso2/carbon/identity/application/common/dao/impl/AuthenticatorManagementDAOImpl.java @@ -23,7 +23,6 @@ import org.wso2.carbon.database.utils.jdbc.NamedJdbcTemplate; import org.wso2.carbon.database.utils.jdbc.NamedPreparedStatement; import org.wso2.carbon.database.utils.jdbc.exceptions.DataAccessException; -import org.wso2.carbon.database.utils.jdbc.exceptions.TransactionException; import org.wso2.carbon.identity.application.common.constant.AuthenticatorMgtSQLConstants.Column; import org.wso2.carbon.identity.application.common.constant.AuthenticatorMgtSQLConstants.Query; import org.wso2.carbon.identity.application.common.dao.AuthenticatorManagementDAO; @@ -192,16 +191,14 @@ public void deleteUserDefinedLocalAuthenticator(String authenticatorConfigName, NamedJdbcTemplate jdbcTemplate = new NamedJdbcTemplate(IdentityDatabaseUtil.getDataSource()); try { - jdbcTemplate.withTransaction(template -> { - return template.executeQuery(Query.DELETE_AUTHENTICATOR_SQL, - (resultSet, rowNumber) -> null, - statement -> { - statement.setString(Column.NAME, authenticatorConfigName); - statement.setInt(Column.TENANT_ID, tenantId); - statement.executeUpdate(); - }); - }); - } catch (TransactionException e) { + + jdbcTemplate.executeUpdate(Query.DELETE_AUTHENTICATOR_SQL, + statement -> { + statement.setString(Column.NAME, authenticatorConfigName); + statement.setInt(Column.TENANT_ID, tenantId); + statement.executeUpdate(); + }); + } catch (DataAccessException e) { if (LOG.isDebugEnabled()) { LOG.debug(String.format("Error while deleting the authenticator: %s in tenant domain: %s. " + "Rolling back deleted Authenticator information.", authenticatorConfigName, diff --git a/components/application-mgt/org.wso2.carbon.identity.application.common/src/main/java/org/wso2/carbon/identity/application/common/dao/impl/AuthenticatorManagementFacade.java b/components/application-mgt/org.wso2.carbon.identity.application.common/src/main/java/org/wso2/carbon/identity/application/common/dao/impl/AuthenticatorManagementFacade.java index 8f6378eb0a96..f9f885557e1a 100644 --- a/components/application-mgt/org.wso2.carbon.identity.application.common/src/main/java/org/wso2/carbon/identity/application/common/dao/impl/AuthenticatorManagementFacade.java +++ b/components/application-mgt/org.wso2.carbon.identity.application.common/src/main/java/org/wso2/carbon/identity/application/common/dao/impl/AuthenticatorManagementFacade.java @@ -67,7 +67,7 @@ public UserDefinedLocalAuthenticatorConfig addUserDefinedLocalAuthenticator( LOG.debug("Error while creating the user defined local authenticator: " + authenticatorConfig.getName() + " in Tenant Domain: " + IdentityTenantUtil.getTenantDomain(tenantId) + ". Rolling back created authenticator information, and associated action."); - throw handleAuthenticatorMgtException(e); + throw handleAuthenticatorMgtException(e.getCause()); } } @@ -91,7 +91,7 @@ public UserDefinedLocalAuthenticatorConfig updateUserDefinedLocalAuthenticator(U newAuthenticatorConfig.getName() + " in Tenant Domain: " + IdentityTenantUtil.getTenantDomain(tenantId) + ". Rolling back updated authenticator information, and associated action."); - throw handleAuthenticatorMgtException(e); + throw handleAuthenticatorMgtException(e.getCause()); } } @@ -131,7 +131,7 @@ public void deleteUserDefinedLocalAuthenticator(String authenticatorConfigName, LOG.debug("Error while deleting the user defined local authenticator: " + authenticatorConfigName + " in Tenant Domain: " + IdentityTenantUtil.getTenantDomain(tenantId) + ". Rolling back deleted authenticator information, and associated action."); - throw handleAuthenticatorMgtException(e); + throw handleAuthenticatorMgtException(e.getCause()); } } diff --git a/components/application-mgt/org.wso2.carbon.identity.application.common/src/main/java/org/wso2/carbon/identity/application/common/util/UserDefinedLocalAuthenticatorValidator.java b/components/application-mgt/org.wso2.carbon.identity.application.common/src/main/java/org/wso2/carbon/identity/application/common/util/UserDefinedLocalAuthenticatorValidator.java index a457c1d49f91..fdc978e86b72 100644 --- a/components/application-mgt/org.wso2.carbon.identity.application.common/src/main/java/org/wso2/carbon/identity/application/common/util/UserDefinedLocalAuthenticatorValidator.java +++ b/components/application-mgt/org.wso2.carbon.identity.application.common/src/main/java/org/wso2/carbon/identity/application/common/util/UserDefinedLocalAuthenticatorValidator.java @@ -63,18 +63,4 @@ public void validateAuthenticatorName(String name) throws AuthenticatorMgtClient name, AUTHENTICATOR_NAME_REGEX); } } - - /** - * Validate the authenticator is a user defined by authenticator. - * - * @param definedByType The defined by type of the authenticator config. - * @throws AuthenticatorMgtClientException if the authenticator is not a user defined authenticator. - */ - public void validateDefinedByType(DefinedByType definedByType) - throws AuthenticatorMgtClientException { - - if (definedByType != DefinedByType.USER) { - throw buildClientException(AuthenticatorMgtError.ERROR_OP_ON_SYSTEM_AUTHENTICATOR); - } - } }