Examples of ASN1Choice


Examples of codec.asn1.ASN1Choice

  crlEntry_ = new ASN1Sequence();
  userCertificate_ = new ASN1Integer();

  crlEntry_.add(userCertificate_);

  revocationDate_ = new ASN1Choice();
  revocationDate_.addType(new ASN1UTCTime());
  revocationDate_.addType(new ASN1GeneralizedTime());

  crlEntry_.add(revocationDate_);
View Full Code Here

Examples of codec.asn1.ASN1Choice

  issuer_ = new codec.x501.Name();
  add(issuer_);

  ASN1Sequence validity = new ASN1Sequence();
  notBefore_ = new ASN1Choice();
  notBefore_.addType(new ASN1UTCTime());
  notBefore_.addType(new ASN1GeneralizedTime());
  validity.add(notBefore_);
  notAfter_ = new ASN1Choice();
  notAfter_.addType(new ASN1UTCTime());
  notAfter_.addType(new ASN1GeneralizedTime());
  validity.add(notAfter_);
  add(validity);
View Full Code Here

Examples of codec.asn1.ASN1Choice

  TBSCertList.add(signatureAlgorithm);

  issuer = new codec.x501.Name();
  TBSCertList.add(issuer);

  thisUpdate = new ASN1Choice();
  thisUpdate.addType(new ASN1UTCTime());
  thisUpdate.addType(new ASN1GeneralizedTime());
  TBSCertList.add(thisUpdate);

  nextUpdate = new ASN1Choice();
  nextUpdate.setOptional(true);
  nextUpdate.addType(new ASN1UTCTime());
  nextUpdate.addType(new ASN1GeneralizedTime());

  TBSCertList.add(nextUpdate);
View Full Code Here

Examples of codec.asn1.ASN1Choice

  TBSCertList.add(signatureAlgorithm);

  issuer = new codec.x501.Name();
  TBSCertList.add(issuer);

  thisUpdate = new ASN1Choice();
  thisUpdate.addType(new ASN1UTCTime());
  thisUpdate.addType(new ASN1GeneralizedTime());
  TBSCertList.add(thisUpdate);

  /*
 
View Full Code Here

Examples of org.apache.harmony.security.asn1.ASN1Choice

        }
    }

    public void testChoiceInSequenceOf() throws IOException {

        ASN1Choice choice = new ASN1Choice(new ASN1Type[] {
                ASN1Boolean.getInstance(), ASN1Integer.getInstance() }) {

            public int getIndex(Object object) {
                if (object instanceof Boolean) {
                    return 0; // ASN1Boolean
View Full Code Here

Examples of org.apache.harmony.security.asn1.ASN1Choice

    //
    //

    public void test_ExplicitChoice() throws IOException {

        ASN1Choice choice = new ASN1Choice(new ASN1Type[] { ASN1Boolean
                .getInstance() }) {

            public Object getObjectToEncode(Object obj) {
                return obj;
            }
View Full Code Here

Examples of org.apache.harmony.security.asn1.ASN1Choice

    /**
     * TODO Put method description here
     */
    public void testChoiceOfChoice() throws Exception {

        ASN1Choice choice1 = new ASN1Choice(new ASN1Type[] {
                ASN1Oid.getInstance(), // first
                ASN1Boolean.getInstance(),// second: decoded component
                ASN1Integer.getInstance() // third
                }) {

            public Object getDecodedObject(BerInputStream in)
                    throws IOException {

                assertEquals("choice1", 1, in.choiceIndex);

                return in.content;
            }

            public Object getObjectToEncode(Object obj) {
                return obj;
            }

            public int getIndex(Object obj) {
                return 0;
            }
        };

        ASN1Choice choice2 = new ASN1Choice(new ASN1Type[] { choice1, // first: decoded component
                ASN1BitString.getInstance() // second
                }) {

            public Object getDecodedObject(BerInputStream in)
                    throws IOException {

                assertEquals("choice2", 0, in.choiceIndex);

                return in.content;
            }

            public Object getObjectToEncode(Object obj) {
                return obj;
            }

            public int getIndex(Object obj) {
                return 0;
            }
        };

        Boolean b = (Boolean) choice2.decode(new byte[] { 0x01, 0x01, 0x00 });

        assertTrue(b == Boolean.FALSE);
    }
View Full Code Here

Examples of org.apache.harmony.security.asn1.ASN1Choice

    /**
     * TODO Put method description here
     */
    public void testDistinctTags() throws Exception {

        ASN1Choice choice1 = new ASN1Choice(new ASN1Type[] {
                ASN1Boolean.getInstance(),// component to be checked
                ASN1Oid.getInstance(), ASN1Integer.getInstance() }) {

            public Object getObjectToEncode(Object obj) {
                return obj;
            }

            public int getIndex(Object obj) {
                return 0;
            }
        };

        // two ASN.1 booleans
        try {
            new ASN1Choice(new ASN1Type[] { choice1, //
                    ASN1Boolean.getInstance() // component to be checked
                    }) {

                public Object getObjectToEncode(Object obj) {
                    return obj;
                }

                public int getIndex(Object obj) {
                    return 0;
                }
            };
            fail("No expected IllegalArgumentException");
        } catch (IllegalArgumentException e) {
        }

        // ASN.1 ANY
        try {
            new ASN1Choice(new ASN1Type[] { choice1,//
                    ASN1Any.getInstance() // component to be checked
                    }) {

                public Object getObjectToEncode(Object obj) {
                    return obj;
                }

                public int getIndex(Object obj) {
                    return 0;
                }
            };
            fail("No expected IllegalArgumentException");
        } catch (IllegalArgumentException e) {
        }

        // two choices
        ASN1Choice choice2 = new ASN1Choice(new ASN1Type[] {
                ASN1BitString.getInstance(), //
                ASN1Boolean.getInstance() //component to be checked
                }) {

            public Object getObjectToEncode(Object obj) {
                return obj;
            }

            public int getIndex(Object obj) {
                return 0;
            }
        };

        try {
            new ASN1Choice(new ASN1Type[] { choice1, choice2 }) {

                public Object getObjectToEncode(Object obj) {
                    return obj;
                }

View Full Code Here

Examples of org.apache.harmony.security.asn1.ASN1Choice

        }
    }

    public void testChoiceInSequenceOf() throws IOException {

        ASN1Choice choice = new ASN1Choice(new ASN1Type[] {
                ASN1Boolean.getInstance(), ASN1Integer.getInstance() }) {

            public int getIndex(Object object) {
                if (object instanceof Boolean) {
                    return 0; // ASN1Boolean
View Full Code Here

Examples of org.apache.harmony.security.asn1.ASN1Choice

    //
    //

    public void test_ExplicitChoice() throws IOException {

        ASN1Choice choice = new ASN1Choice(new ASN1Type[] { ASN1Boolean
                .getInstance() }) {

            public Object getObjectToEncode(Object obj) {
                return obj;
            }
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.