code: public static char[] generatePassword(String username, Key sharedSecret, String algorithm) {
          byte[] key = sharedSecret.getEncoded();
          Mac hmac;
          try {
              hmac = Mac.getInstance(algorithm);
              SecretKeySpec signingKey = new SecretKeySpec(key, algorithm);
              hmac.init(signingKey);
          } catch (InvalidKeyException | NoSuchAlgorithmException e) {
              throw new TurnException("Unable to generate password", e);
          }
  
          return Base64.getEncoder().encodeToString(hmac.doFinal(username.getBytes())).toCharArray();
      }
docs: This function generates the secret key based on the procedure described in
  https://tools.ietf.org/html/draft-uberti-rtcweb-turn-rest-00#section-2.2
  
  @param username - the username of the API
  @param sharedSecret - the shared secret used by the TURN server as well
  @param algorithm - the algorithm. COTURN only supports HmacSHA1 as of 2016/08/18
  @return - the actual password