class PkiExpress::SignatureStarter

Public Class Methods

get_result(response, transfer_file) click to toggle source

endregion

# File lib/pki_express/signature_starter.rb, line 102
def self.get_result(response, transfer_file)
  {
      toSignHash: response[0],
      digestAlgorithmName: response[1],
      digestAlgorithmOid: response[2],
      transferFile: transfer_file
  }
end
new(config=PkiExpressConfig.new) click to toggle source
Calls superclass method PkiExpress::BaseSigner::new
# File lib/pki_express/signature_starter.rb, line 5
def initialize(config=PkiExpressConfig.new)
  super(config)
  @certificate_path = nil
end

Public Instance Methods

certificate() click to toggle source

region The “certificate” accessors

# File lib/pki_express/signature_starter.rb, line 12
def certificate
  _get_certificate
end
certificate=(content_raw) click to toggle source
# File lib/pki_express/signature_starter.rb, line 25
def certificate=(content_raw)
  _set_certificate(content_raw)
end
certificate_base64() click to toggle source
# File lib/pki_express/signature_starter.rb, line 42
def certificate_base64
  _get_certificate_base64
end
certificate_base64=(content_base64) click to toggle source
# File lib/pki_express/signature_starter.rb, line 56
def certificate_base64=(content_base64)
  _set_certificate_base64(content_base64)
end
certificate_path() click to toggle source
# File lib/pki_express/signature_starter.rb, line 75
def certificate_path
  _get_certificate_path
end
certificate_path=(path) click to toggle source
# File lib/pki_express/signature_starter.rb, line 84
def certificate_path=(path)
  _set_certificate_path(path)
end
start() click to toggle source
# File lib/pki_express/signature_starter.rb, line 111
def start
  raise NotImplementedError.new('This method is not implemented')
end

Private Instance Methods

_get_certificate() click to toggle source
# File lib/pki_express/signature_starter.rb, line 16
def _get_certificate
  unless @certificate_path
    return nil
  end

  File.read(@certificate_path)
end
_get_certificate_base64() click to toggle source
# File lib/pki_express/signature_starter.rb, line 46
def _get_certificate_base64
  unless @certificate_path
    return nil
  end

  content = File.read(@certificate_path)
  Base64.encode64(content)
end
_get_certificate_path() click to toggle source
# File lib/pki_express/signature_starter.rb, line 79
def _get_certificate_path
  @certificate_path
end
_set_certificate(content_raw) click to toggle source
# File lib/pki_express/signature_starter.rb, line 29
def _set_certificate(content_raw)
  unless content_raw
    raise 'The provided "certificate" is not valid'
  end

  temp_file_path = self.create_temp_file
  File.open(temp_file_path, 'wb') do |f|
    f.write(content_raw)
  end
  @certificate_path = temp_file_path
end
_set_certificate_base64(content_base64) click to toggle source
# File lib/pki_express/signature_starter.rb, line 60
def _set_certificate_base64(content_base64)
  unless content_base64
    raise 'The provided "certificate_base64" is not valid'
  end

  begin
    content_raw = Base64.decode64(content_base64)
  rescue Error
    raise 'The provided "certificate_base64" is not Base64-encoded'
  end

  _set_certificate(content_raw)
end
_set_certificate_path(path) click to toggle source
# File lib/pki_express/signature_starter.rb, line 88
def _set_certificate_path(path)
  unless path
    raise 'The provided "certificate_path" is not valid'
  end
  unless File.exists?(path)
    raise 'The provided "certificate_path" does not exist'
  end

  @certificate_path = path
end