public void checkCertificate(String pathToCert){
File certFile = new File(pathToCert);
if (!certFile.exists())
throw new PAPCertificateException("Certificate file '"+pathToCert+"' does not exist!");
if (!certFile.canRead())
throw new PAPCertificateException("Certificate file '"+pathToCert+"' is not readable!");
X509Certificate serviceCert = null;
try {
FileInputStream fis = new FileInputStream(certFile);
serviceCert = (X509Certificate) certificateFactory.generateCertificate( fis );
if (serviceCert == null)
throw new PAPCertificateException("Certificate could not be generated!");
serviceCert.checkValidity();
} catch ( FileNotFoundException e ) {
throw new PAPCertificateException("Certificate file '"+pathToCert+"' does not exist!");
} catch ( CertificateExpiredException e ) {
throw new PAPCertificateException("Certificate '"+pathToCert+"' has expired!",e);
} catch ( CertificateNotYetValidException e ) {
throw new PAPCertificateException("Certificate '"+pathToCert+"' isn't yet valid!",e);
} catch ( CertificateException e ) {
throw new PAPCertificateException("Error parsing certificate file '"+pathToCert+"': "+ e.getMessage(),e);
}
}