Class: LDAP::Control
- Inherits:
-
Object
- Object
- LDAP::Control
- Defined in:
- lib/ldap/control.rb
Class Method Summary collapse
-
.encode(*vals) ⇒ Object
Take
vals
, produce an Array of values in ASN.1 format and then convert the Array to DER.
Instance Method Summary collapse
-
#decode ⇒ Object
Take an Array of ASN.1 data and return an Array of decoded values.
Class Method Details
.encode(*vals) ⇒ Object
Take vals
, produce an Array of values in ASN.1 format and then convert the Array to DER.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/ldap/control.rb', line 16 def Control.encode( *vals ) encoded_vals = [] vals.each do |val| encoded_vals << case val when Integer OpenSSL::ASN1::Integer( val ) when String OpenSSL::ASN1::OctetString.new( val ) else # What other types may exist? end end OpenSSL::ASN1::Sequence.new( encoded_vals ).to_der end |
Instance Method Details
#decode ⇒ Object
Take an Array of ASN.1 data and return an Array of decoded values.
37 38 39 40 41 42 43 44 45 |
# File 'lib/ldap/control.rb', line 37 def decode values = [] OpenSSL::ASN1::decode( self.value ).value.each do |val| values << val.value end values end |