Skip to content

Commit

Permalink
Add service layer support to manage the user defined local authentica…
Browse files Browse the repository at this point in the history
…tors
  • Loading branch information
Thisara-Welmilla committed Dec 1, 2024
1 parent 812538e commit d6dd220
Showing 1 changed file with 6 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,7 @@ public UserDefinedLocalAuthenticatorConfig addUserDefinedLocalAuthenticator(
IdentityTenantUtil.getTenantDomain(tenantId)));
}
IdentityDatabaseUtil.rollbackTransaction(dbConnection);

ErrorMessages error = ErrorMessages.ERROR_WHILE_ADDING_AUTHENTICATOR;
throw new AuthenticatorMgtServerException(error.getMessage(), error.getMessage(), error.getCode(), e);
throw buildServerException(AuthenticatorMgtError.ERROR_WHILE_ADDING_AUTHENTICATOR, e);
} finally {
IdentityDatabaseUtil.closeConnection(dbConnection);
}
Expand Down Expand Up @@ -127,8 +125,7 @@ public UserDefinedLocalAuthenticatorConfig updateUserDefinedLocalAuthenticator(
existingAuthenticatorConfig.getName(), IdentityTenantUtil.getTenantDomain(tenantId)));
}
IdentityDatabaseUtil.rollbackTransaction(dbConnection);
ErrorMessages error = ErrorMessages.ERROR_WHILE_UPDATING_AUTHENTICATOR;
throw new AuthenticatorMgtServerException(error.getMessage(), error.getMessage(), error.getCode(), e);
throw buildServerException(AuthenticatorMgtError.ERROR_WHILE_UPDATING_AUTHENTICATOR, e);
} finally {
IdentityDatabaseUtil.closeConnection(dbConnection);
}
Expand Down Expand Up @@ -175,8 +172,7 @@ public List<UserDefinedLocalAuthenticatorConfig> getAllUserDefinedLocalAuthentic
LOG.debug(String.format("Error while retrieving the all user defined local authenticators in tenant " +
"domain: %s.", IdentityTenantUtil.getTenantDomain(tenantId)));
}
ErrorMessages error = ErrorMessages.ERROR_WHILE_DELETING_AUTHENTICATOR;
throw new AuthenticatorMgtServerException(error.getMessage(), error.getMessage(), error.getCode(), e);
throw buildServerException(AuthenticatorMgtError.ERROR_WHILE_DELETING_AUTHENTICATOR, e);
}
}

Expand All @@ -199,8 +195,7 @@ public void deleteUserDefinedLocalAuthenticator(String authenticatorConfigName,
IdentityTenantUtil.getTenantDomain(tenantId)));
}
IdentityDatabaseUtil.rollbackTransaction(dbConnection);
ErrorMessages error = ErrorMessages.ERROR_WHILE_DELETING_AUTHENTICATOR;
throw new AuthenticatorMgtServerException(error.getMessage(), error.getMessage(), error.getCode(), e);
throw buildServerException(AuthenticatorMgtError.ERROR_WHILE_DELETING_AUTHENTICATOR, e);
} finally {
IdentityDatabaseUtil.closeConnection(dbConnection);
}
Expand Down Expand Up @@ -251,8 +246,7 @@ private UserDefinedLocalAuthenticatorConfig getUserDefinedLocalAuthenticatorByNa
IdentityDatabaseUtil.commitTransaction(dbConnection);
return config;
} catch (SQLException e) {
ErrorMessages error = ErrorMessages.ERROR_WHILE_RETRIEVING_AUTHENTICATOR_BY_NAME;
throw new AuthenticatorMgtServerException(error.getMessage(), error.getMessage(), error.getCode(), e);
throw buildServerException(AuthenticatorMgtError.ERROR_WHILE_RETRIEVING_AUTHENTICATOR_BY_NAME, e);
}
}

Expand Down Expand Up @@ -286,7 +280,7 @@ private int getAuthenticatorIdentifier(Connection dbConnection, String authentic
}
IdentityDatabaseUtil.commitTransaction(dbConnection);
}
throw new AuthenticatorMgtServerException(String.format("Authenticator with name: %s not found in the database."
throw buildServerException(String.format("Authenticator with name: %s not found in the database."
, authenticatorConfigName));
}

Expand Down

0 comments on commit d6dd220

Please sign in to comment.