home *** CD-ROM | disk | FTP | other *** search
/ Symantec Visual Cafe for Java 2.5 / symantec-visual-cafe-2.5-database-dev-edition.iso / VPage / Java.bin / CLASSES.ZIP / sun / security / pkcs / ContentInfo.class (.txt) next >
Encoding:
Java Class File  |  1997-07-08  |  3.2 KB  |  87 lines

  1. package sun.security.pkcs;
  2.  
  3. import java.io.IOException;
  4. import sun.security.util.DerInputStream;
  5. import sun.security.util.DerOutputStream;
  6. import sun.security.util.DerValue;
  7. import sun.security.util.ObjectIdentifier;
  8.  
  9. public class ContentInfo {
  10.    private static int[] pkcs7 = new int[]{1, 2, 840, 1113549, 1, 7};
  11.    private static int[] data = new int[]{1, 2, 840, 1113549, 1, 7, 1};
  12.    private static int[] sdata = new int[]{1, 2, 840, 1113549, 1, 7, 2};
  13.    private static int[] edata = new int[]{1, 2, 840, 1113549, 1, 7, 3};
  14.    private static int[] sedata = new int[]{1, 2, 840, 1113549, 1, 7, 4};
  15.    private static int[] ddata = new int[]{1, 2, 840, 1113549, 1, 7, 5};
  16.    private static int[] crdata = new int[]{1, 2, 840, 1113549, 1, 7, 6};
  17.    public static final ObjectIdentifier PKCS7_OID;
  18.    public static final ObjectIdentifier DATA_OID;
  19.    public static final ObjectIdentifier SIGNED_DATA_OID;
  20.    public static final ObjectIdentifier ENVELOPED_DATA_OID;
  21.    public static final ObjectIdentifier SIGNED_AND_ENVELOPED_DATA_OID;
  22.    public static final ObjectIdentifier DIGESTED_DATA_OID;
  23.    public static final ObjectIdentifier ENCRYPTED_DATA_OID;
  24.    ObjectIdentifier contentType;
  25.    DerValue content;
  26.  
  27.    public ContentInfo(ObjectIdentifier var1, DerValue var2) {
  28.       this.contentType = var1;
  29.       this.content = var2;
  30.    }
  31.  
  32.    public ContentInfo(byte[] var1) {
  33.       DerValue var2 = new DerValue((byte)4, var1);
  34.       this.contentType = DATA_OID;
  35.       this.content = var2;
  36.    }
  37.  
  38.    public ContentInfo(DerInputStream var1) throws IOException, ParsingException {
  39.       DerValue[] var2 = var1.getSequence(2);
  40.       DerValue var3 = var2[0];
  41.       DerInputStream var4 = new DerInputStream(var3.toByteArray());
  42.       this.contentType = var4.getOID();
  43.       this.content = var2[1];
  44.    }
  45.  
  46.    public DerValue getContent() {
  47.       return this.content;
  48.    }
  49.  
  50.    public byte[] getData() throws IOException {
  51.       if (this.contentType.equals(DATA_OID)) {
  52.          return this.content.getOctetString();
  53.       } else {
  54.          throw new IOException("content type is not DATA: " + this.contentType);
  55.       }
  56.    }
  57.  
  58.    public void encode(DerOutputStream var1) throws IOException {
  59.       DerOutputStream var2 = new DerOutputStream();
  60.       var2.putOID(this.contentType);
  61.       this.content.emit(var2);
  62.       var1.write((byte)48, var2);
  63.    }
  64.  
  65.    public byte[] getContentBytes() throws IOException {
  66.       DerInputStream var1 = new DerInputStream(this.content.toByteArray());
  67.       return var1.getOctetString();
  68.    }
  69.  
  70.    public String toString() {
  71.       String var1 = "";
  72.       var1 = var1 + "Content Info Sequence\n\tContent type: " + this.contentType + "\n";
  73.       var1 = var1 + "\tContent: " + this.content;
  74.       return var1;
  75.    }
  76.  
  77.    static {
  78.       PKCS7_OID = new ObjectIdentifier(pkcs7);
  79.       DATA_OID = new ObjectIdentifier(data);
  80.       SIGNED_DATA_OID = new ObjectIdentifier(sdata);
  81.       ENVELOPED_DATA_OID = new ObjectIdentifier(edata);
  82.       SIGNED_AND_ENVELOPED_DATA_OID = new ObjectIdentifier(sedata);
  83.       DIGESTED_DATA_OID = new ObjectIdentifier(ddata);
  84.       ENCRYPTED_DATA_OID = new ObjectIdentifier(crdata);
  85.    }
  86. }
  87.