Atitit.提升电子商务安全性 在线充值功能安全方面的设计
Atitit.提升电子商务安全性 在线充值功能安全方面的设计
1. 防止dataservcie对充值订单表的直接改写,只能通过api,不能通过sql1
1.2. 判断是否有此订单,否则CantFindRechargeOrderEx1
1.3. 如果订单状态有无。throw new RechargeOrderStatErr(" order.stat:" + order_id + "." + stat);1
1.4. 判断次订单是否处理过。。if (finished(order_id))1
1.6. 判断来路money是否与数据库内的相同FeeNotEquEx2
1.7. 判断订单修改状态,如果不为1 OrderFinishEx2
1. 防止dataservcie对充值订单表的直接改写,只能通过api,不能通过sql
1.1. Order_id的安全取值,注入检测
String order_id = (String) SqlSecuryCheckor.val(m.get("order_id"));
1.2. 判断是否有此订单,否则CantFindRechargeOrderEx
1.3. 如果订单状态有无。throw new RechargeOrderStatErr(" order.stat:" + order_id + "." + stat);
1.4. 判断次订单是否处理过。。if (finished(order_id))
return "already_finish";
必须判断feeFromUrl throw new SecuryEx(" feeFromUrl is null");
作者:: ★(attilax)>>> 绰号:老哇的爪子 ( 全名::Attilax Akbar Al Rapanui 阿提拉克斯 阿克巴 阿尔 拉帕努伊 ) 汉字名:艾龙, EMAIL:1466519819@qq.com
转载请注明来源: http://www.cnblogs.com/attilax/
1.5.
if(m.get("feeFromUrl")==null)
throw new SecuryEx(" feeFromUrl is null");
1.6. 判断来路money是否与数据库内的相同FeeNotEquEx
if( money_frmDb.compareTo(money_frmUrl)!=0 )
throw new FeeNotEquEx(" froom url total_fee.dbfee:"+m.get("feeFromUrl").toString()+"-"+ ormx.querySingleRow.get("money") );
1.7. 判断订单修改状态,如果不为1 OrderFinishEx
Object r = ormx.exe(m);
if ((Integer) r == 1)
{
String uid=ormx.querySingleRow.get("uid").toString();
BigDecimal money=(BigDecimal) ormx.querySingleRow.get("money");
accSvr.addAmount(uid, money);
return "ok";
}
throw new OrderFinishEx(" order finish ex");
1.8. Codce
package com.attilax.order;
import java.math.BigDecimal;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.lang3.StringUtils;
import org.apache.xmlbeans.impl.xb.xsdschema.Public;
import aaaCfg.IocX4casher;
import bsh.StringUtil;
import com.attilax.acc.Acc;
import com.attilax.acc.AccService;
//import com.attilax.bet.AmountCalcService;
import com.attilax.data.DataStoreService;
import com.attilax.db.DBX;
import com.attilax.db.DbService;
import com.attilax.function.Function;
import com.attilax.io.filex;
import com.attilax.ioc.IocUtilV2;
import com.attilax.ioc.IocXq214;
import com.attilax.json.AtiJson;
import com.attilax.lang.FunctinImp;
import com.attilax.lang.Global;
import com.attilax.lang.SecuryEx;
import com.attilax.log.LogSvr;
import com.attilax.math.ADecimal;
import com.attilax.orm.AOrm;
import com.attilax.orm.AtiOrm;
import com.attilax.sms.SmsService;
import com.attilax.sql.SqlSecuryCheckor;
//import com.attilax.sql.DbService;
import com.attilax.store.StoreService;
import com.attilax.user.User;
import com.attilax.user.UserService;
import com.attilax.util.DataMapper;
import com.attilax.web.ReqX;
import com.google.common.collect.Maps;
import com.google.inject.ImplementedBy;
import com.google.inject.Inject;
import com.google.inject.name.Named;
import com.attilax.trigger.Trigger_after;
/**
* v3 add refuse and accept com.attilax.order.OrderService4jobus.refuse
*
* com.attilax.order.RechargeOrderService
* @author attilax 2016年4月14日 下午12:36:44
*/
public class RechargeOrderService extends OrderService {
public static void main(String[] args) {
System.out.println("--f");
System.setProperty("apptype", "jobus");
System.setProperty("prj", "jobus");
RechargeOrderService srv = IocUtilV2
.getBean(RechargeOrderService.class);
// System.out.println(srv.refuse("0301_152839_178"));
// System.out.println(srv.accept("0301_152839_178"));
Map m = Maps.newLinkedHashMap();
m.put("$table", "orderv2");
m.put("order_id", "198201");
//
String finishMsg = (String) srv.finish(m);
System.out.println(finishMsg);
System.out.println("--f");
}
@Inject
DataStoreService storeSvr;
@Inject
UserService userSvr;
@Inject
AccService accSvr;
@Inject
AmountCalcService amoutCalcSvr;
@Inject
private LogSvr logSvr;
// @Inject @Named("order_service_dataMaper")
// @ImplementedBy(FunctinImp.class) should ostion in interface java hto..
// public Function dataMaper;
@Inject
public Trigger_after trig_bef;
@Inject
public Trigger_after trig_aft;
public int insert(HttpServletRequest req) {
return insert(ReqX.toMap(req));
}
public int insert(Map order) {
if (userSvr == null)
throw new RuntimeException("#userSvr_is_null");
if (accSvr == null)
throw new RuntimeException("#accSvr_is_null");
if (amoutCalcSvr == null)
throw new RuntimeException("#amoutCalcSvr_is_null");
if (userSvr.isNotLogin()) {
throw new RuntimeException(" not login 没登录,请先登录..#not_login");
}
User u = userSvr.getLoginUser();
Acc a = accSvr.getAcc(u.id);
BigDecimal needMoney = amoutCalcSvr.calc(order);
if (new ADecimal(needMoney).biggerEqualThan(a.amount))
throw new RuntimeException(
" amount not enough 金额不足够 ..#amount_not_enough ");
// /...insert
order.put("$op", "insert");
order.put("order_id", filex.getUUidName());
order.put("order_money", needMoney);
trig_bef.apply(order);
storeSvr.insert(order);
int rzt = accSvr.reduceAmount(u.id.toString(), needMoney.doubleValue());
logSvr.log(order);
return rzt;
}
@Inject
AtiOrm ormx;
/**
* for req
attilax 2016年4月20日 下午4:11:03
* @return
*/
public Object finish()
{
HttpServletRequest req=Global.req.get();
return finish(ReqX.toMap(req));
}
public Object finish(Map m) {
// if(StringUtils.isEmpty((String)m.get("$where")) )
// throw new RuntimeException("no $where contion..");
String order_id = (String) SqlSecuryCheckor.val(m.get("order_id"));
if (finished(order_id))
return "already_finish";
//-------check money equ
if(m.get("feeFromUrl")==null)
throw new SecuryEx(" feeFromUrl is null");
BigDecimal money_frmDb=(BigDecimal) ormx.querySingleRow.get("money");
BigDecimal money_frmUrl=new BigDecimal( m.get("feeFromUrl").toString());
if( money_frmDb.compareTo(money_frmUrl)!=0 )
throw new FeeNotEquEx(" froom url total_fee.dbfee:"+m.get("feeFromUrl").toString()+"-"+ ormx.querySingleRow.get("money") );
m.put("stat", 1);
String where = " order_id='$order_id$'".replace("$order_id$",
SqlSecuryCheckor.val(m.get("order_id")));
m.put("$where", where);
m.remove("order_id");
// m.put("stat",1);
ormx.m = m;
ormx.setOp(ormx.update);
ormx.setTable("orderv2");
Object r = ormx.exe(m);
if ((Integer) r == 1)
{
String uid=ormx.querySingleRow.get("uid").toString();
BigDecimal money=(BigDecimal) ormx.querySingleRow.get("money");
accSvr.addAmount(uid, money);
return "ok";
}
throw new OrderFinishEx(" order finish ex");
}
/**
attilax 2016年4月21日 下午9:29:02
* @param string
* @return
*/
private Exception FeeNotEquEx(String string) {
// TODO Auto-generated method stub
return null;
}
private boolean finished(String order_id) {
String s = "select * from orderv2 where order_id='" + order_id + "'";
Map m = ormx.tabletype("sql").querySingleRow(s).querySingleRow;
if (m == null)
throw new CantFindRechargeOrder("order id:" + order_id);
String stat = m.get("stat").toString();
if (stat.equals("1"))
return true;
if (stat.equals("0"))
return false;
throw new RechargeOrderStatErr(" order.stat:" + order_id + "." + stat);
// return m.get("stat").toString().equals("1");
// ormx.tabletype("sql").exist(s).existRzt;
// false;
}
public List<Map> query(Map order) {
if (userSvr.isNotLogin()) {
throw new RuntimeException(" not login 没登录,请先登录..#not_login");
}
User u = userSvr.getLoginUser();
return null;
// /...insert
// return accSvr.reduceAmount(u.id.toString(), needMoney.doubleValue());
}
@Deprecated
public String query2json(Map order) {
return AtiJson.toJson(query(order));
// /...insert
// return accSvr.reduceAmount(u.id.toString(), needMoney.doubleValue());
}
}
Atitit.提升电子商务安全性 在线充值功能安全方面的设计的更多相关文章
- Atitit.在线充值功能的设计
Atitit.在线充值功能的设计 1. 流程1 2. Js sdk api 增加订单1 3. Java api 返回servlet处理1 3.1. 返回网址的本地host测试2 1. 流程 本地增 ...
- Atitit.提升 升级类库框架后的api代码兼容性设计指南
Atitit.提升 升级类库框架后的api代码兼容性设计指南 1. 增加api直接增加,版本号在注释上面增加1 2. 废弃api,使用主见@dep1 3. 修改api,1 4. 修改依赖import, ...
- Atitit 提升开发进度大方法--高频功能与步骤的优化 类似性能优化
Atitit 提升开发进度大方法--高频功能与步骤的优化 类似性能优化 1. 通用功能又可以组合成crud模块1 1.1. 查询(包括步骤,发送查询dsl,通讯返回结果,绑定到表格控件)2 1.2. ...
- Atitit. 提升存储过程与编程语言的可读性解决方案v3 qc25.docx
Atitit. 提升存储过程与编程语言的可读性解决方案v3 qc25.docx 1. 大原则:分解+命名1 1.1. 命名规范1 1.2. 分层.DI和AOP是继OO1 1.3. 运算符可读性一般要比 ...
- Atitit 软件项目非法模块与功能的管理与 监狱管理的对比 原理与概论attilax总结
Atitit 软件项目非法模块与功能的管理与 监狱管理的对比 原理与概论attilax总结 软件项目中的非法模块非法功能非法分子与人类中的非法分子很是相似,必须要建议不同的的约束管理标准化... 软 ...
- Atitit.linux 内核 新特性 新功能
Atitit.linux 内核 新特性 新功能 1. Linux 3.2内核新特性 2012-02-12 22:41:471 1.1. EXT4:支持更大的块2 1.2. BTRFS:更快的数据清理 ...
- Atitit。数据库 安全性 重要敏感数据加密存储解决方案
Atitit.数据库 安全性 重要敏感数据加密存储解决方案 1.1. 加密存储的重要性1 1.2. 使用的加密算法aes1 1.3. 数据加密以后会有一些问题.1 1.3.1. 一个是统计,比如统计资 ...
- Atitit.提升语言可读性原理与实践
Atitit.提升语言可读性原理与实践 表1-1 语言评价标准和影响它们的语言特性1 1.3.1.2 正交性2 1.3.2.2 对抽象的支持3 1.3.2.3 表达性3 .6 语言设计中的权 ...
- atitit.提升软件开发的效率and 质量的那些强大概念and方法总结
atitit.提升软件开发的效率and 质量的那些强大概念and方法总结 1. 主流编程中三个最糟糕的问题 1 1.1. 从理解问题后到实现的时间很长 1 1.2. 理解和维护代码 2 1.3. 学 ...
随机推荐
- IP,路由,交换基础培训记录
IP 掩码 子网划分 vlan划分(有助于减少广播压力) vlan之间互通通过交换机打通. 路由,静态路由,动态路由(学习到的),路由表,下一跳,网络位长的优先级高. 交换机,hub集线器. hub ...
- 基于HTML5技术的电力3D监控应用(一)
最近参与了国网计量中心的四线一库自动化检定系统的项目开发,团队封闭开发了大半年终于快到尾声了,整个项目过程实在非常累,我的mentor杨杨老师是这样描述的:累的不想说话了.我估计是我太渴望新知识,整天 ...
- Git学习笔记(二)
一.创建远程仓库(GitHub) 1.GitHub网站地址:https://github.com/,这个网站就是提供Git仓库托管服务的,所以,只要注册一个GitHub账号,就可以免费获得Git远程仓 ...
- PHP内核研究(内存管理1)
PHP内存管理 PHP在5.3之前采用的是引用计数法 PHP在5.3之后采用了新的垃圾回收机制 操作系统在申请内存空间的时候回引发系统调用 在操作系统申请内存空间的时候,会将CPU从用户态切换到内核态 ...
- 理解SQL Server是如何执行查询的 (2/3)
查询执行的内存授予(Query Execution Memory Grant) 有些操作符需要较多的内存才能完成操作.例如,SORT.HASH.HAS聚合等.执行计划通过操作符需要处理数据量的预估值( ...
- 编写Chrome扩展程序
Chrome的扩展程序很多,也很容易入门,可以来简单实现一下 看看,慢慢就能实现出一个扩展程序来 每个扩展程序应用一般会包含: 一个manifest清单文件 html文件 js文件 其他文件等 可以看 ...
- javascript设计模式实践之代理模式--图片预加载
图片的预加载就是在加载大图片前,先显示一个loading.gif,就算在网络比较慢的时候也能让人知道正在加载,总比啥反应都没有强. 下面这段代码就是预加载的一个简单的实现,假设先不处理加载图片时的on ...
- JavaScript动态增删改表格数据
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <m ...
- iOS阶段学习第30天笔记( UIViewController—Delegate(代理) )
iOS学习(UI)知识点整理 一.UIViewController的介绍 1)概念:UIViewController 即视图控制器,用来管理和控制页面跳转的一个类 ,iOS里面采用了MVC的体系结构, ...
- Java并发编程:synchronized
Java并发编程:synchronized 虽然多线程编程极大地提高了效率,但是也会带来一定的隐患.比如说两个线程同时往一个数据库表中插入不重复的数据,就可能会导致数据库中插入了相同的数据.今天我们就 ...