...
|
...
|
@@ -9,13 +9,12 @@ import com.tianbo.util.Date.DateUtil; |
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.UUID;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import java.util.*;
|
|
|
|
|
|
@Slf4j
|
|
|
@RestController
|
...
|
...
|
@@ -31,6 +30,9 @@ public class NmmsController { |
|
|
@Resource
|
|
|
COMPANYUSERMapper companyuserMapper;
|
|
|
|
|
|
@Value("${sso.witheIP}")
|
|
|
private String whiteIP;
|
|
|
|
|
|
@ApiOperation(value = "删除分单信息", notes = "awba主单号格式\\d{3}-\\d{8},awbh分单号")
|
|
|
@DeleteMapping("/delOriginAWBH")
|
|
|
public ResultJson getCustomMessageId(@RequestParam(value = "awba",required = true) String awba,
|
...
|
...
|
@@ -53,7 +55,10 @@ public class NmmsController { |
|
|
@ApiOperation(value = "统一认证平台同步资源接口", notes = "用户信息同步")
|
|
|
@PostMapping(value = "/userSynchronization")
|
|
|
@ResponseBody
|
|
|
public ResultMessage userSynchronization(@RequestBody UAM uam) throws Exception {
|
|
|
public ResultMessage userSynchronization(@RequestBody UAM uam, HttpServletRequest request) {
|
|
|
if(!witheIP(request)){
|
|
|
return new ResultMessage("401", "资源同步失败,来源IP非法");
|
|
|
};
|
|
|
if ("user".equals(uam.getResType())){
|
|
|
|
|
|
List<UserData> list = uam.getData();
|
...
|
...
|
@@ -89,4 +94,40 @@ public class NmmsController { |
|
|
return new ResultMessage("201","不是用户信息");
|
|
|
}
|
|
|
|
|
|
private boolean witheIP(HttpServletRequest request){
|
|
|
|
|
|
List<String> witheIPList = Arrays.asList(whiteIP.split(","));
|
|
|
// 优先取 X-Real-IP
|
|
|
String ip = request.getHeader("X-Real-IP");
|
|
|
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)){
|
|
|
log.info("X-Real-IP = [{}]",ip);
|
|
|
ip = request.getHeader("x-forwarded-for");
|
|
|
log.info("x-forwarded-for= [{}]",ip);
|
|
|
}
|
|
|
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)){
|
|
|
ip = request.getRemoteAddr();
|
|
|
log.info("RemoteAddr= [{}]",ip);
|
|
|
if ("0:0:0:0:0:0:0:1".equals(ip))
|
|
|
{
|
|
|
ip = "unknown";
|
|
|
log.info(ip);
|
|
|
}
|
|
|
}
|
|
|
if ("unknown".equalsIgnoreCase(ip)){
|
|
|
ip = "unknown";
|
|
|
}
|
|
|
int index = ip.indexOf(',');
|
|
|
if (index >= 0){
|
|
|
ip = ip.substring(0, index);
|
|
|
}
|
|
|
log.info("用户IP来源为:[{}]",ip);
|
|
|
for (String whitIp : witheIPList ) {
|
|
|
if(ip.contains(whitIp)){
|
|
|
return true;
|
|
|
}
|
|
|
}
|
|
|
log.info("用户IP[{}]来源非法",ip);
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
} |
...
|
...
|
|