JwtsSigningKeyResolver implements SigningKeyResolver { @Override public Key resolveSigningKey(JwsHeader jwsHeader, Claims claims) { return resolveSigningKey(jwsHeader); } JwtsSigningKeyResolver(final String serverUrl, final SSLContext sslContext);  JwtsSigningKeyResolver(final String serverUrl, final SSLContext sslContext, boolean skipConfig); @Override Key resolveSigningKey(JwsHeader jwsHeader, Claims claims); @Override Key resolveSigningKey(JwsHeader jwsHeader, String body); void addPublicKey(final String keyId, final PublicKey publicKey); static final String ZTS_PROP_ATHENZ_CONF; }
@Test public void testResolveSigningKey() { final String oldConf = System.setProperty(JwtsSigningKeyResolver.ZTS_PROP_ATHENZ_CONF, "src/test/resources/athenz.conf"); JwtsSigningKeyResolver resolver = new JwtsSigningKeyResolver(null, null); JwsHeader header = Mockito.mock(JwsHeader.class); Mockito.when(header.getKeyId()) .thenReturn("eckey1") .thenReturn("unknown"); java.security.Key key = resolver.resolveSigningKey(header, "body"); assertNotNull(key); key = resolver.resolveSigningKey(header, "body"); assertNull(key); if (oldConf == null) { System.clearProperty(JwtsSigningKeyResolver.ZTS_PROP_ATHENZ_CONF); } else { System.setProperty(JwtsSigningKeyResolver.ZTS_PROP_ATHENZ_CONF, oldConf); } }