check if a pst file is password protected with java-libpst

浪子不回头ぞ 提交于 2019-12-06 14:55:25

Do not know any open source java library for .pst file, but there is commercial library JPST. We used it to read .pst files. The library was able to read password hash from .pst file. As I remember password is stored in MessageStore object.

Password is not used to encrypt .pst file content. Any application or library can read Outlook .pst file without to know password.

In password protected pst files, ,nothing is actually encrypted .The Password of a pst file is stored against identifier 0x67FF.If there is no password the value stored is 0x00000000.This password is matched by outlook while opening pst file.Due to this reason,The java library java-libpst can also access all contents of password protected files without the actual need of password.

To check if the file is password protected,using java-libpst use this:

     /**
     * 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;
    }
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!