01: package org.bouncycastle.bcpg.sig;
02:
03: import org.bouncycastle.bcpg.SignatureSubpacket;
04: import org.bouncycastle.bcpg.SignatureSubpacketTags;
05:
06: /**
07: * packet giving the User ID of the signer.
08: */
09: public class SignerUserID extends SignatureSubpacket {
10: private static byte[] userIDToBytes(String id) {
11: byte[] idData = new byte[id.length()];
12:
13: for (int i = 0; i != id.length(); i++) {
14: idData[i] = (byte) id.charAt(i);
15: }
16:
17: return idData;
18: }
19:
20: public SignerUserID(boolean critical, byte[] data) {
21: super (SignatureSubpacketTags.SIGNER_USER_ID, critical, data);
22: }
23:
24: public SignerUserID(boolean critical, String userID) {
25: super (SignatureSubpacketTags.SIGNER_USER_ID, critical,
26: userIDToBytes(userID));
27: }
28:
29: public String getID() {
30: char[] chars = new char[data.length];
31:
32: for (int i = 0; i != chars.length; i++) {
33: chars[i] = (char) (data[i] & 0xff);
34: }
35:
36: return new String(chars);
37: }
38: }
|