|
This is a duplicate of DIRLDAP-78.
Emmanuel Lecharny made changes - 03/Feb/06 05:38 PM
The LdapProxy (in sandbox) use the twix codec, so it seems that is is possible to use twix to write a proxy or a client ;-)
The big picture is the following : 1) CLIENT uses twix classes to prepare LdapMessage requests 2) CLIENT sends those messages to the PROXY/SERVER after having encoded them as BER, using twix 3) PROXY/SERVER receives a BER binary encoded data 4) PROXY/SERVER calls the decoder which produce a twix instance of the message 5) PROXY/SERVER then calls the transformer to switch from this twix representation to the internal message representation 6) PROXY/SERVER does it jobs ... 7) PROXY/SERVER creates an instance of the LdapMessage response using the internal representation 8) PROXY/SERVER calls the transformer to switch from the internal representation to the twix representation 9) PROXY/SERVER encodes the message as BER, using twix 10) PROXY/SERVER sends the binary data back to the CLIENT 11) CLIENT decodes the binary data and creates an instance of a twix representation of the message I must admit that the transformation is a bit overkilling, to say the least, but it does not prevent the implementation of a client or a proxy. The merge between the internal representation and the twix representation is something that is planned in a forthcoming release. Thanks Emmanuel for your prompt response.
If I understand it correctly, your LDAP Proxy doesn't transform LDAP messages between Twix format and the "internal" message presentation. Our LDAP client/proxy, when implemented with MINA + Twix Codec Provider, is currently failing to communicate with the server. It throws a NPE when running this segment of code: public void testEncodeBindRequest() throws EncoderException { final BindRequestImpl req0 = new BindRequestImpl( 1 ); req0.setCredentials( "password".getBytes() ); req0.setName( "cn=admin,dc=example,dc=com" ); req0.setSimple( true ); req0.setVersion3( true ); final MessageEncoder encoder = new MessageEncoder(); encoder.encode( req0 ); } I would suspect that a similar error will be received if you try to get the Twix Codec Provider to decode an LDAP response. The reasons for this are as I explained in my previous comment. We can discuss further off-line if that is more convenient to you. Thanks and Regards, Van Hi Van (if Van is your firstname :),
it would work if you use the twix object instead of the internal object. In you piece of code, just do that : import org.apache.ldap.common.codec.bind.BindRequest; public void testEncodeBindRequest() throws EncoderException { final BindRequest req0 = new BindRequest(); req0.setMessageId( 1 ) ((SimpleAuthentication)req0.getAuthentication()).setSimple( "password".getBytes( "UTF8" ) ); req0.setName( new LdapDN( "cn=admin,dc=example,dc=com" ) ); req0.setVersion( 3 ); try { ByteBuffer bb = req0.encode( null ); } catch ( EncoderException ee ) { ee.printStackTrace(); fail( ee.getMessage() ); } } You will get a bytebuffer with the encoded value to be send to the server. The twix API is not very confortable atm, but it can evelve in the future. feel free to contact me directly if you need any information.
Alex Karasulu made changes - 07/Feb/06 01:29 PM
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
This makes the TwixTransformer work double time just to convert a message from one format to another. And currently it converts LDAP requests from the Twix format to the "common" format and converts the LDAP responses from the "common" format to Twix format so that the ApacheDS server can decode the incoming requests and encode the responses before sending them back to the clients.
In addition, the TwixTransformer at the moment doesn't transform a "common" request to Twix request nor does it transform a Twix response to a "common" response. This makes it impossible to use the Twix codec together with MINA to implement an LDAP client or an LDAP proxy that acts like a client to an LDAP Server.
This is not a problem with the old Snickers codec, so I wonder if someone has a plan as how we can clean this up and make the Twix codec support ASN1 encoding of the requests and decoding of the responses. Thanks.