Java Code Examples for cn.hutool.core.util.ObjectUtil#clone()

The following examples show how to use cn.hutool.core.util.ObjectUtil#clone() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OperateLogController.java    From Jpom with MIT License 4 votes vote down vote up
@Override
public void before(JoinPoint joinPoint) {
    Signature signature = joinPoint.getSignature();
    if (signature instanceof MethodSignature) {
        MethodSignature methodSignature = (MethodSignature) signature;
        Method method = methodSignature.getMethod();
        UserOperateLogV1.OptType optType = null;
        OptLog optLog = method.getAnnotation(OptLog.class);
        if (optLog != null) {
            optType = optLog.value();
        }
        if (optType != null) {
            CacheInfo cacheInfo = new CacheInfo();
            cacheInfo.optType = optType;

            ServletRequestAttributes servletRequestAttributes = BaseServerController.getRequestAttributes();
            HttpServletRequest request = servletRequestAttributes.getRequest();
            if (optType == UserOperateLogV1.OptType.Login) {
                // 获取登录人的信息
                String userName = request.getParameter("userName");
                UserService userService = SpringUtil.getBean(UserService.class);
                cacheInfo.userModel = userService.getItem(userName);
            }
            // 获取ip地址
            cacheInfo.ip = ServletUtil.getClientIP(request);
            // 获取节点
            cacheInfo.nodeModel = (NodeModel) request.getAttribute("node");
            //
            cacheInfo.dataId = request.getParameter("id");
            //
            cacheInfo.userAgent = ServletUtil.getHeaderIgnoreCase(request, HttpHeaders.USER_AGENT);
            //
            Map<String, String[]> map = ObjectUtil.clone(request.getParameterMap());
            // 过滤密码字段
            Set<Map.Entry<String, String[]>> entries = map.entrySet();
            for (Map.Entry<String, String[]> entry : entries) {
                String key = entry.getKey();
                if (StrUtil.containsAnyIgnoreCase(key, "pwd", "password")) {
                    entry.setValue(new String[]{"***"});
                }
            }
            cacheInfo.setReqData(JSONObject.toJSONString(map));
            CACHE_INFO_THREAD_LOCAL.set(cacheInfo);
        }
    }
}
 
Example 2
Source File: CommandUtil.java    From Jpom with MIT License 4 votes vote down vote up
public static List<String> getCommand() {
    return ObjectUtil.clone(COMMAND);
}