Package org.apache.harmony.security.asn1

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


     */
    public EnvelopedData() {
  super(3);

  version_ = new ASN1Integer(0);
  recipients_ = new ASN1SetOf(RecipientInfo.class);
  info_ = new EncryptedContentInfo();

  add(version_); // version
  add(recipients_);
  add(info_);
View Full Code Here


    public EnvelopedData(SecretKey bek, String bea, AlgorithmParameters params)
      throws InvalidAlgorithmParameterException {
  super(3);

  version_ = new ASN1Integer(0);
  recipients_ = new ASN1SetOf(RecipientInfo.class);
  info_ = new EncryptedContentInfo(bea, bek, params);

  add(version_); // version
  add(recipients_);
  add(info_);
View Full Code Here

    public SignedData() {
  super(6);

  add(new ASN1Integer(1)); // version

  digestID_ = new ASN1SetOf(AlgorithmIdentifier.class);
  add(digestID_);

  content_ = new ContentInfo();
  add(content_);

  certs_ = new Certificates();
  add(new ASN1TaggedType(0, certs_, false, true));

  crls_ = new ASN1SetOf(ASN1Opaque.class);
  add(new ASN1TaggedType(1, crls_, false, true));

  infos_ = new ASN1SetOf(SignerInfo.class);
  add(infos_);
    }
View Full Code Here

    public SignedData(int _version) {
  super(6);

  add(new ASN1Integer(_version)); // version

  digestID_ = new ASN1SetOf(AlgorithmIdentifier.class);
  add(digestID_);

  content_ = new ContentInfo();
  add(content_);

  certs_ = new Certificates();
  add(new ASN1TaggedType(0, certs_, false, true));

  crls_ = new ASN1SetOf(ASN1Opaque.class);
  add(new ASN1TaggedType(1, crls_, false, true));

  infos_ = new ASN1SetOf(SignerInfo.class);
  add(infos_);
    }
View Full Code Here

                    new byte[] { 0x03, 0x02, 0x07, (byte) 0x80 } } };

    public void testDecode_Encode() throws IOException {

        // decoder/encoder for testing
        ASN1BitString asn1 = ASN1BitString.getInstance();

        // decode from byte array
        for (int i = 0; i < validBitstring.length; i++) {
            DerInputStream in = new DerInputStream(
                    (byte[]) validBitstring[i][1]);

            BitString expected = (BitString) validBitstring[i][0];
            BitString decoded = (BitString) asn1.decode(in);

            assertEquals("Testcase: " + i, expected.unusedBits,
                    decoded.unusedBits);

            assertTrue("Testcase: " + i, Arrays.equals(expected.bytes,
                    decoded.bytes));
        }

        // decode from input stream
        for (int i = 0; i < validBitstring.length; i++) {
            DerInputStream in = new DerInputStream(new ByteArrayInputStream(
                    (byte[]) validBitstring[i][1]));

            BitString expected = (BitString) validBitstring[i][0];
            BitString decoded = (BitString) asn1.decode(in);

            assertEquals("Testcase: " + i, expected.unusedBits,
                    decoded.unusedBits);

            assertTrue("Testcase: " + i, Arrays.equals(expected.bytes,
View Full Code Here

                {
                        new boolean[] { false, false, false, false, false,
                                false, false, false, true }, // object
                        new byte[] { 0x03, 0x03, 0x07, 0x00, (byte) 0x80 } } };

        ASN1NamedBitList decoder = new ASN1NamedBitList();

        for (int i = 0; i < testcaseBoolean.length; i++) {
            DerInputStream in = new DerInputStream(
                    (byte[]) testcaseBoolean[i][1]);

            assertTrue("Testcase: " + i, Arrays.equals(
                    (boolean[]) testcaseBoolean[i][0], (boolean[]) decoder
                            .decode(in)));
        }
    }
View Full Code Here

                {
                        new boolean[] { false, false, false, false, false,
                                false, false, false, true }, // object
                        new byte[] { 0x03, 0x03, 0x07, 0x00, (byte) 0x80 } } };

        ASN1NamedBitList decoder = new ASN1NamedBitList(8);

        for (int i = 0; i < testcaseBoolean.length; i++) {
            DerInputStream in = new DerInputStream(
                    (byte[]) testcaseBoolean[i][1]);

            assertTrue("Testcase: " + i, Arrays.equals(
                    (boolean[]) testcaseBoolean[i][0], (boolean[]) decoder
                            .decode(in)));
        }
    }
View Full Code Here

                {
                        new boolean[] { false, false, false, false, false,
                                false, false, false, true }, // object
                        new byte[] { 0x03, 0x03, 0x07, 0x00, (byte) 0x80 } } };

        ASN1NamedBitList encoder = new ASN1NamedBitList();

        for (int i = 0; i < testcaseBoolean.length; i++) {
            DerOutputStream out = new DerOutputStream(encoder,
                    testcaseBoolean[i][0]);
            assertTrue("Testcase: " + i, Arrays.equals(
View Full Code Here

    private static byte[] eTrue = new byte[] { 0x01, 0x01, (byte) 0xFF };

    public void test_Decode_Encode() throws IOException {

        // oid decoder/encoder for testing
        ASN1Boolean asn1 = ASN1Boolean.getInstance();

        // decoding false
        DerInputStream in = new DerInputStream(eFalse);
        assertEquals("Decoding false value", Boolean.FALSE, asn1.decode(in));

        // decoding true
        in = new DerInputStream(eTrue);
        assertEquals("Decoding true value", Boolean.TRUE, asn1.decode(in));

        // encoding false
        DerOutputStream out = new DerOutputStream(asn1, Boolean.FALSE);
        assertTrue("Encoding false value", Arrays.equals(eFalse, out.encoded));
View Full Code Here

        }
    }

    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

TOP

Related Classes of org.apache.harmony.security.asn1.ASN1SetOf

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.