public static X509Certificate decodeX509Certificate(String hexString) { return decodeX509Certificate(HexUtilities.decodeFromHex(hexString)); }
/** * Converts the given byte array to a String in HEX representation. * * @param bytes the bytes to convert. * @return a String in HEX format. */ public static String encodeToHex(byte[] bytes) { return encodeToHex(bytes, false, false); }
public static PublicKey decodeX509PublicKey(String hexString) { return decodeX509PublicKey(HexUtilities.decodeFromHex(hexString)); }
protected PlainPin(String pinHexString) { super(pinHexString); this.publicKey = X509CertificateUtilities.decodeX509PublicKey(pinBytes); }
protected Pin(String pinHexString) { pinBytes = HexUtilities.decodeFromHex(pinHexString); }
protected CertPlainPin(String pinHexString) { super(pinHexString); if (sha256md == null) { throw new IllegalStateException("Can not create sha256 pins"); } this.certificate = X509CertificateUtilities.decodeX509Certificate(pinBytes); }
public static X509Certificate decodeX509Certificate(String hexString) { return decodeX509Certificate(HexUtilities.decodeFromHex(hexString)); }
public static PublicKey decodeX509PublicKey(String hexString) { return decodeX509PublicKey(HexUtilities.decodeFromHex(hexString)); }
/** * Converts the given byte array to a String in HEX representation. * * @param bytes the bytes to convert. * @return a String in HEX format. */ public static String encodeToHex(byte[] bytes) { return encodeToHex(bytes, false, false); }
protected PlainPin(String pinHexString) { super(pinHexString); this.publicKey = X509CertificateUtilities.decodeX509PublicKey(pinBytes); }
protected Pin(String pinHexString) { pinBytes = HexUtilities.decodeFromHex(pinHexString); }
protected CertPlainPin(String pinHexString) { super(pinHexString); if (sha256md == null) { throw new IllegalStateException("Can not create sha256 pins"); } this.certificate = X509CertificateUtilities.decodeX509Certificate(pinBytes); }
/** * Deprecated. * * @deprecated This method appends an unnecessary colon to the end of the * HEX String, please use * {@link HexUtilities#encodeToHex(byte[])} instead, which does * not do this. */ @Deprecated public static StringBuilder toHex(byte[] bytes, boolean uppercase) { return new StringBuilder(HexUtilities.encodeToHex(bytes, uppercase, true) + ":"); }
@Test(expected = IllegalArgumentException.class) public void decodeX509PublicKey_invalidEncodedPublicKey_throwsIllegalArgumentException() { assertNotNull(X509CertificateUtilities .decodeX509PublicKey("03a391615ce416307380e27601a0767e83c3264dba6b31074b1ac1480643d4d2")); } }
@Test(expected = IllegalArgumentException.class) public void decodeFromHex_divisibleByTwoWithInvalidCharactersString_throwsException() { HexUtilities.decodeFromHex("This is not a valid hex String"); }
@Test public void decodeX509Certificate_validEncodedCertificate_returnsX509Certificate() { assertNotNull(X509CertificateUtilities.decodeX509Certificate(TestUtilities.PLAIN_CERTIFICATE_1)); }
/** * Deprecated. * * @deprecated This method appends an unnecessary colon to the end of the * HEX String, please use * {@link HexUtilities#encodeToHex(byte[])} instead, which does * not do this. */ @Deprecated public static StringBuilder toHex(byte[] bytes, boolean uppercase) { return new StringBuilder(HexUtilities.encodeToHex(bytes, uppercase, true) + ":"); }
@Test public void decodeX509PublicKey_validEncodedPublicKey_returnsX509Certificate() { assertNotNull(X509CertificateUtilities.decodeX509PublicKey(TestUtilities.PLAIN_PUBLIC_KEY_1)); }
@Test(expected = IllegalArgumentException.class) public void decodeFromHex_notDivisibleByTwoHexString_throwsException() { HexUtilities.decodeFromHex("4b6e616"); }
@Test public void encodeToHexUppercase_anyByteArray_returnsCorrectHexString() { assertEquals("4B6E6162", HexUtilities.encodeToHex(new byte[] { 75, 110, 97, 98 }, true, false)); }