我的方法安全吗?

时间:2018-05-17 09:10:34

标签: java security jwt simple-web-token

我正在为我们的Web应用程序创建一个tokensystem。你们怎么想?这个isWebTokenAvailable()方法是否安全?

/**
     * Checked if webToken is available {@link de.security.WebToken}.
     *
     * @param webToken to check if webToken is available.
     * @return true if webToken is available and if there is no available token then returns false.
     */
    public boolean isWebTokenAvailable(@NonNull String webToken) {
        return !em.createNamedQuery("validateToken").setParameter("token", webToken)
                .getResultList().isEmpty();
    }

1 个答案:

答案 0 :(得分:1)

据我了解,如果您有身份验证问题,只需验证以下步骤:

  • 在创建令牌时,您需要在其中设置基本内容 喜欢userRole / id根据你的app的要求。
  • 您需要通过从令牌中提取该信息来验证用户 使用数据库中的信息验证它。
  • 提供令牌 db只是您在身份验证后正在执行的步骤 检查到期日。
相关问题