com.wangshanhai.power.service.impl.PowerTokenGenerateServiceImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of shanhai-power-spring-boot-starter Show documentation
Show all versions of shanhai-power-spring-boot-starter Show documentation
山海Power - 基于SpringBoot的权限组件,极致精简,只为满足简单需要。
The newest version!
package com.wangshanhai.power.service.impl;
import com.wangshanhai.power.config.ShanhaiPowerConfig;
import com.wangshanhai.power.service.TokenGenerateService;
import com.wangshanhai.power.utils.TokenAlgorithmUtils;
import java.util.Map;
import java.util.UUID;
/**
* 生成Token
* @author Shmily
*/
public class PowerTokenGenerateServiceImpl implements TokenGenerateService {
@Override
public String generateToken(ShanhaiPowerConfig shanhaiPowerConfig, Map extParams) {
if(shanhaiPowerConfig!=null){
switch (shanhaiPowerConfig.getTokenAlgorithm()){
case "uuid": return TokenAlgorithmUtils.uuid();
case "sha512": return TokenAlgorithmUtils.SHA512(TokenAlgorithmUtils.uuid());
default: return UUID.randomUUID().toString();
}
}
return null;
}
}