Package org.apache.harmony.jndi.provider.ldap.asn1

Examples of org.apache.harmony.jndi.provider.ldap.asn1.Utils


  public void setAddress(String address) {
    this.address = address;
  }

    public void decodeSearchResponse(Object[] values) {
        ChosenValue chosen = (ChosenValue) values[0];
        switch (chosen.getIndex()) {
        case LdapASN1Constant.OP_SEARCH_RESULT_ENTRY:
            decodeEntry(chosen.getValue());
            break;
        case LdapASN1Constant.OP_SEARCH_RESULT_REF:
            decodeRef(chosen.getValue());
            break;
        case LdapASN1Constant.OP_SEARCH_RESULT_DONE:
            decodeDone(chosen.getValue());
            break;
        }
    }
View Full Code Here


        messageId = ASN1Integer.toIntValue(values[0]);
        if (values[1] == null) {
            return;
        }

        ChosenValue chosen = (ChosenValue) values[1];
        opIndex = chosen.getIndex();
        // failed to retrieve responseOp
        responseOp = getResponseOp();
        if (responseOp == null) {
            return;
        }

        if (opIndex == LdapASN1Constant.OP_SEARCH_RESULT_DONE
                || opIndex == LdapASN1Constant.OP_SEARCH_RESULT_ENTRY
                || opIndex == LdapASN1Constant.OP_SEARCH_RESULT_REF) {
            /*
             * we use LdapSearchResult to decode all types of search responses,
             * so we need index to determine which type of response to decode
             */
            responseOp.decodeValues(new Object[] { chosen });
        } else {
            responseOp.decodeValues((Object[]) chosen.getValue());
        }

        if (values[2] != null) {
            Collection<Object[]> list = (Collection<Object[]>) values[2];
            controls = new Control[list.size()];
View Full Code Here

        if (opIndex == LdapASN1Constant.OP_ABANDON_REQUEST
                || opIndex == LdapASN1Constant.OP_DEL_REQUEST
                || opIndex == LdapASN1Constant.OP_UNBIND_REQUEST) {
            Object[] objs = new Object[1];
            requestOp.encodeValues(objs);
            values[1] = new ChosenValue(opIndex, objs[0]);
        } else {
            values[1] = new ChosenValue(opIndex, requestOp);
        }

        // encode controls, wrap to LdapControl, so it could be encoded
        if (controls != null) {
            List<LdapControl> list = new ArrayList<LdapControl>(controls.length);
View Full Code Here

        if (type == null) {
            type = (ASN1Choice) LdapASN1Constant.Filter;
        }
        // has not been decoded
        if (!(out.content instanceof byte[])) {
            ChosenValue chosen = (ChosenValue) out.content;
            int index = chosen.getIndex();
            byte[] bytes = type.type[index].encode(chosen.getValue());
            out.content = bytes;
            out.length = bytes.length;
        }
        // TODO: Any way better to do this(append out.content to out.encoded)?
        out.encodeString();
View Full Code Here

    public void setEncodingContent(BerOutputStream out) {
        if (type == null) {
            type = (ASN1Choice) LdapASN1Constant.Filter;
        }

        ChosenValue chosen = null;
        if (out.content instanceof Filter) {
            Object[] values = new Object[1];
            ((Filter) out.content).encodeValues(values);
            chosen = (ChosenValue) values[0];
        } else {
            chosen = (ChosenValue) out.content;
        }

        int index = chosen.getIndex();
        byte[] bytes = type.type[index].encode(chosen.getValue());

        out.content = bytes;
        out.length = bytes.length;
    }
View Full Code Here

        assertEquals(SubstringFilter.class, filter.getValue().getClass());
        SubstringFilter sub = (SubstringFilter) filter.getValue();
        assertEquals("cn", sub.getType());
        // TODO: not sure whether '*' should be part of 'any'
        // assertEquals(1, sub.getSubstrings().size());
        ChosenValue chosen = sub.getSubstrings().get(0);
        assertEquals("Babs J", chosen.getValue());
        assertEquals(0, chosen.getIndex());
    }
View Full Code Here

            Assert.assertTrue(objs[0] instanceof Integer);

            int index = ((Integer) objs[0]).intValue();
            checkEncode(objs[1], type.type[index]);
        } else if (value instanceof ChosenValue) {
            ChosenValue chosen = (ChosenValue) value;
            checkEncode(chosen.getValue(), type.type[chosen.getIndex()]);
        } else if (value instanceof ASN1Encodable) {
            Object[] objs = new Object[1];
            ((ASN1Encodable) value).encodeValues(objs);
            checkEncode(objs[0], type);
        } else {
View Full Code Here

    public void test_getIndex_LObject() {
        Object[] values = new Object[] { Integer.valueOf(1),
                Integer.valueOf(100) };
        assertEquals(1, choice.getIndex(values));

        ChosenValue chosen = new ChosenValue(2, Boolean.valueOf(true));
        assertEquals(2, choice.getIndex(chosen));
    }
View Full Code Here

    public void test_getObjectToEncode_LObject() {
        Object[] values = new Object[] { Integer.valueOf(1),
                Integer.valueOf(100) };
        assertEquals(values[1], choice.getObjectToEncode(values));

        ChosenValue chosen = new ChosenValue(0, "hello");
        assertEquals(chosen.getValue(), choice.getObjectToEncode(chosen));
    }
View Full Code Here

        Object[] values = new Object[] { Integer.valueOf(index), value };
        byte[] encoded = choice.encode(values);
        Object decoded = choice.decode(encoded);

        assertTrue(decoded instanceof ChosenValue);
        ChosenValue chosen = (ChosenValue) decoded;

        assertEquals(index, chosen.getIndex());
        assertEquals(value, chosen.getValue());
    }
View Full Code Here

TOP

Related Classes of org.apache.harmony.jndi.provider.ldap.asn1.Utils

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.