import com.auth0.jwt.JWT;
import com.auth0.jwt.algorithms.Algorithm;
import java.util.Calendar;
import java.util.Date;
public class SigUtils {
/**
* Create Signature
*
* @param appId Session Identifier
* @param appKey Session Key
* @param sigExp Signature validity time: in seconds
* @return
*/
public static String createSig(String appId, String appKey, int sigExp) {
Calendar nowTime = Calendar.getInstance();
nowTime.add(Calendar.SECOND, sigExp);
Date expiresDate = nowTime.getTime();
return JWT.create()
//Release date
.withIssuedAt(new Date())
//effective time
.withExpiresAt(expiresDate)
//load
.withClaim("appId", appId)
//encryption
.sign(Algorithm.HMAC256(appKey));
}
}