|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.mindbright.util.ASCIIArmour
Encode/decode binary data to/from ASCII. Typical output looks like this:
-----BEGIN RSA PRIVATE KEY----- Proc-Type: 4,ENCRYPTED DEK-Info: DES-EDE3-CBC,A68BCF5FE86D7652 ZlH6zo6nf8mBxFPGkaUkfXtzgUDTKmUYAUO24eXkoV/fbg+IPOtbPdJa7PKlhQTs 2Ycjb5Gk/ZVwGZaqa01roRSmfGDHL2ZSVrXHHMxDxCn1aU+rOFHcUA== -----END RSA PRIVATE KEY-----
Base64
Field Summary | |
static int |
DEFAULT_LINE_LENGTH
Default length of encoded lines |
Constructor Summary | |
ASCIIArmour(java.lang.String headerLinePrePostFix)
Creates an instance ready for decoding |
|
ASCIIArmour(java.lang.String headerLine,
java.lang.String tailLine)
Creates an instance ready for encoding or decoding |
|
ASCIIArmour(java.lang.String headerLine,
java.lang.String tailLine,
boolean blankHeaderSep,
int lineLen)
Creates an instance ready for encoding or decoding |
Method Summary | |
byte[] |
decode(byte[] data)
Decode the given array. |
byte[] |
decode(byte[] data,
int offset,
int length)
Decode the given array. |
byte[] |
decode(java.io.InputStream in)
Decode data from the given InputStream. |
byte[] |
encode(byte[] data)
Encode data and return the encoded ascii blob |
byte[] |
encode(byte[] data,
int offset,
int length)
Encode data and return the encoded ascii blob |
void |
encode(java.io.OutputStream out,
byte[] data)
Encode data and print it to the given OutputStream |
void |
encode(java.io.OutputStream out,
byte[] data,
int off,
int len)
Encode data and print it to the given OutputStream |
java.lang.String |
getHeaderField(java.lang.String headerName)
Get one header field |
java.util.Hashtable |
getHeaderFields()
Get the header fields |
java.lang.String |
getHeaderLine()
Get the header line |
java.lang.String |
printHeaders()
Print the header fields to a String. |
void |
setBlankHeaderSep(boolean value)
Control if a blank line should follow the headers |
void |
setCanonicalLineEnd(boolean value)
Set if canoncial end of line markings should be used or not |
void |
setHeaderField(java.lang.String headerName,
java.lang.String value)
Set a header field |
void |
setHeaderLine(java.lang.String headerLine)
Set the header line |
void |
setLineLength(int lineLen)
Set length of encoded lines |
void |
setTailLine(java.lang.String tailLine)
Set the tailing line |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int DEFAULT_LINE_LENGTH
Constructor Detail |
public ASCIIArmour(java.lang.String headerLine, java.lang.String tailLine, boolean blankHeaderSep, int lineLen)
headerLine
- the first line in the filetailLine
- the last line in the fileblankHeaderSep
- true if a blank line should follow the
header lineslineLen
- maximum length of generated linespublic ASCIIArmour(java.lang.String headerLine, java.lang.String tailLine)
headerLine
- the first line in the filetailLine
- the last line in the filepublic ASCIIArmour(java.lang.String headerLinePrePostFix)
headerLinePrePostFix
- start of header and tail lineMethod Detail |
public void setCanonicalLineEnd(boolean value)
value
- true means CRLF which false means LFpublic void setBlankHeaderSep(boolean value)
public void setLineLength(int lineLen)
public java.lang.String getHeaderLine()
public void setHeaderLine(java.lang.String headerLine)
public void setTailLine(java.lang.String tailLine)
public java.util.Hashtable getHeaderFields()
public java.lang.String getHeaderField(java.lang.String headerName)
public void setHeaderField(java.lang.String headerName, java.lang.String value)
public byte[] encode(byte[] data)
data
- the array which will be encodedpublic byte[] encode(byte[] data, int offset, int length)
data
- array in which the data can be foundoffset
- offset in array where data beginslength
- how many bytes the data consists ofpublic void encode(java.io.OutputStream out, byte[] data) throws java.io.IOException
out
- where to send the encoded blobdata
- the array which will be encoded
java.io.IOException
public void encode(java.io.OutputStream out, byte[] data, int off, int len) throws java.io.IOException
out
- where to send the encoded blobdata
- array in which the data can be foundoff
- offset in array where data beginslen
- how many bytes the data consists of
java.io.IOException
public byte[] decode(byte[] data)
data
- array containg the ascii blob to decode
public byte[] decode(byte[] data, int offset, int length)
data
- array containg the ascii blob to decodeoffset
- offset in array where data beginslength
- how many bytes the data consists of
public byte[] decode(java.io.InputStream in) throws java.io.IOException
in
- stream to read data from
java.io.IOException
public java.lang.String printHeaders()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |