@Test public void testLoadPemKeyWithWrongLocation() throws Exception { expectedEx.expect(UnresolvableKeyException.class); JWTAuthContextInfo contextInfo = new JWTAuthContextInfo(); contextInfo.setDecryptionKeyLocation("wrong_location.pem"); new DecryptionKeyLocationResolver(contextInfo).resolveKey(encryption, emptyList()); }
@Override public Key resolveKey(JsonWebEncryption jwe, List<JsonWebStructure> nestingContext) throws UnresolvableKeyException { verifyKid(jwe, authContextInfo.getTokenDecryptionKeyId()); if (key != null) { return key; } Key theKey = tryAsDecryptionJwk(jwe); if (theKey == null) { reportUnresolvableKeyException(authContextInfo.getDecryptionKeyContent(), authContextInfo.getDecryptionKeyLocation()); } return theKey; }
DecryptionKeyLocationResolver extends AbstractKeyLocationResolver implements DecryptionKeyResolver { @Override public Key resolveKey(JsonWebEncryption jwe, List<JsonWebStructure> nestingContext) throws UnresolvableKeyException { verifyKid(jwe, authContextInfo.getTokenDecryptionKeyId()); if (key != null) { return key; } Key theKey = tryAsDecryptionJwk(jwe); if (theKey == null) { reportUnresolvableKeyException(authContextInfo.getDecryptionKeyContent(), authContextInfo.getDecryptionKeyLocation()); } return theKey; } }
DecryptionKeyLocationResolver extends AbstractKeyLocationResolver implements DecryptionKeyResolver { @Override public Key resolveKey(JsonWebEncryption jwe, List<JsonWebStructure> nestingContext) throws UnresolvableKeyException { verifyKid(jwe, authContextInfo.getTokenDecryptionKeyId()); if (key != null) { return key; } Key theKey = tryAsDecryptionJwk(jwe); if (theKey == null) { reportUnresolvableKeyException(authContextInfo.getDecryptionKeyContent(), authContextInfo.getDecryptionKeyLocation()); } return theKey; } DecryptionKeyLocationResolver(JWTAuthContextInfo authContextInfo); }
DecryptionKeyLocationResolver extends AbstractKeyLocationResolver implements DecryptionKeyResolver { @Override public Key resolveKey(JsonWebEncryption jwe, List<JsonWebStructure> nestingContext) throws UnresolvableKeyException { verifyKid(jwe, authContextInfo.getTokenDecryptionKeyId()); if (key != null) { return key; } Key theKey = tryAsDecryptionJwk(jwe); if (theKey == null) { reportUnresolvableKeyException(authContextInfo.getDecryptionKeyContent(), authContextInfo.getDecryptionKeyLocation()); } return theKey; } DecryptionKeyLocationResolver(JWTAuthContextInfo authContextInfo); @Override Key resolveKey(JsonWebEncryption jwe, List<JsonWebStructure> nestingContext); }
DecryptionKeyLocationResolver extends AbstractKeyLocationResolver implements DecryptionKeyResolver { @Override public Key resolveKey(JsonWebEncryption jwe, List<JsonWebStructure> nestingContext) throws UnresolvableKeyException { verifyKid(jwe, authContextInfo.getTokenDecryptionKeyId()); if (key != null) { return key; } Key theKey = tryAsDecryptionJwk(jwe); if (theKey == null) { reportUnresolvableKeyException(authContextInfo.getDecryptionKeyContent(), authContextInfo.getDecryptionKeyLocation()); } return theKey; } DecryptionKeyLocationResolver(JWTAuthContextInfo authContextInfo); @Override Key resolveKey(JsonWebEncryption jwe, List<JsonWebStructure> nestingContext);  }