PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.ruby > Problem with decoding a compressed string
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Problem with decoding a compressed string

Réponse
 
LinkBack Outils de la discussion
Vieux 02/12/2007, 11h05   #1
keith_g
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Problem with decoding a compressed string

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
%2BW71kakEBWE1SoKiqxRG3gwM04Q2Li2MbjNPD3pGmrwgFu1v jNW2ZmevXZKrIBh9LolE7CmBLQwpRSVyl9KhbBJb3KTk
%2BmyFtl2azztV7BRwfoydCpkY0fKe2cZoajRKZ5C8i8YOvZ
%2FR1LwphZZ7wRRlGynKe0rQAaqKtXDlVTN6C0svbdciHqdzu8 TakrsLqh5PlgK9naWiJ2sNToufZDKY4vgkkSxEkRn7MkZvHZCy X5Xula6l2C
%2F2y97kDIbosiD%2FLHdTESbGQJ7mFAp7QyplIQCtNSMkME5w c7N0Zj14Jbg9tIAU
%2Bru5TW3ltkUdT3fXhsingkfW9cg%2BdhhxEXuE2Rc0S5Gdi9 64Bm42TZGM79GOn
%2F1vnBDM2OctPoB1W239g2yHKeGyXFF5kpZfobB9wf5MnCuJb 7v9Um4WSsyDJ4G6Gs02hByDcJJSVRtlP9fRrDwXwD

I get this error: "Zlib:ataError: 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 .

Thanks in anticipation,

Keith
  Réponse avec citation
Vieux 03/12/2007, 02h53   #2
MonkeeSage
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Problem with decoding a compressed string

On Dec 2, 5:05 am, keith_g <kpgar...@gmail.com> 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
> %2BW71kakEBWE1SoKiqxRG3gwM04Q2Li2MbjNPD3pGmrwgFu1v jNW2ZmevXZKrIBh9LolE7CmBLQwpRSVyl9KhbBJb3KTk
> %2BmyFtl2azztV7BRwfoydCpkY0fKe2cZoajRKZ5C8i8YOvZ
> %2FR1LwphZZ7wRRlGynKe0rQAaqKtXDlVTN6C0svbdciHqdzu8 TakrsLqh5PlgK9naWiJ2sNToufZDKY4vgkkSxEkRn7MkZvHZCy X5Xula6l2C
> %2F2y97kDIbosiD%2FLHdTESbGQJ7mFAp7QyplIQCtNSMkME5w c7N0Zj14Jbg9tIAU
> %2Bru5TW3ltkUdT3fXhsingkfW9cg%2BdhhxEXuE2Rc0S5Gdi9 64Bm42TZGM79GOn
> %2F1vnBDM2OctPoB1W239g2yHKeGyXFF5kpZfobB9wf5MnCuJb 7v9Um4WSsyDJ4G6Gs02hByDcJJSVRtlP9fRrDwXwD
>
> I get this error: "Zlib:ataError: 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 .
>
> 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 .
Jordan
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 16h50.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,10424 seconds with 10 queries