EWS Java-如何识别文件附件是否受密码保护?

时间:2017-02-16 20:37:29

标签: java encoding exchange-server exchangewebservices ewsjavaapi

我试图验证附件是否受密码保护,是否有可以检查的属性。如果附件受密码保护,我不想处理附件。

以下是我尝试的代码:

        FileAttachment fileAttachment = (FileAttachment) attachment;
        // if we don't call this, the Content property may be null.
        fileAttachment.load();

        // I was hoping this should not give me content of the file if it's password protected
        attachmentContent = fileAttachment.getContent(); //but I get the content without error.

        if (attachmentContent != null && attachmentContent.length > 0) {

            //check the size, I get the length as well
            int attachmentSize = attachmentContent.length;

我再次检查是否可以解码内容,我也可以获得解码内容。

byte[] decodedFile;
    try {
        String base64Encoded = Base64.encodeBase64String(attachmentContent);
        decodedFile = Base64.decodeBase64(base64Encoded);
    } catch (Exception e) {
        throw e);
    }

0 个答案:

没有答案