List of usage examples for java.security InvalidKeyException initCause
public synchronized Throwable initCause(Throwable cause)
From source file:org.ejbca.core.protocol.cmp.CrmfRequestMessage.java
private PublicKey getPublicKey(final SubjectPublicKeyInfo subjectPKInfo, final String provider) throws NoSuchAlgorithmException, NoSuchProviderException, InvalidKeyException { try {//from w w w. j a v a2 s. c o m final X509EncodedKeySpec xspec = new X509EncodedKeySpec(new DERBitString(subjectPKInfo).getBytes()); final AlgorithmIdentifier keyAlg = subjectPKInfo.getAlgorithm(); return KeyFactory.getInstance(keyAlg.getAlgorithm().getId(), provider).generatePublic(xspec); } catch (java.security.spec.InvalidKeySpecException e) { final InvalidKeyException newe = new InvalidKeyException("Error decoding public key."); newe.initCause(e); throw newe; } catch (IOException e) { final InvalidKeyException newe = new InvalidKeyException("Error decoding public key."); newe.initCause(e); throw newe; } }