@Override
  public void init(Properties config, ServletContext servletContext,
                   long tokenValidity) throws Exception {

    String signatureSecretFile = config.getProperty(
        AuthenticationFilter.SIGNATURE_SECRET_FILE, null);

    if (signatureSecretFile != null) {
      try (Reader reader = new InputStreamReader(Files.newInputStream(
              Paths.get(signatureSecretFile)), StandardCharsets.UTF_8)) {
        StringBuilder sb = new StringBuilder();
        int c = reader.read();
        while (c > -1) {
          sb.append((char) c);
          c = reader.read();
        }

        secret = sb.toString().getBytes(StandardCharsets.UTF_8);
        if (secret.length == 0) {
          throw new RuntimeException("No secret in signature secret file: "
             + signatureSecretFile);
        }
      } catch (IOException ex) {
        throw new RuntimeException("Could not read signature secret file: " +
            signatureSecretFile);
      }
    }

    secrets = new byte[][]{secret};
  }
@Test
  public void testEmptySecretFileThrows() throws Exception {
    File secretFile = File.createTempFile("test_empty_secret", ".txt");
    assertTrue(secretFile.exists());

    FileSignerSecretProvider secretProvider
            = new FileSignerSecretProvider();
    Properties secretProviderProps = new Properties();
    secretProviderProps.setProperty(
            AuthenticationFilter.SIGNATURE_SECRET_FILE,
            secretFile.getAbsolutePath());

    Exception exception =
        assertThrows(RuntimeException.class, new ThrowingRunnable() {
          @Override
          public void run() throws Throwable {
            secretProvider.init(secretProviderProps, null, -1);
          }
        });
    assertTrue(exception.getMessage().startsWith(
        "No secret in signature secret file:"));
  }