Guest User

Untitled

a guest
Oct 18th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. public static RSAPublicKey getKey(String filename)
  2. throws Exception {
  3.  
  4. byte[] keyBytes = Files.readAllBytes(Paths.get(filename));
  5.  
  6. X509EncodedKeySpec spec =
  7. new X509EncodedKeySpec(keyBytes);
  8. KeyFactory kf = KeyFactory.getInstance("RSA");
  9. return (RSAPublicKey)kf.generatePublic(spec);
  10. }
  11.  
  12. RSAPublicKey pubKey = (RSAPublicKey) GeneraKeysRsa.getKey(file);
  13. CaviumRSAPublicKey key = (CaviumRSAPublicKey) pubKey;
  14.  
  15. ClassCastException: sun.security.rsa.RSAPublicKeyImpl cannot be cast to com.cavium.key.CaviumRSAPublicKey
Add Comment
Please, Sign In to add comment