Module: Saml::Kit::Serializable

Included in:
Bindings::HttpPost, Bindings::HttpRedirect, Bindings::UrlBuilder
Defined in:
lib/saml/kit/concerns/serializable.rb

Overview

This module is responsible for serializing/deserialing values.

Instance Method Summary collapse

Instance Method Details

#decode(value) ⇒ Object

Base 64 decodes the value.

Parameters:

  • value (String)

    the string to base 64 decode.



10
11
12
# File 'lib/saml/kit/concerns/serializable.rb', line 10

def decode(value)
  Base64.decode64(value)
end

#deflate(value, level: Zlib::BEST_COMPRESSION) ⇒ Object

Deflate the value and drop the header and checksum as per the SAML spec. en.wikipedia.org/wiki/SAML_2.0#HTTP_Redirect_Binding

Parameters:

  • value (String)

    the value to deflate.

  • level (Integer) (defaults to: Zlib::BEST_COMPRESSION)

    the level of compression.



34
35
36
# File 'lib/saml/kit/concerns/serializable.rb', line 34

def deflate(value, level: Zlib::BEST_COMPRESSION)
  Zlib::Deflate.deflate(value, level)[2..-5]
end

#encode(value) ⇒ Object

Base 64 encodes the value.

Parameters:

  • value (String)

    the string to base 64 encode.



17
18
19
# File 'lib/saml/kit/concerns/serializable.rb', line 17

def encode(value)
  Base64.strict_encode64(value)
end

#escape(value) ⇒ Object

URL escape a value

Parameters:

  • value (String)

    the value to escape.



48
49
50
# File 'lib/saml/kit/concerns/serializable.rb', line 48

def escape(value)
  CGI.escape(value)
end

#inflate(value) ⇒ Object

Inflates the value using zlib decompression.

Parameters:

  • value (String)

    the value to inflate.



24
25
26
27
# File 'lib/saml/kit/concerns/serializable.rb', line 24

def inflate(value)
  inflater = Zlib::Inflate.new(-Zlib::MAX_WBITS)
  inflater.inflate(value)
end

#unescape(value) ⇒ Object

URL unescape a value

Parameters:

  • value (String)

    the value to unescape.



41
42
43
# File 'lib/saml/kit/concerns/serializable.rb', line 41

def unescape(value)
  CGI.unescape(value)
end