【问题标题】:check if a pst file is password protected with java-libpst检查 pst 文件是否受 java-libpst 密码保护
【发布时间】:2013-02-27 23:47:42
【问题描述】:

我正在使用开源库java-libpst 解析outlook pst 文件。在解析之前我想知道该文件是否受密码保护。我们这个库打开密码保护文件时没有密码的问题,所以我没有找到任何方法来检查文件是否受密码保护。

我可以为此目的使用任何其他 java 库,只要它们是开源的。

【问题讨论】:

    标签: outlook java pst


    【解决方案1】:

    不知道.pst 文件的任何开源java 库,但有商业库JPST。我们用它来读取 .pst 文件。该库能够从 .pst 文件中读取密码哈希。我记得密码存储在 MessageStore 对象中。

    密码不用于加密 .pst 文件内容。任何应用程序或库都可以在不知道密码的情况下读取 Outlook .pst 文件。

    【讨论】:

    • Thnaks。你的回答很有帮助。我创建了一个实用方法来通过解析 pst 文件头来检查密码保护。查看我的回答
    【解决方案2】:

    在受密码保护的 pst 文件中,实际上没有加密。pst 文件的密码存储在标识符 0x67FF 中。如果没有密码,则存储的值为 0x00000000。Outlook 在打开 pst 文件时会匹配此密码。由于为此,java库java-libpst也可以在不需要密码的情况下访问受密码保护的文件的所有内容。

    要检查文件是否受密码保护,使用 java-libpst 使用:

         /**
         * checks if a pst file is password protected
         * 
         * @param file - pst file to check 
         * @return - true if protected,false otherwise
         * 
         * pstfile has the password stored against identifier 0x67FF.
         * if there is no password the value stored is 0x00000000.
         */
        private static boolean ifProtected(PSTFile file,boolean reomovePwd){
            try {
                String fileDetails = file.getMessageStore().getDetails();
                String[] lines = fileDetails.split("\n");
                for(String line:lines){
                    if(line.contains("0x67FF")){
                        if(line.contains("0x00000000"))
                            return false;
                        else
                            return true;
                    }
    
                }
            } catch (PSTException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return false;
        }
    

    【讨论】:

      猜你喜欢
      • 2013-02-05
      • 2015-08-24
      • 1970-01-01
      • 2014-12-30
      • 2017-11-01
      • 2023-03-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多