### Question:
PemKeySource implements KeySource { @Override public List<LoadedPublicKey> loadKeysFromSource() { try { LOG.info("Loading public key for token signature verification from PEM {}", pemKeyLocation); X509Certificate cer = loadCertificate(pemKeyLocation); RSAPublicKey publicKey = extractRsaPublicKey(cer); LOG.info("Loaded public key for token signature verification from PEM {}", pemKeyLocation); return Collections.singletonList(new LoadedPublicKey(kid, publicKey, this)); } catch (IOException | CertificateException | NullPointerException | ClassCastException e) { throw new KeyLoadFailedException( "Failed to load public key for token signature verification from PEM " + pemKeyLocation, e); } } PemKeySource(String kid, URI pemKeyLocation); @Override List<LoadedPublicKey> loadKeysFromSource(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString();  }### Answer:
@Test public void shouldLoadPemKeyFromHttp() { String location = "http: PemKeySource pemKeySource = new PemKeySource("exampleHttp", URI.create(location)); List<LoadedPublicKey> loadedPublicKeys = pemKeySource.loadKeysFromSource(); assertThat(loadedPublicKeys).hasSize(1); LoadedPublicKey loadedPublicKey = loadedPublicKeys.get(0); assertThat(loadedPublicKey.getKeySource()).isSameAs(pemKeySource); assertThat(loadedPublicKey.getKid()).isEqualTo("exampleHttp"); assertThatLoadedKeyContainsPublicKey(loadedPublicKey); }
@Test public void shouldLoadPemKeyFromFile() { PemKeySource pemKeySource = new PemKeySource(null, new File(ResourceHelpers.resourceFilePath("example.pem")).toURI()); List<LoadedPublicKey> loadedPublicKeys = pemKeySource.loadKeysFromSource(); assertThat(loadedPublicKeys).hasSize(1); LoadedPublicKey loadedPublicKey = loadedPublicKeys.get(0); assertThat(loadedPublicKey.getKeySource()).isSameAs(pemKeySource); assertThat(loadedPublicKey.getKid()).isNull(); assertThatLoadedKeyContainsPublicKey(loadedPublicKey); }