package com.dxhy.auth.util.client;

import javax.annotation.Resource;

import org.springframework.context.annotation.Configuration;

import com.dxhy.admin.sys.config.AdminConfig;
import com.dxhy.auth.config.KeyConfiguration;
import com.dxhy.common.jwt.IJWTInfo;
import com.dxhy.common.jwt.JWTHelper;

import lombok.extern.slf4j.Slf4j;

/**
 * @author jiaohongyang
 * @date 2019年3月26日 下午5:55:51
 *
 */
@Configuration
@Slf4j
public class ClientTokenUtil {
    @Resource
    private KeyConfiguration keyConfiguration;

    public String generateToken(IJWTInfo jwtInfo) throws Exception {
        return JWTHelper.generateToken(jwtInfo, keyConfiguration.getServicePriKey(), AdminConfig.expire);
    }

    public IJWTInfo getInfoFromToken(String token) throws Exception {
        return JWTHelper.getInfoFromToken(token, keyConfiguration.getServicePubKey());
    }

}
