You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2016/06/30 15:45:41 UTC
commons-crypto git commit: [CRYPTO-94] Consistently camel-case type
names: IoUtils.
Repository: commons-crypto
Updated Branches:
refs/heads/master 06276c333 -> 6154eb8e0
[CRYPTO-94] Consistently camel-case type names: IoUtils.
Project: http://git-wip-us.apache.org/repos/asf/commons-crypto/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-crypto/commit/6154eb8e
Tree: http://git-wip-us.apache.org/repos/asf/commons-crypto/tree/6154eb8e
Diff: http://git-wip-us.apache.org/repos/asf/commons-crypto/diff/6154eb8e
Branch: refs/heads/master
Commit: 6154eb8e074f64c235f622ce15f9c7de70a30ba0
Parents: 06276c3
Author: Gary Gregory <gg...@apache.org>
Authored: Thu Jun 30 08:45:37 2016 -0700
Committer: Gary Gregory <gg...@apache.org>
Committed: Thu Jun 30 08:45:37 2016 -0700
----------------------------------------------------------------------
.../commons/crypto/random/OsCryptoRandom.java | 6 +-
.../stream/PositionedCryptoInputStream.java | 4 +-
.../apache/commons/crypto/utils/IOUtils.java | 99 --------------------
.../apache/commons/crypto/utils/IoUtils.java | 99 ++++++++++++++++++++
4 files changed, 104 insertions(+), 104 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-crypto/blob/6154eb8e/src/main/java/org/apache/commons/crypto/random/OsCryptoRandom.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/crypto/random/OsCryptoRandom.java b/src/main/java/org/apache/commons/crypto/random/OsCryptoRandom.java
index b93177a..a15686c 100644
--- a/src/main/java/org/apache/commons/crypto/random/OsCryptoRandom.java
+++ b/src/main/java/org/apache/commons/crypto/random/OsCryptoRandom.java
@@ -24,7 +24,7 @@ import java.util.Properties;
import java.util.Random;
import org.apache.commons.crypto.conf.ConfigurationKeys;
-import org.apache.commons.crypto.utils.IOUtils;
+import org.apache.commons.crypto.utils.IoUtils;
/**
* A Random implementation that uses random bytes sourced from the operating
@@ -50,7 +50,7 @@ class OsCryptoRandom extends Random implements CryptoRandom {
private void fillReservoir(int min) {
if (pos >= reservoir.length - min) {
try {
- IOUtils.readFully(stream, reservoir, 0, reservoir.length);
+ IoUtils.readFully(stream, reservoir, 0, reservoir.length);
} catch (IOException e) {
throw new RuntimeException("failed to fill reservoir", e);
}
@@ -132,7 +132,7 @@ class OsCryptoRandom extends Random implements CryptoRandom {
@Override
synchronized public void close() {
if (stream != null) {
- IOUtils.cleanup(stream);
+ IoUtils.cleanup(stream);
stream = null;
}
}
http://git-wip-us.apache.org/repos/asf/commons-crypto/blob/6154eb8e/src/main/java/org/apache/commons/crypto/stream/PositionedCryptoInputStream.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/crypto/stream/PositionedCryptoInputStream.java b/src/main/java/org/apache/commons/crypto/stream/PositionedCryptoInputStream.java
index d92e3aa..bd6c39d 100644
--- a/src/main/java/org/apache/commons/crypto/stream/PositionedCryptoInputStream.java
+++ b/src/main/java/org/apache/commons/crypto/stream/PositionedCryptoInputStream.java
@@ -34,7 +34,7 @@ import javax.crypto.spec.IvParameterSpec;
import org.apache.commons.crypto.cipher.CryptoCipher;
import org.apache.commons.crypto.cipher.CryptoCipherFactory;
import org.apache.commons.crypto.stream.input.Input;
-import org.apache.commons.crypto.utils.IOUtils;
+import org.apache.commons.crypto.utils.IoUtils;
import org.apache.commons.crypto.utils.Utils;
/**
@@ -133,7 +133,7 @@ public class PositionedCryptoInputStream extends CTRCryptoInputStream {
public void readFully(long position, byte[] buffer, int offset, int length)
throws IOException {
checkStream();
- IOUtils.readFully(input, position, buffer, offset, length);
+ IoUtils.readFully(input, position, buffer, offset, length);
if (length > 0) {
// This operation does not change the current offset of the file
decrypt(position, buffer, offset, length);
http://git-wip-us.apache.org/repos/asf/commons-crypto/blob/6154eb8e/src/main/java/org/apache/commons/crypto/utils/IOUtils.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/crypto/utils/IOUtils.java b/src/main/java/org/apache/commons/crypto/utils/IOUtils.java
deleted file mode 100644
index 67f82ae..0000000
--- a/src/main/java/org/apache/commons/crypto/utils/IOUtils.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.commons.crypto.utils;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-import org.apache.commons.crypto.stream.input.Input;
-
-/**
- * General utility methods for working with IO.
- */
-public final class IOUtils {
-
- /**
- * Teh private constructor of {@link IOUtils}.
- */
- private IOUtils() {
- }
-
- /**
- * Does the readFully based on the Input read.
- *
- * @param in the input stream of bytes.
- * @param buf the buffer to be read.
- * @param off the start offset in array buffer.
- * @param len the maximum number of bytes to read.
- * @throws IOException if an I/O error occurs.
- */
- public static void readFully(InputStream in, byte buf[], int off, int len)
- throws IOException {
- int toRead = len;
- while (toRead > 0) {
- int ret = in.read(buf, off, toRead);
- if (ret < 0) {
- throw new IOException("Premature EOF from inputStream");
- }
- toRead -= ret;
- off += ret;
- }
- }
-
- /**
- * Does the readFully based on Input's positioned read. This does not change
- * the current offset of the stream and is thread-safe.
- *
- * @param in the input source.
- * @param position the given position.
- * @param buffer the buffer to be read.
- * @param length the maximum number of bytes to read.
- * @param offset the start offset in array buffer.
- * @throws IOException if an I/O error occurs.
- */
- public static void readFully(Input in, long position, byte[] buffer,
- int offset, int length) throws IOException {
- int nread = 0;
- while (nread < length) {
- int nbytes = in.read(position + nread, buffer, offset + nread,
- length - nread);
- if (nbytes < 0) {
- throw new IOException(
- "End of stream reached before reading fully.");
- }
- nread += nbytes;
- }
- }
-
- /**
- * Closes the Closeable objects and <b>ignore</b> any {@link IOException} or
- * null pointers. Must only be used for cleanup in exception handlers.
- *
- * @param closeables the objects to close.
- */
- public static void cleanup(java.io.Closeable... closeables) {
- for (java.io.Closeable c : closeables) {
- if (c != null) {
- try {
- c.close();
- } catch (IOException e) { // NOPMD
- }
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/commons-crypto/blob/6154eb8e/src/main/java/org/apache/commons/crypto/utils/IoUtils.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/crypto/utils/IoUtils.java b/src/main/java/org/apache/commons/crypto/utils/IoUtils.java
new file mode 100644
index 0000000..9c74db6
--- /dev/null
+++ b/src/main/java/org/apache/commons/crypto/utils/IoUtils.java
@@ -0,0 +1,99 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 org.apache.commons.crypto.utils;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.apache.commons.crypto.stream.input.Input;
+
+/**
+ * General utility methods for working with IO.
+ */
+public final class IoUtils {
+
+ /**
+ * Teh private constructor of {@link IoUtils}.
+ */
+ private IoUtils() {
+ }
+
+ /**
+ * Does the readFully based on the Input read.
+ *
+ * @param in the input stream of bytes.
+ * @param buf the buffer to be read.
+ * @param off the start offset in array buffer.
+ * @param len the maximum number of bytes to read.
+ * @throws IOException if an I/O error occurs.
+ */
+ public static void readFully(InputStream in, byte buf[], int off, int len)
+ throws IOException {
+ int toRead = len;
+ while (toRead > 0) {
+ int ret = in.read(buf, off, toRead);
+ if (ret < 0) {
+ throw new IOException("Premature EOF from inputStream");
+ }
+ toRead -= ret;
+ off += ret;
+ }
+ }
+
+ /**
+ * Does the readFully based on Input's positioned read. This does not change
+ * the current offset of the stream and is thread-safe.
+ *
+ * @param in the input source.
+ * @param position the given position.
+ * @param buffer the buffer to be read.
+ * @param length the maximum number of bytes to read.
+ * @param offset the start offset in array buffer.
+ * @throws IOException if an I/O error occurs.
+ */
+ public static void readFully(Input in, long position, byte[] buffer,
+ int offset, int length) throws IOException {
+ int nread = 0;
+ while (nread < length) {
+ int nbytes = in.read(position + nread, buffer, offset + nread,
+ length - nread);
+ if (nbytes < 0) {
+ throw new IOException(
+ "End of stream reached before reading fully.");
+ }
+ nread += nbytes;
+ }
+ }
+
+ /**
+ * Closes the Closeable objects and <b>ignore</b> any {@link IOException} or
+ * null pointers. Must only be used for cleanup in exception handlers.
+ *
+ * @param closeables the objects to close.
+ */
+ public static void cleanup(java.io.Closeable... closeables) {
+ for (java.io.Closeable c : closeables) {
+ if (c != null) {
+ try {
+ c.close();
+ } catch (IOException e) { // NOPMD
+ }
+ }
+ }
+ }
+}