Package org.apache.poi.poifs.crypt

Examples of org.apache.poi.poifs.crypt.EncryptionInfo


                 new OutlookExtractor(root, context);

           extractor.parse(xhtml, metadata);
           break;
        case ENCRYPTED:
           EncryptionInfo info = new EncryptionInfo(root);
           Decryptor d = Decryptor.getInstance(info);

           try {
              // By default, use the default Office Password
              String password = Decryptor.DEFAULT_PASSWORD;
View Full Code Here


    protected int getKeySizeInBytes() {
        return builder.getHeader().getKeySize()/8;
    }
   
    protected void createEncryptionInfoEntry(DirectoryNode dir) throws IOException {
        final EncryptionInfo info = builder.getEncryptionInfo();
        final StandardEncryptionHeader header = builder.getHeader();
        final StandardEncryptionVerifier verifier = builder.getVerifier();
       
        EncryptionRecord er = new EncryptionRecord(){
            public void write(LittleEndianByteArrayOutputStream bos) {
                bos.writeShort(info.getVersionMajor());
                bos.writeShort(info.getVersionMinor());
                bos.writeInt(info.getEncryptionFlags());
                header.write(bos);
                verifier.write(bos);
            }
        };
       
View Full Code Here

                        extractor.parse(xhtml, metadata);
                    }
                    break;
                case ENCRYPTED:
                    EncryptionInfo info = new EncryptionInfo(filesystem);
                    Decryptor d = new Decryptor(info);

                    try {
                        if (!d.verifyPassword(Decryptor.DEFAULT_PASSWORD)) {
                            throw new TikaException("Unable to process: document is encrypted");
View Full Code Here

                 new OutlookExtractor(root, context);

           extractor.parse(xhtml, metadata);
           break;
        case ENCRYPTED:
           EncryptionInfo info = new EncryptionInfo(root);
           Decryptor d = Decryptor.getInstance(info);

           try {
              // By default, use the default Office Password
              String password = Decryptor.DEFAULT_PASSWORD;
View Full Code Here

        bos.write("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\r\n".getBytes("UTF-8"));
        ed.save(bos, xo);

        final byte buf[] = new byte[5000];       
        LittleEndianByteArrayOutputStream leos = new LittleEndianByteArrayOutputStream(buf, 0);
        EncryptionInfo info = builder.getInfo();

        // EncryptionVersionInfo (4 bytes): A Version structure (section 2.1.4), where
        // Version.vMajor MUST be 0x0004 and Version.vMinor MUST be 0x0004
        leos.writeShort(info.getVersionMajor());
        leos.writeShort(info.getVersionMinor());
        // Reserved (4 bytes): A value that MUST be 0x00000040
        leos.writeInt(0x40);
        leos.write(bos.toByteArray());
       
        dir.createDocument("EncryptionInfo", leos.getWriteIndex(), new POIFSWriterListener() {
View Full Code Here

    protected int getKeySizeInBytes() {
        return builder.getHeader().getKeySize()/8;
    }
   
    protected void createEncryptionInfoEntry(DirectoryNode dir) throws IOException {
        final EncryptionInfo info = builder.getEncryptionInfo();
        final StandardEncryptionHeader header = builder.getHeader();
        final StandardEncryptionVerifier verifier = builder.getVerifier();
       
        EncryptionRecord er = new EncryptionRecord(){
            public void write(LittleEndianByteArrayOutputStream bos) {
                bos.writeShort(info.getVersionMajor());
                bos.writeShort(info.getVersionMinor());
                bos.writeInt(info.getEncryptionFlags());
                header.write(bos);
                verifier.write(bos);
            }
        };
       
View Full Code Here

    public void bug53475NoCSPName() throws Exception {
        File file = POIDataSamples.getDocumentInstance().getFile("bug53475-password-is-solrcell.docx");
        NPOIFSFileSystem filesystem = new NPOIFSFileSystem(file, true);

        // Check the encryption details
        EncryptionInfo info = new EncryptionInfo(filesystem);
        assertEquals(128, info.getHeader().getKeySize());
        assertEquals(CipherAlgorithm.aes128, info.getHeader().getCipherAlgorithm());
        assertEquals(HashAlgorithm.sha1, info.getHeader().getHashAlgorithmEx());

        // Check it can be decoded
        Decryptor d = Decryptor.getInstance(info);   
        assertTrue("Unable to process: document is encrypted", d.verifyPassword("solrcell"));
View Full Code Here

        File file = POIDataSamples.getDocumentInstance().getFile("bug53475-password-is-pass.docx");
        NPOIFSFileSystem filesystem = new NPOIFSFileSystem(file, true);

        // Check the encryption details
        EncryptionInfo info = new EncryptionInfo(filesystem);
        assertEquals(16, info.getHeader().getBlockSize());
        assertEquals(256, info.getHeader().getKeySize());
        assertEquals(CipherAlgorithm.aes256, info.getHeader().getCipherAlgorithm());
        assertEquals(HashAlgorithm.sha1, info.getHeader().getHashAlgorithmEx());

        // Check it can be decoded
        Decryptor d = Decryptor.getInstance(info);   
        assertTrue("Unable to process: document is encrypted", d.verifyPassword("pass"));
View Full Code Here

    public void bug53475NoCSPName() throws Exception {
        File file = POIDataSamples.getDocumentInstance().getFile("bug53475-password-is-solrcell.docx");
        NPOIFSFileSystem filesystem = new NPOIFSFileSystem(file, true);

        // Check the encryption details
        EncryptionInfo info = new EncryptionInfo(filesystem);
        assertEquals(128, info.getHeader().getKeySize());
        assertEquals(CipherAlgorithm.aes128, info.getHeader().getCipherAlgorithm());
        assertEquals(HashAlgorithm.sha1, info.getHeader().getHashAlgorithmEx());

        // Check it can be decoded
        Decryptor d = Decryptor.getInstance(info);   
        assertTrue("Unable to process: document is encrypted", d.verifyPassword("solrcell"));
View Full Code Here

        File file = POIDataSamples.getDocumentInstance().getFile("bug53475-password-is-pass.docx");
        NPOIFSFileSystem filesystem = new NPOIFSFileSystem(file, true);

        // Check the encryption details
        EncryptionInfo info = new EncryptionInfo(filesystem);
        assertEquals(16, info.getHeader().getBlockSize());
        assertEquals(256, info.getHeader().getKeySize());
        assertEquals(CipherAlgorithm.aes256, info.getHeader().getCipherAlgorithm());
        assertEquals(HashAlgorithm.sha1, info.getHeader().getHashAlgorithmEx());

        // Check it can be decoded
        Decryptor d = Decryptor.getInstance(info);   
        assertTrue("Unable to process: document is encrypted", d.verifyPassword("pass"));
View Full Code Here

TOP

Related Classes of org.apache.poi.poifs.crypt.EncryptionInfo

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.