Sha256: ebfac56f3749bdc9d032e2386c1c623b38d78b0961d0b2853bc21239ff7f6744

Contents?: true

Size: 1.01 KB

Versions: 3

Compression:

Stored size: 1.01 KB

Contents

require 'async'
require 'vaas/client_credentials_grant_authenticator'
require 'vaas/vaas_main'

CLIENT_ID = ENV.fetch('CLIENT_ID')
CLIENT_SECRET = ENV.fetch('CLIENT_SECRET')
VAAS_URL = ENV.fetch('VAAS_URL', "wss://gateway.production.vaas.gdatasecurity.de")
TOKEN_URL = ENV.fetch('TOKEN_URL', 'https://account.gdata.de/realms/vaas-production/protocol/openid-connect/token')

URL = ENV.fetch('URL')

def main
  authenticator = VAAS::ClientCredentialsGrantAuthenticator.new(
    CLIENT_ID,
    CLIENT_SECRET,
    TOKEN_URL
  )

  # create a vaas object and get a token to authenticate
  vaas = VAAS::VaasMain.new(VAAS_URL)
  token = authenticator.get_token

  Async do
    vaas.connect(token)

    # reconnect if connection closed
    begin
      verdict = vaas.for_url(URL)
    rescue VAAS::VaasConnectionClosedError
      token = authenticator.get_token
      vaas.connect(token)
      retry
    end
    puts "Verdict #{verdict.wait.sha256} is detected as #{verdict.wait.verdict}"

    vaas.close
  end
end

if __FILE__  == $0
  main
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
vaas-4.1.0 examples/example_with_reconnect.rb
vaas-4.0.0 examples/example_with_reconnect.rb
vaas-3.1.0 examples/example_with_reconnect.rb