Class: WWPassConnection
- Inherits:
-
Object
- Object
- WWPassConnection
- Defined in:
- lib/wwpass-ruby-sdk/wwpass_connection.rb
Instance Method Summary collapse
- #get_name ⇒ Object
- #get_puid(ticket, auth_type = '') ⇒ Object
- #get_ticket(auth_type = '', ttl = 120) ⇒ Object
-
#initialize(cert_file, key_file, cafile, timeout = 10, spfe_addr = 'https://spfe.wwpass.com') ⇒ WWPassConnection
constructor
A new instance of WWPassConnection.
- #lock(ticket, lock_timeout, lockid) ⇒ Object
- #put_ticket(ticket, ttl = 120, auth_type = '') ⇒ Object
- #read_data(ticket, container = '') ⇒ Object
- #read_data_and_lock(ticket, lock_timeout, container = '') ⇒ Object
- #unlock(ticket, lockid) ⇒ Object
- #write_data(ticket, data, container = '') ⇒ Object
- #write_data_and_unlock(ticket, data, container = '') ⇒ Object
Constructor Details
#initialize(cert_file, key_file, cafile, timeout = 10, spfe_addr = 'https://spfe.wwpass.com') ⇒ WWPassConnection
Returns a new instance of WWPassConnection.
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/wwpass-ruby-sdk/wwpass_connection.rb', line 8 def initialize(cert_file, key_file, cafile, timeout = 10, spfe_addr = 'https://spfe.wwpass.com') @resource = RestClient::Resource.new( spfe_addr, :ssl_client_cert => OpenSSL::X509::Certificate.new(File.read(cert_file)), :ssl_client_key => OpenSSL::PKey::RSA.new(File.read(key_file)), :ssl_ca_file => cafile, :verify_ssl => OpenSSL::SSL::VERIFY_PEER, :timeout => timeout ) end |
Instance Method Details
#get_name ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/wwpass-ruby-sdk/wwpass_connection.rb', line 19 def get_name ticket = get_ticket('', 0) pos = ticket.index(':') if pos != nil ticket[0, pos] else raise WWPassException.new 'SPFE return ticket without a colon' end end |
#get_puid(ticket, auth_type = '') ⇒ Object
33 34 35 |
# File 'lib/wwpass-ruby-sdk/wwpass_connection.rb', line 33 def get_puid(ticket, auth_type = '') make_request('GET', 'puid', :params => {:ticket => ticket, :auth_type => auth_type}) end |
#get_ticket(auth_type = '', ttl = 120) ⇒ Object
29 30 31 |
# File 'lib/wwpass-ruby-sdk/wwpass_connection.rb', line 29 def get_ticket(auth_type = '', ttl=120) make_request('GET', 'get', :params => {:ttl => ttl, :auth_type => auth_type}) end |
#lock(ticket, lock_timeout, lockid) ⇒ Object
57 58 59 |
# File 'lib/wwpass-ruby-sdk/wwpass_connection.rb', line 57 def lock(ticket, lock_timeout, lockid) make_request('GET','lock',:params => {:ticket => ticket, :lockid => lockid, :to => lock_timeout}) end |
#put_ticket(ticket, ttl = 120, auth_type = '') ⇒ Object
37 38 39 |
# File 'lib/wwpass-ruby-sdk/wwpass_connection.rb', line 37 def put_ticket(ticket, ttl = 120, auth_type = '') make_request('GET','put', :params => {:ticket => ticket, :ttl => ttl, :auth_type => auth_type}) end |
#read_data(ticket, container = '') ⇒ Object
41 42 43 |
# File 'lib/wwpass-ruby-sdk/wwpass_connection.rb', line 41 def read_data(ticket, container = '') make_request('GET','read', :params => {:ticket => ticket, :container => container}) end |
#read_data_and_lock(ticket, lock_timeout, container = '') ⇒ Object
45 46 47 |
# File 'lib/wwpass-ruby-sdk/wwpass_connection.rb', line 45 def read_data_and_lock(ticket, lock_timeout, container = '') make_request('GET','read', :params => {:ticket => ticket, :container => container, :lock => '1', :to => lock_timeout}) end |
#unlock(ticket, lockid) ⇒ Object
61 62 63 |
# File 'lib/wwpass-ruby-sdk/wwpass_connection.rb', line 61 def unlock(ticket, lockid) make_request('GET','unlock', :params => {:ticket => ticket, :lockid => lockid}) end |
#write_data(ticket, data, container = '') ⇒ Object
49 50 51 |
# File 'lib/wwpass-ruby-sdk/wwpass_connection.rb', line 49 def write_data(ticket, data, container = '') make_request('POST','write', {:ticket => ticket, :data => data, :container => container}, 1) end |
#write_data_and_unlock(ticket, data, container = '') ⇒ Object
53 54 55 |
# File 'lib/wwpass-ruby-sdk/wwpass_connection.rb', line 53 def write_data_and_unlock(ticket, data, container = '') make_request('POST','write', {:ticket => ticket, :data => data, :container => container, :unlock => '1'}, 1) end |