Discussion:
[Exist-open] authenticate user with xmlrpc
Swami Kevala
2008-03-30 07:47:35 UTC
Permalink
Can anybody tell me how I specify the user authentication details when I do
rpc calls.

I thought I could use the url:

http://username:***@localhost:8080/exist/xmlrpc

but this is not working for me

(I am working on a Flex app that needs to retrieve xml data from and eXist
database. I am using
http://danielmclaren.net/2007/08/03/xmlrpc-for-actionscript-30-free-library#comment-869
this actionscript 3.0 xmlrpc library

Currently, I can only do anything if the username is admin and the password
is blank

In the Developer's Guide (XML-RPC section), for a complete list of available
methods it refers to the Java interface
http://exist.sourceforge.net/api/org/exist/xmlrpc/RpcAPI.html RpcAPI.java .

All the methods here, take a User (Java) object as their first parameter.
I'm assuming that if the user passed to the xml-rcp method call doesn't have
the necessary permissions to execute the remote procedure then a
permissiondeniedexception will be thrown - but how do I create this User
object in Actionscript and pass it as an xml-rcp parameter?


Kind Regards

Swami Kevala
--
View this message in context: http://www.nabble.com/authenticate-user-with-xmlrpc-tp16372702p16372702.html
Sent from the exist-open mailing list archive at Nabble.com.
Wolfgang
2008-03-30 09:36:21 UTC
Permalink
Post by Swami Kevala
but this is not working for me
The XML-RPC service uses HTTP basic authorization by default. You need
to send an authorization header with the HTTP request, e.g.

Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
Post by Swami Kevala
In the Developer's Guide (XML-RPC section), for a complete list of available
methods it refers to the Java interface
http://exist.sourceforge.net/api/org/exist/xmlrpc/RpcAPI.html RpcAPI.java .
All the methods here, take a User (Java) object as their first parameter.
I'm assuming that if the user passed to the xml-rcp method call doesn't have
the necessary permissions to execute the remote procedure then a
permissiondeniedexception will be thrown - but how do I create this User
object in Actionscript and pass it as an xml-rcp parameter?
The User object is created by the XML-service, using the authentication
information from the HTTP header. You cannot pass it directly.

Wolfgang
Michael Westbay
2008-03-30 09:44:31 UTC
Permalink
Post by Swami Kevala
Can anybody tell me how I specify the user authentication details when I do
rpc calls.
but this is not working for me
Documentation specifies that Basic Authentication is necessary for
xmlrpc calls.

Enclosed please find the modified Groovy-based XMLRCPServerProxy.java
class that I use to make xmlrpc calls. Much of the xmlrpc stuff is
handled by the Groovy RPCServerProxy, I just added the Basic
Authentication stuff to the original proxy server.

Usage in Groovy goes something like this:

/* url is the collection URL.
* user and passwd are obvious.
* query is the XPath or XQuery to execute.
* action is a Groovy Closure that does some work with the result.
*/
def query(String query, Closure action) {
def params = ['encoding':'UTF-8','omit-xml-declaration':'no']
XMLRPCServerProxy proxy = new XMLRPCServerProxy(url, user, passwd)
proxy.executeQuery(query, params) { resultId ->
try {
def summary = proxy.querySummary(resultId)
(0..<summary['hits']).each { idx ->
action(new ByteArrayInputStream(proxy.retrieve(resultId, idx,
params)))
}
} finally {
proxy.releaseQueryResult(resultId)
}
}
}


Hopefully you can use this as psudocode to which ever language you wish
to use for communication with the xmlrpc server.
--
Michael Westbay
Writer/System Administrator
http://JapaneseBaseball.com
Loading...