Method: Quaff::BaseEndpoint#register
- Defined in:
- lib/endpoint.rb
#register(expires = "3600", aka = false) ⇒ Object
Utility method - handles a REGISTER/200 or REGISTER/401/REGISTER/200 flow to authenticate the subscriber. Currently only supports SIP Digest authentication. Re-REGISTERs are not handled; if you need long-running endpoints you should create a thread to re-REGISTER them yourself.
Returns the Message representing the 200 OK, or throws an exception on failure to authenticate successfully.
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 |
# File 'lib/endpoint.rb', line 149 def register expires="3600", aka=false @reg_call ||= outgoing_call(@uri) auth_hdr = Quaff::Auth.gen_empty_auth_header @username @reg_call.update_branch @reg_call.send_request("REGISTER", "", {"Authorization" => auth_hdr, "Expires" => expires.to_s}) response_data = @reg_call.recv_response("401|200") if response_data.status_code == "401" if aka rand = Quaff::Auth.extract_rand response_data.header("WWW-Authenticate") password = @kernel.f3 rand else password = @password end auth_hdr = Quaff::Auth.gen_auth_header response_data.header("WWW-Authenticate"), @username, @password, "REGISTER", @uri @reg_call.update_branch @reg_call.send_request("REGISTER", "", {"Authorization" => auth_hdr, "Expires" => expires.to_s}) response_data = @reg_call.recv_response("200") end return response_data # always the 200 OK end |