Example usage for org.bouncycastle.openssl PEMException PEMException

List of usage examples for org.bouncycastle.openssl PEMException PEMException

Introduction

In this page you can find the example usage for org.bouncycastle.openssl PEMException PEMException.

Prototype

public PEMException(String message, Exception underlying) 

Source Link

Usage

From source file:co.lqnt.lockbox.key.KeyFactory.java

License:Open Source License

/**
 * Parses PEM data and returns a specialized object.
 *
 * @param input The PEM data to read.// ww w. j av a 2  s .  c o  m
 *
 * @return The specialized object.
 * @throws PEMException If the PEM data is invalid.
 */
protected Object parsePemObject(final InputStream input) throws PEMException {
    PEMParser parser = this.pemParserFactory.create(input);
    Object pemObject;
    try {
        pemObject = parser.readObject();
    } catch (IOException e) {
        throw new PEMException("Unable to read PEM stream.", e);
    }

    if (null == pemObject) {
        throw new PEMException("No PEM data found.");
    }

    return pemObject;
}