【问题标题】:org.jasypt.exceptions.EncryptionOperationNotPossibleException throwing HTTP Status 500org.jasypt.exceptions.EncryptionOperationNotPossibleException 抛出 HTTP 状态 500
【发布时间】:2021-07-22 04:56:52
【问题描述】:

我正在检查字符串是否未加密,然后显示消息,但其抛出 HTTP Status 500 – Internal Server Error 如下:

org.jasypt.exceptions.EncryptionOperationNotPossibleException
    org.jasypt.encryption.pbe.StandardPBEByteEncryptor.decrypt(StandardPBEByteEncryptor.java:1055)
    org.jasypt.encryption.pbe.StandardPBEStringEncryptor.decrypt(StandardPBEStringEncryptor.java:725)
    parvaz.aero.commons.security.Encryptor.decrypt(Encryptor.java:64)
    parvaz.aero.registration.staff.reset.ResetPassword.doGet(ResetPassword.java:34)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:626)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:733)
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)

这是我检查字符串是否加密的方法

public static boolean isStringEncrypted(String str) {
    try {
        decrypt(str);
        return false;
    }catch(Exception e) {
        return true;
    }
}

如果字符串未解密,我将在此处显示我的消息

        if(!isTokenNull) {
            String resetTokenEmail      = Encryptor.decrypt(resetToken);
            boolean isEmailEncrypted    = Encryptor.isStringEncrypted(resetTokenEmail);
        
            if(isEmailEncrypted) {
                String form = ChangePasswordForm.displayForm(resetToken,"","");
                out.println(SiteTemplate.webPage(form));
            }
            else {
                out.println(SiteTemplate.webPage(Message.getExpired()));
            }
        }
        else {
            out.println(SiteTemplate.webPage(Message.getExpired()));
        }

尽管显示了Message.getExpired(),为什么它会抛出HTTP Status 500 – Internal Server Error

【问题讨论】:

    标签: java exception encryption http-status-code-500 jasypt


    【解决方案1】:

    我发现这个错误是在以下情况下抛出的:

    1. String 已经是Encrypted
    2. 加密或解密时出现空白。所以str.replaceAll(" ", "+");str.replaceAll("+", " "); 解决了这个问题

    【讨论】:

      猜你喜欢
      • 2017-06-25
      • 2013-02-04
      • 2015-12-01
      • 2014-12-24
      • 2013-03-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多