Module: Saml::Kit::Serializable

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

Instance Method Summary collapse

Instance Method Details

#decode(value) ⇒ Object

Base 64 decodes the value.

Parameters:

  • value (String)

    the string to base 64 decode.



7
8
9
# File 'lib/saml/kit/serializable.rb', line 7

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.



31
32
33
# File 'lib/saml/kit/serializable.rb', line 31

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.



14
15
16
# File 'lib/saml/kit/serializable.rb', line 14

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

#escape(value) ⇒ Object

URL escape a value

Parameters:

  • value (String)

    the value to escape.



45
46
47
# File 'lib/saml/kit/serializable.rb', line 45

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

#inflate(value) ⇒ Object

Inflates the value using zlib decompression.

Parameters:

  • value (String)

    the value to inflate.



21
22
23
24
# File 'lib/saml/kit/serializable.rb', line 21

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.



38
39
40
# File 'lib/saml/kit/serializable.rb', line 38

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