检查pst文件是否受java-libpst密码保护

时间:2013-02-27 23:47:43

标签: outlook java pst

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

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

2 个答案:

答案 0 :(得分:1)

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

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

答案 1 :(得分:1)

在受密码保护的pst文件中,实际上没有任何内容被加密.pst文件的密码是根据标识符0x67FF存储的。如果没有密码,则存储的值为0x00000000。在打开pst文件时,此密码与outlook匹配.Due为此,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;
    }
相关问题