Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public OpenPGPKeyReader(OpenPGPImplementation implementation, OpenPGPPolicy poli
public OpenPGPCertificate parseCertificate(String armored)
throws IOException
{
OpenPGPCertificate certificate = parseCertificateOrKey(armored);
OpenPGPCertificate certificate = parseKeyOrCertificate(armored);
if (certificate instanceof OpenPGPKey)
{
throw new IOException("Could not parse OpenPGPCertificate: Is OpenPGPKey.");
Expand All @@ -67,7 +67,7 @@ public OpenPGPCertificate parseCertificate(String armored)
public OpenPGPCertificate parseCertificate(InputStream inputStream)
throws IOException
{
OpenPGPCertificate certificate = parseCertificateOrKey(inputStream);
OpenPGPCertificate certificate = parseKeyOrCertificate(inputStream);
if (certificate instanceof OpenPGPKey)
{
throw new IOException("Could not parse OpenPGPCertificate: Is OpenPGPKey.");
Expand All @@ -85,7 +85,7 @@ public OpenPGPCertificate parseCertificate(InputStream inputStream)
public OpenPGPCertificate parseCertificate(byte[] bytes)
throws IOException
{
OpenPGPCertificate certificate = parseCertificateOrKey(bytes);
OpenPGPCertificate certificate = parseKeyOrCertificate(bytes);
if (certificate instanceof OpenPGPKey)
{
throw new IOException("Could not parse OpenPGPCertificate: Is OpenPGPKey.");
Expand All @@ -99,11 +99,14 @@ public OpenPGPCertificate parseCertificate(byte[] bytes)
* @param armored ASCII armored string
* @return parsed certificate or key
* @throws IOException if the key or certificate cannot be parsed
*
* @deprecated use {@link #parseKeyOrCertificate(String)} instead.
*/
@Deprecated
public OpenPGPCertificate parseCertificateOrKey(String armored)
throws IOException
{
return parseCertificateOrKey(Strings.toUTF8ByteArray(armored));
return parseKeyOrCertificate(armored);
}

/**
Expand All @@ -112,11 +115,14 @@ public OpenPGPCertificate parseCertificateOrKey(String armored)
* @param inputStream input stream containing the ASCII armored or binary key or certificate
* @return parsed certificate or key
* @throws IOException if the key or certificate cannot be parsed
*
* @deprecated use {@link #parseKeyOrCertificate(InputStream)} instead.
*/
@Deprecated
public OpenPGPCertificate parseCertificateOrKey(InputStream inputStream)
throws IOException
{
return parseCertificateOrKey(Streams.readAll(inputStream));
return parseKeyOrCertificate(inputStream);
}

/**
Expand All @@ -125,9 +131,51 @@ public OpenPGPCertificate parseCertificateOrKey(InputStream inputStream)
* @param bytes ASCII armored or binary key or certificate
* @return parsed certificate or key
* @throws IOException if the key or certificate cannot be parsed
*
* @deprecated use {@link #parseKeyOrCertificate(byte[])} instead.
*/
@Deprecated
public OpenPGPCertificate parseCertificateOrKey(byte[] bytes)
throws IOException
{
return parseKeyOrCertificate(bytes);
}

/**
* Parse a single {@link OpenPGPCertificate} or {@link OpenPGPKey} from an ASCII armored string.
*
* @param armored ASCII armored string
* @return parsed certificate or key
* @throws IOException if the key or certificate cannot be parsed
*/
public OpenPGPCertificate parseKeyOrCertificate(String armored)
throws IOException
{
return parseKeyOrCertificate(Strings.toUTF8ByteArray(armored));
}

/**
* Parse a single {@link OpenPGPCertificate} or {@link OpenPGPKey} from an {@link InputStream}.
*
* @param inputStream input stream containing the ASCII armored or binary key or certificate
* @return parsed certificate or key
* @throws IOException if the key or certificate cannot be parsed
*/
public OpenPGPCertificate parseKeyOrCertificate(InputStream inputStream)
throws IOException
{
return parseKeyOrCertificate(Streams.readAll(inputStream));
}

/**
* Parse a single {@link OpenPGPCertificate} or {@link OpenPGPKey} from bytes.
*
* @param bytes ASCII armored or binary key or certificate
* @return parsed certificate or key
* @throws IOException if the key or certificate cannot be parsed
*/
public OpenPGPCertificate parseKeyOrCertificate(byte[] bytes)
throws IOException
{
ByteArrayInputStream bIn = new ByteArrayInputStream(bytes);
InputStream decoderStream = PGPUtil.getDecoderStream(bIn);
Expand Down