home *** CD-ROM | disk | FTP | other *** search
- package sun.security.pkcs;
-
- import java.io.IOException;
- import sun.security.util.DerInputStream;
- import sun.security.util.DerOutputStream;
- import sun.security.util.DerValue;
- import sun.security.util.ObjectIdentifier;
-
- public class ContentInfo {
- private static int[] pkcs7 = new int[]{1, 2, 840, 1113549, 1, 7};
- private static int[] data = new int[]{1, 2, 840, 1113549, 1, 7, 1};
- private static int[] sdata = new int[]{1, 2, 840, 1113549, 1, 7, 2};
- private static int[] edata = new int[]{1, 2, 840, 1113549, 1, 7, 3};
- private static int[] sedata = new int[]{1, 2, 840, 1113549, 1, 7, 4};
- private static int[] ddata = new int[]{1, 2, 840, 1113549, 1, 7, 5};
- private static int[] crdata = new int[]{1, 2, 840, 1113549, 1, 7, 6};
- public static final ObjectIdentifier PKCS7_OID;
- public static final ObjectIdentifier DATA_OID;
- public static final ObjectIdentifier SIGNED_DATA_OID;
- public static final ObjectIdentifier ENVELOPED_DATA_OID;
- public static final ObjectIdentifier SIGNED_AND_ENVELOPED_DATA_OID;
- public static final ObjectIdentifier DIGESTED_DATA_OID;
- public static final ObjectIdentifier ENCRYPTED_DATA_OID;
- ObjectIdentifier contentType;
- DerValue content;
-
- public ContentInfo(ObjectIdentifier var1, DerValue var2) {
- this.contentType = var1;
- this.content = var2;
- }
-
- public ContentInfo(byte[] var1) {
- DerValue var2 = new DerValue((byte)4, var1);
- this.contentType = DATA_OID;
- this.content = var2;
- }
-
- public ContentInfo(DerInputStream var1) throws IOException, ParsingException {
- DerValue[] var2 = var1.getSequence(2);
- DerValue var3 = var2[0];
- DerInputStream var4 = new DerInputStream(var3.toByteArray());
- this.contentType = var4.getOID();
- this.content = var2[1];
- }
-
- public DerValue getContent() {
- return this.content;
- }
-
- public byte[] getData() throws IOException {
- if (this.contentType.equals(DATA_OID)) {
- return this.content.getOctetString();
- } else {
- throw new IOException("content type is not DATA: " + this.contentType);
- }
- }
-
- public void encode(DerOutputStream var1) throws IOException {
- DerOutputStream var2 = new DerOutputStream();
- var2.putOID(this.contentType);
- this.content.emit(var2);
- var1.write((byte)48, var2);
- }
-
- public byte[] getContentBytes() throws IOException {
- DerInputStream var1 = new DerInputStream(this.content.toByteArray());
- return var1.getOctetString();
- }
-
- public String toString() {
- String var1 = "";
- var1 = var1 + "Content Info Sequence\n\tContent type: " + this.contentType + "\n";
- var1 = var1 + "\tContent: " + this.content;
- return var1;
- }
-
- static {
- PKCS7_OID = new ObjectIdentifier(pkcs7);
- DATA_OID = new ObjectIdentifier(data);
- SIGNED_DATA_OID = new ObjectIdentifier(sdata);
- ENVELOPED_DATA_OID = new ObjectIdentifier(edata);
- SIGNED_AND_ENVELOPED_DATA_OID = new ObjectIdentifier(sedata);
- DIGESTED_DATA_OID = new ObjectIdentifier(ddata);
- ENCRYPTED_DATA_OID = new ObjectIdentifier(crdata);
- }
- }
-