Sha256: d6d09d695701dd8e23e7a4b6ba92c18051dc90e436f3db2552e7705cfce86296

Contents?: true

Size: 1.3 KB

Versions: 21

Compression:

Stored size: 1.3 KB

Contents

module Saml
  module Kit
    module Serializable
      # Base 64 decodes the value.
      #
      # @param value [String] the string to base 64 decode.
      def decode(value)
        Base64.decode64(value)
      end

      # Base 64 encodes the value.
      #
      # @param value [String] the string to base 64 encode.
      def encode(value)
        Base64.strict_encode64(value)
      end

      # Inflates the value using zlib decompression.
      #
      # @param value [String] the value to inflate.
      def inflate(value)
        inflater = Zlib::Inflate.new(-Zlib::MAX_WBITS)
        inflater.inflate(value)
      end

      # Deflate the value and drop the header and checksum as per the SAML spec.
      # https://en.wikipedia.org/wiki/SAML_2.0#HTTP_Redirect_Binding
      #
      # @param value [String] the value to deflate.
      # @param level [Integer] the level of compression.
      def deflate(value, level: Zlib::BEST_COMPRESSION)
        Zlib::Deflate.deflate(value, level)[2..-5]
      end

      # URL unescape a value
      #
      # @param value [String] the value to unescape.
      def unescape(value)
        CGI.unescape(value)
      end

      # URL escape a value
      #
      # @param value [String] the value to escape.
      def escape(value)
        CGI.escape(value)
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
saml-kit-1.0.9 lib/saml/kit/serializable.rb
saml-kit-1.0.8 lib/saml/kit/serializable.rb
saml-kit-1.0.7 lib/saml/kit/serializable.rb
saml-kit-1.0.6 lib/saml/kit/serializable.rb
saml-kit-1.0.5 lib/saml/kit/serializable.rb
saml-kit-1.0.4 lib/saml/kit/serializable.rb
saml-kit-1.0.3 lib/saml/kit/serializable.rb
saml-kit-1.0.2 lib/saml/kit/serializable.rb
saml-kit-1.0.1 lib/saml/kit/serializable.rb
saml-kit-1.0.0 lib/saml/kit/serializable.rb
saml-kit-0.3.6 lib/saml/kit/serializable.rb
saml-kit-0.3.5 lib/saml/kit/serializable.rb
saml-kit-0.3.4 lib/saml/kit/serializable.rb
saml-kit-0.3.3 lib/saml/kit/serializable.rb
saml-kit-0.3.2 lib/saml/kit/serializable.rb
saml-kit-0.3.1 lib/saml/kit/serializable.rb
saml-kit-0.3.0 lib/saml/kit/serializable.rb
saml-kit-0.2.18 lib/saml/kit/serializable.rb
saml-kit-0.2.17 lib/saml/kit/serializable.rb
saml-kit-0.2.16 lib/saml/kit/serializable.rb