axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nadira...@apache.org
Subject svn commit: r428621 - in /webservices/axis/trunk/c/src: engine/client/Stub.cpp soap/apr_base64.cpp soap/apr_base64.h transport/axis3/HTTPTransport.cpp
Date Fri, 04 Aug 2006 04:52:32 GMT
Author: nadiramra
Date: Thu Aug  3 21:52:31 2006
New Revision: 428621

URL: http://svn.apache.org/viewvc?rev=428621&view=rev
Log:
Invoke  apr_base64_encode instead of apr_base64_encode_binary in order
to give ebcdic-based platforms an opportunity to convert data to ascii
prior to encoding.  This affects basic authentication userid and password.

Modified:
    webservices/axis/trunk/c/src/engine/client/Stub.cpp
    webservices/axis/trunk/c/src/soap/apr_base64.cpp
    webservices/axis/trunk/c/src/soap/apr_base64.h
    webservices/axis/trunk/c/src/transport/axis3/HTTPTransport.cpp

Modified: webservices/axis/trunk/c/src/engine/client/Stub.cpp
URL: http://svn.apache.org/viewvc/webservices/axis/trunk/c/src/engine/client/Stub.cpp?rev=428621&r1=428620&r2=428621&view=diff
==============================================================================
--- webservices/axis/trunk/c/src/engine/client/Stub.cpp (original)
+++ webservices/axis/trunk/c/src/engine/client/Stub.cpp Thu Aug  3 21:52:31 2006
@@ -427,12 +427,10 @@
     strcpy( cpUsernamePassword, m_proxyUsername );
     strcat( cpUsernamePassword, ":" );
     strcat( cpUsernamePassword, m_proxyPassword );
+    
     int len = apr_base64_encode_len (strlen(cpUsernamePassword));
-     
     AxisChar* base64Value = new AxisChar[len + 1];
-    len = apr_base64_encode_binary (base64Value, 
-                                    (const unsigned char*)cpUsernamePassword, 
-                                    strlen(cpUsernamePassword));
+    len = apr_base64_encode (base64Value, (const char*)cpUsernamePassword);
   
     std::string strValue = "Basic ";
     strValue += base64Value;

Modified: webservices/axis/trunk/c/src/soap/apr_base64.cpp
URL: http://svn.apache.org/viewvc/webservices/axis/trunk/c/src/soap/apr_base64.cpp?rev=428621&r1=428620&r2=428621&view=diff
==============================================================================
--- webservices/axis/trunk/c/src/soap/apr_base64.cpp (original)
+++ webservices/axis/trunk/c/src/soap/apr_base64.cpp Thu Aug  3 21:52:31 2006
@@ -66,30 +66,6 @@
     #endif /* APR_CHARSET_EBCDIC */
 };
 
-#ifdef __OS400__
-
-static unsigned char os_toascii[256] = {
-/* 0    1    2    3    4    5    6    7    8    9    A    B    C    D    E    F */
-   0,   1,   2,   3, 156,   9, 134, 127, 151, 141, 142,  11,  12,  13,  14,  15,    
-  16,  17,  18,  19, 157, 133,   8, 135,  24,  25, 146, 143,  28,  29,  30,  31,    
- 128, 129, 130, 131, 132,  10,  23,  27, 136, 137, 138, 139, 140,   5,   6,   7,    
- 144, 145,  22, 147, 148, 149, 150,   4, 152, 153, 154, 155,  20,  21, 158,  26,    
-  32, 160, 226, 228, 224, 225, 227, 229, 231, 241, 162,  46,  60,  40,  43, 124,    
-  38, 233, 234, 235, 232, 237, 238, 239, 236, 223,  33,  36,  42,  41,  59, 172,    
-  45,  47, 194, 196, 192, 193, 195, 197, 199, 209, 166,  44,  37,  95,  62,  63,    
-  248, 201, 202, 203, 200, 205, 206, 207, 204,  96,  58,  35,  64,  39,  61,  34,   
-  216,  97,  98,  99, 100, 101, 102, 103, 104, 105, 171, 187, 240, 253, 254, 177,   
-  176, 106, 107, 108, 109, 110, 111, 112, 113, 114, 170, 186, 230, 184, 198, 164,   
-  181, 126, 115, 116, 117, 118, 119, 120, 121, 122, 161, 191, 208, 221, 222, 174,   
-   94, 163, 165, 183, 169, 167, 182, 188, 189, 190,  91,  93, 175, 168, 180, 215,   
-  123,  65,  66,  67,  68,  69,  70,  71,  72,  73, 173, 244, 246, 242, 243, 245,   
-  125,  74,  75,  76,  77,  78,  79,  80,  81,  82, 185, 251, 252, 249, 250, 255,   
-   92, 247,  83,  84,  85,  86,  87,  88,  89,  90, 178, 212, 214, 210, 211, 213,   
-   48,  49,  50,  51,  52,  53,  54,  55,  56,  57, 179, 219, 220, 217, 218, 159
-};
-
-#endif /* __OS400__ */
-
 APU_DECLARE(int) apr_base64_decode_len(const char *bufcoded)
 {
     int nbytesdecoded;
@@ -105,6 +81,7 @@
     return nbytesdecoded + 1;
 }
 
+// TODO - on ebcdic platforms need to convert data to job/process character set.
 APU_DECLARE(int) apr_base64_decode(char *bufplain, const char *bufcoded)
 {
     int len;
@@ -174,43 +151,19 @@
     return ((len + 2) / 3 * 4) + 1;
 }
 
-APU_DECLARE(int) apr_base64_encode(char *encoded, const char *string, int len)
+// This routine, for ebcdic platforms, will first convert the string to 
+// UTF-8, and then encode the ascii data. For ascii platforms, the data
+// is converted as-is. This routine should only be used for character data.
+APU_DECLARE(int) apr_base64_encode(char *encoded, const char *string)
 {
 #ifndef __OS400__
-    return apr_base64_encode_binary(encoded, (const unsigned char *) string, len);
+    return apr_base64_encode_binary(encoded, (const unsigned char *) string, strlen(string));
 #else /* __OS400__ */
-    int i;
-    char *p;
-
-    p = encoded;
-    for (i = 0; i < len - 2; i += 3)
-    {
-        *p++ = basis_64[(os_toascii[string[i]] >> 2) & 0x3F];
-        *p++ = basis_64[((os_toascii[string[i]] & 0x3) << 4) |
-                        ((int) (os_toascii[string[i + 1]] & 0xF0) >> 4)];
-        *p++ = basis_64[((os_toascii[string[i + 1]] & 0xF) << 2) |
-                        ((int) (os_toascii[string[i + 2]] & 0xC0) >> 6)];
-        *p++ = basis_64[os_toascii[string[i + 2]] & 0x3F];
-    }
-    if (i < len)
-    {
-        *p++ = basis_64[(os_toascii[string[i]] >> 2) & 0x3F];
-        if (i == (len - 1))
-        {
-            *p++ = basis_64[((os_toascii[string[i]] & 0x3) << 4)];
-            *p++ = '=';
-        }
-        else
-        {
-            *p++ = basis_64[((os_toascii[string[i]] & 0x3) << 4) |
-                            ((int) (os_toascii[string[i + 1]] & 0xF0) >> 4)];
-            *p++ = basis_64[((os_toascii[string[i + 1]] & 0xF) << 2)];
-        }
-        *p++ = '=';
-    }
-
-    *p++ = '\0';
-    return p - encoded;
+    // First convert to UTF-8, then encode data using apr_base64_encode_binary
+    char *utf8Buffer = (char *)toUTF8((char *)string, strlen(string)+1);
+    int rc = apr_base64_encode_binary(encoded, (const unsigned char *)utf8Buffer, strlen(utf8Buffer));
+    free(utf8Buffer); // free() is correct - do not replace
+    return rc;
 #endif                /* __OS400__ */
 }
 

Modified: webservices/axis/trunk/c/src/soap/apr_base64.h
URL: http://svn.apache.org/viewvc/webservices/axis/trunk/c/src/soap/apr_base64.h?rev=428621&r1=428620&r2=428621&view=diff
==============================================================================
--- webservices/axis/trunk/c/src/soap/apr_base64.h (original)
+++ webservices/axis/trunk/c/src/soap/apr_base64.h Thu Aug  3 21:52:31 2006
@@ -68,17 +68,16 @@
 APU_DECLARE(int) apr_base64_encode_len(int len);
 
 /*
- * Encode a text string using base64encoding.
+ * Encode a string using base64encoding.
+ * On EBCDIC platforms, data will be converted to UTF-8 prior to encoding. 
+ * On non-EBCDIC platforms, data is encoded as-is.
  * @param coded_dst The destination string for the encoded string.
- * @param plain_src The original string in plain text
- * @param len_plain_src The length of the plain text string
+ * @param plain_src The original string in plain text - must be null terminated.
  * @return the length of the encoded string
  */ 
-APU_DECLARE(int) apr_base64_encode(char * coded_dst, const char *plain_src, 
-                                 int len_plain_src);
+APU_DECLARE(int) apr_base64_encode(char * coded_dst, const char *plain_src);
 
 /*
- * Encode an EBCDIC string using base64encoding.
  * @param coded_dst The destination string for the encoded string.
  * @param plain_src The original string in plain text
  * @param len_plain_src The length of the plain text string

Modified: webservices/axis/trunk/c/src/transport/axis3/HTTPTransport.cpp
URL: http://svn.apache.org/viewvc/webservices/axis/trunk/c/src/transport/axis3/HTTPTransport.cpp?rev=428621&r1=428620&r2=428621&view=diff
==============================================================================
--- webservices/axis/trunk/c/src/transport/axis3/HTTPTransport.cpp (original)
+++ webservices/axis/trunk/c/src/transport/axis3/HTTPTransport.cpp Thu Aug  3 21:52:31 2006
@@ -385,11 +385,12 @@
         strcat (cpUsernamePassword, ":");
         strcat (cpUsernamePassword, getPassword());
 
+        // We use apr_base64_encode and NOT apr_base64_encode_binary since this is 
+        // textual data that needs to be converted to ascii on ebcdic platforms. 
+        // On ascii platforms the data will just get passed to apr_base64_encode_binary().
         int len = apr_base64_encode_len (strlen (cpUsernamePassword));
         AxisChar *base64Value = new AxisChar[len + 1];
-        len = apr_base64_encode_binary (base64Value,
-                                        (const unsigned char *) cpUsernamePassword,
-                                        strlen (cpUsernamePassword));
+        len = apr_base64_encode(base64Value,(const char *) cpUsernamePassword);
 
         std::string strValue = "Basic ";
         strValue += base64Value;



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org


Mime
View raw message