org.bouncycastle.pqc.jcajce.provider.util.SpecUtil Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bcprov-jdk15to18 Show documentation
Show all versions of bcprov-jdk15to18 Show documentation
The Bouncy Castle Crypto package is a Java implementation of cryptographic algorithms. This jar contains JCE provider and lightweight API for the Bouncy Castle Cryptography APIs for JDK 1.5 to JDK 1.8.
package org.bouncycastle.pqc.jcajce.provider.util;
import java.lang.reflect.Method;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.security.spec.AlgorithmParameterSpec;
public class SpecUtil
{
private static Class[] NO_PARAMS = new Class[0];
private static Object[] NO_ARGS = new Object[0];
public static String getNameFrom(final AlgorithmParameterSpec paramSpec)
{
return (String)AccessController.doPrivileged(new PrivilegedAction()
{
public Object run()
{
try
{
Method m = paramSpec.getClass().getMethod("getName", NO_PARAMS);
return m.invoke(paramSpec, NO_ARGS);
}
catch (Exception e)
{
// ignore - maybe log?
}
return null;
}
});
}
}