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

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

我可以使用任何其他java库来实现此目的,前提是它们是开源的。

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

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

在密码保护的pst文件中,实际上没有任何内容被加密.pst文件的密码是根据标识符0x67FF存储的。如果没有密码,则存储的值是0x00000000。这个密码在打开pst文件时由outlook匹配。由于这个原因,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; }