01: package org.bouncycastle.bcpg;
02:
03: import java.io.ByteArrayOutputStream;
04: import java.io.IOException;
05:
06: /**
07: * Basic type for a trust packet
08: */
09: public class TrustPacket extends ContainedPacket {
10: byte[] levelAndTrustAmount;
11:
12: public TrustPacket(BCPGInputStream in) throws IOException {
13: ByteArrayOutputStream bOut = new ByteArrayOutputStream();
14: int ch;
15:
16: while ((ch = in.read()) >= 0) {
17: bOut.write(ch);
18: }
19:
20: levelAndTrustAmount = bOut.toByteArray();
21: }
22:
23: public TrustPacket(int trustCode) {
24: this .levelAndTrustAmount = new byte[1];
25:
26: this .levelAndTrustAmount[0] = (byte) trustCode;
27: }
28:
29: public byte[] getLevelAndTrustAmount() {
30: return levelAndTrustAmount;
31: }
32:
33: public void encode(BCPGOutputStream out) throws IOException {
34: out.writePacket(TRUST, levelAndTrustAmount, true);
35: }
36: }
|