use of org.wso2.carbon.identity.user.functionality.mgt.exception.UserFunctionalityManagementException in project identity-governance by wso2-extensions.
the class SecurityQuestionPasswordRecoveryManager method getFunctionalityStatusOfUser.
/**
* Get the lock status of a functionality given the tenant domain, user name and the functionality identifier.
*
* @param user User.
* @param functionalityIdentifier Identifier of the the functionality.
* @return The status of the functionality, {@link FunctionalityLockStatus}.
*/
private FunctionalityLockStatus getFunctionalityStatusOfUser(User user, String functionalityIdentifier) throws IdentityRecoveryServerException {
int tenantId = IdentityTenantUtil.getTenantId(user.getTenantDomain());
String userId = Utils.getUserId(user.getUserName(), tenantId);
UserFunctionalityManager userFunctionalityManager = IdentityRecoveryServiceDataHolder.getInstance().getUserFunctionalityManagerService();
try {
return userFunctionalityManager.getLockStatus(userId, tenantId, functionalityIdentifier);
} catch (UserFunctionalityManagementException e) {
String mappedErrorCode = Utils.prependOperationScenarioToErrorCode(IdentityRecoveryConstants.ErrorMessages.ERROR_CODE_FAILED_TO_GET_LOCK_STATUS_FOR_FUNCTIONALITY.getCode(), IdentityRecoveryConstants.PASSWORD_RECOVERY_SCENARIO);
StringBuilder message = new StringBuilder(IdentityRecoveryConstants.ErrorMessages.ERROR_CODE_FAILED_TO_GET_LOCK_STATUS_FOR_FUNCTIONALITY.getMessage());
if (isDetailedErrorMessagesEnabled) {
message.append(String.format("functionalityIdentifier: %s for %s.", IdentityRecoveryConstants.FunctionalityTypes.FUNCTIONALITY_SECURITY_QUESTION_PW_RECOVERY.getFunctionalityIdentifier(), user.getUserName()));
}
String errorMessage = "Error occurred while getting functionality status of user.";
if (e instanceof UserFunctionalityManagementClientException) {
if (log.isDebugEnabled()) {
log.debug(errorMessage, e);
}
} else {
log.error(errorMessage, e);
}
throw Utils.handleServerException(mappedErrorCode, message.toString(), null);
}
}
use of org.wso2.carbon.identity.user.functionality.mgt.exception.UserFunctionalityManagementException in project identity-governance by wso2-extensions.
the class UserAccountRecoveryManager method getFunctionalityStatusOfUser.
/**
* Get the lock status of a functionality given the tenant domain, user name and the functionality identifier.
*
* @param tenantDomain Tenant domain of the user.
* @param userName Username of the user.
* @param functionalityIdentifier Identifier of the the functionality.
* @return The status of the functionality, {@link FunctionalityLockStatus}.
*/
private FunctionalityLockStatus getFunctionalityStatusOfUser(String userName, String tenantDomain, String functionalityIdentifier) throws IdentityRecoveryServerException {
int tenantId = IdentityTenantUtil.getTenantId(tenantDomain);
String userId = Utils.getUserId(userName, tenantId);
UserFunctionalityManager userFunctionalityManager = IdentityRecoveryServiceDataHolder.getInstance().getUserFunctionalityManagerService();
try {
return userFunctionalityManager.getLockStatus(userId, tenantId, functionalityIdentifier);
} catch (UserFunctionalityManagementException e) {
String mappedErrorCode = Utils.prependOperationScenarioToErrorCode(IdentityRecoveryConstants.ErrorMessages.ERROR_CODE_FAILED_TO_GET_LOCK_STATUS_FOR_FUNCTIONALITY.getCode(), IdentityRecoveryConstants.PASSWORD_RECOVERY_SCENARIO);
String message = IdentityRecoveryConstants.ErrorMessages.ERROR_CODE_FAILED_TO_GET_LOCK_STATUS_FOR_FUNCTIONALITY.getMessage();
throw Utils.handleServerException(mappedErrorCode, message, null);
}
}
use of org.wso2.carbon.identity.user.functionality.mgt.exception.UserFunctionalityManagementException in project identity-governance by wso2-extensions.
the class PasswordRecoveryManagerImpl method getFunctionalityStatusOfUser.
/**
* Get the lock status of a functionality given the tenant domain, user name and the functionality type.
*
* @param tenantDomain Tenant domain of the user.
* @param userName Username of the user.
* @param functionalityIdentifier Identifier of the the functionality.
* @return The status of the functionality, {@link FunctionalityLockStatus}.
*/
private FunctionalityLockStatus getFunctionalityStatusOfUser(String tenantDomain, String userName, String functionalityIdentifier) throws IdentityRecoveryServerException {
int tenantId = IdentityTenantUtil.getTenantId(tenantDomain);
String userId = Utils.getUserId(userName, tenantId);
UserFunctionalityManager userFunctionalityManager = IdentityRecoveryServiceDataHolder.getInstance().getUserFunctionalityManagerService();
try {
return userFunctionalityManager.getLockStatus(userId, tenantId, functionalityIdentifier);
} catch (UserFunctionalityManagementException e) {
String mappedErrorCode = Utils.prependOperationScenarioToErrorCode(IdentityRecoveryConstants.ErrorMessages.ERROR_CODE_FAILED_TO_GET_LOCK_STATUS_FOR_FUNCTIONALITY.getCode(), IdentityRecoveryConstants.PASSWORD_RECOVERY_SCENARIO);
StringBuilder message = new StringBuilder(IdentityRecoveryConstants.ErrorMessages.ERROR_CODE_FAILED_TO_GET_LOCK_STATUS_FOR_FUNCTIONALITY.getMessage());
if (isDetailedErrorMessagesEnabled) {
message.append(String.format("functionality: %s for %s.", IdentityRecoveryConstants.FunctionalityTypes.FUNCTIONALITY_SECURITY_QUESTION_PW_RECOVERY.getFunctionalityIdentifier(), userName));
}
throw Utils.handleServerException(mappedErrorCode, message.toString(), null);
}
}
use of org.wso2.carbon.identity.user.functionality.mgt.exception.UserFunctionalityManagementException in project identity-governance by wso2-extensions.
the class SecurityQuestionPasswordRecoveryManager method resetRecoveryPasswordProperties.
private void resetRecoveryPasswordProperties(User user, boolean resetFailedLoginLockOutCount) throws IdentityRecoveryException {
Property[] connectorConfigs = getConnectorConfigs(user.getTenantDomain());
for (Property connectorConfig : connectorConfigs) {
if ((PROPERTY_ACCOUNT_LOCK_ON_FAILURE.equals(connectorConfig.getName())) && !Boolean.parseBoolean(connectorConfig.getValue())) {
return;
}
}
int tenantId = IdentityTenantUtil.getTenantId(user.getTenantDomain());
String userId = Utils.getUserId(user.getUserName(), tenantId);
UserFunctionalityManager userFunctionalityManager = IdentityRecoveryServiceDataHolder.getInstance().getUserFunctionalityManagerService();
if (resetFailedLoginLockOutCount) {
try {
userFunctionalityManager.unlock(userId, tenantId, IdentityRecoveryConstants.FunctionalityTypes.FUNCTIONALITY_SECURITY_QUESTION_PW_RECOVERY.getFunctionalityIdentifier());
userFunctionalityManager.deleteAllPropertiesForUser(userId, tenantId, IdentityRecoveryConstants.FunctionalityTypes.FUNCTIONALITY_SECURITY_QUESTION_PW_RECOVERY.getFunctionalityIdentifier());
} catch (UserFunctionalityManagementException e) {
throw Utils.handleFunctionalityLockMgtServerException(IdentityRecoveryConstants.ErrorMessages.ERROR_CODE_FAILED_TO_UNLOCK_FUNCTIONALITY_FOR_USER, userId, tenantId, IdentityRecoveryConstants.FunctionalityTypes.FUNCTIONALITY_SECURITY_QUESTION_PW_RECOVERY.getFunctionalityIdentifier(), isDetailedErrorMessagesEnabled);
}
} else {
try {
Map<String, String> propertiesToUpdate = new HashMap<String, String>();
propertiesToUpdate.put(IdentityRecoveryConstants.FUNCTION_FAILED_ATTEMPTS_PROPERTY, "0");
userFunctionalityManager.setProperties(userId, tenantId, IdentityRecoveryConstants.FunctionalityTypes.FUNCTIONALITY_SECURITY_QUESTION_PW_RECOVERY.getFunctionalityIdentifier(), propertiesToUpdate);
} catch (UserFunctionalityManagementException e) {
throw Utils.handleFunctionalityLockMgtServerException(IdentityRecoveryConstants.ErrorMessages.ERROR_CODE_FAILED_TO_UPDATE_PROPERTIES_FOR_FUNCTIONALITY, userId, tenantId, IdentityRecoveryConstants.FunctionalityTypes.FUNCTIONALITY_SECURITY_QUESTION_PW_RECOVERY.getFunctionalityIdentifier(), isDetailedErrorMessagesEnabled);
}
}
}
Aggregations