ws-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Javier Espinazo Pagán <jespin...@um.es>
Subject Problem with Basic Authentication
Date Fri, 11 Nov 2011 12:33:12 GMT
Hello.

I am trying to authenticate a client against a Trac XML-RPC server
using the following code, which does a simple request:

package es.modelum.migration.mylyn.trac;

import java.net.MalformedURLException;
import java.net.URL;

import org.apache.xmlrpc.client.XmlRpcClient;
import org.apache.xmlrpc.client.XmlRpcClientConfigImpl;
import org.lustin.trac.xmlprc.Ticket;
import org.lustin.trac.xmlprc.TrackerDynamicProxy;

import tasks.Task;

public class TracInitializer {
	XmlRpcClient rpcClient = new XmlRpcClient();
	TrackerDynamicProxy rpcProxy;
	
	public TracInitializer(String serverURL, String username, String
password) throws MalformedURLException {
		XmlRpcClientConfigImpl rpcConf = new XmlRpcClientConfigImpl();
		rpcConf.setBasicUserName(username);
		rpcConf.setBasicPassword(password);
		rpcConf.setServerURL(new URL(serverURL));
		
		rpcClient.setConfig(rpcConf);		
		rpcProxy = new TrackerDynamicProxy(rpcClient);
	}
	
	public void getTicket(int ticketID) {
		Ticket ticket = (Ticket)rpcProxy.newInstance(Ticket.class);		
		System.err.println(ticket.getTicketFields());		
	}
	
	public void createTicket(Task task) {
		
	}
	
	static public void main(String[] args) {
		try {
			TracInitializer tracInitializer = new
TracInitializer("http://modelum.es/trac/mylyntest", "user", "pass");
			tracInitializer.getTicket(2);
		} catch (MalformedURLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}		
	}
}

However, when the request ticket.getTicketFields() is called, I get
the following exception:

Exception in thread "main" java.lang.reflect.UndeclaredThrowableException
	at $Proxy0.getTicketFields(Unknown Source)
	at es.modelum.migration.mylyn.trac.TracInitializer.getTicket(TracInitializer.java:29)
	at es.modelum.migration.mylyn.trac.TracInitializer.main(TracInitializer.java:39)
Caused by: org.apache.xmlrpc.XmlRpcException: Failed to create input
stream: Server returned HTTP response code: 401 for URL:
http://modelum.es/trac/mylyntest
	at org.apache.xmlrpc.client.XmlRpcSunHttpTransport.getInputStream(XmlRpcSunHttpTransport.java:60)
	at org.apache.xmlrpc.client.XmlRpcStreamTransport.sendRequest(XmlRpcStreamTransport.java:141)
	at org.apache.xmlrpc.client.XmlRpcHttpTransport.sendRequest(XmlRpcHttpTransport.java:94)
	at org.apache.xmlrpc.client.XmlRpcSunHttpTransport.sendRequest(XmlRpcSunHttpTransport.java:39)
	at org.apache.xmlrpc.client.XmlRpcClientWorker.execute(XmlRpcClientWorker.java:53)
	at org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:166)
	at org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:136)
	at org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:125)
	at org.lustin.trac.xmlprc.TrackerDynamicProxy$1.invoke(TrackerDynamicProxy.java:125)
	... 3 more

User and password are correct and the server answers XML-ROC requests
correctly from the Mylyn Trac connector. I found an old archived
thread with a similar problem
http://mail-archives.apache.org/mod_mbox/ws-xmlrpc-dev/200711.mbox/%3C661040B2-C42C-4B24-A11A-012209741047@acm.org%3E
but the author didn't provide his solution to the problem.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ws.apache.org
For additional commands, e-mail: dev-help@ws.apache.org


Mime
View raw message