Examples of ASN1Type


Examples of codec.asn1.ASN1Type

     *
     * @throws NoSuchElementException
     *                 if the content type is not {@link Data Data}.
     */
    public Data getData() throws NoSuchElementException {
  ASN1Type o;

  o = content_.getContent();

  if (o == null) {
      return null;
View Full Code Here

Examples of codec.asn1.ASN1Type

     * type {@link Data Data} and the content contained in it is not null.
     *
     * @return <code>true</code> if there is a payload.
     */
    public boolean hasData() {
  ASN1Type o;
  byte[] b;

  o = content_.getContent();

  if (o == null) {
View Full Code Here

Examples of codec.asn1.ASN1Type

     *
     * If the content type is <code>Data</code> then there is no problem
     * because we can simply grab the contents octets from it.
     */
    public void update() throws GeneralSecurityException {
  ASN1Type t;
  boolean tagging;

  t = target_.getContent();

  if (t == null) {
      return;
  }
  if (t instanceof Data) {
      update(((Data) t).getByteArray());
      return;
  }
  ByteArrayOutputStream bos;
  DEREncoder enc;

  /*
   * We know it must be EXPLICIT but hey...
   */
  tagging = t.isExplicit();
  bos = new ByteArrayOutputStream();
  enc = new DEREncoder(bos);

  if (this.strict)
      enc.setStrict(true);

  try {
      t.setExplicit(false);
      enc.writeType(t);

      update(bos.toByteArray());
  } catch (Exception e) {
      throw new SignatureException("Exception while re-encoding!");
  } finally {
      t.setExplicit(tagging);

      try {
    enc.close();
      } catch (Exception e) {
      }
View Full Code Here

Examples of codec.asn1.ASN1Type

     */
    public void encode(Encoder encoder) throws IOException, ASN1Exception {
  /*
   * Yet another nail in my coffin...
   */
  ASN1Type t;
  boolean opt;

  t = (ASN1Type) get(3);
  opt = (auth_.size() == 0);
  t.setOptional(opt);

  t = (ASN1Type) get(6);
  opt = (attr_.size() == 0);
  t.setOptional(opt);

  super.encode(encoder);
    }
View Full Code Here

Examples of codec.asn1.ASN1Type

     *
     * If the content type is <code>Data</code> then there is no problem
     * because we can simply grab the contents octets from it.
     */
    public void update() throws GeneralSecurityException {
  ASN1Type t;
  boolean tagging;

  t = target_.getContent();

  if (t == null) {
      return;
  }
  if (t instanceof Data) {
      update(((Data) t).getByteArray());
      return;
  }
  ByteArrayOutputStream bos;
  DEREncoder enc;

  /*
   * We know it must be EXPLICIT but hey...
   */
  tagging = t.isExplicit();
  bos = new ByteArrayOutputStream();
  enc = new DEREncoder(bos);
  if (this.strict)
      enc.setStrict(true);

  try {
      t.setExplicit(false);
      enc.writeType(t);

      update(bos.toByteArray());
  } catch (Exception e) {
      throw new SignatureException("Exception while re-encoding!");
  } finally {
      t.setExplicit(tagging);

      try {
    enc.close();
      } catch (Exception e) {
    /* Ignore */
 
View Full Code Here

Examples of codec.asn1.ASN1Type

    }

    public void decode(Decoder dec) throws ASN1Exception, IOException {
  super.decode(dec);

  ASN1Type inner = (ASN1Type) super.getValue();

  if (!(inner instanceof ASN1Enumerated)) {
      throw new ASN1Exception("unexpected extension value "
        + inner.toString());
  }
  theReason = (ASN1Enumerated) inner;
    }
View Full Code Here

Examples of codec.asn1.ASN1Type

     *
     * @return The <code>content</code> or <code>null</code> if no content
     *         is available.
     */
    public ASN1Type getContent() {
  ASN1Type o;

  if (content_.isOptional()) {
      return null;
  }
  o = content_.getInnerType();
View Full Code Here

Examples of codec.asn1.ASN1Type

     *                The {@link Decoder Decoder} to use.
     */
    public void decode(Decoder decoder) throws ASN1Exception, IOException {
  super.decode(decoder);

  ASN1Type t;
  ASN1OpenType o;

  if (!content_.isOptional()) {
      t = content_.getInnerType();

View Full Code Here

Examples of codec.asn1.ASN1Type

    public void decode(Decoder dec) throws ASN1Exception, IOException {

  super.decode(dec);

  ASN1Type inner = (ASN1Type) super.getValue();

  if (!(inner instanceof ASN1SequenceOf)) {
      throw new ASN1Exception("unexpected type of inner value "
        + inner.getClass().getName());
  }

  if (!(((ASN1SequenceOf) inner).getElementType()
    .equals(ASN1Sequence.class))) {
      throw new ASN1Exception("unexpected content of inner type "
View Full Code Here

Examples of codec.asn1.ASN1Type

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

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

View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.