use of io.jpom.model.node.NodeAgentWhitelist in project Jpom by dromara.
the class SystemConfigController method getWhitelist.
/**
* 加载白名单配置
*
* @return json
*/
@RequestMapping(value = "get_whitelist", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
@Feature(cls = ClassFeature.SYSTEM_NODE_WHITELIST, method = MethodFeature.LIST)
public String getWhitelist() {
String workspaceId = nodeService.getCheckUserWorkspace(getRequest());
NodeAgentWhitelist config = systemParametersServer.getConfigDefNewInstance(StrUtil.format("node_whitelist_{}", workspaceId), NodeAgentWhitelist.class);
return JsonMessage.getString(200, "加载成功", config);
}
use of io.jpom.model.node.NodeAgentWhitelist in project Jpom by dromara.
the class SystemConfigController method saveWhitelist.
/**
* 保存白名单配置
*
* @return json
*/
@RequestMapping(value = "save_whitelist", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
@Feature(cls = ClassFeature.SYSTEM_NODE_WHITELIST, method = MethodFeature.EDIT)
public String saveWhitelist(@ValidatorItem(msg = "请选择分发的节点") String nodeIds, String project, String certificate, String nginx, String allowEditSuffix, String allowRemoteDownloadHost) {
HttpServletRequest httpServletRequest = getRequest();
String workspaceId = nodeService.getCheckUserWorkspace(httpServletRequest);
NodeAgentWhitelist agentWhitelist = new NodeAgentWhitelist();
agentWhitelist.setNodeIds(nodeIds);
agentWhitelist.setProject(project);
agentWhitelist.setCertificate(certificate);
agentWhitelist.setNginx(nginx);
agentWhitelist.setAllowEditSuffix(allowEditSuffix);
agentWhitelist.setAllowRemoteDownloadHost(allowRemoteDownloadHost);
String format = StrUtil.format("node_whitelist_{}", workspaceId);
systemParametersServer.upsert(format, agentWhitelist, format);
//
List<String> nodeIdsStr = StrUtil.splitTrim(nodeIds, StrUtil.LF);
UserModel user = getUser();
for (String s : nodeIdsStr) {
NodeModel byKey = nodeService.getByKey(s, httpServletRequest);
JSONObject jsonObject = (JSONObject) JSONObject.toJSON(agentWhitelist);
JsonMessage<String> request = NodeForward.request(byKey, NodeUrl.WhitelistDirectory_Submit, user, jsonObject);
Assert.state(request.getCode() == 200, "分发 " + byKey.getName() + " 节点配置失败" + request.getMsg());
}
return JsonMessage.getString(200, "保存成功");
}
Aggregations