Search in sources :

Example 1 with GetSaltResponse

use of beans.response.GetSaltResponse in project MSEC by Tencent.

the class GetSalt method exec.

public GetSaltResponse exec(LoginRequest request) {
    GetSaltResponse resp = new GetSaltResponse();
    if (request.getStaff_name() == null || request.getStaff_name().length() < 1) {
        resp.setStatus(100);
        resp.setMessage("login name empty!");
        return resp;
    }
    DBUtil util = new DBUtil();
    if (util.getConnection() == null) {
        resp.setStatus(100);
        resp.setMessage("db connect failed!");
        return resp;
    }
    List<StaffInfo> saltList;
    String sql = "select salt from t_staff where  staff_name=? ";
    List<Object> params = new ArrayList<Object>();
    params.add(request.getStaff_name());
    try {
        saltList = util.findMoreRefResult(sql, params, StaffInfo.class);
        if (saltList.size() != 1) {
            resp.setMessage("query salt failed");
            resp.setStatus(100);
            return resp;
        }
        String salt = saltList.get(0).getSalt();
        String challenge = geneChallenge();
        resp.setMessage("success");
        resp.setChallenge(challenge);
        resp.setSalt(salt);
        resp.setStatus(0);
        return resp;
    } catch (Exception e) {
        resp.setStatus(100);
        resp.setMessage("db query exception!");
        e.printStackTrace();
        return resp;
    } finally {
        util.releaseConn();
    }
}
Also used : DBUtil(msec.org.DBUtil) GetSaltResponse(beans.response.GetSaltResponse) ArrayList(java.util.ArrayList) StaffInfo(beans.dbaccess.StaffInfo)

Aggregations

StaffInfo (beans.dbaccess.StaffInfo)1 GetSaltResponse (beans.response.GetSaltResponse)1 ArrayList (java.util.ArrayList)1 DBUtil (msec.org.DBUtil)1