I need help passing a Java class as an argument to a specific Java method.
The method in question is getKeySpec()
from the java.security.KeyFactory
class:
getKeySpec(Key key, Class<T> keySpec)
In the NativeScript Typings, the signature for this method is:
public getKeySpec(param0: java.security.Key, param1: java.lang.Class<any>): java.security.spec.KeySpec;
I am unsure of how to pass a java.lang.Class<any>
to this method specifically when I want to use
java.security.spec.X509EncodedKeySpec
.
The current challenge lies within my TypeScript code, which fails at the point of calling getKeySpec()
.
function getPublicKey(keyPair: java.security.KeyPair): string {
const kf = java.security.KeyFactory.getInstance("RSA");
let pubKeySpec = kf.getKeySpec(keyPair.getPublic(), java.security.spec.X509EncodedKeySpec);
return pubKeySpec.getEncoded();
}