java.lang.Object
org.bzdev.net.PemEncoder
PEM Encoder class.
This class will encode data using the PEM format described in
RFC 7468 and RFC 1421. The PEM-encoded data may be preceded
or followed by headers that consist of a key, followed by a
colon, followed by a value.
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionPemEncoder
(Appendable out) Constructor.PemEncoder
(Appendable out, PemEncoder.EOL eol) Constructor specifying the end-of-line sequence. -
Method Summary
-
Constructor Details
-
PemEncoder
Constructor. When called directly, the EOL sequence will be CRLF.- Parameters:
out
- theAppendable
used for output
-
PemEncoder
Constructor specifying the end-of-line sequence.- Parameters:
out
- theAppendable
used for outputeol
-PemEncoder.EOL.CRLF
if lines are terminated with a carriage return followed by a line feed;PemEncoder.EOL.CR
if lines are terminated with a carriage return;PemEncoder.EOL.LF
if lines are terminated with a line feed
-
-
Method Details
-
addHeader
Add a header. Names must consist of only letters, digits, underscores, or a minus. Values must contain only a single line of text without any new-line characters or any character denoting a vertical change in position in the text. In both cases, the characters should be those in the US ASCII character set.Note that RFC 7468 allows data to be inserted before the encapsulated encoding.
- Parameters:
key
- the name of the headervalue
- the value of the header- Throws:
IOException
-
encode
public void encode(String type, byte[] data) throws IOException, IllegalArgumentException, NullPointerException Encode data using PEM format.- Parameters:
type
- the type of the datadata
- the data to be encoded- Throws:
IOException
- if an IO error occursNullPointerException
- if an argument is nullIllegalArgumentException
- if the first argument contains only whitespace or if it contains a minus
-