我正在使用开源库java-libpst解析outlook pst
file.be解析之前我想知道文件是否受密码保护或不是。问题是我们库打开密码保护的文件没有密码,所以我没有找到任何方式来检查该文件是否受密码保护。检查pst文件是否使用java-libpst进行密码保护
我可以使用任何其他Java库来达到这个目的,只要它们是开源的。
我正在使用开源库java-libpst解析outlook pst
file.be解析之前我想知道文件是否受密码保护或不是。问题是我们库打开密码保护的文件没有密码,所以我没有找到任何方式来检查该文件是否受密码保护。检查pst文件是否使用java-libpst进行密码保护
我可以使用任何其他Java库来达到这个目的,只要它们是开源的。
在密码保护的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;
}
不知道任何开源的java库.pst文件,但有商业库JPST。我们用它来读取.pst文件。该库能够从.pst文件读取密码哈希。正如我记得密码存储在MessageStore对象中。
密码不用于加密.pst文件内容。任何应用程序或库都可以在不知道密码的情况下读取Outlook .pst文件。
Thnaks.Your答案帮lot.I创造了一个实用的方法通过解析PST文件头检查密码保护看到我的答案 – vishesh 2013-02-28 10:10:55