Problem with decoding a compressed string

Discussion in 'Ruby' started by keith_g, Dec 2, 2007.

  1. keith_g

    keith_g Guest

    I am writing an app in Ruby on Rails that I want to use for
    authenticating Google Apps users.

    I am having difficulty decoding the SAMLRequest. My code looks like
    this:

    string = CGI::unescape(params[:SAMLRequest])
    doc = Base64.decode64(string)
    zstream = Zlib::Inflate.new
    buf = zstream.inflate(string)

    The data from the SAMLRequest looks like this:

    fVLJTsMwEL0j8Q
    %2BW71kakEBWE1SoKiqxRG3gwM04Q2Li2MbjNPD3pGmrwgFu1vjNW2ZmevXZKrIBh9LolE7CmBLQwpRSVyl9KhbBJb3KTk
    %2BmyFtl2azztV7BRwfoydCpkY0fKe2cZoajRKZ5C8i8YOvZ
    %2FR1LwphZZ7wRRlGynKe0rQAaqKtXDlVTN6C0svbdciHqdzu8TakrsLqh5PlgK9naWiJ2sNToufZDKY4vgkkSxEkRn7MkZvHZCyX5Xula6l2C
    %2F2y97kDIbosiD%2FLHdTESbGQJ7mFAp7QyplIQCtNSMkME5wc7N0Zj14Jbg9tIAU
    %2Bru5TW3ltkUdT3fXhsingkfW9cg%2BdhhxEXuE2Rc0S5Gdi964Bm42TZGM79GOn
    %2F1vnBDM2OctPoB1W239g2yHKeGyXFF5kpZfobB9wf5MnCuJb7v9Um4WSsyDJ4G6Gs02hByDcJJSVRtlP9fRrDwXwD

    I get this error: "Zlib::DataError: incorrect header check"

    I have tried every combination of unescape, decode and inflate that I
    can think of, but no joy.

    I will really appreciate any help.

    Thanks in anticipation,

    Keith
    keith_g, Dec 2, 2007
    #1
    1. Advertising

  2. keith_g

    MonkeeSage Guest

    On Dec 2, 5:05 am, keith_g <> wrote:
    > I am writing an app in Ruby on Rails that I want to use for
    > authenticating Google Apps users.
    >
    > I am having difficulty decoding the SAMLRequest. My code looks like
    > this:
    >
    > string = CGI::unescape(params[:SAMLRequest])
    > doc = Base64.decode64(string)
    > zstream = Zlib::Inflate.new
    > buf = zstream.inflate(string)
    >
    > The data from the SAMLRequest looks like this:
    >
    > fVLJTsMwEL0j8Q
    > %2BW71kakEBWE1SoKiqxRG3gwM04Q2Li2MbjNPD3pGmrwgFu1vjNW2ZmevXZKrIBh9LolE7CmBLQwpRSVyl9KhbBJb3KTk
    > %2BmyFtl2azztV7BRwfoydCpkY0fKe2cZoajRKZ5C8i8YOvZ
    > %2FR1LwphZZ7wRRlGynKe0rQAaqKtXDlVTN6C0svbdciHqdzu8TakrsLqh5PlgK9naWiJ2sNToufZDKY4vgkkSxEkRn7MkZvHZCyX5Xula6l2C
    > %2F2y97kDIbosiD%2FLHdTESbGQJ7mFAp7QyplIQCtNSMkME5wc7N0Zj14Jbg9tIAU
    > %2Bru5TW3ltkUdT3fXhsingkfW9cg%2BdhhxEXuE2Rc0S5Gdi964Bm42TZGM79GOn
    > %2F1vnBDM2OctPoB1W239g2yHKeGyXFF5kpZfobB9wf5MnCuJb7v9Um4WSsyDJ4G6Gs02hByDcJJSVRtlP9fRrDwXwD
    >
    > I get this error: "Zlib::DataError: incorrect header check"
    >
    > I have tried every combination of unescape, decode and inflate that I
    > can think of, but no joy.
    >
    > I will really appreciate any help.
    >
    > Thanks in anticipation,
    >
    > Keith


    I've no idea the format of SAMLRequest, but if you're going to feed
    that data (which I assume is the contents of the "string" variable?)
    to #decode64, I think you need to remove the newlines and unescape
    it...

    string = string.gsub("\n", "")
    string = string.gsub(/%[0-9A-Fa-f]{2}/) { | h |
    h[1..-1].hex.chr
    }

    Also, what is the point of "doc" since you're just passing "string" to
    #inflate?

    Sorry I can't be of more help.
    Jordan
    MonkeeSage, Dec 3, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. ad
    Replies:
    6
    Views:
    3,184
  2. Joseph

    compressed suffix trie

    Joseph, Sep 22, 2004, in forum: Java
    Replies:
    1
    Views:
    511
    =?ISO-8859-1?Q?Daniel_Sj=F6blom?=
    Sep 22, 2004
  3. Replies:
    7
    Views:
    1,692
    espenskogen
    Jan 31, 2011
  4. M. Posseth

    huh can`t send compressed string ??????? with webservice

    M. Posseth, Apr 2, 2005, in forum: ASP .Net Web Services
    Replies:
    1
    Views:
    237
    M. Posseth
    Apr 3, 2005
  5. Replies:
    0
    Views:
    101
Loading...

Share This Page