Method: Session#refresh_token

Defined in:
lib/ucslib/service/ucs/session.rb

#refresh_token(tokenjson) ⇒ Object



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/ucslib/service/ucs/session.rb', line 54

def refresh_token(tokenjson)

  cookie   = "#{JSON.parse(tokenjson)['cookie']}"
  username = "#{JSON.parse(tokenjson)['username']}"
   password = "#{JSON.parse(tokenjson)['password']}"
   ip       = "#{JSON.parse(tokenjson)['ip']}"
   url   = "https://#{ip}/nuova"


   xml_builder = Nokogiri::XML::Builder.new do |xml|
       xml.aaaRefresh('inName' => username, 'inPassword' => password, 'inCookie' => cookie)
       end
   aaa_refresh_xml = xml_builder.to_xml.to_s

   ucs_response = rest_post(aaa_refresh_xml,@url)


    = Nokogiri::XML(ucs_response)
    = .root
   new_cookie = .attributes['outCookie']

   begin
    #return ucs_session json containing new cookie, url, ip
  return session = {  :cookie   => "#{new_cookie}",
              :username => "#{username}",
              :password => "#{password}",
              :ip       => "#{ip}"  }.to_json
  rescue Exception => e
    'An Error Occured. Please check authentication credentials'
  else
    Process.exit
  end

end