public static void sign(File jsrFile,PrivateKey privateKey,X509Certificate[] certificateChain,SignatureType signatureType,String signatureName,String signer,DigestType digestType,String tsaUrl,Provider provider) throws IOException, CryptoException {
  File tmpFile=File.createTempFile("kse","tmp");
  tmpFile.deleteOnExit();
  sign(jsrFile,tmpFile,privateKey,certificateChain,signatureType,signatureName,signer,digestType,tsaUrl,provider);
  CopyUtil.copyClose(new FileInputStream(tmpFile),new FileOutputStream(jsrFile));
  tmpFile.delete();
}

public static void sign ( File jsrFile , PrivateKey privateKey , X509Certificate [ ] certificateChain , SignatureType signatureType , String signatureName , String signer , DigestType digestType , String tsaUrl , Provider provider ) throws IOException , CryptoException { File tmpFile = File . createTempFile ( "kse" , "tmp" ) ; tmpFile . deleteOnExit ( ) ; sign ( jsrFile , tmpFile , privateKey , certificateChain , signatureType , signatureName , signer , digestType , tsaUrl , provider ) ; CopyUtil . copyClose ( new FileInputStream ( tmpFile ) , new FileOutputStream ( jsrFile ) ) ; tmpFile . delete ( ) ; }
sign a jar file overwriting it with the signed jar .
