Search in sources :

Example 1 with BadRequestException

use of io.kamax.mxisd.exception.BadRequestException in project mxisd by kamax-io.

the class KeyController method getKey.

@RequestMapping(value = "/pubkey/{keyType}:{keyId}", method = GET)
public String getKey(@PathVariable String keyType, @PathVariable int keyId) {
    if (!"ed25519".contentEquals(keyType)) {
        throw new BadRequestException("Invalid algorithm: " + keyType);
    }
    log.info("Key {}:{} was requested", keyType, keyId);
    JsonObject obj = new JsonObject();
    obj.addProperty("public_key", keyMgr.getPublicKeyBase64(keyId));
    return gson.toJson(obj);
}
Also used : BadRequestException(io.kamax.mxisd.exception.BadRequestException) JsonObject(com.google.gson.JsonObject)

Aggregations

JsonObject (com.google.gson.JsonObject)1 BadRequestException (io.kamax.mxisd.exception.BadRequestException)1