[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[no subject]



----- Cut Here -----
sub new {
    my $class = shift;
    my $self = ($#_ == 0) ? { %{ (shift) } } : { @_ };
                                                                                                                             
    bless $self, $class;
                                                                                                                             
    die "Frontier::RPC::new: no url defined\n"
        if !defined $self->{'url'};
                                                                                                                             
    $self->{'ua'} = LWP::UserAgent->new;
    $self->{'ua'}->proxy('http', $self->{'proxy'})
        if(defined $self->{'proxy'});
    $self->{'rq'} = HTTP::Request->new (POST => $self->{'url'});
    $self->{'rq'}->header('Content-Type' => 'text/xml');
                                                                                                                             
    my @options;
                                                                                                                             
    if(defined $self->{'encoding'}) {
        push @options, 'encoding' => $self->{'encoding'};
    }
                                                                                                                             
    if (defined $self->{'use_objects'} && $self->{'use_objects'}) {
        push @options, 'use_objects' => $self->{'use_objects'};
    }
                                                                                                                             
    $self->{'enc'} = Frontier::RPC2->new(@options);
                                                                                                                             
    return $self;
}
----- Cut Here -----

I think I'll modify it to accept a LWP::UserAgentboject instead of
creating a new one.  That will allow me to pass the cookie jar over. 
Basically to do form authentication on our device is this simple:

----- Cut Here -----
my $ua = LWP::UserAgent->new();
$ua->cookie_jar({ file => "$ENV{HOME}/.cookies.txt" });
my $response = $ua-&gt;post(&quot;<a  rel="nofollow" href="http://192.168.2.120/cgi-bin/login&quot";>http://192.168.2.120/cgi-bin/login&quot</a>;,
        { 'user' =&gt; &quot;root&quot;, 'pass' =&gt; &quot;password&quot; });
----- Cut Here -----

This modification will allow me to pass over the LWP object that has
authenticated into our web site.  What do you think?  would modifying
the constructor to accept a LWP::UserAgent object be a good idea to get
past the form based authentication the site forces on a user?


On Fri, 2005-02-11 at 08:52, Christopher Fowler wrote:
&gt; Thanks for all your help.  I happened to have the O'Reilly book but it
&gt; was hidden by other books on my shelf.  Late last night I found it.  It
&gt; is brief but is providing me some answers.  I've been able to create
&gt; some code on our device from scratch that is working great with the
&gt; Frontier client.  I've not done the XML parsing on the device or created
&gt; any methods but I'm working on that today and next week.
&gt; 
&gt; 
&gt; Has anyone used the Frontier client?
&gt; 
&gt; --- Test Code ---
&gt; use Frontier::Client;
&gt; $server = Frontier::Client-&gt;new( debug =&gt; 1, url =&gt;
&gt; '<a  rel="nofollow" href="https://192.168.2.120/cgi-bin/xml-rpc";>https://192.168.2.120/cgi-bin/xml-rpc</a>' );
&gt; $result = $server-&gt;call('restart', (&quot;now&quot;));
&gt; print &quot;$result\n&quot;;
&gt; --- Test Code ---
&gt; 
&gt; Here is the problem.  It works fine when the code is in stand alone
&gt; debug mode.  But I'm not doing any authentication. Instead of using
&gt; a string as the 'url' in the contstructor I need to use LWP to login to
&gt; the site to get a valid cookie.  If I place this code in the production
&gt; site without a valid cookie I'll simply be redirected to
&gt; '/cgi-bin/login' .  I'm not really planning on using Frontier for
&gt; production code.  The PERL in this case is all test code.  J2EE will be
&gt; doing the interfacing with the remote device.  I'll eventually create a
&gt; device object in Perl that will use XML-RPC to execute remote commands
&gt; but that is not important now.  I'm just curious as to how I can use
&gt; Frontier with my device since all pages on my device require form based
&gt; authentication.
&gt; 
&gt; Thanks,
&gt; Chris
&gt; 
&gt;   
&gt; On Fri, 2005-02-11 at 08:13, Fletch wrote:
&gt; &gt; &gt;&gt;&gt;&gt;&gt; &quot;Christopher&quot; == Christopher Fowler &lt;cfowler at outpostsentinel.com&gt; writes:
&gt; &gt; 
&gt; &gt; [...]
&gt; &gt; 
&gt; &gt;     Christopher&gt; I think that is right.  I can not seem to find info
&gt; &gt;     Christopher&gt; on how to return errors.  Simply like what XML do I
&gt; &gt;     Christopher&gt; return if for example a method is called that does
&gt; &gt;     Christopher&gt; not exist on the server?
&gt; &gt; 
&gt; &gt; I can't recall offhand (I want to say it's something like
&gt; &gt; &lt;error&gt;&lt;code&gt;#&lt;/code&gt;&lt;message&gt;...&lt;/message&gt;&lt;/error&gt;), but if you
&gt; &gt; install the Perl RPC::XML module (or use the Python one which is stock
&gt; &gt; post 2.3 I think, or the Ruby one that's stock post 1.8.2 :) and send
&gt; &gt; a simple server a bogus request you should be able to see what those
&gt; &gt; send back.
&gt; 
&gt; _______________________________________________
&gt; Ale mailing list
&gt; Ale at ale.org
&gt; <a  rel="nofollow" href="http://www.ale.org/mailman/listinfo/ale";>http://www.ale.org/mailman/listinfo/ale</a>


</pre>
<!--X-Body-of-Message-End-->
<!--X-MsgBody-End-->
<!--X-Follow-Ups-->
<hr>
<!--X-Follow-Ups-End-->
<!--X-References-->
<ul><li><strong>References</strong>:
<ul>
<li><strong><a name="00381" href="msg00381.html">[ale] Implementing XML-RPC</a></strong>
<ul><li><em>From:</em> cfowler at outpostsentinel.com (Christopher Fowler)</li></ul></li>
<li><strong><a name="00383" href="msg00383.html">[ale] Implementing XML-RPC</a></strong>
<ul><li><em>From:</em> cfowler at outpostsentinel.com (Christopher Fowler)</li></ul></li>
<li><strong><a name="00387" href="msg00387.html">[ale] Implementing XML-RPC</a></strong>
<ul><li><em>From:</em> fletch at phydeaux.org (Fletch)</li></ul></li>
<li><strong><a name="00388" href="msg00388.html">[ale] Implementing XML-RPC</a></strong>
<ul><li><em>From:</em> cfowler at outpostsentinel.com (Christopher Fowler)</li></ul></li>
<li><strong><a name="00396" href="msg00396.html">[ale] Implementing XML-RPC</a></strong>
<ul><li><em>From:</em> fletch at phydeaux.org (Fletch)</li></ul></li>
<li><strong><a name="00399" href="msg00399.html">[ale] Implementing XML-RPC</a></strong>
<ul><li><em>From:</em> cfowler at outpostsentinel.com (Christopher Fowler)</li></ul></li>
</ul></li></ul>
<!--X-References-End-->
<!--X-BotPNI-->
<ul>
<li>Prev by Date:
<strong><a href="msg00401.html">[ale] Perl + CDDB</a></strong>
</li>
<li>Next by Date:
<strong><a href="msg00403.html">[ale] Sunbird calendar via sftp (on non-standard port)</a></strong>
</li>
<li>Previous by thread:
<strong><a href="msg00399.html">[ale] Implementing XML-RPC</a></strong>
</li>
<li>Next by thread:
<strong><a href="msg00394.html">[ale] Is delivered mail</a></strong>
</li>
<li>Index(es):
<ul>
<li><a href="maillist.html#00402"><strong>Date</strong></a></li>
<li><a href="threads.html#00402"><strong>Thread</strong></a></li>
</ul>
</li>
</ul>

<!--X-BotPNI-End-->
<!--X-User-Footer-->
<!--X-User-Footer-End-->
</body>
</html>