模板权限集成示例代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
1.3 KiB

package com.tptj.course.hg.auth.template;
import com.fr.decision.base.util.UUIDUtil;
import com.fr.decision.config.FSConfig;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.StringUtils;
import com.fr.store.StateHubManager;
import com.fr.store.StateHubService;
/**
* @author 秃破天际
* @version 10.0
* Created by 秃破天际 on 2021/6/23
**/
public class StateHubUtils {
private static StateHubService getTemplateAuthService(){
return StateHubManager.applyForService("TemplateAuthKey");
}
public static String initAuthKey( String templateId ){
int timeout = (int) FSConfig.getInstance().getLoginConfig().getLoginTimeout();
String key = UUIDUtil.generate()+System.currentTimeMillis();
try{
getTemplateAuthService().put( key, templateId,timeout );
return key;
}catch(Exception e){
FineLoggerFactory.getLogger().error(e.getMessage(),e);
}
return StringUtils.EMPTY;
}
public static boolean authKey( String templateId, String key ){
try{
return templateId.equals( getTemplateAuthService().get(key) );
}catch(Exception e){
FineLoggerFactory.getLogger().error(e.getMessage(),e);
}
return false;
}
}