Skip to content

Commit b8434f8

Browse files
committed
Merge branch 'main' of gitlab.cryptoworkshop.com:root/bc-java
2 parents e010a8a + caf23e3 commit b8434f8

File tree

12 files changed

+25
-43
lines changed

12 files changed

+25
-43
lines changed

tls/src/main/java/org/bouncycastle/tls/ReflectionUtil.java renamed to tls/src/main/java/org/bouncycastle/jsse/provider/ReflectionUtil.java

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package org.bouncycastle.tls;
1+
package org.bouncycastle.jsse.provider;
22

33
import java.lang.reflect.Constructor;
44
import java.lang.reflect.Field;
@@ -7,9 +7,9 @@
77
import java.security.AccessController;
88
import java.security.PrivilegedAction;
99

10-
public abstract class ReflectionUtil
10+
class ReflectionUtil
1111
{
12-
public static Method findMethod(Method[] methods, String name)
12+
static Method findMethod(Method[] methods, String name)
1313
{
1414
if (methods != null)
1515
{
@@ -24,12 +24,13 @@ public static Method findMethod(Method[] methods, String name)
2424
return null;
2525
}
2626

27-
public static boolean hasMethod(Method[] methods, String name)
27+
static boolean hasMethod(Method[] methods, String name)
2828
{
2929
return null != findMethod(methods, name);
3030
}
3131

32-
public static Class<?> getClass(final String className)
32+
33+
static Class<?> getClass(final String className)
3334
{
3435
if (null == className)
3536
{
@@ -57,7 +58,7 @@ public Class<?> run()
5758
});
5859
}
5960

60-
public static <T> Constructor<T> getDeclaredConstructor(final String className, final Class<?>... parameterTypes)
61+
static <T> Constructor<T> getDeclaredConstructor(final String className, final Class<?>... parameterTypes)
6162
{
6263
if (null == className)
6364
{
@@ -89,7 +90,7 @@ public Constructor<T> run()
8990
});
9091
}
9192

92-
public static Method getMethod(final String className, final String methodName, final Class<?>... parameterTypes)
93+
static Method getMethod(final String className, final String methodName, final Class<?>... parameterTypes)
9394
{
9495
if (null == className || null == methodName)
9596
{
@@ -121,7 +122,7 @@ public Method run()
121122
});
122123
}
123124

124-
public static Method[] getMethods(final String className)
125+
static Method[] getMethods(final String className)
125126
{
126127
if (null == className)
127128
{
@@ -153,7 +154,7 @@ public Method[] run()
153154
});
154155
}
155156

156-
public static Integer getStaticInt(final String className, final String fieldName)
157+
static Integer getStaticInt(final String className, final String fieldName)
157158
{
158159
return AccessController.doPrivileged(new PrivilegedAction<Integer>()
159160
{
@@ -188,18 +189,18 @@ public Integer run()
188189
});
189190
}
190191

191-
public static Integer getStaticIntOrDefault(final String className, final String fieldName, int defaultValue)
192+
static Integer getStaticIntOrDefault(final String className, final String fieldName, int defaultValue)
192193
{
193194
Integer value = getStaticInt(className, fieldName);
194195
return null == value ? defaultValue : value.intValue();
195196
}
196197

197-
public static Object invokeGetter(final Object obj, final Method method)
198+
static Object invokeGetter(final Object obj, final Method method)
198199
{
199200
return invokeMethod(obj, method);
200201
}
201202

202-
public static Object invokeMethod(final Object obj, final Method method, final Object... args)
203+
static Object invokeMethod(final Object obj, final Method method, final Object... args)
203204
{
204205
return AccessController.doPrivileged(new PrivilegedAction<Object>()
205206
{
@@ -221,7 +222,7 @@ public Object run()
221222
});
222223
}
223224

224-
public static void invokeSetter(final Object obj, final Method method, final Object arg)
225+
static void invokeSetter(final Object obj, final Method method, final Object arg)
225226
{
226227
invokeMethod(obj, method, arg);
227228
}

tls/src/main/jdk1.5/org/bouncycastle/jsse/provider/IDNUtil.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
import java.lang.reflect.Method;
44

5-
import org.bouncycastle.tls.ReflectionUtil;
6-
75
public class IDNUtil
86
{
97
public static final int ALLOW_UNASSIGNED;

tls/src/main/jdk1.5/org/bouncycastle/jsse/provider/KeyStoreUtil.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
import java.security.NoSuchAlgorithmException;
88
import java.security.UnrecoverableKeyException;
99

10-
import org.bouncycastle.tls.ReflectionUtil;
11-
1210
abstract class KeyStoreUtil
1311
{
1412
private static final Method getProtectionAlgorithm;

tls/src/main/jdk1.5/org/bouncycastle/jsse/provider/PKIXUtil.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
import java.security.cert.X509Certificate;
66
import java.util.Map;
77

8-
import org.bouncycastle.tls.ReflectionUtil;
9-
108
abstract class PKIXUtil
119
{
1210
private static final Class<?> pkixRevocationCheckerClass;

tls/src/main/jdk1.5/org/bouncycastle/jsse/provider/SSLEngineUtil.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import org.bouncycastle.jsse.BCExtendedSSLSession;
1010
import org.bouncycastle.jsse.BCSSLEngine;
1111
import org.bouncycastle.jsse.BCSSLParameters;
12-
import org.bouncycastle.tls.ReflectionUtil;
1312

1413
abstract class SSLEngineUtil
1514
{

tls/src/main/jdk1.5/org/bouncycastle/jsse/provider/SSLParametersUtil.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import org.bouncycastle.jsse.BCSNIServerName;
1111
import org.bouncycastle.jsse.BCSSLParameters;
1212
import org.bouncycastle.jsse.java.security.BCAlgorithmConstraints;
13-
import org.bouncycastle.tls.ReflectionUtil;
1413

1514
abstract class SSLParametersUtil
1615
{

tls/src/main/jdk1.5/org/bouncycastle/jsse/provider/SSLSessionUtil.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import javax.net.ssl.SSLSession;
77

88
import org.bouncycastle.jsse.BCExtendedSSLSession;
9-
import org.bouncycastle.tls.ReflectionUtil;
109

1110
abstract class SSLSessionUtil
1211
{

tls/src/main/jdk1.5/org/bouncycastle/jsse/provider/SSLSocketUtil.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
import org.bouncycastle.jsse.BCExtendedSSLSession;
1616
import org.bouncycastle.jsse.BCSSLParameters;
1717
import org.bouncycastle.jsse.BCSSLSocket;
18-
import org.bouncycastle.tls.ReflectionUtil;
1918

2019
abstract class SSLSocketUtil
2120
{

tls/src/main/jdk1.5/org/bouncycastle/jsse/provider/X509TrustManagerUtil.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
import org.bouncycastle.jcajce.util.JcaJceHelper;
1010
import org.bouncycastle.jsse.BCX509ExtendedTrustManager;
11-
import org.bouncycastle.tls.ReflectionUtil;
1211

1312
abstract class X509TrustManagerUtil
1413
{

tls/src/main/jdk1.5/org/bouncycastle/tls/crypto/impl/jcajce/PrivateKeyUtil.java

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,18 @@
11
package org.bouncycastle.tls.crypto.impl.jcajce;
22

3-
import java.lang.reflect.Method;
43
import java.security.PrivateKey;
54

6-
import org.bouncycastle.tls.ReflectionUtil;
5+
import javax.security.auth.Destroyable;
76

87
abstract class PrivateKeyUtil
98
{
10-
private static final Method destroy;
11-
12-
static
13-
{
14-
Method[] methods = ReflectionUtil.getMethods("java.security.PrivateKey");
15-
16-
destroy = ReflectionUtil.findMethod(methods, "destroy");
17-
}
18-
199
static void destroy(PrivateKey privateKey)
2010
{
21-
if (destroy != null)
11+
if (privateKey instanceof Destroyable)
2212
{
2313
try
2414
{
25-
ReflectionUtil.invokeMethod(privateKey, destroy);
15+
((Destroyable)privateKey).destroy();
2616
}
2717
catch (Exception e)
2818
{

0 commit comments

Comments
 (0)