use of com.yahoo.vespa.hosted.controller.api.integration.athenz.ZmsException in project vespa by vespa-engine.
the class ZmsKeystoreImpl method preloadKeys.
@Override
public void preloadKeys(AthenzService service) {
try {
log.log(LogLevel.INFO, "Downloading keys for " + service);
List<AthenzPublicKey> publicKeys = athenzClientFactory.createZmsClientWithServicePrincipal().getPublicKeys(service);
for (AthenzPublicKey publicKey : publicKeys) {
FullKeyId fullKeyId = new FullKeyId(service, publicKey.getKeyId());
log.log(LogLevel.DEBUG, "Adding key " + fullKeyId + " to the cache");
cachedKeys.put(fullKeyId, publicKey.getPublicKey());
}
log.log(LogLevel.INFO, "Successfully downloaded keys for " + service);
} catch (ZmsException e) {
log.log(LogLevel.WARNING, "Failed to download keys for " + service + ": " + e.getMessage());
}
}
use of com.yahoo.vespa.hosted.controller.api.integration.athenz.ZmsException in project vespa by vespa-engine.
the class ApplicationApiHandler method createApplication.
private HttpResponse createApplication(String tenantName, String applicationName, HttpRequest request) {
Application application;
try {
application = controller.applications().createApplication(ApplicationId.from(tenantName, applicationName, "default"), getUserPrincipal(request).getNToken());
} catch (ZmsException e) {
// TODO: Push conversion down
if (e.getCode() == com.yahoo.jdisc.Response.Status.FORBIDDEN)
throw new ForbiddenException("Not authorized to create application", e);
else
throw e;
}
Slime slime = new Slime();
toSlime(application, slime.setObject(), request);
return new SlimeJsonResponse(slime);
}
use of com.yahoo.vespa.hosted.controller.api.integration.athenz.ZmsException in project vespa by vespa-engine.
the class ZmsKeystoreImpl method downloadPublicKey.
private Optional<PublicKey> downloadPublicKey(FullKeyId fullKeyId) {
try {
log.log(LogLevel.INFO, "Downloading key " + fullKeyId);
AthenzPublicKey publicKey = athenzClientFactory.createZmsClientWithServicePrincipal().getPublicKey(fullKeyId.service, fullKeyId.keyId);
return Optional.of(publicKey.getPublicKey());
} catch (ZmsException e) {
if (e.getCode() == 404) {
// Key does not exist
log.log(LogLevel.INFO, "Key " + fullKeyId + " not found");
return Optional.empty();
}
String msg = String.format("Unable to retrieve public key from Athens (%s): %s", fullKeyId, e.getMessage());
throw createException(msg, e);
}
}
Aggregations