[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Translate to ASCII after URL encoding



   I need to encrypt the query string of a URL using PBEWithMD5AndDES.
   I'm using Java to do that and it's working great.  However, the
   encrypted string can include special characters which are not
   URL-safe.  I use http_url_encoder_addvar to URL encode it and, again,
   this works great.  I need to write the URL in a batch file on the IFS
   that will be later called by the Windows client to launch a browser.


   The problem I'm having is that after using http_xlate, the string that
   is returned strips the `%' and the first of the two hex characters from
   the encoded special character strings.  In the query string examples
   below, the first line is what is returned from the Java encryption
   program to my RPG program.  The second line is what I get after
   converting it to ASCII and writing to the IFS file.  The last line is
   the second line with spaces added to illustrate what characters are
   missing.


   &aa=HlsJMyUO9aCCTrNuo4YFc4iej8OFUm6%2FfVyPvl297evOWkGkG3xZVai%2FnuiI6pv
   aFKN%2F5PZOI%2Bk%3D

   &aa=HlsJMyUO9aCCTrNuo4YFc4iej8OFUm6FfVyPvl297evOWkGkG3xZVaiFnuiI6pvaFKN
   F5PZOIBkD

   &aa=HlsJMyUO9aCCTrNuo4YFc4iej8OFUm6  FfVyPvl297evOWkGkG3xZVai
   FnuiI6pvaFKN  F5PZOI  Bk  D


   How can I make the encrypted portion URL-safe and get it (along with
   the rest of the URL) into a batch file that Windows understands?


   Here is part of the program:


      Exsr EncryptURL;    // the encrypted query string is returned in
   EncryptedQuery



      // URL encode the
   result

      EncryptedQryV =
   %trim(EncryptedQuery);

      Encoder =
   http_url_encoder_new();

      rc = http_url_encoder_addvar(Encoder: 'aa': %addr(EncryptedQryV)
   +2:

           %len(EncryptedQryV));

      EncodedQuery = http_url_encoder_getstr(Encoder);

      http_url_encoder_free(Encoder);


      URLFull = URLDomain + %trim(EncodedQuery) +
   DblQuote;



    EndIf;



    If Not
   Error;

      // Write the batch
   file

      Exsr OpenFile;

      Exsr
   WriteFile;

      callp
   close(fd);

    EndIf;



   BegSr WriteFile;        // Convert the data to ASCII and write the file

   //==================


   DataASCII = 'start ' + URLFull;

   dataLen   = %Len(%Trim(DataASCII));


   // Translate it to ASCII and write the record

   callp http_xlate(dataLen: DataASCII: TO_ASCII );


   callp write(fd: %Addr(DataASCII): DataLen);


   DataASCII = CRLF + 'exit' + CRLF;

   dataLen   = %Len(%Trim(DataASCII));


   // Translate it to ASCII and write the record


   callp http_xlate(dataLen: DataASCII: TO_ASCII );

   DataLen = %Len(%Trim(DataASCII));

   callp write(fd: %Addr(DataASCII): DataLen);


   EndSr;  // WriteFile;



   Thanks,


   Barry Shrum
-----------------------------------------------------------------------
This is the FTPAPI mailing list.  To unsubscribe, please go to:
http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------