Class: RubyGPG2::ColonRecord
- Inherits:
-
Object
- Object
- RubyGPG2::ColonRecord
- Defined in:
- lib/ruby_gpg2/colon_record.rb
Overview
rubocop:disable Metrics/ClassLength
Constant Summary collapse
- USER_ID_REGEX =
/^(.*?) (?:\((.*)\) )?<(.*)>$/.freeze
- TYPES =
{ 'pub' => :public_key, 'crt' => :x509_certificate, 'crs' => :x509_certificate_and_private_key, 'sub' => :sub_key, 'sec' => :secret_key, 'ssb' => :secret_sub_key, 'uid' => :user_id, 'uat' => :user_attribute, 'sig' => :signature, 'rev' => :revocation_signature, 'rvs' => :standalone_revocation_signature, 'fpr' => :fingerprint, 'pkd' => :public_key_data, 'grp' => :key_grip, 'rvk' => :revocation_key, 'tfs' => :tofu_statistics, 'tru' => :trust_database_information, 'spk' => :signature_sub_packet, 'cfg' => :configuration_data }.freeze
- TRUST_MODELS =
{ '0' => :classic, '1' => :pgp }.freeze
- VALIDITIES =
{ 'o' => :unknown_new_key, 'i' => :invalid, 'd' => :disabled, 'r' => :revoked, 'e' => :expired, '-' => :unknown, 'q' => :undefined, 'n' => :never, 'm' => :marginal, 'f' => :full, 'u' => :ultimate, 'w' => :well_known_private, 's' => :special }.freeze
- KEY_ALGORITHMS =
{ '1' => :rsa_encrypt_or_sign, '2' => :rsa_encrypt_only, '3' => :rsa_sign_only, '16' => :elgamal_encrypt_only, '17' => :dsa, '18' => :ecdh, '19' => :ecdsa }.freeze
- TRUSTS =
{ '-' => :unknown, 'n' => :never, 'm' => :marginal, 'f' => :full, 'u' => :ultimate }.freeze
- KEY_CAPABILITIES =
{ 'e' => :encrypt, 's' => :sign, 'c' => :certify, 'a' => :authenticate, 'E' => :primary_encrypt, 'S' => :primary_sign, 'C' => :primary_certify, 'A' => :primary_authenticate, '?' => :unknown }.freeze
- COMPLIANCE_MODES =
{ '8' => :rfc_4880bis, '23' => :de_vs, '6001' => :roca_screening_hit }.freeze
Instance Attribute Summary collapse
-
#compliance_modes ⇒ Object
readonly
Returns the value of attribute compliance_modes.
-
#creation_date ⇒ Object
readonly
Returns the value of attribute creation_date.
-
#expiration_date ⇒ Object
readonly
Returns the value of attribute expiration_date.
-
#fingerprint ⇒ Object
readonly
Returns the value of attribute fingerprint.
-
#key_algorithm ⇒ Object
readonly
Returns the value of attribute key_algorithm.
-
#key_capabilities ⇒ Object
readonly
Returns the value of attribute key_capabilities.
-
#key_grip ⇒ Object
readonly
Returns the value of attribute key_grip.
-
#key_id ⇒ Object
readonly
Returns the value of attribute key_id.
-
#key_length ⇒ Object
readonly
Returns the value of attribute key_length.
-
#last_update ⇒ Object
readonly
Returns the value of attribute last_update.
-
#maximum_certificate_chain_depth ⇒ Object
readonly
Returns the value of attribute maximum_certificate_chain_depth.
-
#new_key_signer_complete_count ⇒ Object
readonly
Returns the value of attribute new_key_signer_complete_count.
-
#new_key_signer_marginal_count ⇒ Object
readonly
Returns the value of attribute new_key_signer_marginal_count.
-
#origin ⇒ Object
readonly
Returns the value of attribute origin.
-
#owner_trust ⇒ Object
readonly
Returns the value of attribute owner_trust.
-
#raw ⇒ Object
readonly
Returns the value of attribute raw.
-
#serial_number ⇒ Object
readonly
Returns the value of attribute serial_number.
-
#signature_class ⇒ Object
readonly
Returns the value of attribute signature_class.
-
#trust_model ⇒ Object
readonly
Returns the value of attribute trust_model.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#user_id ⇒ Object
readonly
Returns the value of attribute user_id.
-
#user_id_hash ⇒ Object
readonly
Returns the value of attribute user_id_hash.
-
#validity ⇒ Object
readonly
Returns the value of attribute validity.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#fingerprint_record? ⇒ Boolean
rubocop:enable Metrics/AbcSize rubocop:enable Metrics/MethodLength.
-
#initialize(opts) ⇒ ColonRecord
constructor
rubocop:disable Metrics/MethodLength rubocop:disable Metrics/AbcSize.
- #user_comment ⇒ Object
- #user_email ⇒ Object
- #user_id_record? ⇒ Boolean
- #user_name ⇒ Object
Constructor Details
#initialize(opts) ⇒ ColonRecord
rubocop:disable Metrics/MethodLength rubocop:disable Metrics/AbcSize
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
# File 'lib/ruby_gpg2/colon_record.rb', line 127 def initialize(opts) @raw = opts[:raw] @type = opts[:type] @trust_model = opts[:trust_model] @validity = opts[:validity] @key_length = opts[:key_length] @key_algorithm = opts[:key_algorithm] @key_id = opts[:key_id] @creation_date = opts[:creation_date] @expiration_date = opts[:expiration_date] @user_id_hash = opts[:user_id_hash] @owner_trust = opts[:owner_trust] @fingerprint = opts[:fingerprint] @key_grip = opts[:key_grip] @user_id = opts[:user_id] @signature_class = opts[:signature_class] @key_capabilities = opts[:key_capabilities] @serial_number = opts[:serial_number] @compliance_modes = opts[:compliance_modes] @last_update = opts[:last_update] @origin = opts[:origin] @new_key_signer_marginal_count = opts[:new_key_signer_marginal_count] @new_key_signer_complete_count = opts[:new_key_signer_complete_count] @maximum_certificate_chain_depth = opts[:maximum_certificate_chain_depth] end |
Instance Attribute Details
#compliance_modes ⇒ Object (readonly)
Returns the value of attribute compliance_modes.
99 100 101 |
# File 'lib/ruby_gpg2/colon_record.rb', line 99 def compliance_modes @compliance_modes end |
#creation_date ⇒ Object (readonly)
Returns the value of attribute creation_date.
99 100 101 |
# File 'lib/ruby_gpg2/colon_record.rb', line 99 def creation_date @creation_date end |
#expiration_date ⇒ Object (readonly)
Returns the value of attribute expiration_date.
99 100 101 |
# File 'lib/ruby_gpg2/colon_record.rb', line 99 def expiration_date @expiration_date end |
#fingerprint ⇒ Object (readonly)
Returns the value of attribute fingerprint.
99 100 101 |
# File 'lib/ruby_gpg2/colon_record.rb', line 99 def fingerprint @fingerprint end |
#key_algorithm ⇒ Object (readonly)
Returns the value of attribute key_algorithm.
99 100 101 |
# File 'lib/ruby_gpg2/colon_record.rb', line 99 def key_algorithm @key_algorithm end |
#key_capabilities ⇒ Object (readonly)
Returns the value of attribute key_capabilities.
99 100 101 |
# File 'lib/ruby_gpg2/colon_record.rb', line 99 def key_capabilities @key_capabilities end |
#key_grip ⇒ Object (readonly)
Returns the value of attribute key_grip.
99 100 101 |
# File 'lib/ruby_gpg2/colon_record.rb', line 99 def key_grip @key_grip end |
#key_id ⇒ Object (readonly)
Returns the value of attribute key_id.
99 100 101 |
# File 'lib/ruby_gpg2/colon_record.rb', line 99 def key_id @key_id end |
#key_length ⇒ Object (readonly)
Returns the value of attribute key_length.
99 100 101 |
# File 'lib/ruby_gpg2/colon_record.rb', line 99 def key_length @key_length end |
#last_update ⇒ Object (readonly)
Returns the value of attribute last_update.
99 100 101 |
# File 'lib/ruby_gpg2/colon_record.rb', line 99 def last_update @last_update end |
#maximum_certificate_chain_depth ⇒ Object (readonly)
Returns the value of attribute maximum_certificate_chain_depth.
99 100 101 |
# File 'lib/ruby_gpg2/colon_record.rb', line 99 def maximum_certificate_chain_depth @maximum_certificate_chain_depth end |
#new_key_signer_complete_count ⇒ Object (readonly)
Returns the value of attribute new_key_signer_complete_count.
99 100 101 |
# File 'lib/ruby_gpg2/colon_record.rb', line 99 def new_key_signer_complete_count @new_key_signer_complete_count end |
#new_key_signer_marginal_count ⇒ Object (readonly)
Returns the value of attribute new_key_signer_marginal_count.
99 100 101 |
# File 'lib/ruby_gpg2/colon_record.rb', line 99 def new_key_signer_marginal_count @new_key_signer_marginal_count end |
#origin ⇒ Object (readonly)
Returns the value of attribute origin.
99 100 101 |
# File 'lib/ruby_gpg2/colon_record.rb', line 99 def origin @origin end |
#owner_trust ⇒ Object (readonly)
Returns the value of attribute owner_trust.
99 100 101 |
# File 'lib/ruby_gpg2/colon_record.rb', line 99 def owner_trust @owner_trust end |
#raw ⇒ Object (readonly)
Returns the value of attribute raw.
99 100 101 |
# File 'lib/ruby_gpg2/colon_record.rb', line 99 def raw @raw end |
#serial_number ⇒ Object (readonly)
Returns the value of attribute serial_number.
99 100 101 |
# File 'lib/ruby_gpg2/colon_record.rb', line 99 def serial_number @serial_number end |
#signature_class ⇒ Object (readonly)
Returns the value of attribute signature_class.
99 100 101 |
# File 'lib/ruby_gpg2/colon_record.rb', line 99 def signature_class @signature_class end |
#trust_model ⇒ Object (readonly)
Returns the value of attribute trust_model.
99 100 101 |
# File 'lib/ruby_gpg2/colon_record.rb', line 99 def trust_model @trust_model end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
99 100 101 |
# File 'lib/ruby_gpg2/colon_record.rb', line 99 def type @type end |
#user_id ⇒ Object (readonly)
Returns the value of attribute user_id.
99 100 101 |
# File 'lib/ruby_gpg2/colon_record.rb', line 99 def user_id @user_id end |
#user_id_hash ⇒ Object (readonly)
Returns the value of attribute user_id_hash.
99 100 101 |
# File 'lib/ruby_gpg2/colon_record.rb', line 99 def user_id_hash @user_id_hash end |
#validity ⇒ Object (readonly)
Returns the value of attribute validity.
99 100 101 |
# File 'lib/ruby_gpg2/colon_record.rb', line 99 def validity @validity end |
Class Method Details
.parse(record) ⇒ Object
89 90 91 92 93 94 95 96 97 |
# File 'lib/ruby_gpg2/colon_record.rb', line 89 def self.parse(record) fields = record.split(':', 22) type = type(fields[0]) if trust_base_record?(type) make_trust_base_record(record, type, fields) else make_standard_record(record, type, fields) end end |
Instance Method Details
#==(other) ⇒ Object
184 185 186 |
# File 'lib/ruby_gpg2/colon_record.rb', line 184 def ==(other) other.class == self.class && other.state == state end |
#fingerprint_record? ⇒ Boolean
rubocop:enable Metrics/AbcSize rubocop:enable Metrics/MethodLength
155 156 157 |
# File 'lib/ruby_gpg2/colon_record.rb', line 155 def fingerprint_record? type == :fingerprint end |
#user_comment ⇒ Object
170 171 172 173 174 175 |
# File 'lib/ruby_gpg2/colon_record.rb', line 170 def user_comment match = user_id&.match(USER_ID_REGEX) return unless match match[2] end |
#user_email ⇒ Object
177 178 179 180 181 182 |
# File 'lib/ruby_gpg2/colon_record.rb', line 177 def user_email match = user_id&.match(USER_ID_REGEX) return unless match match[3] end |
#user_id_record? ⇒ Boolean
159 160 161 |
# File 'lib/ruby_gpg2/colon_record.rb', line 159 def user_id_record? type == :user_id end |
#user_name ⇒ Object
163 164 165 166 167 168 |
# File 'lib/ruby_gpg2/colon_record.rb', line 163 def user_name match = user_id&.match(USER_ID_REGEX) return unless match match[1] end |