Sha256: 895357086f4d7878d879b3e9eb0f866608fb43bff5d49927142c757ff60997ed

Contents?: true

Size: 673 Bytes

Versions: 13

Compression:

Stored size: 673 Bytes

Contents

module RASN1
  module Types

    # ASN.1 Printable String
    # @author Sylvain Daubert
    class PrintableString < OctetString
      TAG = 19

      # Get ASN.1 type
      # @return [String]
      def self.type
        'PrintableString'
      end

      private
      
      def value_to_der
        check_characters
        @value.to_s.force_encoding('BINARY')
      end

      def der_to_value(der, ber:false)
        super
        check_characters
      end

      def check_characters
        if @value.to_s =~ /([^a-zA-Z0-9 '=\(\)\+,\-\.\/:\?])/
          raise ASN1Error, "PRINTABLE STRING #@name: invalid character: '#{$1}'"
        end
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
rasn1-0.6.8 lib/rasn1/types/printable_string.rb
rasn1-0.6.7 lib/rasn1/types/printable_string.rb
rasn1-0.6.6 lib/rasn1/types/printable_string.rb
rasn1-0.6.5 lib/rasn1/types/printable_string.rb
rasn1-0.6.4 lib/rasn1/types/printable_string.rb
rasn1-0.6.3 lib/rasn1/types/printable_string.rb
rasn1-0.6.2 lib/rasn1/types/printable_string.rb
rasn1-0.6.1 lib/rasn1/types/printable_string.rb
rasn1-0.6.0 lib/rasn1/types/printable_string.rb
rasn1-0.5.0 lib/rasn1/types/printable_string.rb
rasn1-0.4.0 lib/rasn1/types/printable_string.rb
rasn1-0.3.1 lib/rasn1/types/printable_string.rb
rasn1-0.3.0 lib/rasn1/types/printable_string.rb