Search in sources :

Example 1 with DeprecatedProfileException

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("}");
}
Also used : VerificationCodeFor2FARequiredException(org.orcid.frontend.web.exception.VerificationCodeFor2FARequiredException) Bad2FARecoveryCodeException(org.orcid.frontend.web.exception.Bad2FARecoveryCodeException) DisabledException(org.springframework.security.authentication.DisabledException) DeprecatedProfileException(org.orcid.core.security.DeprecatedProfileException) Bad2FAVerificationCodeException(org.orcid.frontend.web.exception.Bad2FAVerificationCodeException) UnclaimedProfileExistsException(org.orcid.core.security.UnclaimedProfileExistsException) PrintWriter(java.io.PrintWriter)

Aggregations

PrintWriter (java.io.PrintWriter)1 DeprecatedProfileException (org.orcid.core.security.DeprecatedProfileException)1 UnclaimedProfileExistsException (org.orcid.core.security.UnclaimedProfileExistsException)1 Bad2FARecoveryCodeException (org.orcid.frontend.web.exception.Bad2FARecoveryCodeException)1 Bad2FAVerificationCodeException (org.orcid.frontend.web.exception.Bad2FAVerificationCodeException)1 VerificationCodeFor2FARequiredException (org.orcid.frontend.web.exception.VerificationCodeFor2FARequiredException)1 DisabledException (org.springframework.security.authentication.DisabledException)1