Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor changes #135

Merged
merged 1 commit into from
Oct 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,9 @@ The following provides more details on the included cryptographic software:
<name>Adam Retter</name>
<organization>Evolved Binary</organization>
</contributor>
<contributor>
<name>Arturo Bernal</name>
</contributor>
</contributors>

<profiles>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/apache/commons/crypto/Crypto.java
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public static boolean isNativeCodeLoaded() {
* @param args Not used.
* @throws Exception if getCryptoRandom or getCryptoCipher get error.
*/
public static void main(final String args[]) throws Exception {
public static void main(final String[] args) throws Exception {
info("%s %s", getComponentName(), getComponentVersion());
if (isNativeCodeLoaded()) {
info("Native code loaded OK: %s", OpenSslInfoNative.NativeVersion());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,7 @@ public static CryptoCipher getCryptoCipher(final String transformation, final Pr
final Class<?> cls = ReflectionUtils.getClassByName(klass);
cipher = ReflectionUtils.newInstance(cls.asSubclass
(CryptoCipher.class), properties, transformation);
if (cipher != null) {
break;
}
break;
} catch (final Exception e) {
lastException = e;
errorMessage.append("{" + klass + "}");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ class OpenSsl10XNativeJna {
* @return 1 for success and 0 for failure.
*/
public static native int EVP_CipherInit_ex(PointerByReference ctx, PointerByReference cipher,
PointerByReference impl, byte key[], byte iv[], int enc);
PointerByReference impl, byte[] key, byte[] iv, int enc);

/**
* Continues a multiple-part encryption/decryption operation.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ class OpenSsl11XNativeJna {
* @return 1 for success and 0 for failure.
*/
public static native int EVP_CipherInit_ex(PointerByReference ctx, PointerByReference cipher,
PointerByReference impl, byte key[], byte iv[], int enc);
PointerByReference impl, byte[] key, byte[] iv, int enc);

/**
* Continues a multiple-part encryption/decryption operation.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public void setSeed(final long seed) {
final protected int next(final int numBits) {
Utils.checkArgument(numBits >= 0 && numBits <= 32);
final int numBytes = (numBits + 7) / 8;
final byte b[] = new byte[numBytes];
final byte[] b = new byte[numBytes];
int next = 0;

nextBytes(b);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,7 @@ public static CryptoRandom getCryptoRandom(final Properties props)
try {
final Class<?> klass = ReflectionUtils.getClassByName(klassName);
random = (CryptoRandom) ReflectionUtils.newInstance(klass, props);
if (random != null) {
break;
}
break;
} catch (final ClassCastException e) {
lastException = e;
errorMessage.append("Class: [" + klassName + "] is not a CryptoRandom.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public void setSeed(final long seed) {
final protected int next(final int numBits) {
Utils.checkArgument(numBits >= 0 && numBits <= 32);
final int numBytes = (numBits + 7) / 8;
final byte b[] = new byte[numBytes];
final byte[] b = new byte[numBytes];
int next = 0;

nextBytes(b);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/apache/commons/crypto/utils/IoUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ private IoUtils() {
* @param len the maximum number of bytes to read.
* @throws IOException if an I/O error occurs.
*/
public static void readFully(final InputStream in, final byte buf[], int off, final int len)
public static void readFully(final InputStream in, final byte[] buf, int off, final int len)
throws IOException {
int toRead = len;
while (toRead > 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ private static Class<?> getClassByNameOrNull(final String name) {
final Map<String, WeakReference<Class<?>>> map;

synchronized (CACHE_CLASSES) {
map = CACHE_CLASSES.computeIfAbsent(CLASSLOADER, k -> Collections.synchronizedMap(new WeakHashMap<String, WeakReference<Class<?>>>()));
map = CACHE_CLASSES.computeIfAbsent(CLASSLOADER, k -> Collections.synchronizedMap(new WeakHashMap<>()));
}

Class<?> clazz = null;
Expand All @@ -131,11 +131,11 @@ private static Class<?> getClassByNameOrNull(final String name) {
clazz = Class.forName(name, true, CLASSLOADER);
} catch (final ClassNotFoundException e) {
// Leave a marker that the class isn't found
map.put(name, new WeakReference<Class<?>>(NEGATIVE_CACHE_SENTINEL));
map.put(name, new WeakReference<>(NEGATIVE_CACHE_SENTINEL));
return null;
}
// two putters can race here, but they'll put the same class
map.put(name, new WeakReference<Class<?>>(clazz));
map.put(name, new WeakReference<>(clazz));
return clazz;
} else if (clazz == NEGATIVE_CACHE_SENTINEL) {
return null; // not found
Expand Down