src/java.security.sasl/share/classes/com/sun/security/sasl/CramMD5Base.java

Print this page
rev 10521 : 8055723[core]: Replace concat String to append in StringBuilder parameters
Contributed-by: Otavio Santana <otaviojava@java.net>


 179         for (i = 0; i < MD5_BLOCKSIZE; i++) {
 180             ipad[i] ^= 0x36;
 181             opad[i] ^= 0x5c;
 182         }
 183 
 184         /* inner MD5 */
 185         md5.update(ipad);
 186         md5.update(text);
 187         digest = md5.digest();
 188 
 189         /* outer MD5 */
 190         md5.update(opad);
 191         md5.update(digest);
 192         digest = md5.digest();
 193 
 194         // Get character representation of digest
 195         StringBuilder digestString = new StringBuilder();
 196 
 197         for (i = 0; i < digest.length; i++) {
 198             if ((digest[i] & 0x000000ff) < 0x10) {
 199                 digestString.append("0" +
 200                     Integer.toHexString(digest[i] & 0x000000ff));
 201             } else {
 202                 digestString.append(
 203                     Integer.toHexString(digest[i] & 0x000000ff));
 204             }
 205         }
 206 
 207         Arrays.fill(ipad, (byte)0);
 208         Arrays.fill(opad, (byte)0);
 209         ipad = null;
 210         opad = null;
 211 
 212         return (digestString.toString());
 213     }
 214 
 215     /**
 216      * Sets logger field.
 217      */
 218     private static synchronized void initLogger() {
 219         if (logger == null) {
 220             logger = Logger.getLogger(SASL_LOGGER_NAME);


 179         for (i = 0; i < MD5_BLOCKSIZE; i++) {
 180             ipad[i] ^= 0x36;
 181             opad[i] ^= 0x5c;
 182         }
 183 
 184         /* inner MD5 */
 185         md5.update(ipad);
 186         md5.update(text);
 187         digest = md5.digest();
 188 
 189         /* outer MD5 */
 190         md5.update(opad);
 191         md5.update(digest);
 192         digest = md5.digest();
 193 
 194         // Get character representation of digest
 195         StringBuilder digestString = new StringBuilder();
 196 
 197         for (i = 0; i < digest.length; i++) {
 198             if ((digest[i] & 0x000000ff) < 0x10) {
 199                 digestString.append('0').append(Integer.toHexString(digest[i] & 0x000000ff));

 200             } else {
 201                 digestString.append(
 202                     Integer.toHexString(digest[i] & 0x000000ff));
 203             }
 204         }
 205 
 206         Arrays.fill(ipad, (byte)0);
 207         Arrays.fill(opad, (byte)0);
 208         ipad = null;
 209         opad = null;
 210 
 211         return (digestString.toString());
 212     }
 213 
 214     /**
 215      * Sets logger field.
 216      */
 217     private static synchronized void initLogger() {
 218         if (logger == null) {
 219             logger = Logger.getLogger(SASL_LOGGER_NAME);