You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by bu...@apache.org on 2016/11/11 10:05:42 UTC

[Bug 60363] New: Missing Implementation for Encryption of XSSF Workbooks

https://bz.apache.org/bugzilla/show_bug.cgi?id=60363

            Bug ID: 60363
           Summary: Missing Implementation for Encryption of XSSF
                    Workbooks
           Product: POI
           Version: 3.14-FINAL
          Hardware: PC
            Status: NEW
          Severity: blocker
          Priority: P2
         Component: POIFS
          Assignee: dev@poi.apache.org
          Reporter: smear1@gmx.de
  Target Milestone: ---

To create a password protected workbook using Encryptor, an instance of
POIFSFileSystem is required to create the encrypted data stream. There is no
XSSF implementation of POIFSFileSystem and the encryption is therefore not
possible. The following example illustrates the problem, an exception occures
in the line where the POIFSFileSystem is created.

 public static void main(String[] args)
    {
        try(Workbook wb = new XSSFWorkbook())
        {
            Sheet sheet = wb.createSheet();
            Row r = sheet.createRow(0);
            Cell cell = r.createCell(0);
            cell.setCellType(Cell.CELL_TYPE_STRING);
            cell.setCellValue("Test");
            try(ByteArrayOutputStream baos = new ByteArrayOutputStream())
            {
                wb.write(baos);
                byte[] res = baos.toByteArray();
                try(ByteArrayInputStream bais = new ByteArrayInputStream(res))
                {
                    try(POIFSFileSystem fileSystem = new
POIFSFileSystem(bais);) // Exception here
                    {
                        EncryptionInfo info = new
EncryptionInfo(EncryptionMode.agile);
                        Encryptor enc = info.getEncryptor();
                        enc.confirmPassword("pass");
                        OutputStream encryptedDS =
enc.getDataStream(fileSystem);
                        OPCPackage opc = OPCPackage.open(new
File("example.xlsx"), PackageAccess.READ_WRITE);
                        opc.save(encryptedDS);
                        opc.close();
                    }
                }
            }
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }
    }

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 60363] Missing Implementation for Encryption of XSSF Workbooks

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=60363

--- Comment #3 from Mathis <sm...@gmx.de> ---
Thank you very much for you help and sorry for the unnecessary ticket!

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 60363] Missing Implementation for Encryption of XSSF Workbooks

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=60363

Nick Burch <ap...@gagravarr.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |INVALID
             Status|NEW                         |RESOLVED

--- Comment #2 from Nick Burch <ap...@gagravarr.org> ---
You don't open the POIFS with the document to be encrypted, you start with a
new empty one and populate it. Working code shown at
https://poi.apache.org/encryption.html#XML-based+formats+-+Encryption

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 60363] Missing Implementation for Encryption of XSSF Workbooks

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=60363

Mathis <sm...@gmx.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |smear1@gmx.de
                 OS|                            |All

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 60363] Missing Implementation for Encryption of XSSF Workbooks

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=60363

--- Comment #1 from Mathis <sm...@gmx.de> ---
Please note: There is no example.xlsx, but this line is not reached anyway.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org