[prev in list] [next in list] [prev in thread] [next in thread] 

List:       poi-user
Subject:    RE: protected word doc
From:       "Sushil Khekare" <Sushil.Khekare () symphonysv ! com>
Date:       2006-05-18 6:55:07
Message-ID: DD8AEE8B34FBBF4E9135BE48418C3FB63BED40 () PUNMAIL ! symphonysv ! com
[Download RAW message or body]

Cool. It works and also solved my problem thanks a lot Daniel.

Sushil 

-----Original Message-----
From: Daniel Noll [mailto:daniel@nuix.com.au] 
Sent: Thursday, May 18, 2006 11:06 AM
To: POI Users List
Subject: Re: protected word doc

Sushil Khekare wrote:
> How to find out a document is encrypted using java. While using POI 
> error is thrown at constructor level only so no way to use any method 
> on the object of wordDocument or hwpfdocument.

Here's one way:

     POIFSFileSystem fileSystem = // ...

     Entry summaryEntry = fileSystem.getRoot().getEntry(
         SummaryInformation.DEFAULT_STREAM_NAME);
     if (summaryEntry instanceof DocumentEntry) {
         PropertySet ps = PropertySetFactory.create(
             new DocumentInputStream((DocumentEntry) summaryEntry));
         SummaryInformation summary = new SummaryInformation(ps);
         if ((summary.getSecurity() & PASSWORD_PROTECTED_MASK) != 0) {
             // Is encrypted
         }
     }

This is trusting the summary properties, and the summary properties
might be lying, but it works for us.

Daniel


--
Daniel Noll

Nuix Pty Ltd
Suite 79, 89 Jones St, Ultimo NSW 2007, Australia    Ph: +61 2 9280 0699
Web: http://www.nuix.com.au/                        Fax: +61 2 9212 6902

This message is intended only for the named recipient. If you are not
the intended recipient you are notified that disclosing, copying,
distributing or taking any action in reliance on the contents of this
message or attachment is strictly prohibited.

---------------------------------------------------------------------
To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
Mailing List:     http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/


---------------------------------------------------------------------
To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
Mailing List:     http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic