List of usage examples for java.security SignatureException getCause
public synchronized Throwable getCause()
From source file:com.xinferin.licensing.LicenceGenerator.java
/** * Signs the data and returns the signature. * @param toBeSigned Data to be signed//from ww w . ja va2s.c o m * @return byte[] Signature * @throws Exception */ public byte[] signData(byte[] toBeSigned) throws Exception { try { if (privateKey == null) initialisePrivateKey(); Signature signatureInstance = Signature.getInstance("SHA1withRSA"); signatureInstance.initSign(privateKey); signatureInstance.update(toBeSigned); return signatureInstance.sign(); } catch (NoSuchAlgorithmException ex) { throw new Exception("The SHA1withRSA algorithm was not found. " + ex.getCause()); } catch (InvalidKeyException in) { throw new Exception("Invalid key returned from database. " + in.getCause()); } catch (SignatureException se) { throw new Exception("No signature instance can be created. " + se.getCause()); } }