< prev index next >

src/java.security.sasl/share/classes/com/sun/security/sasl/digest/DigestMD5Base.java

Print this page
rev 10947 : 8055723: Replace concat String to append in StringBuilder parameters


 374             }
 375             return new String(buf, 0, j);
 376         } else {
 377             return str;
 378         }
 379     }
 380 
 381     /**
 382      * Convert a byte array to hexadecimal string.
 383      *
 384      * @param a non-null byte array
 385      * @return a non-null String contain the HEX value
 386      */
 387     protected byte[] binaryToHex(byte[] digest) throws
 388     UnsupportedEncodingException {
 389 
 390         StringBuilder digestString = new StringBuilder();
 391 
 392         for (int i = 0; i < digest.length; i ++) {
 393             if ((digest[i] & 0x000000ff) < 0x10) {
 394                 digestString.append("0"+
 395                     Integer.toHexString(digest[i] & 0x000000ff));
 396             } else {
 397                 digestString.append(
 398                     Integer.toHexString(digest[i] & 0x000000ff));
 399             }
 400         }
 401         return digestString.toString().getBytes(encoding);
 402     }
 403 
 404     /**
 405      * Used to convert username-value, passwd or realm to 8859_1 encoding
 406      * if all chars in string are within the 8859_1 (Latin 1) encoding range.
 407      *
 408      * @param a non-null String
 409      * @return a non-nuill byte array containing the correct character encoding
 410      * for username, paswd or realm.
 411      */
 412     protected byte[] stringToByte_8859_1(String str) throws SaslException {
 413 
 414         char[] buffer = str.toCharArray();
 415 




 374             }
 375             return new String(buf, 0, j);
 376         } else {
 377             return str;
 378         }
 379     }
 380 
 381     /**
 382      * Convert a byte array to hexadecimal string.
 383      *
 384      * @param a non-null byte array
 385      * @return a non-null String contain the HEX value
 386      */
 387     protected byte[] binaryToHex(byte[] digest) throws
 388     UnsupportedEncodingException {
 389 
 390         StringBuilder digestString = new StringBuilder();
 391 
 392         for (int i = 0; i < digest.length; i ++) {
 393             if ((digest[i] & 0x000000ff) < 0x10) {
 394                 digestString.append('0').append(Integer.toHexString(digest[i] & 0x000000ff));

 395             } else {
 396                 digestString.append(
 397                     Integer.toHexString(digest[i] & 0x000000ff));
 398             }
 399         }
 400         return digestString.toString().getBytes(encoding);
 401     }
 402 
 403     /**
 404      * Used to convert username-value, passwd or realm to 8859_1 encoding
 405      * if all chars in string are within the 8859_1 (Latin 1) encoding range.
 406      *
 407      * @param a non-null String
 408      * @return a non-nuill byte array containing the correct character encoding
 409      * for username, paswd or realm.
 410      */
 411     protected byte[] stringToByte_8859_1(String str) throws SaslException {
 412 
 413         char[] buffer = str.toCharArray();
 414 


< prev index next >