Beispiel #1
0
  public static String gen(User user) {
    Token token = new Token();
    token.setTid(user.getId());
    //		token.setDvhs(teacher.getLastDeviceId().hashCode());

    token.setThs(getHashCode(user));

    String str = JsonUtil.obj2Json(token);
    return CipherUtil.encode(str, PropertyUtil.getProperty("key"));
  }
Beispiel #2
0
  public static Token toToken(String strToken) {
    String authToken;
    try {
      authToken = CipherUtil.decode(strToken, PropertyUtil.getProperty("key"));
    } catch (Exception e) {
      throw new BusinessException("TOKEN验证错误.", BusinessException.INVALIDE_TOKEN);
    }

    Token token = GsonUtil.json2Object(authToken, Token.class);

    token.setStrToken(strToken);
    return token;
  }