Commit f47e12af by s_guodong

update

parent 609409f8
package com.ceb.gjjs.mda.resource.base;
import com.brilliance.mda.runtime.mda.driver.MdaEnv;
import com.brilliance.mda.runtime.request.BaseVO;
import com.brilliance.mda.runtime.response.ResponseSet;
import com.brilliance.mda.support.service.ICommonService;
import com.brilliance.mda.support.td.BDAuthInfo;
import com.ceb.gjjs.mda.special.vo.RequestBaseVo;
import com.ceb.gjjs.mda.util.ReflectUtil;
import com.ceb.gjjs.mda.util.ValidatorUtil;
......@@ -18,7 +20,6 @@ import javax.ws.rs.PathParam;
* @create 2021-09-24 11:51
*/
public abstract class AbstractCommonResource<V extends BaseVO> {
protected abstract ICommonService getCommonService();
protected abstract V getVo();
......@@ -252,8 +253,16 @@ public abstract class AbstractCommonResource<V extends BaseVO> {
if (src.length() > 12) {
return "业务来源src不能超过12";
}
before(baseVO);
return "";
}
private void before(V baseVO) {
BDAuthInfo authInfo = (BDAuthInfo) MdaEnv.getAuthInfo();
authInfo.setCifno(baseVO.getCifno());
authInfo.setUsrInr(baseVO.getUserid());
}
}
package com.ceb.gjjs.mda.special.vo;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;
/**
* @Description
* @Author s_guodong
* @Date 2023/8/14
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
@Data
public class DemoResultVo extends RespondBaseVo{
}
package com.ceb.gjjs.mda.special.vo;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;
/**
* @Description
* @Author s_guodong
* @Date 2023/8/14
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
@Data
public class DemoVo extends RequestBaseVo {
}
......@@ -7,6 +7,8 @@ import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import java.io.Serializable;
/**
* @Description 请求定制vo的基类
* @Author s_guodong
......@@ -15,7 +17,7 @@ import org.hibernate.validator.constraints.Length;
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
@Data
public class RequestBaseVo {
public class RequestBaseVo implements Serializable {
@Length(max = 8, message = "长度最大8")
@Need
......
package com.ceb.gjjs.mda.special.vo;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;
import java.io.Serializable;
/**
* @Description 返回定制vo的基类
* @Author s_guodong
* @Date 2023/8/10
*/
public class RespondBaseVo {
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
@Data
public class RespondBaseVo implements Serializable {
}
......@@ -16,6 +16,7 @@ public class LoginConstants {
//用户ID
public static final String usrinr= "usrinr";
public static final String cifno= "cifno";
public static final String ptyinr= "ptyinr";
public static final String errorText= "errorText";
......
......@@ -6,7 +6,6 @@ import com.brilliance.mda.runtime.mda.driver.MdaEnv;
import com.brilliance.mda.runtime.mda.util.Systems;
import com.brilliance.mda.support.cache.ICache;
import com.brilliance.mda.support.td.BDAuthInfo;
import com.ceb.gjjs.mda.bo.Usr;
import com.ceb.gjjs.mda.dao.PtyMapper;
import com.ceb.gjjs.mda.dao.UsrMapper;
import com.ceb.gjjs.mda.util.LoginConstants;
......@@ -17,7 +16,9 @@ import javax.ws.rs.container.ContainerRequestContext;
import javax.ws.rs.container.ContainerRequestFilter;
import javax.ws.rs.ext.Provider;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import static com.brilliance.mda.runtime.mda.Constants.tdContextLASTUSERACTIONTIME;
......@@ -50,19 +51,6 @@ public class AuthorizationRequestFilter implements ContainerRequestFilter {
*/
@Override
public void filter(ContainerRequestContext request) {
//String logName = request.getHeaderString("userId");
//客户核心编号
String cid = request.getHeaderString(LoginConstants.cid);
//逻辑修改补充在这里.....
Map<String,Object> argsMap = new HashMap<>();
argsMap.put("sql","select * from usr where cid='"+cid+"'");
List<Usr> usrList = usrMapper.dyncRead(argsMap);
if(usrList.size()==0)
{
return ;
}
String userId=usrList.get(0).getInr();
//网银编号
String ncid = request.getHeaderString(LoginConstants.ncid);
String CN = request.getHeaderString(LoginConstants.CN);
......@@ -72,20 +60,18 @@ public class AuthorizationRequestFilter implements ContainerRequestFilter {
String CERT = request.getHeaderString(LoginConstants.CERT);
//errorText
String errorText=request.getHeaderString(LoginConstants.errorText);
Map<String,Object> headMap=new HashMap<>();
headMap.put(LoginConstants.usrinr,userId);
headMap.put(LoginConstants.ncid,ncid);
headMap.put(LoginConstants.errorText,errorText);
headMap.put(LoginConstants.CN,CN);
headMap.put(LoginConstants.needSign,needSign);
headMap.put(LoginConstants.__terminalType,__terminalType);
headMap.put(LoginConstants.algorithm,algorithm);
headMap.put(LoginConstants.CERT,CERT);
String errorText = request.getHeaderString(LoginConstants.errorText);
Map<String, Object> headMap = new HashMap<>();
headMap.put(LoginConstants.ncid, ncid);
headMap.put(LoginConstants.errorText, errorText);
headMap.put(LoginConstants.CN, CN);
headMap.put(LoginConstants.needSign, needSign);
headMap.put(LoginConstants.__terminalType, __terminalType);
headMap.put(LoginConstants.algorithm, algorithm);
headMap.put(LoginConstants.CERT, CERT);
String token = getTokenKey(request);
//目前采用自动登录模式认证
getOrCreateAuthInfo(token, headMap);
getOrCreateAuthInfo(headMap);
//设置一些系统参数
String actionTime = new SimpleDateFormat("yyyyMMddHHmmssSSS").format(new Date());
Systems.setContext(tdContextLASTUSERACTIONTIME, actionTime);
......@@ -93,39 +79,18 @@ public class AuthorizationRequestFilter implements ContainerRequestFilter {
}
private String getTokenKey(ContainerRequestContext request) {
/*String token = request.getHeaderString(LoginConstants.token);
if (token == null || "undefined".equals(token))
token = "test";
return token;*/
return UUID.randomUUID().toString();
}
private IAuthInfo getOrCreateAuthInfo(String tokenKey, Map<String,Object> headMap) {
IAuthInfo authInfo = authInfoICache.get(tokenKey);
if (authInfo == null) {
synchronized (authInfoICache) {
authInfo = authInfoICache.get(tokenKey);
if (authInfo == null) {
String usrinr=headMap.get(LoginConstants.usrinr)==null?"":headMap.get(LoginConstants.usrinr).toString();
String ptyinr=headMap.get(LoginConstants.ptyinr)==null?"":headMap.get(LoginConstants.ncid).toString();
String errorText=headMap.get(LoginConstants.errorText)==null?"":headMap.get(LoginConstants.errorText).toString();
String CN=headMap.get(LoginConstants.CN)==null?"":headMap.get(LoginConstants.CN).toString();
String needSign=headMap.get(LoginConstants.needSign)==null?"":headMap.get(LoginConstants.needSign).toString();
String __terminalType=headMap.get(LoginConstants.__terminalType)==null?"":headMap.get(LoginConstants.__terminalType).toString();
String algorithm=headMap.get(LoginConstants.algorithm)==null?"":headMap.get(LoginConstants.algorithm).toString();
String CERT=headMap.get(LoginConstants.CERT)==null?"":headMap.get(LoginConstants.CERT).toString();
BDAuthInfo tdAuthInfo = new BDAuthInfo(usrinr,ptyinr,errorText,__terminalType,needSign,CN,algorithm,CERT);
authInfo = tdAuthInfo;
authInfoICache.store(tokenKey, authInfo);
//构造authInfo,本该在登录里面做
// initAuthInfo(userId,authInfo);
}
}
}
MdaEnv.setAuthInfo(authInfo);
return authInfo;
private IAuthInfo getOrCreateAuthInfo(Map<String, Object> headMap) {
String usrinr = headMap.get(LoginConstants.usrinr) == null ? "" : headMap.get(LoginConstants.usrinr).toString();
String ptyinr = headMap.get(LoginConstants.ptyinr) == null ? "" : headMap.get(LoginConstants.ncid).toString();
String errorText = headMap.get(LoginConstants.errorText) == null ? "" : headMap.get(LoginConstants.errorText).toString();
String CN = headMap.get(LoginConstants.CN) == null ? "" : headMap.get(LoginConstants.CN).toString();
String needSign = headMap.get(LoginConstants.needSign) == null ? "" : headMap.get(LoginConstants.needSign).toString();
String __terminalType = headMap.get(LoginConstants.__terminalType) == null ? "" : headMap.get(LoginConstants.__terminalType).toString();
String algorithm = headMap.get(LoginConstants.algorithm) == null ? "" : headMap.get(LoginConstants.algorithm).toString();
String CERT = headMap.get(LoginConstants.CERT) == null ? "" : headMap.get(LoginConstants.CERT).toString();
BDAuthInfo bdAuthInfo = new BDAuthInfo(usrinr, ptyinr, errorText, __terminalType, needSign, CN, algorithm, CERT);
MdaEnv.setAuthInfo(bdAuthInfo);
return bdAuthInfo;
}
}
......@@ -8,6 +8,7 @@ import java.util.List;
public class BDAuthInfo implements IAuthInfo {
private String usrInr;
private String cifno;
private String ptyInr;
private String errorText;
private String terminalType;
......@@ -106,4 +107,16 @@ public class BDAuthInfo implements IAuthInfo {
}
}
}
public void setUsrInr(String usrInr) {
this.usrInr = usrInr;
}
public String getCifno() {
return cifno;
}
public void setCifno(String cifno) {
this.cifno = cifno;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment