throws InvalidKeySpecException, NoSuchAlgorithmException, IOException{
KeyFactory keyFactory = KeyFactory.getInstance("RSA");
KeySpec keySpec = null;
PEMReader pr = new PEMReader(encodedPrivateKey);
if(PEMReader.PRIVATE_PKCS1_MARKER.equals(pr.getBeginMarker())){
keySpec = (new PKCS1EncodedKeySpec(pr.getDerBytes())).getKeySpec();
}else if(PEMReader.PRIVATE_PKCS8_MARKER.equals(pr.getBeginMarker())){
keySpec = new PKCS8EncodedKeySpec(pr.getDerBytes());
}
this.privateKey = keyFactory.generatePrivate(keySpec);
}