use of io.github.ihongs.CoreConfig in project HongsCORE by ihongs.
the class MoreAction method eval.
@Action("eval")
public void eval(ActionHelper helper) throws HongsException {
CoreConfig cnf = CoreConfig.getInstance();
HttpServletRequest req = helper.getRequest();
HttpServletResponse rsp = helper.getResponse();
// 许可及IP白名单
boolean sw = cnf.getProperty("core.eval.more.enable", false);
String ia = cnf.getProperty("core.eval.more.allows");
String ip = ActionDriver.getClientAddr(req);
Set ias = Synt.toTerms(ia);
if (ias == null || ias.isEmpty()) {
ias = new HashSet();
ias.add("::1");
ias.add("127.0.0.1");
ias.add("0:0:0:0:0:0:0:1");
}
if (!sw) {
throw new HongsException(400, "Illegal request!");
}
if (!ias.contains(ip)) {
throw new HongsException(400, "Illegal request.");
}
Map map = helper.getRequestData();
String act = Core.ACTION_NAME.get();
String uri = (String) map.get("act");
// 从参数提取参数
helper.setRequestData(data(map.get("request")));
helper.setContextData(data(map.get("context")));
helper.setSessionData(data(map.get("session")));
helper.setCookiesData(data(map.get("cookies")));
try {
eval(helper, uri, req, rsp);
} finally {
Core.ACTION_NAME.set(act);
}
}
use of io.github.ihongs.CoreConfig in project HongsCORE by ihongs.
the class ActionDriver method doCommit.
private void doCommit(Core core, ActionHelper hlpr, HttpServletRequest req, HttpServletResponse rsp) throws ServletException, IOException {
/**
* 输出特定服务信息
*/
if (rsp.isCommitted() == false) {
String pb;
CoreConfig cc = core.got(CoreConfig.class);
pb = cc.getProperty("core.service.by");
if (pb != null && pb.length() != 0) {
rsp.setHeader("Server", pb);
}
pb = cc.getProperty("core.powered.by");
if (pb != null && pb.length() != 0) {
rsp.setHeader("X-Powered-By", pb);
}
}
Map dat = hlpr.getResponseData();
if (dat != null) {
req.setAttribute(Cnst.RESPON_ATTR, dat);
hlpr.updateHelper(req, rsp);
hlpr.flush();
}
}
use of io.github.ihongs.CoreConfig in project HongsCORE by ihongs.
the class AuthFilter method isJsop.
private boolean isJsop(HttpServletRequest req) {
String c = Cnst.CB_KEY;
c = req.getParameter(c);
if (c != null && !c.isEmpty()) {
return true;
}
CoreConfig cnf = CoreConfig.getInstance("default");
c = cnf.getProperty("core.callback", "callback");
c = req.getParameter(c);
if (c != null && !c.isEmpty()) {
return true;
}
return false;
}
Aggregations