Hi Danny,Brant

Got your point completly. I will use the same credentials to get the
connection with xdbc server; if connection successful then its a valid
user.:-)

Brent, actually i am creating a webservice framework for
authentication,exception handling,logging by framework. This framework will
be used my Java RestWs; whrere in which i am trying authenticate user and
then allowing to process request. Java webservice will load in memory xml
(generated inside webservice) to marklogic.:-):-)

Thank you very much for guiding me.
On May 17, 2013 3:07 AM, <[email protected]> wrote:

> Send General mailing list submissions to
>         [email protected]
>
> To subscribe or unsubscribe via the World Wide Web, visit
>         http://developer.marklogic.com/mailman/listinfo/general
> or, via email, send a message with subject or body 'help' to
>         [email protected]
>
> You can reach the person managing the list at
>         [email protected]
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of General digest..."
>
>
> Today's Topics:
>
>    1. Re: General Digest, Vol 107, Issue 41 [XDMP:LOGIN(USER,
>       PASS), not working when using through XDBC] (Danny Sokolsky)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Thu, 16 May 2013 21:36:54 +0000
> From: Danny Sokolsky <[email protected]>
> Subject: Re: [MarkLogic Dev General] General Digest, Vol 107, Issue 41
>         [XDMP:LOGIN(USER, PASS), not working when using through XDBC]
> To: MarkLogic Developer Discussion <[email protected]>
> Message-ID:
>         <d4f697174c071d46b891b38bfc6eafa6095...@exchg10-be01.marklogic.com
> >
> Content-Type: text/plain; charset="us-ascii"
>
> xdmp:login only works on app servers that allow application-level
> authentication, which means it works on HTTP servers, not an XDBC servers
> (it will always return false on an XDBC server).  Also, note that XDBC
> servers do not have app-level authentication.
>
> So as Brent suggests, your Java code can grab the credentials from the
> user and then pass them in with your xcc request with the server set to do
> digest authentication.
>
> -Danny
>
> From: [email protected] [mailto:
> [email protected]] On Behalf Of Brent Hartwig
> Sent: Thursday, May 16, 2013 6:57 AM
> To: MarkLogic Developer Discussion
> Subject: Re: [MarkLogic Dev General] General Digest, Vol 107, Issue 41
> [XDMP:LOGIN(USER, PASS), not working when using through XDBC]
>
> It appears the same credentials are used for the XCC-XDBC connection and
> in the call to xdmp:login(), because "this." isn't in front of "userName"
> and "password" within getConnection().  That might clear things up for you.
>  What benefit are you after by using system credentials for the connection,
> versus using the user-provided credentials (and skipping the call to
> xdmp:login())?
>
> -Brent
>
> From: [email protected]<mailto:
> [email protected]> [mailto:
> [email protected]] On Behalf Of abhinav mishra
> Sent: Thursday, May 16, 2013 9:12 AM
> To: [email protected]<mailto:[email protected]
> >
> Subject: Re: [MarkLogic Dev General] General Digest, Vol 107, Issue 41
> [XDMP:LOGIN(USER, PASS), not working when using through XDBC]
>
> Hi Brent,
>
>
> Yes you are right, My XDBC app server has authentication scheme as
> "digest". XDBC app sever privilege section is also null (Also tried by
> mentioning "xdmp:login" as a value here) . Via XDBC i am always getting
> retrun as "false".
> But via Queryconsole with authentication scheme as "application-level" i
> am getting "true". when i set authentication scheme as "digest" for
> QueryConsole then i am not able to execute xdmp:login. i have mentioned
> description below.
>
>
> ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
> I have written an xquery file on file system module. i have following code
> inside .xqy file>>
>
> //authHelper.xqy
>
> declare variable $userName as xs:string * external;
> declare variable $password as xs:string * external;
>
>
> xdmp:log(fn:concat("UserName: ",$userName,"|Password: ",$password))
> ,
> xdmp:login($userName,$password)
>
> I have a java module where i receive the user name and password and i am
> sending that username and password to marklogic as:
>
> //AuthHelper.java
>
>         private static final String userName =
> ResourceReader.getProperty("mladminuser"); //Reading username from property
> file
>         private static final String password=
> ResourceReader.getProperty("mladminpass");//Reading password from property
> file
>         private static final String url=
> ResourceReader.getProperty("mlurl"); //Reading url "localhost:8006/toolkit"
> from property file
>
>         //To get the connection from marklogic.
>             public static Session getConnection(String userName, String
> password,
>                         String url) {
>                         URI uri;
>                         Session session=null;
>                         try {
>                                     uri = new
> URI(prepareConnectionUrl(userName,password,url));
>                                     ContentSource contentSource =
> ContentSourceFactory
>
> .newContentSource(uri);
>                                     session = contentSource.newSession();
>                         } catch (URISyntaxException e) {
>                                     e.printStackTrace();
>                         } catch (XccConfigException e) {
>                                     e.printStackTrace();
>                         }
>                         return session;
>             }
>
>       private static String prepareConnectionUrl(String userName,String
> password,String url){
>                StringBuffer sb=new StringBuffer("xdbc://");
>                sb.append(userName);
>                sb.append(":");
>                sb.append(password);
>                sb.append("@");
>                sb.append(url);
>                return sb.toString();
>             }
>
> public static void main(String[] args){
> // User name and password here is coming form outside some client, i have
> tajken here as hardcoded.
>                 String user= "abhinav";  //It will come from outside client
>                 String  pass="abhinav"; //It will come from outside client
>
>                         authenticate(user,pass);
> }
>
> public static String authenticate(String user,String pass){
>              try  {
>                                     Session session = getConnection(user,
> password,url);// admin user and password to get connection
>                                     ModuleInvoke req =
> session.newModuleInvoke("authHelper.xqy");
>                                     req.setNewStringVariable("userName",
> user);
>                                     req.setNewStringVariable("password",
> pass);
>                                     ResultSequence rs =
> session.submitRequest(req);
>                                     while (rs.hasNext()) {
>                                                 ResultItem rsItem =
> rs.next();
>                                                 XdmItem item =
> rsItem.getItem();
>                                                 System.out.println(item);
> //Should be true, but getting false.
>                                     }
>                         } catch (Exception e) {
>                                     e.printStackTrace();
>                         }
>
> }
>
> ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
>
> Executed the xdmp:login via QueryConsole:
>
> When i am executing xdmp:login("abhinav","abhinav") in QueryConsole i am
> getting error as "[1.0-ml] XDMP-APPREQ: xdmp:login("abhinav", "abhinav") --
> Application level authentication required"
>
> When i set the QConsole with authentication scheme as "application-level"
> then xdmp:login("abhinav", "abhinav")  is returning true.
>
>
> Please guide me. Thanks a ton in advance.
>
> Regards,
> Abhinav Kumar Mishra
> </snip>
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL:
> http://developer.marklogic.com/pipermail/general/attachments/20130516/335552f2/attachment.html
>
> ------------------------------
>
> _______________________________________________
> General mailing list
> [email protected]
> http://developer.marklogic.com/mailman/listinfo/general
>
>
> End of General Digest, Vol 107, Issue 48
> ****************************************
>
_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to