Module: PolyPseudo::PseudoId

Included in:
Identity, Pseudonym
Defined in:
lib/poly_pseudo/pseudo_id.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#creatorObject (readonly)

Returns the value of attribute creator.



20
21
22
# File 'lib/poly_pseudo/pseudo_id.rb', line 20

def creator
  @creator
end

#point_1Object (readonly)

Returns the value of attribute point_1.



20
21
22
# File 'lib/poly_pseudo/pseudo_id.rb', line 20

def point_1
  @point_1
end

#point_2Object (readonly)

Returns the value of attribute point_2.



20
21
22
# File 'lib/poly_pseudo/pseudo_id.rb', line 20

def point_2
  @point_2
end

#point_3Object (readonly)

Returns the value of attribute point_3.



20
21
22
# File 'lib/poly_pseudo/pseudo_id.rb', line 20

def point_3
  @point_3
end

#recipientObject (readonly)

Returns the value of attribute recipient.



20
21
22
# File 'lib/poly_pseudo/pseudo_id.rb', line 20

def recipient
  @recipient
end

#recipient_key_set_versionObject (readonly)

Returns the value of attribute recipient_key_set_version.



20
21
22
# File 'lib/poly_pseudo/pseudo_id.rb', line 20

def recipient_key_set_version
  @recipient_key_set_version
end

#schema_key_versionObject (readonly)

Returns the value of attribute schema_key_version.



20
21
22
# File 'lib/poly_pseudo/pseudo_id.rb', line 20

def schema_key_version
  @schema_key_version
end

#schema_versionObject (readonly)

Returns the value of attribute schema_version.



20
21
22
# File 'lib/poly_pseudo/pseudo_id.rb', line 20

def schema_version
  @schema_version
end

#typeObject (readonly)

Returns the value of attribute type.



20
21
22
# File 'lib/poly_pseudo/pseudo_id.rb', line 20

def type
  @type
end

Class Method Details

.from_asn1(encoded) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/poly_pseudo/pseudo_id.rb', line 3

def self.from_asn1(encoded)
  asn1 = OpenSSL::ASN1.decode(Base64.decode64(encoded))

  case asn1.value[0].value.to_s
  when /\A.*1\.2\.1\Z/
    Identity.from_asn1(asn1)
  when /\A.*1\.2\.2\Z/
    Pseudonym.from_asn1(asn1)
  when /\A.*1\.2\.3\Z/
    Identity.from_asn1(asn1.value[1].value[0])
  when /\A.*1\.2\.4\Z/
    Pseudonym.from_asn1(asn1.value[1].value[0])
  else
    raise "Invalid type"
  end
end

Instance Method Details

#initialize(attributes) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
# File 'lib/poly_pseudo/pseudo_id.rb', line 22

def initialize(attributes)
  @type                      = attributes["Type"]
  @schema_version            = attributes["SchemaVersion"]
  @schema_key_version        = attributes["SchemaKeyVersion"]
  @recipient                 = attributes["Creator"]
  @recipient                 = attributes["Recipient"]
  @recipient_key_set_version = attributes["RecipientKeySetVersion"]
  @point_1                   = attributes["Point1"]
  @point_2                   = attributes["Point2"]
  @point_3                   = attributes["Point3"]
end