[Bug 62967] New: Stream Closed For EncryptionInfo

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

[Bug 62967] New: Stream Closed For EncryptionInfo

Bugzilla from bugzilla@apache.org
https://bz.apache.org/bugzilla/show_bug.cgi?id=62967

            Bug ID: 62967
           Summary: Stream Closed For EncryptionInfo
           Product: POI
           Version: unspecified
          Hardware: PC
            Status: NEW
          Severity: normal
          Priority: P2
         Component: POIFS
          Assignee: [hidden email]
          Reporter: [hidden email]
  Target Milestone: ---

When I use the following code(from the official document)

```java
POIFSFileSystem fs = new POIFSFileSystem();
EncryptionInfo info = new EncryptionInfo(EncryptionMode.agile);
// EncryptionInfo info = new EncryptionInfo(EncryptionMode.agile,
CipherAlgorithm.aes192, HashAlgorithm.sha384, -1, -1, null);

Encryptor enc = info.getEncryptor();
enc.confirmPassword("foobaa");

// Read in an existing OOXML file and write to encrypted output stream
// don't forget to close the output stream otherwise the padding bytes aren't
added
try (OPCPackage opc = OPCPackage.open(new File("..."),
PackageAccess.READ_WRITE);
    OutputStream os = enc.getDataStream(fs)) {
    opc.save(os);
}

// Write out the encrypted version
FileOutputStream fos = new FileOutputStream("...");
fs.writeFilesystem(fos);
fos.close();
```

The following error occurred

----- 其他异常 : class java.io.IOException
java.io.IOException: Stream Closed
        at java.io.FileOutputStream.writeBytes(FileOutputStream.java)
~[na:1.8.0_191-1-ojdkbuild]
        at java.io.FileOutputStream.write(FileOutputStream.java:326)
~[na:1.8.0_191-1-ojdkbuild]
        at
org.apache.poi.poifs.crypt.agile.AgileEncryptor$ChunkedCipherOutputStream.writeChunk(AgileEncryptor.java:330)
~[poi-ooxml-3.10-FINAL.jar:3.10-FINAL]
        at
org.apache.poi.poifs.crypt.agile.AgileEncryptor$ChunkedCipherOutputStream.close(AgileEncryptor.java:337)
~[poi-ooxml-3.10-FINAL.jar:3.10-FINAL]


Everything is normal after modification

```java
OPCPackage opc = OPCPackage.open(new File(filePath), PackageAccess.READ_WRITE);
OutputStream os = enc.getDataStream(fs);
opc.save(os);
opc.close();
```

--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

[Bug 62967] Stream Closed For EncryptionInfo

Bugzilla from bugzilla@apache.org
https://bz.apache.org/bugzilla/show_bug.cgi?id=62967

Robot <[hidden email]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 OS|                            |All

--- Comment #1 from Robot <[hidden email]> ---
When I use the following code(from the official document) poi verion 3.10.0
```java
POIFSFileSystem fs = new POIFSFileSystem();
EncryptionInfo info = new EncryptionInfo(fs, EncryptionMode.agile);
// EncryptionInfo info = new EncryptionInfo(EncryptionMode.agile,
CipherAlgorithm.aes192, HashAlgorithm.sha384, -1, -1, null);

Encryptor enc = info.getEncryptor();
enc.confirmPassword("foobaa");

// Read in an existing OOXML file and write to encrypted output stream
// don't forget to close the output stream otherwise the padding bytes aren't
added
try (OPCPackage opc = OPCPackage.open(new File("..."),
PackageAccess.READ_WRITE);
    OutputStream os = enc.getDataStream(fs)) {
    opc.save(os);
}

// Write out the encrypted version
FileOutputStream fos = new FileOutputStream("...");
fs.writeFilesystem(fos);
fos.close();
```

The following error occurred

----- 其他异常 : class java.io.IOException
java.io.IOException: Stream Closed
        at java.io.FileOutputStream.writeBytes(FileOutputStream.java)
~[na:1.8.0_191-1-ojdkbuild]
        at java.io.FileOutputStream.write(FileOutputStream.java:326)
~[na:1.8.0_191-1-ojdkbuild]
        at
org.apache.poi.poifs.crypt.agile.AgileEncryptor$ChunkedCipherOutputStream.writeChunk(AgileEncryptor.java:330)
~[poi-ooxml-3.10-FINAL.jar:3.10-FINAL]
        at
org.apache.poi.poifs.crypt.agile.AgileEncryptor$ChunkedCipherOutputStream.close(AgileEncryptor.java:337)
~[poi-ooxml-3.10-FINAL.jar:3.10-FINAL]


Everything is normal after modification

```java
OPCPackage opc = OPCPackage.open(new File(filePath), PackageAccess.READ_WRITE);
OutputStream os = enc.getDataStream(fs);
opc.save(os);
opc.close();
```

--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

[Bug 62967] Stream Closed For EncryptionInfo

Bugzilla from bugzilla@apache.org
In reply to this post by Bugzilla from bugzilla@apache.org
https://bz.apache.org/bugzilla/show_bug.cgi?id=62967

--- Comment #2 from PJ Fanning <[hidden email]> ---
The web site only has documentation for the current version of poi (4.0.0 with
4.0.1 coming out soon).
POI 3.10 is ancient.

--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

[Bug 62967] Stream Closed For EncryptionInfo

Bugzilla from bugzilla@apache.org
In reply to this post by Bugzilla from bugzilla@apache.org
https://bz.apache.org/bugzilla/show_bug.cgi?id=62967

Robot <[hidden email]> changed:

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

--- Comment #3 from Robot <[hidden email]> ---
I got it.

--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]