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();
}
}
Aggregations