code: public static boolean canProxyAs(String userNameToProxyAs, String superUserName, Path superUserKeytabLocation) {
      try {
        loginAndProxyAsUser(userNameToProxyAs, superUserName, superUserKeytabLocation);
      } catch (IOException e) {
        return false;
      }
      return true;
    }
docs: Returns true if superUserName can proxy as userNameToProxyAs using the specified superUserKeytabLocation, false
  otherwise.