Class: Nis::ApostilleAudit

Inherits:
Object
  • Object
show all
Defined in:
lib/nis/apostille_audit.rb

Constant Summary collapse

CHECKSUM =
'fe4e5459'.freeze

Instance Method Summary collapse

Constructor Details

#initialize(file, apostille_hash) ⇒ ApostilleAudit

Returns a new instance of ApostilleAudit.

Parameters:

  • file (File)
  • Apostille (apostille_hash)

    formatted hash



11
12
13
14
15
# File 'lib/nis/apostille_audit.rb', line 11

def initialize(file, apostille_hash)
  @file = file
  @apostille_hash = apostille_hash
  @checksum, @version, @algo, @hash = split_apostille_hash
end

Instance Method Details

#private?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/nis/apostille_audit.rb', line 23

def private?
  @version == 0x80
end

#split_apostille_hashObject



27
28
29
30
31
32
# File 'lib/nis/apostille_audit.rb', line 27

def split_apostille_hash
  [ @apostille_hash[0, 8],
    @apostille_hash[8, 1].to_i,
    @apostille_hash[9, 1].to_i,
    @apostille_hash[10, @apostille_hash.size] ]
end

#valid?Boolean

Returns:

  • (Boolean)


17
18
19
20
21
# File 'lib/nis/apostille_audit.rb', line 17

def valid?
  raise 'Not implemented private apostille' if private?
  raise "Invalid checksum: #{@checksum}" unless @checksum == CHECKSUM
  @hash == calc_hash
end