### Question:
SecurityUtils { public static PublicKey loadPublicKey(HttpsConfig config) { if (config.getKeyStore() != null) { try { KeyStore ks = loadKeyStore(config); Certificate cert = null; if (config.getKeyAlias() != null) { cert = ks.getCertificate(config.getKeyAlias()); } else { for (Enumeration<String> e = ks.aliases(); e.hasMoreElements(); ) { String alias = e.nextElement(); cert = ks.getCertificate(alias); if (cert != null) { break; } } } if (cert != null) { return cert.getPublicKey(); } } catch (NoSuchAlgorithmException | KeyStoreException | CertificateException | IOException e) { apimlLog.log("org.zowe.apiml.common.errorLoadingPublicKey", e.getMessage()); throw new HttpsConfigError(e.getMessage(), e, HttpsConfigError.ErrorCode.HTTP_CLIENT_INITIALIZATION_FAILED, config); } } return null; }  static String readSecret(HttpsConfig config); static Key loadKey(HttpsConfig config); static Certificate[] loadCertificateChain(HttpsConfig config); static Set<String> loadCertificateChainBase64(HttpsConfig config); static PublicKey loadPublicKey(HttpsConfig config); static Key findPrivateKeyByPublic(HttpsConfig config, byte[] publicKey); static KeyStore loadKeyStore(HttpsConfig config); static URL keyRingUrl(String uri, String trustStore); static String replaceFourSlashes(String storeUri); static KeyPair generateKeyPair(String algorithm, int keySize); static final String SAFKEYRING; }### Answer:
@Test public void testLoadPublicKey() { HttpsConfig httpsConfig = httpsConfigBuilder.keyAlias(JWT_KEY_ALIAS).build(); PublicKey publicKey = SecurityUtils.loadPublicKey(httpsConfig); assertNotNull(publicKey); }
@Test(expected = HttpsConfigError.class) public void testLoadPublicKeyWithBadKeyStore() { HttpsConfig httpsConfig = httpsConfigBuilder.keyStore("/localhost.truststore.p12").build(); PublicKey publicKey = SecurityUtils.loadPublicKey(httpsConfig); assertNull(publicKey); }