Package codec.asn1

Examples of codec.asn1.ASN1T61String


     */
    public void setPrivateKey(PrivateKey key) throws InvalidKeyException {
  if (key == null)
      throw new NullPointerException("Key is null!");

  DERDecoder dec;

  clear();

  version_ = new ASN1Integer(VERSION);
  add(version_);

  algorithm_ = new AlgorithmIdentifier();
  add(algorithm_);

  encodedKey_ = new ASN1OctetString();
  add(encodedKey_);

  attributes_ = new ASN1SetOf(Attribute.class);
  add(new ASN1TaggedType(0, attributes_, false, true));

  try {
      dec = new DERDecoder(new ByteArrayInputStream(key.getEncoded()));

      decode(dec);
      dec.close();
  } catch (IOException e) {
      throw new InvalidKeyException("Caught IOException!");
  } catch (ASN1Exception e) {
      throw new InvalidKeyException("Bad encoding!");
  }
View Full Code Here


     * encodings.
     *
     * @return The raw key decoded according to DER.
     */
    public ASN1Type getDecodedRawKey() throws CorruptedCodeException {
  DERDecoder dec;
  ASN1Type raw;

  try {
      dec = new DERDecoder(new ByteArrayInputStream(encodedKey_
        .getByteArray()));

      raw = dec.readType();
      dec.close();

      return raw;
  } catch (ASN1Exception e) {
      throw new CorruptedCodeException("Cannot decode raw key!");
  } catch (IOException e) {
View Full Code Here

  this();

  try {
      ByteArrayInputStream bais = new ByteArrayInputStream(enc);

      decode(new DERDecoder(bais));
      bais.close();
  } catch (IOException e) {
      throw new ASN1Exception(e.getMessage());
  }
    }
View Full Code Here

     */
    public CertificationRequest(InputStream in) throws ASN1Exception,
      IOException {
  this();

  DERDecoder dec;

  dec = new DERDecoder(in);
  decode(dec);
  dec.close();
    }
View Full Code Here

  this();

  try {
      ByteArrayInputStream bais = new ByteArrayInputStream(cert);
      decode(new DERDecoder(bais));
      bais.close();
  } catch (Exception e) {
      throw new java.security.cert.CertificateEncodingException(e
        .getMessage());
  }
View Full Code Here

    public X509Certificate(InputStream in)
      throws java.security.cert.CertificateEncodingException {
  this();

  try {
      decode(new DERDecoder(in));
  } catch (Exception e) {
      throw new java.security.cert.CertificateEncodingException(e
        .getMessage());
  }
    }
View Full Code Here

  }
    }

    public void readExternal(ObjectInput s) throws IOException {
  try {
      decode(new DERDecoder((ObjectInputStream) s));
  } catch (ASN1Exception e) {
      throw new RuntimeException(e.toString());
  }
    }
View Full Code Here

     */
    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

    private ContentInfo makeEncryptedData(SafeContents safe, char[] pwd,
      String algorithm) throws IOException, ASN1Exception,
      GeneralSecurityException {
  ByteArrayOutputStream baos = new ByteArrayOutputStream();
  ByteArrayInputStream bais;
  DEREncoder encoder = new DEREncoder(baos);
  safe.encode(encoder);
  byte[] help = baos.toByteArray();

  // for ( int i = 0; i < help.length; i++)
  // System.out.print(help[i] + "\t");
View Full Code Here

      java.security.cert.X509Certificate[] cert) throws IOException,
      GeneralSecurityException, BadNameException, ASN1Exception {
  // BER encode the SafeBag
  ByteArrayOutputStream baos = new ByteArrayOutputStream();
  ByteArrayInputStream bais;
  DEREncoder encoder = new DEREncoder(baos);
  safe.encode(encoder);
  bais = new ByteArrayInputStream(baos.toByteArray());
  baos.close();

  // Make an envelopedData and put it in a ContentInfo
View Full Code Here

TOP

Related Classes of codec.asn1.ASN1T61String

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.