/usr/share/perl5/POE/Component/Jabber/J14.pm is in libpoe-component-jabber-perl 3.00-4.
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 | package POE::Component::Jabber::J14;
use warnings;
use strict;
use 5.010;
no if $] >= 5.017011, warnings => 'experimental::smartmatch';
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_ACCEPT;
}
sub get_states()
{
return [ 'set_auth', 'init_input_handler' ];
}
sub get_input_event()
{
return 'init_input_handler';
}
sub set_auth()
{
my ($kernel, $heap, $self) = @_[KERNEL, HEAP, OBJECT];
my $node = POE::Filter::XML::Node->new('handshake');
my $config = $heap->config();
$node->appendText(sha1_hex($self->{'sid'}.$config->{'password'}));
$kernel->post($heap->events(), +PCJ_AUTHNEGOTIATE);
$kernel->yield('output_handler', $node, 1);
return;
}
sub init_input_handler()
{
my ($kernel, $heap, $self, $node) = @_[KERNEL, HEAP, OBJECT, ARG0];
given($node->nodeName())
{
when('handshake')
{
my $config = $heap->config();
$kernel->post($heap->events(), +PCJ_AUTHSUCCESS);
$kernel->post($heap->events(), +PCJ_READY);
$heap->jid($config->{'hostname'});
$heap->relinquish_states();
}
when('stream:stream')
{
$self->{'sid'} = $node->getAttribute('id');
$kernel->yield('set_auth');
}
default
{
$heap->debug_message('Unknown state: ' . $node->toString());
$kernel->post($heap->events(), +PCJ_AUTHFAIL);
}
}
}
1;
__END__
=pod
=head1 NAME
POE::Component::Jabber::J14 - connect to the jabberd14 router as a service
=head1 SYNOPSIS
PCJ::J14 is a Protocol implementation that connects as a service to a jabberd14
server.
=head1 DESCRIPTION
PCJ::J14 authenticates with the server backend using the method outlined in
XEP-114 (Jabber Component Protocol)
[http://www.xmpp.org/extensions/xep-0114.html]
=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 event constructs and sends the <handshake/> element for authentication.
=item init_input_handler
This is out main entry point that PCJ uses to send us all of the input. It
handles the authentication response.
=back
=head1 NOTES AND BUGS
This only implements the jabber:component:accept namespace (ie. the component
initiates the connection to the server).
Also be aware that before this protocol was documented as an XEP, it was widely
implemented with loose rules. I conform to this document. If there is a problem
with the implementation against older server implementations, let me know.
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
|