Revision 336

Date:
2013/05/03 19:59:49
Author:
ahitrov
Revision Log:
Another sha1 algorythm
Files:

Legend:

 
Added
 
Removed
 
Modified
  • utf8/plugins/tokbox/config.proto

     
    7 7 PLUGINS += tokbox
    8 8
    9 9 PROJECT_REQUIRED += XML-Fast
    10 PROJECT_REQUIRED += Digest-SHA1
    10 PROJECT_REQUIRED += Digest-SHA
    11 11 PROJECT_REQUIRED += MIME-Base64
    12 12
    13 13
  • utf8/plugins/tokbox/lib/tokbox/Keeper.pm

     
    2 2
    3 3 use strict;
    4 4 use warnings 'all';
    5 use Time::HiRes;
    5 use Time::HiRes qw( gettimeofday );
    6 6 use MIME::Base64;
    7 use Digest::SHA1 qw(sha1 sha1_hex);
    7 use Digest::SHA qw(hmac_sha1 hmac_sha1_hex);
    8 8 use LWP::UserAgent;
    9 9 use URI;
    10 10 use Data::Dumper;
     
    14 14
    15 15 use Contenido::Globals;
    16 16
    17 our $SUBSCRIBER = "subscriber";
    18 our $PUBLISHER = "publisher";
    19 our $MODERATOR = "moderator";
    17 my $SUBSCRIBER = "subscriber";
    18 my $PUBLISHER = "publisher";
    19 my $MODERATOR = "moderator";
    20 20
    21 21 sub OpenTokSession {
    22 22 my ($self, $sessionId, $properties) = @_;
     
    41 41 my $connection_data = delete $opts{connection_data} || '';
    42 42
    43 43 my $create_time = time;
    44 my $nonce = gettimeofday() . rand();
    44 my $nonce = rand();
    45 45
    46 46 if ( !$role ) {
    47 47 $role = $PUBLISHER;
     
    49 49 warn "unknown role $role\n";
    50 50 return;
    51 51 }
    52 my $data_string = "session_id=$session_id&create_time=$create_time&role=$role&nonce=$nonce";
    52 my $data_string = "role=$role&session_id=$session_id&create_time=$create_time&nonce=$nonce";
    53 53 if ( defined $expire_time ) {
    54 54 if ( $expire_time =~ /\D/ ) {
    55 55 warn "Expire time must be a number\n";
     
    68 68 warn "Connection data must be less than 1000 characters\n";
    69 69 return;
    70 70 }
    71 $data_string .= "&connection_data=" . Utils::HTML::url_escape($connection_data);
    71 $data_string .= "&connection_data=" . Utils::HTML::url_escape( $connection_data );
    72 } else {
    73 $data_string .= "&connection_data=";
    72 74 }
    75
    73 76 my $sig = $self->_sign_string($data_string, $self->state->{tokbox_secret});
    74 77 my $api_key = $self->state->{tokbox_api_key};
    75 78
    76 return "T1==" . encode_base64("partner_id=$api_key&sig=$sig:$data_string");
    79 warn "AUTH: [partner_id=$api_key&sig=$sig:$data_string]\n" if $DEBUG;
    80 return "T1==" . MIME::Base64::encode_base64("partner_id=$api_key&sig=$sig:$data_string", '');
    77 81 }
    78 82
    79 83
     
    117 121 ########################################################
    118 122 sub _sign_string {
    119 123 my ($self, $string, $secret) = @_;
    120 return sha1_hex($string, $secret);
    124 return hmac_sha1_hex($string, $secret);
    121 125 }
    122 126
    123 127 sub _do_request {