Clover coverage report - Maven Clover report
Coverage timestamp: Thu Jan 25 2007 11:17:27 IST
file stats: LOC: 66   Methods: 2
NCLOC: 53   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
Decrypt.java 83.3% 94.4% 100% 92.3%
coverage coverage
 1    package org.wiztools.wizcrypt;
 2   
 3    import java.io.UnsupportedEncodingException;
 4    import javax.crypto.NoSuchPaddingException;
 5   
 6    import java.security.NoSuchAlgorithmException;
 7    import java.security.InvalidKeyException;
 8   
 9    import java.io.FileInputStream;
 10    import java.io.FileOutputStream;
 11    import java.io.File;
 12    import java.io.IOException;
 13    import java.io.FileNotFoundException;
 14   
 15    import java.util.ResourceBundle;
 16   
 17    /**
 18    * Class to do the decryption using the WizCrypt naming convention (*.wiz).
 19    */
 20    public class Decrypt implements IProcess{
 21   
 22    private static final ResourceBundle rb = ResourceBundle.getBundle("org.wiztools.wizcrypt.wizcryptmsg");
 23   
 24    private CipherKey ce;
 25   
 26  2 public void init(final String keyStr)
 27    throws
 28    NoSuchAlgorithmException,
 29    UnsupportedEncodingException,
 30    InvalidKeyException,
 31    NoSuchPaddingException{
 32  2 ce = CipherKeyGen.getCipherKeyForDecrypt(keyStr);
 33    }
 34   
 35  3 public void process(final File file, final boolean forceOverwrite)
 36    throws FileNotFoundException,
 37    DestinationFileExistsException,
 38    PasswordMismatchException,
 39    IOException{
 40  3 FileInputStream fis = null;
 41  3 FileOutputStream fos = null;
 42  3 boolean canDelete = false;
 43  3 try{
 44  3 String path = file.getAbsolutePath();
 45  3 if(!path.endsWith(".wiz")){
 46  1 throw new FileNotFoundException(rb.getString("err.file.not.end.wiz")+path);
 47    }
 48  2 String newPath = path.replaceFirst(".wiz$", "");
 49  2 File outFile = new File(newPath);
 50  2 if(!forceOverwrite && outFile.exists()){
 51  0 throw new DestinationFileExistsException(
 52    rb.getString("err.destination.file.exists")+
 53    outFile.getAbsolutePath());
 54    }
 55  2 fis = new FileInputStream(file);
 56  2 fos = new FileOutputStream(outFile);
 57  2 WizCrypt.decrypt(fis, fos, ce);
 58  1 canDelete = true;
 59    } finally{
 60    // fos & fis will be closed by WizCrypt.decrypt() API
 61  3 if(canDelete){
 62  1 file.delete();
 63    }
 64    }
 65    }
 66    }