class PkiExpress::TrustServicesManager

Public Class Methods

new(config=PkiExpressConfig.new) click to toggle source
Calls superclass method PkiExpress::PkiExpressOperator::new
# File lib/pki_express/trust_service_manager.rb, line 3
def initialize(config=PkiExpressConfig.new)
  super(config)
end

Public Instance Methods

check_by_cnpj(service, cnpj) click to toggle source
# File lib/pki_express/trust_service_manager.rb, line 34
def check_by_cnpj(service, cnpj)
  unless service
    raise "The provided service is not valid"
  end

  unless cnpj
      raise "The provided CNPJ is not valid"
  end

  args = [
    service,
    '--cnpj',
    cnpj,
  ]

  # This operation can only be used on versions greater than 1.18 of
  # the PKI Express.
  @version_manager.require_version('1.18')

  # Invoke command.
  response = invoke(Commands::CHECK_SERVICE, args)

  # Parse output and return result.
  model = parse_output(response)
  CheckServiceResult.new(model)
end
check_by_cpf(service, cpf) click to toggle source
# File lib/pki_express/trust_service_manager.rb, line 7
def check_by_cpf(service, cpf)
  unless service
    raise "The provided service is not valid"
  end

  unless cpf
      raise "The provided CPF is not valid"
  end

  args = [
    service,
    '--cpf',
    cpf,
  ]

  # This operation can only be used on versions greater than 1.18 of
  # the PKI Express.
  @version_manager.require_version('1.18')

  # Invoke command.
  response = invoke(Commands::CHECK_SERVICE, args)

  # Parse output and return result.
  model = parse_output(response)
  CheckServiceResult.new(model)
end
complete_auth(code, state) click to toggle source
# File lib/pki_express/trust_service_manager.rb, line 235
def complete_auth(code, state)
  unless code
    raise "The provided code is not valid"
  end

  unless state
      raise "The provided state is not valid"
  end

  args = [code, state]

  # This operation can only be used on versions greater than 1.18 of
  # the PKI Express.
  @version_manager.require_version('1.18')

  # Invoke command.
  response = invoke(Commands::COMPLETE_SERVICE_AUTH, args)

  # Parse output and return result.
  model = parse_output(response)
  TrustServiceSessionResult.new(model)
end
discover_by_cnpj(cnpj, throw_exceptions=false) click to toggle source
# File lib/pki_express/trust_service_manager.rb, line 87
def discover_by_cnpj(cnpj, throw_exceptions=false)
  unless cnpj
    raise "The provided CNPJ is not valid"
  end

  args = [
    '--cnpj', 
    cnpj
  ]

  if throw_exceptions
    args.append('--throw')
  end
  # This operation can only be used on versions greater than 1.18 of
  # the PKI Express.
  @version_manager.require_version('1.18')

  # Invoke command.
  response = invoke(Commands::DISCOVER_SERVICES, args)

  # Parse output and return result.
  model = parse_output(response)
  DiscoverServicesResult.new(model).services
end
discover_by_cnpj_and_start_auth(cnpj, redirect_url, session_type=TrustServiceSessionTypes::SIGNATURE_SESSION, custom_state=nil, throw_exceptions=false) click to toggle source
# File lib/pki_express/trust_service_manager.rb, line 155
def discover_by_cnpj_and_start_auth(cnpj, redirect_url, 
  session_type=TrustServiceSessionTypes::SIGNATURE_SESSION, 
  custom_state=nil, throw_exceptions=false)
  unless cnpj
    raise "The provided CNPJ is not valid"
  end
  unless redirect_url
      raise "The provided redirectUrl is not valid"
  end
  unless session_type
    raise "No session type was provided"
  end

  args = [
    '--cnpj',
    cnpj,
    '--redirect-url',
    redirect_url,
    '--session-type',
    session_type
  ]

  if custom_state
      args.append('--custom-state')
      args.append(custom_state)
  end

  if throw_exceptions
      args.append('--throw')
  end

  # This operation can only be used on versions greater than 1.18 of
  # the PKI Express.
  @version_manager.require_version('1.18')

  # Invoke command.
  response = invoke(Commands::DISCOVER_SERVICES, args)

  # Parse output and return result.
  model = parse_output(response)
  DiscoverServicesResult.new(model).auth_parameters
end
discover_by_cpf(cpf, throw_exceptions=false) click to toggle source
# File lib/pki_express/trust_service_manager.rb, line 61
def discover_by_cpf(cpf, throw_exceptions=false)
  unless cpf
    raise "The provided CPF is not valid"
  end

  args = [
    '--cpf', 
    cpf
  ]

  if throw_exceptions
    args.append('--throw')
  end

  # This operation can only be used on versions greater than 1.18 of
  # the PKI Express.
  @version_manager.require_version('1.18')

  # Invoke command.
  response = invoke(Commands::DISCOVER_SERVICES, args)

  # Parse output and return result.
  model = parse_output(response)
  DiscoverServicesResult.new(model).services
end
discover_by_cpf_and_start_auth(cpf, redirect_url, session_type=TrustServiceSessionTypes::SIGNATURE_SESSION, custom_state=nil, throw_exceptions=false) click to toggle source
# File lib/pki_express/trust_service_manager.rb, line 112
def discover_by_cpf_and_start_auth(cpf, redirect_url, 
  session_type=TrustServiceSessionTypes::SIGNATURE_SESSION, 
  custom_state=nil, throw_exceptions=false)
  unless cpf
      raise "The provided CPF is not valid"
  end
  unless redirect_url
      raise "The provided redirectUrl is not valid"
  end
  unless session_type
    raise "No session type was provided"
  end

  args = [
    '--cpf',
    cpf,
    '--redirect-url',
    redirect_url,
    '--session-type',
    session_type,
  ]

  if custom_state
      args.append('--custom-state')
      args.append(custom_state)
  end

  if throw_exceptions
      args.append('--throw')
  end

  # This operation can only be used on versions greater than 1.18 of
  # the PKI Express.
  @version_manager.require_version('1.18')

  # Invoke command.
  response = invoke(Commands::DISCOVER_SERVICES, args)

  # Parse output and return result.
  model = parse_output(response)
  DiscoverServicesResult.new(model).auth_parameters
end
password_authorize(service, username, password, session_type=TrustServiceSessionTypes::SIGNATURE_SESSION) click to toggle source
# File lib/pki_express/trust_service_manager.rb, line 198
def password_authorize(service, username, password,
  session_type=TrustServiceSessionTypes::SIGNATURE_SESSION)
  unless service
    raise "The provided service is not valid"
  end

  unless username
    raise "The provided username is not valid"
  end

  unless password
      raise "The provided password is not valid"
  end

  unless session_type
      raise "No session type was provided"
  end

  args = [
    service,
    username,
    password,
    session_type
  ]

  # This operation can only be used on versions greater than 1.18 of
  # the PKI Express.
  @version_manager.require_version('1.18')

  # Invoke command.
  response = invoke(Commands::PASSWORD_AUTHORIZE, args)

  # Parse output and return result.
  model = parse_output(response)
  TrustServiceSessionResult.new(model)
end