Skip to content

Commit 9b3216d

Browse files
committed
relocated class - added getContextFrom()
1 parent 7d2e736 commit 9b3216d

File tree

2 files changed

+60
-0
lines changed

2 files changed

+60
-0
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
package org.bouncycastle.jcajce.util;
2+
3+
import java.lang.reflect.Method;
4+
import java.security.AccessController;
5+
import java.security.PrivilegedAction;
6+
import java.security.spec.AlgorithmParameterSpec;
7+
8+
public class SpecUtil
9+
{
10+
private static Class[] NO_PARAMS = new Class[0];
11+
private static Object[] NO_ARGS = new Object[0];
12+
13+
public static String getNameFrom(final AlgorithmParameterSpec paramSpec)
14+
{
15+
return (String)AccessController.doPrivileged(new PrivilegedAction()
16+
{
17+
public Object run()
18+
{
19+
try
20+
{
21+
Method m = paramSpec.getClass().getMethod("getName", NO_PARAMS);
22+
23+
return m.invoke(paramSpec, NO_ARGS);
24+
}
25+
catch (Exception e)
26+
{
27+
// ignore - maybe log?
28+
}
29+
30+
return null;
31+
}
32+
});
33+
}
34+
35+
public static byte[] getContextFrom(final AlgorithmParameterSpec paramSpec)
36+
{
37+
return (byte[])AccessController.doPrivileged(new PrivilegedAction()
38+
{
39+
public Object run()
40+
{
41+
try
42+
{
43+
Method m = paramSpec.getClass().getMethod("getContext", NO_PARAMS);
44+
45+
return m.invoke(paramSpec, NO_ARGS);
46+
}
47+
catch (Exception e)
48+
{
49+
// ignore - maybe log?
50+
}
51+
52+
return null;
53+
}
54+
});
55+
}
56+
}

prov/src/main/java/org/bouncycastle/pqc/jcajce/provider/util/SpecUtil.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
import java.security.PrivilegedAction;
66
import java.security.spec.AlgorithmParameterSpec;
77

8+
/**
9+
* @deprecated use org.bouncycastle.jcajce.util.SpecUtil
10+
*/
11+
@Deprecated
812
public class SpecUtil
913
{
1014
private static Class[] NO_PARAMS = new Class[0];

0 commit comments

Comments
 (0)