01: package org.bouncycastle.bcpg;
02:
03: import java.io.IOException;
04:
05: import org.bouncycastle.util.Strings;
06:
07: /**
08: * Basic type for a user ID packet.
09: */
10: public class UserIDPacket extends ContainedPacket {
11: private byte[] idData;
12:
13: public UserIDPacket(BCPGInputStream in) throws IOException {
14: idData = new byte[in.available()];
15: in.readFully(idData);
16: }
17:
18: public UserIDPacket(String id) {
19: this .idData = Strings.toUTF8ByteArray(id);
20: }
21:
22: public String getID() {
23: return Strings.fromUTF8ByteArray(idData);
24: }
25:
26: public void encode(BCPGOutputStream out) throws IOException {
27: out.writePacket(USER_ID, idData, true);
28: }
29: }
|