[java-shib-shared] branch main updated: Add deflate and inflate IO stream convenience impls.

Codeberg noreply at shibboleth.net
Sun May 10 00:32:41 UTC 2026


This is an automated email from the git hooks/post-receive script.

codeberg pushed a commit to branch main
in repository java-shib-shared.

View the commit online:
https://codeberg.org/Shibboleth/java-shib-shared/commit/2658147a85a7abe760427fbb8ddbb5092791695a

The following commit(s) were added to refs/heads/main by this push:
     new 2658147a Add deflate and inflate IO stream convenience impls.
2658147a is described below

commit 2658147a85a7abe760427fbb8ddbb5092791695a
Author: Brent Putman <putmanb at georgetown.edu>
AuthorDate: Sat May 9 20:13:14 2026 -0400

    Add deflate and inflate IO stream convenience impls.
    
    These are exact copies of what are in the OpenSAML
    HTTPRedirectDeflateEncoder and -Decoder impls, where they were private
    inner classes.
---
 .../io/NoWrapAutoEndDeflaterOutputStream.java      | 48 ++++++++++++++++++++++
 .../io/NoWrapAutoEndInflaterInputStream.java       | 46 +++++++++++++++++++++
 .../net/shibboleth/shared/io/package-info.java     | 19 +++++++++
 3 files changed, 113 insertions(+)

diff --git a/shib-support/src/main/java/net/shibboleth/shared/io/NoWrapAutoEndDeflaterOutputStream.java b/shib-support/src/main/java/net/shibboleth/shared/io/NoWrapAutoEndDeflaterOutputStream.java
new file mode 100644
index 00000000..e9420b58
--- /dev/null
+++ b/shib-support/src/main/java/net/shibboleth/shared/io/NoWrapAutoEndDeflaterOutputStream.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.shibboleth.shared.io;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.zip.Deflater;
+import java.util.zip.DeflaterOutputStream;
+
+import javax.annotation.Nonnull;
+
+/** A subclass of {@link DeflaterOutputStream} which defaults in a no-wrap {@link Deflater} instance and
+ * closes it when the stream is closed.
+ */
+public class NoWrapAutoEndDeflaterOutputStream extends  DeflaterOutputStream {
+    
+    /**
+     * Creates a new output stream with a default no-wrap compressor and buffer size,
+     * and the specified compression level.
+     *
+     * @param os the output stream
+     * @param level the compression level (0-9)
+     */
+    public NoWrapAutoEndDeflaterOutputStream(@Nonnull final OutputStream os, final int level) {
+        super(os, new Deflater(level, true));
+    }
+
+    /** {@inheritDoc} */
+    public void close() throws IOException {
+        if (def != null) {
+            def.end();
+        }
+        super.close();
+    }
+
+}
diff --git a/shib-support/src/main/java/net/shibboleth/shared/io/NoWrapAutoEndInflaterInputStream.java b/shib-support/src/main/java/net/shibboleth/shared/io/NoWrapAutoEndInflaterInputStream.java
new file mode 100644
index 00000000..ae53a679
--- /dev/null
+++ b/shib-support/src/main/java/net/shibboleth/shared/io/NoWrapAutoEndInflaterInputStream.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package net.shibboleth.shared.io;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.zip.Inflater;
+import java.util.zip.InflaterInputStream;
+
+import javax.annotation.Nonnull;
+
+/** A subclass of {@link InflaterInputStream} which defaults in a no-wrap {@link Inflater} instance and
+ * closes it when the stream is closed.
+ */
+public class NoWrapAutoEndInflaterInputStream extends InflaterInputStream {
+    
+    /**
+     * Creates a new input stream with a default no-wrap decompressor and buffer size.
+     *
+     * @param is the input stream
+     */
+    public NoWrapAutoEndInflaterInputStream(@Nonnull final InputStream is) {
+        super(is, new Inflater(true));
+    }
+
+    /** {@inheritDoc} */
+    public void close() throws IOException {
+        if (inf != null) {
+            inf.end();
+        }
+        super.close();
+    }
+
+}
diff --git a/shib-support/src/main/java/net/shibboleth/shared/io/package-info.java b/shib-support/src/main/java/net/shibboleth/shared/io/package-info.java
new file mode 100644
index 00000000..00f28d4c
--- /dev/null
+++ b/shib-support/src/main/java/net/shibboleth/shared/io/package-info.java
@@ -0,0 +1,19 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Support components for I/O operations.
+ */
+
+package net.shibboleth.shared.io;
\ No newline at end of file

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list