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

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


    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


  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

        };
    }

    public ASN1Decodable getResponse() {

        return new ASN1Decodable() {
            public void decodeValues(Object[] values) {
                result = new LdapResult();
                result.decodeValues(values);
                if (values[4] != null) {
                    serverSaslCreds = (byte[]) values[4];
View Full Code Here

    }

    public void abandon(final int messageId, Control[] controls)
            throws IOException {
        doOperationWithoutResponse(LdapASN1Constant.OP_ABANDON_REQUEST,
                new ASN1Encodable() {

                    public void encodeValues(Object[] values) {
                        values[0] = ASN1Integer.fromIntValue(messageId);
                    }
View Full Code Here

        DirContext context = new InitialDirContext(env);

        final MockLdapServer referralServer = new MockLdapServer();
        referralServer.start();

        ASN1Encodable ref = new ASN1Encodable() {

            public void encodeValues(Object[] values) {
                List<byte[]> list = new ArrayList<byte[]>();
                list.add(Utils.getBytes(referralServer.getURL()));
                values[0] = list;
View Full Code Here

    }

    public void abandon(final int messageId, Control[] controls)
            throws IOException {
        doOperationWithoutResponse(LdapASN1Constant.OP_ABANDON_REQUEST,
                new ASN1Encodable() {

                    public void encodeValues(Object[] values) {
                        values[0] = ASN1Integer.fromIntValue(messageId);
                    }
View Full Code Here

        DirContext context = new InitialDirContext(env);

        final MockLdapServer referralServer = new MockLdapServer();
        referralServer.start();

        ASN1Encodable ref = new ASN1Encodable() {

            public void encodeValues(Object[] values) {
                List<byte[]> list = new ArrayList<byte[]>();
                list.add(Utils.getBytes(referralServer.getURL()));
                values[0] = list;
View Full Code Here

    public void testExtendedOperation() throws Exception {
        server.setResponseSeq(new LdapMessage[] { new LdapMessage(
                LdapASN1Constant.OP_BIND_RESPONSE, new BindResponse(), null) });
        LdapContext context = new InitialLdapContext(env, null);

        ASN1Encodable encodableResponse = new ASN1Encodable() {

            public void encodeValues(Object[] values) {
                new EncodableLdapResult().encodeValues(values);
                values[4] = Utils.getBytes("It's my id");
                values[5] = new byte[] { 0, 1, 2, 3 };
            }

        };
        server
                .setResponseSeq(new LdapMessage[] { new LdapMessage(
                        LdapASN1Constant.OP_EXTENDED_RESPONSE,
                        encodableResponse, null) });

        ExtendedResponse response = context
                .extendedOperation(new MockExtendedRequest());
        assertTrue(response instanceof MockExtendedResponse);
        assertEquals("It's my id", response.getID());
        assertEquals(4, response.getEncodedValue().length);
        assertEquals(0, response.getEncodedValue()[0]);
        assertEquals(1, response.getEncodedValue()[1]);
        assertEquals(2, response.getEncodedValue()[2]);
        assertEquals(3, response.getEncodedValue()[3]);

        // test exception
        encodableResponse = new ASN1Encodable() {
            public void encodeValues(Object[] values) {
                new EncodableLdapResult().encodeValues(values);
                values[4] = Utils.getBytes("exception");
                values[5] = new byte[] { 0, 1, 2, 3 };
            }
View Full Code Here

            authChoice = new AuthenticationChoice(1, saslCreds);
        }
    }

    public ASN1Encodable getRequest() {
        return new ASN1Encodable() {
            public void encodeValues(Object[] values) {
                values[0] = ASN1Integer.fromIntValue(3);
                values[1] = Utils.getBytes(name);
                values[2] = authChoice;
            }
View Full Code Here

    }

    public void abandon(final int messageId, Control[] controls)
            throws IOException {
        doOperationWithoutResponse(LdapASN1Constant.OP_ABANDON_REQUEST,
                new ASN1Encodable() {

                    public void encodeValues(Object[] values) {
                        values[0] = ASN1Integer.fromIntValue(messageId);
                    }
View Full Code Here

TOP

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

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.