Advertisement
Guest User

Untitled

a guest
Sep 25th, 2017
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package org.ossnetworks.net.rtmp
  2. {
  3.     import com.adobe.crypto.MD5;
  4.     import com.adobe.crypto.HMAC;
  5.    
  6.     import flash.net.NetConnection;
  7.    
  8.     import net.zedia.utils.StringUtils;
  9.    
  10.     public class AuthorizedNetConnection extends NetConnection
  11.     {
  12.         private var username:String;
  13.         private var password:String;
  14.         [Bindable] public var isAuthorized:Boolean=false;
  15.        
  16.         public function AuthorizedNetConnection(_username:String,_password:String)
  17.         {
  18.             this.username=_username;
  19.             this.password=_password;
  20.             super();
  21.         }
  22.        
  23.         public function authorize():void{
  24.             this.isAuthorized=true;
  25.             this.dispatchEvent(new NetConnectionAuthorizeEvent(NetConnectionAuthorizeEvent.NCA_AUTHORIZED));
  26.         }
  27.        
  28.         public function remoteErrorProxy(e:*):void{
  29.             var e:Error = new Error(e);
  30.             throw e;
  31.         }
  32.        
  33.         public function nonceAuth(ronce:String):String{
  34.             /*
  35.             Auth pattern corresponds to a poor mans` implementation of noonce algo used in SIP sessions.
  36.             we construct the string using ronce provided by server
  37.             Hash it with md5 and return to server
  38.             */
  39.             trace('----------------------------------------------')
  40.             trace(this.username+' '+HMAC.hash(this.password,ronce))
  41.             trace('----------------------------------------------')
  42.             return this.username+' '+HMAC.hash(this.password,ronce)
  43.         }
  44.     }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement