Class: Gitlab::Database::X509SerialNumberAttribute

Inherits:
ActiveRecord::ConnectionAdapters::PostgreSQL::OID::Bytea
  • Object
show all
Defined in:
lib/gitlab/database/x509_serial_number_attribute.rb

Overview

Class for casting binary data to int.

Using X509SerialNumberAttribute allows you to store X509 certificate serial number values as binary while still using integer to access them. rfc 5280 - 4.1.2.2 Serial number (20 octets is the maximum), could be:

  • 1461501637330902918203684832716283019655932542975

  • 0xffffffffffffffffffffffffffffffffffffffff

Constant Summary collapse

PACK_FORMAT =
'H*'

Instance Method Summary collapse

Instance Method Details

#deserialize(value) ⇒ Object


15
16
17
18
# File 'lib/gitlab/database/x509_serial_number_attribute.rb', line 15

def deserialize(value)
  value = super(value)
  value ? value.unpack1(PACK_FORMAT).to_i : nil
end

#serialize(value) ⇒ Object


20
21
22
23
# File 'lib/gitlab/database/x509_serial_number_attribute.rb', line 20

def serialize(value)
  arg = value ? [value.to_s].pack(PACK_FORMAT) : nil
  super(arg)
end