Thanks a lot or replying mike...Its very helpful. Can you please explain the
process of changing the server to allow basic authentication. That would
really help me.

Thanks in Advance.

Regards,
Bharat

On Thu, Mar 17, 2011 at 8:03 PM, Michael Blakeley <[email protected]> wrote:

> Your Java code specifies basic authentication, and the app-server defaults
> to digest. You can change the Java code to use digest: this is the preferred
> solution because basic isn't secure. In an environment where digest
> authentication isn't possible, you could change the server to allow basic
> authentication. An even less secure option is to specify application-level
> authentication and a sufficiently-privileged default user.
>
> http://en.wikipedia.org/wiki/Basic_access_authentication
>
> http://en.wikipedia.org/wiki/Digest_access_authentication
>
>
> http://docs.marklogic.com/4.2doc/docapp.xqy#display.xqy?fname=http://pubs/4.2doc/xml/security/authentication.xml%2356266
>
> -- Mike
>
> On 17 Mar 2011, at 04:52 , Bharat kumar wrote:
>
> > Hi,
> >
> > We have created a HTTP server(with port 8005) in Marklogic and we just
> wrote some sample xqy file(request.xqy) which will return plain XML. So if
> we are hitting the URL in browser its asking for username and password, once
> we give the details its giving the sample XML output.
> >
> > URL : http://localhost:8005/request.xqy Username : admin Password :
> admin.
> >
> > Output of request.xqy : <abc>hi</abc>
> >
> > So we are trying to open the same connection from Java using
> URLConnection but we are getting the 401 unauthorized error code. We are
> making sure that we are embedding the username and password. But still its
> giving error code. Here is the Java code whcih we have used.
> >
> > URL url = new URL("http://10.201.174.163:8005/request.xqy";);
> > String userName = "admin";
> > String password= "admin";
> > String userPassword=userName + ":" +password;
> > String encoding = new
> sun.misc.BASE64Encoder().encode(userPassword.getBytes());
> > System.out.println(encoding);
> > URLConnection connection = url.openConnection();
> > String encoding = base64Encode(userPassword);
> > connection.setRequestProperty("Authorization", "Basic "
> >             + encoding);
> >
> > BufferedReader in = new BufferedReader(new InputStreamReader(
> >           connection.getInputStream()));
> >
> > The same way is implemented in some other project in our account and its
> working fine. But we are not aware of the marklogic settings.
> >
> > Please help us and let us know whether we need to do any other settings
> from Marklogic side to allow accessing the marklogic application using
> HttpConnection by Java.
> >
> > Thanks in Advance.
> >
> > Regards,
> > Bharat. K
> >
> > _______________________________________________
> > General mailing list
> > [email protected]
> > http://developer.marklogic.com/mailman/listinfo/general
>
> _______________________________________________
> General mailing list
> [email protected]
> http://developer.marklogic.com/mailman/listinfo/general
>
_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to