File tree Expand file tree Collapse file tree 2 files changed +60
-0
lines changed
prov/src/main/java/org/bouncycastle Expand file tree Collapse file tree 2 files changed +60
-0
lines changed Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff line change 55import java .security .PrivilegedAction ;
66import java .security .spec .AlgorithmParameterSpec ;
77
8+ /**
9+ * @deprecated use org.bouncycastle.jcajce.util.SpecUtil
10+ */
11+ @ Deprecated
812public class SpecUtil
913{
1014 private static Class [] NO_PARAMS = new Class [0 ];
You can’t perform that action at this time.
0 commit comments