src/share/classes/sun/security/pkcs11/wrapper/Functions.java

Print this page

        

*** 52,62 **** import java.util.*; import static sun.security.pkcs11.wrapper.PKCS11Constants.*; /** ! * This class contains onyl static methods. It is the place for all functions * that are used by several classes in this package. * * @author Karl Scheibelhofer <Karl.Scheibelhofer@iaik.at> * @author Martin Schlaeffer <schlaeff@sbox.tugraz.at> */ --- 52,62 ---- import java.util.*; import static sun.security.pkcs11.wrapper.PKCS11Constants.*; /** ! * This class contains only static methods. It is the place for all functions * that are used by several classes in this package. * * @author Karl Scheibelhofer <Karl.Scheibelhofer@iaik.at> * @author Martin Schlaeffer <schlaeff@sbox.tugraz.at> */
*** 94,143 **** private static final Map<String,Integer> objectClassIds = new HashMap<String,Integer>(); /** - * For converting numbers to their hex presentation. - */ - private static final char[] HEX_DIGITS = "0123456789ABCDEF".toCharArray(); - - /** * Converts a long value to a hexadecimal String of length 16. Includes * leading zeros if necessary. * * @param value The long value to be converted. * @return The hexadecimal string representation of the long value. */ public static String toFullHexString(long value) { ! long currentValue = value; ! StringBuffer stringBuffer = new StringBuffer(16); ! for(int j = 0; j < 16; j++) { ! int currentDigit = (int) currentValue & 0xf; ! stringBuffer.append(HEX_DIGITS[currentDigit]); ! currentValue >>>= 4; ! } ! ! return stringBuffer.reverse().toString(); } /** * Converts a int value to a hexadecimal String of length 8. Includes * leading zeros if necessary. * * @param value The int value to be converted. * @return The hexadecimal string representation of the int value. */ public static String toFullHexString(int value) { ! int currentValue = value; ! StringBuffer stringBuffer = new StringBuffer(8); ! for(int i = 0; i < 8; i++) { ! int currentDigit = currentValue & 0xf; ! stringBuffer.append(HEX_DIGITS[currentDigit]); ! currentValue >>>= 4; ! } ! ! return stringBuffer.reverse().toString(); } /** * converts a long value to a hexadecimal String * --- 94,124 ---- private static final Map<String,Integer> objectClassIds = new HashMap<String,Integer>(); /** * Converts a long value to a hexadecimal String of length 16. Includes * leading zeros if necessary. * * @param value The long value to be converted. * @return The hexadecimal string representation of the long value. */ public static String toFullHexString(long value) { ! return Long.toHexString(value, 16) ! .toUpperCase(); } /** * Converts a int value to a hexadecimal String of length 8. Includes * leading zeros if necessary. * * @param value The int value to be converted. * @return The hexadecimal string representation of the int value. */ public static String toFullHexString(int value) { ! return Integer.toHexString(value, 8) ! .toUpperCase(); } /** * converts a long value to a hexadecimal String *
*** 159,182 **** public static String toHexString(byte[] value) { if (value == null) { return null; } ! StringBuffer buffer = new StringBuffer(2 * value.length); ! int single; ! ! for (int i = 0; i < value.length; i++) { ! single = value[i] & 0xFF; ! ! if (single < 0x10) { ! buffer.append('0'); ! } ! ! buffer.append(Integer.toString(single, 16)); } ! ! return buffer.toString(); } /** * converts a long value to a binary String * --- 140,154 ---- public static String toHexString(byte[] value) { if (value == null) { return null; } ! StringBuilder sb = new StringBuilder(2 * value.length); ! for (byte b : value) { ! sb.append(Integer.toHexString((int)b & 0xFF, 2)); } ! return sb.toString(); } /** * converts a long value to a binary String *