Class: Binenc::Java::ASN1Sequence

Inherits:
Object
  • Object
show all
Includes:
ASN1Object
Defined in:
lib/binenc/asn1_engine/object/sequence.rb

Instance Attribute Summary

Attributes included from ASN1Object

#value

Instance Method Summary collapse

Methods included from ASN1Object

decode

Methods included from DataConversion

#from_b64, #from_hex, included, #to_b64, #to_b64_mime, #to_bin, #to_hex, #to_java_bytes, #to_str

Constructor Details

#initialize(*args, &block) ⇒ ASN1Sequence

Returns a new instance of ASN1Sequence.



9
10
11
12
# File 'lib/binenc/asn1_engine/object/sequence.rb', line 9

def initialize(*args, &block)
  super
  @value = to_value(@value) 
end

Instance Method Details

#encoded(binary = true) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/binenc/asn1_engine/object/sequence.rb', line 14

def encoded(binary = true)
  @value = [@value] if not @value.is_a?(Array)
  value = to_encoded(@value)
  obj = org.bouncycastle.asn1.DERSequence.new(value)

  if binary
    obj.encoded
  else
    obj
  end
end

#is_equal?(val) ⇒ Boolean

Returns:

  • (Boolean)


26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/binenc/asn1_engine/object/sequence.rb', line 26

def is_equal?(val)

  if @value.length == val.length
    res = true
    @value.each do |e|
      if not val.include?(e)
        res = false
        break
      end
    end
    res
  else
    false
  end
end