/usr/share/perl5/POE/Component/Jabber/Legacy.pm is in libpoe-component-jabber-perl 3.00-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 | package POE::Component::Jabber::Legacy;
use warnings;
use strict;
use 5.010;
use POE;
use POE::Component::Jabber::Events;
use POE::Filter::XML;
use POE::Filter::XML::Node;
use POE::Filter::XML::NS qw/ :JABBER :IQ /;
use Digest::SHA qw/ sha1_hex /;
use base('POE::Component::Jabber::Protocol');
our $VERSION = '3.00';
sub get_version()
{
return '0.9';
}
sub get_xmlns()
{
return +NS_JABBER_CLIENT;
}
sub get_states()
{
return [ 'set_auth', 'init_input_handler' ];
}
sub get_input_event()
{
return 'init_input_handler';
}
sub set_auth()
{
my ($kernel, $heap) = @_[KERNEL, HEAP];
my $config = $heap->config();
my $node = POE::Filter::XML::Node->new('iq', ['type', +IQ_SET, 'id', 'AUTH']);
my $query = $node->appendChild('query', ['xmlns', +NS_JABBER_AUTH]);
$query->appendChild('username')->appendText($config->{'username'});
if($config->{'plaintext'})
{
$query->appendChild('password')->appendText($config->{'password'});
} else {
my $hashed = sha1_hex($heap->sid().$config->{'password'});
$query->appendChild('digest')->appendText($hashed);
}
$query->appendChild('resource')->appendText($config->{'resource'});
$kernel->yield('output_handler', $node, 1);
$heap->jid($config->{'username'} . '@' . $config->{'hostname'} . '/' .
$config->{'resource'});
return;
}
sub init_input_handler()
{
my ($kernel, $heap, $node) = @_[KERNEL, HEAP, ARG0];
my $config = $heap->config();
if ($config->{'debug'})
{
$heap->debug_message( "Recd: ".$node->toString() );
}
given($node->nodeName())
{
when('stream:stream')
{
$heap->sid($node->getAttribute('id'));
$kernel->yield('set_auth');
$kernel->post($heap->events(), +PCJ_AUTHNEGOTIATE);
}
when('iq')
{
given([$node->getAttribute('type'), $node->getAttribute('id')])
{
when([+IQ_RESULT, 'AUTH'])
{
$heap->relinquish_states();
$kernel->post($heap->events(), +PCJ_AUTHSUCCESS);
$kernel->post($heap->events(), +PCJ_READY);
}
when([+IQ_ERROR, 'AUTH']) {
$heap->debug_message('Authentication Failed');
$kernel->yield('shutdown');
$kernel->post($heap->events(), +PCJ_AUTHFAIL);
}
}
}
}
return;
}
1;
__END__
=pod
=head1 NAME
POE::Component::Jabber::Legacy - connect using the pre-XMPP Jabber protocol
=head1 SYNOPSIS
PCJ::Legacy is a Protocol implementation for the legacy (ie. Pre-XMPP) Jabber
protocol.
=head1 DESCRIPTION
PCJ::Legacy implements the simple iq:auth authentication mechanism defined in
the deprecated XEP at http://www.xmpp.org/extensions/xep-0078.html. This
Protocol class is mainly used for connecting to legacy jabber servers that do
not conform the to XMPP1.0 RFC.
=head1 METHODS
Please see PCJ::Protocol for what methods this class supports.
=head1 EVENTS
Listed below are the exported events that end up in PCJ's main session:
=over 2
=item set_auth
This handles construction and sending of the iq:auth query.
=item init_input_handler
This is our main entry point. This is used by PCJ to deliver all input events
until we are finished. Also handles responses to authentication.
=back
=head1 NOTES AND BUGS
Ideally, this class wouldn't be necessary, but there is a large unmoving mass
of entrenched users and administrators that refuse to migrate to XMPP. It
largely doesn't help that debian still ships jabberd 1.4.3 which does NOT
support XMPP.
The underlying backend has changed this release to now use a new Node
implementation based on XML::LibXML::Element. Please see POE::Filter::XML::Node
documentation for the relevant API changes.
=head1 AUTHOR
Copyright (c) 2003-2009 Nicholas Perez. Distributed under the GPL.
=cut
|