Ejemplo n.º 1
0
  public Object lookupToken(String username, String value) {
    try {
      Object token =
          lookupEntityManager()
              .createQuery(
                  "select t from "
                      + tokenClass.getName()
                      + " t where "
                      + tokenUsernameProperty.getName()
                      + " = :username and "
                      + tokenValueProperty.getName()
                      + " = :value")
              .setParameter("username", username)
              .setParameter("value", value)
              .getSingleResult();

      return token;
    } catch (NoResultException ex) {
      return null;
    }
  }
Ejemplo n.º 2
0
  public void invalidateAll(String username) {
    Query query =
        lookupEntityManager()
            .createQuery(
                "select t from "
                    + tokenClass.getName()
                    + " t where "
                    + tokenUsernameProperty.getName()
                    + " = :username")
            .setParameter("username", username);

    for (Object token : query.getResultList()) {
      lookupEntityManager().remove(token);
    }
  }