use of org.orcid.core.security.DeprecatedProfileException in project ORCID-Source by ORCID.
the class AjaxAuthenticationFailureHandler method onAuthenticationFailure.
public void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response, AuthenticationException exception) throws IOException, ServletException {
response.setContentType("application/json");
PrintWriter writer = response.getWriter();
writer.println("{");
writer.println("\"success\": false");
if (exception.getCause() instanceof UnclaimedProfileExistsException) {
writer.println(",");
writer.println("\"unclaimed\": true");
} else if (exception.getCause() instanceof DeprecatedProfileException) {
writer.println(",");
writer.println("\"deprecated\": true");
DeprecatedProfileException exc = (DeprecatedProfileException) exception.getCause();
if (exc != null && exc.getPrimary() != null) {
writer.println(",");
writer.println("\"primary\":\"" + exc.getPrimary() + "\"");
}
} else if (exception.getCause() instanceof DisabledException) {
writer.println(",");
writer.println("\"disabled\": true");
} else if (exception instanceof VerificationCodeFor2FARequiredException) {
writer.println(",");
writer.println("\"verificationCodeRequired\": true");
} else if (exception instanceof Bad2FAVerificationCodeException) {
writer.println(",");
writer.println("\"badVerificationCode\": true");
writer.println(",");
writer.println("\"verificationCodeRequired\": true");
} else if (exception instanceof Bad2FARecoveryCodeException) {
writer.println(",");
writer.println("\"badRecoveryCode\": true");
}
writer.println("}");
}
Aggregations