Skip to content

Commit

Permalink
Return error code for a password policy violation error
Browse files Browse the repository at this point in the history
  • Loading branch information
KaveeshaPiumini committed Nov 18, 2024
1 parent 03ad2b8 commit 9b57202
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.identity.application.common.model.Property;
import org.wso2.carbon.identity.base.IdentityException;
import org.wso2.carbon.identity.base.IdentityRuntimeException;
import org.wso2.carbon.identity.core.handler.InitConfig;
import org.wso2.carbon.identity.event.IdentityEventConstants;
Expand All @@ -29,6 +30,7 @@
import org.wso2.carbon.identity.event.handler.AbstractEventHandler;
import org.wso2.carbon.identity.governance.IdentityGovernanceException;
import org.wso2.carbon.identity.governance.common.IdentityConnectorConfig;
import org.wso2.carbon.identity.mgt.constants.PasswordPolicyStatusCodes;
import org.wso2.carbon.identity.mgt.policy.PolicyRegistry;
import org.wso2.carbon.identity.mgt.policy.PolicyViolationException;
import org.wso2.carbon.identity.mgt.policy.password.DefaultPasswordLengthPolicy;
Expand Down Expand Up @@ -165,6 +167,10 @@ public void handleEvent(Event event) throws IdentityEventException {
try {
policyRegistry.enforcePasswordPolicies(credentials.toString(), userName);
} catch (PolicyViolationException e) {
if (PasswordPolicyStatusCodes.ERROR_CODE_PASSWORD_POLICY_VIOLATION
.equals(e.getErrorCode())) {
throw IdentityException.error(IdentityEventException.class, e.getErrorCode(), e.getMessage(), e);
}
throw Utils.handleEventException(
PasswordPolicyConstants.ErrorMessages.ERROR_CODE_VALIDATING_PASSWORD_POLICY, e.getMessage(), e);
}
Expand Down

0 comments on commit 9b57202

Please sign in to comment.