@POST
    @Path("/{algorithm}/{provider}/list")
    @Consumes(APPLICATION_JSON)
    public String list(@PathParam("algorithm") String algorithm, @PathParam("provider") String provider,
                       String keystoreAndPassword) {

        InputStream inputStream = null;
        try {
            KeyStore keyStore = KeyStore.getInstance(algorithm, provider);

            Gson gson = new Gson();
            PathAndPassword pathAndPassword = gson.fromJson(keystoreAndPassword, PathAndPassword.class);

            if (pathAndPassword.path == null) {
                inputStream = null;
            } else {
                inputStream = new FileInputStream(pathAndPassword.path);
            }

            char[] password;
            if (pathAndPassword.password == null) {
                password = null;
            } else {
                password = pathAndPassword.password.toCharArray();
            }

            keyStore.load(inputStream, password);

            List<Map<String, String>> aliases = newLinkedList();

            Enumeration<String> aliasesEnumeration = keyStore.aliases();
            while (aliasesEnumeration.hasMoreElements()) {
                String alias = aliasesEnumeration.nextElement();

                aliases.add(ImmutableMap.of(
                        "alias", alias,
                        "isKey", Boolean.toString(keyStore.isKeyEntry(alias)),
                        "isCert", Boolean.toString(keyStore.isCertificateEntry(alias))));
            }

            return gson.toJson(aliases);
        } catch (KeyStoreException e) {
            throw new WebApplicationException(status(NOT_FOUND).entity(e.getMessage()).build());
        } catch (NoSuchProviderException e) {
            throw new WebApplicationException(status(NOT_FOUND).entity(e.getMessage()).build());
        } catch (FileNotFoundException e) {
            throw new WebApplicationException(status(NOT_FOUND).entity("KeyStore not found").build());
        } catch (CertificateException e) {
            throw new WebApplicationException(status(NOT_FOUND).entity("Certificate not readable").build());
        } catch (NoSuchAlgorithmException e) {
            throw new WebApplicationException(status(NOT_FOUND).entity(e.getMessage()).build());
        } catch (IOException e) {
            throw new WebApplicationException(status(NOT_FOUND).entity("KeyStore not readable or bad password").build());
        } finally {
            Closeables.closeQuietly(inputStream);
        }
    }