[Zope-dev] Zope Cookie Handling
Pearson, Brian Edward (GEA, 056278)
BRIAN.PEARSON@APPL.GE.COM
Thu, 16 Mar 2000 17:19:40 -0500
> All,
>
> Here is another interesting issue that I have encountered while trying to
> process cookies in Zope.
>
> On a different app. server I have a Java class which generates an
> encrypted cookie when a user logs into the site. When the user navigates
> over to my Zope site, I wish to check the value of the UID. I do this by
> retrieving the cookie within the following snippet of DTML:
>
> <dtml-if "REQUEST.cookies.has_key('UID')">
> <dtml-call "REQUEST.set('cookie',
> REQUEST.cookies.values())">
> <dtml-var "validateCookie(REQUEST, REQUEST['REMOTE_ADDR'])">
> </dtml-if>
>
> This DTML calls a DTML method (validateCookie) which in turn is calling
> the following External Python Method:
>
> import xmlrpclib, base64
>
> def validateUID(self, REQUEST, ipaddr):
> cookie = REQUEST.get('cookie')
> servlet =
> xmlrpclib.Server("http://salesnet-dev.appl.ge.com/geaservlet/X
> mlRpcTest")
> cookie = repr(cookie)
> cookie = cookie[2:]
> cookie = cookie[:-2]
> return servlet.validateCookie.check(cookie, ipaddr)
>
> This XML-RPC call attempts to invoke the Java decrypt method. Herein lies
> the problem:
>
> Upon investigation of the value contained in the UID cookie, Zope returned
> the following:
> \316\313\321\310\316\315\314\311\321\312\316\317\317\223\310\321\315\317\3
> 13\316\317'
>
> If I print out each character created during the Java encrypt method, the
> following values are returned:
>
> \206\203\209\200\etc.etc.
>
> A colleague of mine pointed out that Zope was returning the values in
> Octal rather than decimal.
>
> Is this behavior by design? Is there another mechanism I can use to
> retrieve the raw cookie value before Zope places it in a dictionary?
> Rather than code a string parsing routine in Java, are there any
> suggestions as to how to convert each character back to decimal, or obtain
> the string prior to being converted into octal?
>
> Once again, I appreciate the assistance/responses. Everyone on this group
> has been wonderful to interact with.
>
> -Brian