{
passwordFinder = null;
}
Reader reader = null;
PEMReader pemReader = null;
try
{
reader = new FileReader(pemFile);
pemReader = new PEMReader(reader, passwordFinder);
Object pemObject = pemReader.readObject();
if (!checkPemObjectIsOfAllowedTypes(pemObject, expectedInterfaces))
{
throw new IllegalStateException("File " + pemFile + " does not provide a object of the required type."
+ " Read an object of class " + pemObject.getClass().getName()
+ " whilst expecting an implementation of one of the following : " + Arrays.asList(expectedInterfaces));
}
return pemObject;
}
catch(PEMException e)
{
_logger.log(Level.SEVERE, "Unable to read PEM object. Perhaps you need the unlimited strength libraries in <java-home>/jre/lib/security/ ?", e);
throw new IllegalStateException("Unable to read PEM object from file " + pemFile, e);
}
catch (IOException e)
{
throw new RuntimeException("Unable to read PEM object from file " + pemFile, e);
}
finally
{
if(pemReader != null)
{
try
{
pemReader.close();
}
catch(IOException e)
{
_logger.log(Level.SEVERE, "Couldn't close PEM reader", e);
}