Java Code Examples for sun.security.util.DerValue#isPrintableStringChar()

The following examples show how to use sun.security.util.DerValue#isPrintableStringChar() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: P11KeyStore.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * build CKA_ID string from bytes
 */
private static String getID(byte[] bytes) {
    boolean printable = true;
    for (int i = 0; i < bytes.length; i++) {
        if (!DerValue.isPrintableStringChar((char)bytes[i])) {
            printable = false;
            break;
        }
    }

    if (!printable) {
        return "0x" + Functions.toHexString(bytes);
    } else {
        try {
            return new String(bytes, "UTF-8");
        } catch (UnsupportedEncodingException uee) {
            return "0x" + Functions.toHexString(bytes);
        }
    }
}
 
Example 2
Source File: P11KeyStore.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * build CKA_ID string from bytes
 */
private static String getID(byte[] bytes) {
    boolean printable = true;
    for (int i = 0; i < bytes.length; i++) {
        if (!DerValue.isPrintableStringChar((char)bytes[i])) {
            printable = false;
            break;
        }
    }

    if (!printable) {
        return "0x" + Functions.toHexString(bytes);
    } else {
        try {
            return new String(bytes, "UTF-8");
        } catch (UnsupportedEncodingException uee) {
            return "0x" + Functions.toHexString(bytes);
        }
    }
}
 
Example 3
Source File: P11KeyStore.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * build CKA_ID string from bytes
 */
private static String getID(byte[] bytes) {
    boolean printable = true;
    for (int i = 0; i < bytes.length; i++) {
        if (!DerValue.isPrintableStringChar((char)bytes[i])) {
            printable = false;
            break;
        }
    }

    if (!printable) {
        return "0x" + Functions.toHexString(bytes);
    } else {
        try {
            return new String(bytes, "UTF-8");
        } catch (UnsupportedEncodingException uee) {
            return "0x" + Functions.toHexString(bytes);
        }
    }
}
 
Example 4
Source File: P11KeyStore.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * build CKA_ID string from bytes
 */
private static String getID(byte[] bytes) {
    boolean printable = true;
    for (int i = 0; i < bytes.length; i++) {
        if (!DerValue.isPrintableStringChar((char)bytes[i])) {
            printable = false;
            break;
        }
    }

    if (!printable) {
        return "0x" + Functions.toHexString(bytes);
    } else {
        try {
            return new String(bytes, "UTF-8");
        } catch (UnsupportedEncodingException uee) {
            return "0x" + Functions.toHexString(bytes);
        }
    }
}
 
Example 5
Source File: P11KeyStore.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * build CKA_ID string from bytes
 */
private static String getID(byte[] bytes) {
    boolean printable = true;
    for (int i = 0; i < bytes.length; i++) {
        if (!DerValue.isPrintableStringChar((char)bytes[i])) {
            printable = false;
            break;
        }
    }

    if (!printable) {
        return "0x" + Functions.toHexString(bytes);
    } else {
        try {
            return new String(bytes, "UTF-8");
        } catch (UnsupportedEncodingException uee) {
            return "0x" + Functions.toHexString(bytes);
        }
    }
}
 
Example 6
Source File: P11KeyStore.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * build CKA_ID string from bytes
 */
private static String getID(byte[] bytes) {
    boolean printable = true;
    for (int i = 0; i < bytes.length; i++) {
        if (!DerValue.isPrintableStringChar((char)bytes[i])) {
            printable = false;
            break;
        }
    }

    if (!printable) {
        return "0x" + Functions.toHexString(bytes);
    } else {
        try {
            return new String(bytes, "UTF-8");
        } catch (UnsupportedEncodingException uee) {
            return "0x" + Functions.toHexString(bytes);
        }
    }
}
 
Example 7
Source File: P11KeyStore.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * build CKA_ID string from bytes
 */
private static String getID(byte[] bytes) {
    boolean printable = true;
    for (int i = 0; i < bytes.length; i++) {
        if (!DerValue.isPrintableStringChar((char)bytes[i])) {
            printable = false;
            break;
        }
    }

    if (!printable) {
        return "0x" + Functions.toHexString(bytes);
    } else {
        try {
            return new String(bytes, "UTF-8");
        } catch (UnsupportedEncodingException uee) {
            return "0x" + Functions.toHexString(bytes);
        }
    }
}
 
Example 8
Source File: P11KeyStore.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * build CKA_ID string from bytes
 */
private static String getID(byte[] bytes) {
    boolean printable = true;
    for (int i = 0; i < bytes.length; i++) {
        if (!DerValue.isPrintableStringChar((char)bytes[i])) {
            printable = false;
            break;
        }
    }

    if (!printable) {
        return "0x" + Functions.toHexString(bytes);
    } else {
        try {
            return new String(bytes, "UTF-8");
        } catch (UnsupportedEncodingException uee) {
            return "0x" + Functions.toHexString(bytes);
        }
    }
}
 
Example 9
Source File: P11KeyStore.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * build CKA_ID string from bytes
 */
private static String getID(byte[] bytes) {
    boolean printable = true;
    for (int i = 0; i < bytes.length; i++) {
        if (!DerValue.isPrintableStringChar((char)bytes[i])) {
            printable = false;
            break;
        }
    }

    if (!printable) {
        return "0x" + Functions.toHexString(bytes);
    } else {
        try {
            return new String(bytes, "UTF-8");
        } catch (UnsupportedEncodingException uee) {
            return "0x" + Functions.toHexString(bytes);
        }
    }
}
 
Example 10
Source File: P11KeyStore.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * build CKA_ID string from bytes
 */
private static String getID(byte[] bytes) {
    boolean printable = true;
    for (int i = 0; i < bytes.length; i++) {
        if (!DerValue.isPrintableStringChar((char)bytes[i])) {
            printable = false;
            break;
        }
    }

    if (!printable) {
        return "0x" + Functions.toHexString(bytes);
    } else {
        try {
            return new String(bytes, "UTF-8");
        } catch (UnsupportedEncodingException uee) {
            return "0x" + Functions.toHexString(bytes);
        }
    }
}
 
Example 11
Source File: P11KeyStore.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * build CKA_ID string from bytes
 */
private static String getID(byte[] bytes) {
    boolean printable = true;
    for (int i = 0; i < bytes.length; i++) {
        if (!DerValue.isPrintableStringChar((char)bytes[i])) {
            printable = false;
            break;
        }
    }

    if (!printable) {
        return "0x" + Functions.toHexString(bytes);
    } else {
        try {
            return new String(bytes, "UTF-8");
        } catch (UnsupportedEncodingException uee) {
            return "0x" + Functions.toHexString(bytes);
        }
    }
}
 
Example 12
Source File: P11KeyStore.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * build CKA_ID string from bytes
 */
private static String getID(byte[] bytes) {
    boolean printable = true;
    for (int i = 0; i < bytes.length; i++) {
        if (!DerValue.isPrintableStringChar((char)bytes[i])) {
            printable = false;
            break;
        }
    }

    if (!printable) {
        return "0x" + Functions.toHexString(bytes);
    } else {
        try {
            return new String(bytes, "UTF-8");
        } catch (UnsupportedEncodingException uee) {
            return "0x" + Functions.toHexString(bytes);
        }
    }
}
 
Example 13
Source File: P11KeyStore.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * build CKA_ID string from bytes
 */
private static String getID(byte[] bytes) {
    boolean printable = true;
    for (int i = 0; i < bytes.length; i++) {
        if (!DerValue.isPrintableStringChar((char)bytes[i])) {
            printable = false;
            break;
        }
    }

    if (!printable) {
        return "0x" + Functions.toHexString(bytes);
    } else {
        try {
            return new String(bytes, "UTF-8");
        } catch (UnsupportedEncodingException uee) {
            return "0x" + Functions.toHexString(bytes);
        }
    }
}