Package codec.pkcs7

Examples of codec.pkcs7.Signer


     * @param safe
     *                the SafeContents to be added to the AuthenticatedSafe
     */
    public void addSafeContents(SafeContents safe) throws IOException,
      ASN1Exception {
  ContentInfo cinfo = makeData(safe);
  add(cinfo);
    }
View Full Code Here


     *                the PBE algorithm to be used
     */
    public void addSafeContents(SafeContents safe, char[] passwd,
      String algorithm) throws IOException, ASN1Exception,
      GeneralSecurityException {
  ContentInfo cinfo = makeEncryptedData(safe, passwd, algorithm);
  add(cinfo);
    }
View Full Code Here

     */
    public void addSafeContents(SafeContents safe, SecretKey key,
      String algorithm, AlgorithmParameters params,
      java.security.cert.X509Certificate[] cert) throws IOException,
      ASN1Exception, BadNameException, GeneralSecurityException {
  ContentInfo cinfo = makeEnvelopedData(safe, key, algorithm, params,
    cert);
  add(cinfo);
    }
View Full Code Here

     */
    public int[] getProtectionMode() {
  int[] proMode;
  proMode = new int[this.size()];
  for (int i = 0; i < this.size(); i++) {
      ContentInfo cinfo = (ContentInfo) this.get(i);
      if (cinfo.getContent() instanceof Data) {
    proMode[i] = NO_PROTECTION;
      } else if (cinfo.getContent() instanceof EncryptedData) {
    proMode[i] = PASSWORD_PROTECTION;
      } else if (cinfo.getContent() instanceof EnvelopedData) {
    proMode[i] = PUBLIC_KEY_PROTECTION;
      } else {
    throw new IllegalStateException("Illegal protection mode: "
      + proMode[i]);
      }
View Full Code Here

     */
    public SafeContents getSafeContents(int i) throws IOException,
      ASN1Exception {
  byte[] encodedData;
  ByteArrayInputStream bais;
  ContentInfo cinfo = (ContentInfo) this.get(i);
  if (cinfo.getContent() instanceof Data) {
      encodedData = ((Data) cinfo.getContent()).getByteArray();
  } else {
      System.out
        .println("This bag is either password or public-key protected.");
      return null;
  }
View Full Code Here

    public SafeContents getSafeContents(int i, java.security.PrivateKey key,
      java.security.cert.X509Certificate cert) throws IOException,
      ASN1Exception, GeneralSecurityException, NoSuchElementException {
  ByteArrayInputStream bais;

  ContentInfo cinfo = (ContentInfo) this.get(i);
  EnvelopedData envData = null;
  if (cinfo.getContent() instanceof EnvelopedData) {
      envData = (EnvelopedData) cinfo.getContent();
  } else {
      System.out
        .println("This bag is password protected or not protected at all.");
      return null;
  }
View Full Code Here

  ByteArrayOutputStream baos = new ByteArrayOutputStream();
  DEREncoder encoder = new DEREncoder(baos);
  safe.encode(encoder);
  data = new Data(baos.toByteArray());
  baos.close();
  ContentInfo cInfo = new ContentInfo(data);
  return cInfo;
    }
View Full Code Here

  // make an EncryptedData and put it in a ContentInfo
  EncryptedData ecd = new EncryptedData(algorithm, pbekey, params);
  ecd.setData(bais);
  bais.close();

  ContentInfo cinfo = new ContentInfo();
  cinfo.setContent(new codec.asn1.ASN1ObjectIdentifier(
    "1.2.840.113549.1.7.6"), ecd);
  return cinfo;
    }
View Full Code Here

  bais.close();
  for (int i = 0; i < cert.length; i++) {
      edata.addRecipient(cert[i]);
  }

  ContentInfo cinfo = new ContentInfo(edata);
  return cinfo;
    }
View Full Code Here

     *
     * @return Contentinfo with contentType Data.
     */
    private ContentInfo makeData(SafeContents safe) throws IOException,
      ASN1Exception {
  Data data = null;
  ByteArrayOutputStream baos = new ByteArrayOutputStream();
  DEREncoder encoder = new DEREncoder(baos);
  safe.encode(encoder);
  data = new Data(baos.toByteArray());
  baos.close();
  ContentInfo cInfo = new ContentInfo(data);
  return cInfo;
    }
View Full Code Here

TOP

Related Classes of codec.pkcs7.Signer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.