Class: SamlTool::Decoder

Inherits:
Object
  • Object
show all
Defined in:
lib/saml_tool/decoder.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(encoded_saml) ⇒ Decoder

Returns a new instance of Decoder.



11
12
13
14
# File 'lib/saml_tool/decoder.rb', line 11

def initialize(encoded_saml)
  @saml = encoded_saml
  @output = @saml.clone
end

Instance Attribute Details

#outputObject

Returns the value of attribute output.



5
6
7
# File 'lib/saml_tool/decoder.rb', line 5

def output
  @output
end

#samlObject (readonly)

Returns the value of attribute saml.



4
5
6
# File 'lib/saml_tool/decoder.rb', line 4

def saml
  @saml
end

Class Method Details

.decode(encoded_saml) ⇒ Object



7
8
9
# File 'lib/saml_tool/decoder.rb', line 7

def self.decode(encoded_saml)
  new(encoded_saml).decode
end

Instance Method Details

#base64Object



22
23
24
# File 'lib/saml_tool/decoder.rb', line 22

def base64
  self.output = Base64.decode64 output
end

#decodeObject



16
17
18
19
20
# File 'lib/saml_tool/decoder.rb', line 16

def decode
  base64
  zlib
  output
end

#zlibObject



26
27
28
29
30
31
32
# File 'lib/saml_tool/decoder.rb', line 26

def zlib
  zstream  = Zlib::Inflate.new(-Zlib::MAX_WBITS) # I have no idea why we're using minus Zlib::MAX_WBITS. Zlib documentation suggests just Zlib::MAX_WBITS should work, but it doesn't
    self.output = zstream.inflate(output)
  zstream.finish
  zstream.close
  return output
end