Return-Path: X-Original-To: apmail-directory-dev-archive@www.apache.org Delivered-To: apmail-directory-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id BEFBA11F2E for ; Mon, 22 Sep 2014 15:13:05 +0000 (UTC) Received: (qmail 16258 invoked by uid 500); 22 Sep 2014 15:13:05 -0000 Delivered-To: apmail-directory-dev-archive@directory.apache.org Received: (qmail 16214 invoked by uid 500); 22 Sep 2014 15:13:05 -0000 Mailing-List: contact dev-help@directory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Apache Directory Developers List" Delivered-To: mailing list dev@directory.apache.org Received: (qmail 16204 invoked by uid 99); 22 Sep 2014 15:13:05 -0000 Received: from minotaur.apache.org (HELO minotaur.apache.org) (140.211.11.9) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 22 Sep 2014 15:13:05 +0000 Received: from localhost (HELO mail-we0-f180.google.com) (127.0.0.1) (smtp-auth username kayyagari, mechanism plain) by minotaur.apache.org (qpsmtpd/0.29) with ESMTP; Mon, 22 Sep 2014 15:13:05 +0000 Received: by mail-we0-f180.google.com with SMTP id u56so3069466wes.25 for ; Mon, 22 Sep 2014 08:13:03 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.194.80.2 with SMTP id n2mr21578709wjx.29.1411398783533; Mon, 22 Sep 2014 08:13:03 -0700 (PDT) Received: by 10.216.171.131 with HTTP; Mon, 22 Sep 2014 08:13:03 -0700 (PDT) In-Reply-To: <54203318.7070702@robotron.de> References: <54203318.7070702@robotron.de> Date: Mon, 22 Sep 2014 20:43:03 +0530 Message-ID: Subject: Re: Embedded Apache DS as proxy From: Kiran Ayyagari To: Apache Directory Developers List Content-Type: multipart/alternative; boundary=047d7bf0cc5e210aca0503a8e3b5 --047d7bf0cc5e210aca0503a8e3b5 Content-Type: text/plain; charset=UTF-8 On Mon, Sep 22, 2014 at 8:02 PM, Sebastian Oerding < sebastian.oerding@robotron.de> wrote: > Hello again, > > I tried to use an embedded Apache DS with a self written interceptor as > (kind of) a proxy. Actually I have to "parse" incoming requests to request > the desired data from a database. However I'm struggling doing so. > > 1) I do not get the complete request if parsing the request, for example > when requesting > "(&(objectClass=smpki)(cn=ABC))" > and using the SearchContext in > @Override > public EntryFilteringCursor search(SearchOperationContext > searchContext) { ... } > I get the DN "ou=certificates,dc=smpki" by searchContext.getDn(). However > I do not manage to get the searchfilter from the request (I checked the > RequestControls and ResponseControls of the SearchContext) and do not havy > any idea what to do next. Can someone please provide any hint on how to get > the search filter? > > call searchContext.getFilter() to get the filter in object form, call toString() on it if you want to see it as a string. Note that this method should be called before calling super.search() otherwise you will get a annotated filter that is not syntactically correct for parsing later. > 2) I simply started the embedded server using the following code (some > unimportant lines adding my self-written interceptor omitted): > > DefaultDirectoryServiceFactory factory = new > DefaultDirectoryServiceFactory(); > factory.init(INSTANCE_NAME); > this.directoryService = factory.getDirectoryService(); > this.directoryService.getChangeLog().setEnabled(false); > this.directoryService.setShutdownHookEnabled(true); > InstanceLayout il = new InstanceLayout(INSTANCE_PATH); > this.directoryService.setInstanceLayout(il); > > this.ldapService = new LdapServer(); > this.ldapService.setTransports(new TcpTransport(this.host, > this.port)); > this.ldapService.setDirectoryService(this.directoryService); > > When I let the JUnit test run my interceptor is invoked as expected. > However I got the following exception: > > javax.naming.NamingException: [LDAP: error code 80 - OTHER: failed for > MessageType : SEARCH_REQUEST > Message ID : 2 > SearchRequest > baseDn : 'ou=certificates,dc=smpki' > filter : '(&(objectClass=smpki)(cn=033e07c49e8af56994859466bebfaa > 9057a36924))' > scope : whole subtree > typesOnly : false > Size Limit : no limit > Time Limit : no limit > Deref Aliases : deref Always > attributes : > org.apache.directory.api.ldap.model.message.SearchRequestImpl@4f08934e > ManageDsaITImpl Control > Type OID : '2.16.840.1.113730.3.4.2' > Criticality : 'false' > ' > : null]; remaining name 'ou=certificates,dc=smpki' > at com.sun.jndi.ldap.LdapCtx.mapErrorCode(LdapCtx.java:3111) > .... > > Is this a problem with the configuration of the embedded Apache DS? Doch I > need an instance layout which conforms to the request? > > hard to tell without seeing your code, but this issue is not related to instance layout. > With regards > Sebastian > -- Kiran Ayyagari http://keydap.com --047d7bf0cc5e210aca0503a8e3b5 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable


On Mon, Sep 22, 2014 at 8:02 PM, Sebastian Oerding &l= t;sebast= ian.oerding@robotron.de> wrote:
Hello again,

I tried to use an embedded Apache DS with a self written interceptor as (ki= nd of)=C2=A0 a proxy. Actually I have to "parse" incoming request= s to request the desired data from a database. However I'm struggling d= oing so.

1) I do not get the complete request if parsing the request, for example wh= en requesting
"(&(objectClass=3Dsmpki)(cn=3DABC))"
and using the SearchContext in
@Override
=C2=A0 =C2=A0 public EntryFilteringCursor search(SearchOperationContext sea= rchContext) { ... }
I get the DN "ou=3Dcertificates,dc=3Dsmpki" by searchContext.getD= n(). However I do not manage to get the searchfilter from the request (I ch= ecked the RequestControls and ResponseControls of the SearchContext) and do= not havy any idea what to do next. Can someone please provide any hint on = how to get the search filter?

call searchContext.getFilter() to get the filter in o= bject form, call toString() on it if you want to see it as a string.
Note that this method should be called before calling super.search(= ) otherwise you will get a annotated filter
that is not syntactically co= rrect for parsing later.
2) I simply started the embedded server using the following code (some unim= portant lines adding my self-written interceptor omitted):

=C2=A0 =C2=A0 =C2=A0 =C2=A0 DefaultDirectoryServiceFactory factory =3D new = DefaultDirectoryServiceFactory();
=C2=A0 =C2=A0 =C2=A0 =C2=A0 factory.init(INSTANCE_NAME);
=C2=A0 =C2=A0 =C2=A0 =C2=A0 this.directoryService =3D factory.getDirectoryS= ervice();
=C2=A0 =C2=A0 =C2=A0 =C2=A0 this.directoryService.getChangeLog().set= Enabled(false);
=C2=A0 =C2=A0 =C2=A0 =C2=A0 this.directoryService.setShutdownHookEna= bled(true);
=C2=A0 =C2=A0 =C2=A0 =C2=A0 InstanceLayout il =3D new InstanceLayout(INSTAN= CE_PATH);
=C2=A0 =C2=A0 =C2=A0 =C2=A0 this.directoryService.setInstanceLayout(= il);

=C2=A0 =C2=A0 =C2=A0 =C2=A0 this.ldapService =3D new LdapServer();
=C2=A0 =C2=A0 =C2=A0 =C2=A0 this.ldapService.setTransports(new TcpTr= ansport(this.host, this.port));
=C2=A0 =C2=A0 =C2=A0 =C2=A0 this.ldapService.setDirectoryService(thi= s.directoryService);

When I let the JUnit test run my interceptor is invoked as expected. Howeve= r I got the following exception:

javax.naming.NamingException: [LDAP: error code 80 - OTHER: failed for Mess= ageType : SEARCH_REQUEST
Message ID : 2
=C2=A0 =C2=A0 SearchRequest
=C2=A0 =C2=A0 =C2=A0 =C2=A0 baseDn : 'ou=3Dcertificates,dc=3Dsmpki'=
=C2=A0 =C2=A0 =C2=A0 =C2=A0 filter : '(&(objectClass=3Dsmpki)(cn=3D= 033e07c49e8af56994859466bebfaa9057a36924))'
=C2=A0 =C2=A0 =C2=A0 =C2=A0 scope : whole subtree
=C2=A0 =C2=A0 =C2=A0 =C2=A0 typesOnly : false
=C2=A0 =C2=A0 =C2=A0 =C2=A0 Size Limit : no limit
=C2=A0 =C2=A0 =C2=A0 =C2=A0 Time Limit : no limit
=C2=A0 =C2=A0 =C2=A0 =C2=A0 Deref Aliases : deref Always
=C2=A0 =C2=A0 =C2=A0 =C2=A0 attributes :
org.apache.directory.api.ldap.model.message.SearchRequestImpl= @4f08934e ManageDsaITImpl Control
=C2=A0 =C2=A0 =C2=A0 =C2=A0 Type OID=C2=A0 =C2=A0 : '2.16.840.1.113730.= 3.4.2'
=C2=A0 =C2=A0 =C2=A0 =C2=A0 Criticality : 'false'
'
: null]; remaining name 'ou=3Dcertificates,dc=3Dsmpki'
=C2=A0 =C2=A0 at com.sun.jndi.ldap.LdapCtx.mapErrorCode(LdapCtx.java= :3111)
....

Is this a problem with the configuration of the embedded Apache DS? Doch I = need an instance layout which conforms to the request?

hard to tell without seeing your code, but this issue= is not related to instance layout.
With regards
Sebastian



--
Kiran Ayy= agari
http://keydap.com<= /a>
--047d7bf0cc5e210aca0503a8e3b5--