quaff 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/auth.rb +7 -0
  2. data/lib/endpoint.rb +7 -6
  3. metadata +2 -2
@@ -22,6 +22,13 @@ module Quaff
22
22
  return Base64.decode64(auth_pairs["nonce"])[0..15]
23
23
  end
24
24
 
25
+ def Auth.gen_empty_auth_header username
26
+ return %Q!Digest username="#{username}",realm="",nonce="",uri="",response=""!
27
+ # Return Authorization header with only the username field set,
28
+ # to indicate the private ID in cases where it isn't linked to
29
+ # the SIP URI
30
+ end
31
+
25
32
  def Auth.gen_auth_header auth_line, username, passwd, method, sip_uri
26
33
  # Split auth line on commas
27
34
  auth_pairs = {}
@@ -98,9 +98,10 @@ module Quaff
98
98
  end
99
99
 
100
100
  def register expires="3600", aka=false
101
- call = outgoing_call(@uri)
102
- call.send_request("REGISTER", "", { "Expires" => expires.to_s })
103
- response_data = call.recv_response("401|200")
101
+ @reg_call ||= outgoing_call(@uri)
102
+ auth_hdr = Quaff::Auth.gen_empty_auth_header @username
103
+ @reg_call.send_request("REGISTER", "", {"Authorization" => auth_hdr, "Expires" => expires.to_s})
104
+ response_data = @reg_call.recv_response("401|200")
104
105
  if response_data.status_code == "401"
105
106
  if aka
106
107
  rand = Quaff::Auth.extract_rand response_data.header("WWW-Authenticate")
@@ -109,9 +110,9 @@ module Quaff
109
110
  password = @password
110
111
  end
111
112
  auth_hdr = Quaff::Auth.gen_auth_header response_data.header("WWW-Authenticate"), @username, @password, "REGISTER", @uri
112
- call.update_branch
113
- call.send_request("REGISTER", "", {"Authorization" => auth_hdr, "Expires" => expires.to_s, "CSeq" => "2 REGISTER"})
114
- response_data = call.recv_response("200")
113
+ @reg_call.update_branch
114
+ @reg_call.send_request("REGISTER", "", {"Authorization" => auth_hdr, "Expires" => expires.to_s})
115
+ response_data = @reg_call.recv_response("200")
115
116
  end
116
117
  return response_data # always the 200 OK
117
118
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: quaff
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-12-31 00:00:00.000000000 Z
12
+ date: 2014-02-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: facter