lib/yubico.rb
def add_key( id, nonce )
		  if not @_key
		    return E_MISSING_SECRET
		  end
		  
			operation = "add_key"
			mesg = "id=#{id}&nonce=#{nonce}&operation=#{operation}"
			key = self.hmac( @_id, mesg, 'sha1' )
			url = URI.parse("http://api.yubico.com/wsapi/add_key?operation=#{operation}&id=#{id}&nonce=#{nonce}&h=#{key}")
      http = Net::HTTP.new(url.host, 443)
      http.use_ssl = true
      res = http.get(url.path + "?" + url.query)
			if( ( res.body ) && ( /status=([\w_]+)[\s]/.match(res.body) ) )
				@_res = res.body
				return res.body.scan(/status=([\w_]+)[\s]/).first
			else
				return E_UNKNOWN_ERROR
			end	
		end
# Requests add_key information from the server and returns all the information
# required to encode a Yubikey. This command will create a new key on request,
# so standard practice should be very secure and sure before this is called.
#
#   if( user.created? )
#     user.keyflag = yk.add_key( @_id, timestamp )
#     user.keydata = yk.last_response
#   end
#     # => 
Requests add_key information from the server and returns all the information
required to encode a Yubikey. This command will create a new key on request,
so standard practice should be very secure and sure before this is called.


Requests add_key information from the server and returns all the information required to encode a Yubikey . This command will create a new key on request so standard practice should be very secure and sure before this is called .
def add_key( id, nonce )
		  if not @_key
		    return E_MISSING_SECRET
		  end
			operation = "add_key"
			mesg = "id=#{id}&nonce=#{nonce}&operation=#{operation}"
			key = self.hmac( @_id, mesg, 'sha1' )
			url = URI.parse("http://api.yubico.com/wsapi/add_key?operation=#{operation}&id=#{id}&nonce=#{nonce}&h=#{key}")
      http = Net::HTTP.new(url.host, 443)
      http.use_ssl = true
      res = http.get(url.path + "?" + url.query)
			if( ( res.body ) && ( /status=([\w_]+)[\s]/.match(res.body) ) )
				@_res = res.body
				return res.body.scan(/status=([\w_]+)[\s]/).first
			else
				return E_UNKNOWN_ERROR
			end	
		end
def add_key ( id , nonce ) if not @_key return E_MISSING_SECRET end operation = "add_key" mesg = "id=#{id}&nonce=#{nonce}&operation=#{operation}" key = self . hmac ( @_id , mesg , 'sha1' ) url = URI . parse ( "http://api.yubico.com/wsapi/add_key?operation=#{operation}&id=#{id}&nonce=#{nonce}&h=#{key}" ) http = Net :: HTTP . new ( url . host , 443 ) http . use_ssl = true res = http . get ( url . path + "?" + url . query ) if ( ( res . body ) && ( / status=([ \w _]+)[ \s ] / . match ( res . body ) ) ) @_res = res . body return res . body . scan ( / status=([ \w _]+)[ \s ] / ) . first else return E_UNKNOWN_ERROR end end
Requests add_key information from the server and returns all the information
required to encode a Yubikey.
Requests add_key information from the server and returns all the information required to encode a Yubikey .
id
nonce