Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Trac: Users

Problem with basic authentication using XML-RPC

 

 

Trac users RSS feed   Index | Next | Previous | View Threaded


inbasswetrust at gmail

Nov 11, 2011, 4:54 AM

Post #1 of 3 (414 views)
Permalink
Problem with basic authentication using XML-RPC

Hello.

I downloaded the examples zip from the XML-RPC Trac plugin site and I
am trying to access my Trac repository using XML-RPC. This is my code:

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();
}
}
}

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 Trac serves XML-RPC requests
correctly from the Mylyn Trac connector.

What am I doing wrong?

--
You received this message because you are subscribed to the Google Groups "Trac Users" group.
To post to this group, send email to trac-users [at] googlegroups
To unsubscribe from this group, send email to trac-users+unsubscribe [at] googlegroups
For more options, visit this group at http://groups.google.com/group/trac-users?hl=en.


oddsimons at gmail

Nov 12, 2011, 1:21 AM

Post #2 of 3 (400 views)
Permalink
Re: Problem with basic authentication using XML-RPC [In reply to]

On Nov 11, 2:54 pm, IBWT <inbasswetr...@gmail.com> wrote:

[snip]

>        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();
>                }

[snip]

> Caused by: org.apache.xmlrpc.XmlRpcException: Failed to create input
> stream: Server returned HTTP response code: 401 for URL:http://modelum.es/trac/mylyntest

Your URL seems bad. It gets a 401 (not authorized), and I then doubt
that that URL challenges for authentication - and even if it does it
still lacks a call to the actual RPC handler. The URL should look
something like this (assuming "mylyntest" is a your project):

http://modelum.es/trac/mylyntest/login/rpc


:::simon

--
You received this message because you are subscribed to the Google Groups "Trac Users" group.
To post to this group, send email to trac-users [at] googlegroups
To unsubscribe from this group, send email to trac-users+unsubscribe [at] googlegroups
For more options, visit this group at http://groups.google.com/group/trac-users?hl=en.


inbasswetrust at gmail

Nov 14, 2011, 1:36 AM

Post #3 of 3 (402 views)
Permalink
Re: Problem with basic authentication using XML-RPC [In reply to]

Hello Simon thanks for your response.

My URL works properly with the Ruby XML-RPC implementation (trac4r).
The URL you provide is not recognized by the server, an exception is
thrown by the client saying that no input stream can be created.

On Nov 12, 10:21 am, osimons <oddsim...@gmail.com> wrote:
> On Nov 11, 2:54 pm, IBWT <inbasswetr...@gmail.com> wrote:
>
> [snip]
>
> >        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();
> >                }
>
> [snip]
>
> > Caused by: org.apache.xmlrpc.XmlRpcException: Failed to create input
> > stream: Server returned HTTP response code: 401 for URL:http://modelum.es/trac/mylyntest
>
> Your URL seems bad. It gets a 401 (not authorized), and I then doubt
> that that URL challenges for authentication - and even if it does it
> still lacks a call to the actual RPC handler. The URL should look
> something like this (assuming "mylyntest" is a your project):
>
> http://modelum.es/trac/mylyntest/login/rpc
>
> :::simon

--
You received this message because you are subscribed to the Google Groups "Trac Users" group.
To post to this group, send email to trac-users [at] googlegroups
To unsubscribe from this group, send email to trac-users+unsubscribe [at] googlegroups
For more options, visit this group at http://groups.google.com/group/trac-users?hl=en.

Trac users RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.