Advertisement
Guest User

Untitled

a guest
Jan 18th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. class Authenticate < Header
  2. attr_accessor :scheme, :realm, :domain, :nonce, :opaque, :stale, :algorithm,
  3. :qop
  4.  
  5. def initialize
  6. @name = "Authenticate"
  7. super
  8. end
  9.  
  10. def assign(val_str, parse=true)
  11. unless parse
  12. cache_and_clear(val_str, [:realm, :domain, :nonce, :opaque, :stale, :algorithm, :qop])
  13. else
  14. @frozen_str = nil
  15. @scheme, challenge = val_str.split(" ", 2)
  16. challenge.split(",").each do |x|
  17. k, v = x.split("=", 2)
  18. self.send((k.strip+"=").to_sym, v.strip)
  19. end
  20. @header_params = {}
  21.  
  22. end # parse or assign
  23. self
  24. end # assign method
  25. end
  26.  
  27. class WwwAuthenticate < Authenticate
  28. def initialize
  29. @name = "WWW-Authenticate"
  30. super
  31. end
  32. end
  33.  
  34. auth = SipHeaders::WwwAuthenticate.new
  35. puts "1"
  36. auth.assign challenge #challenge is a previously set string
  37. # I've also tried this: auth = SipHeaders::Authenticate.assign challenge
  38. puts "2"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement