package com.moral.service.impl;
|
|
import com.auth0.jwt.JWT;
|
import com.auth0.jwt.algorithms.Algorithm;
|
import com.moral.service.WebTokenService;
|
import org.apache.commons.lang3.time.DateUtils;
|
import org.springframework.stereotype.Service;
|
|
import java.util.Date;
|
|
@Service
|
public class WebTokenServiceImpl implements WebTokenService {
|
public final static String SECRET = "QXPC_Screen_B/S";
|
@Override
|
public String getToken(String id) {
|
String token="";
|
token= JWT.create()
|
.withIssuer("qxpc")//发布者
|
.withIssuedAt(new Date())//生成时间
|
.withExpiresAt(DateUtils.addHours(new Date(),1))//有效时间
|
.withClaim("aid",id)//存放数据
|
.sign(Algorithm.HMAC256(SECRET));
|
return token;
|
}
|
}
|