MainUserService service = new MainUserServiceImpl();
try {
MainUser mainUser = service.findByLoginName(username);
if(mainUser==null||mainUser.getApprove()!=1){
String json ="{\"status\":\"0\",\"message\":\"���ʺŲ��ڰ������У��������¼!\",\"result\":\"{}\"}";
return new TextRenderer(json);
}
} catch (ServiceException e) {
logger.error("��ȡ��������Ա��Ϣʧ��", e);
String json ="{\"status\":\"0\",\"message\":\"���ʺŰ�����У�����!\",\"result\":"+e.getMessage()+"}";
return new TextRenderer(json);
}
}
//���ʺ�У��
if(!StringUtils.isEmpty(password)&&!StringUtils.isEmpty(username)&&StringUtils.isEmpty(smspasswd)){
String responseInfo = this.step1Login(username, password,ipAddr,macAddr,cpuSerial);
if(responseInfo==null){
String json ="{\"status\":\"0\",\"message\":\"����4A�ӿ���֤ʧ��!\",\"result\":\"{}\"}";
return new TextRenderer(json);
}
Map<String,Object> acctMap = new HashMap<String,Object>();
if(responseInfo!=null){
acctMap = VpnXmlParser.parseMainAcctResponseInfo(responseInfo);
}
if(responseInfo!=null&&responseInfo.indexOf("<KEY>")!=-1){//��֤��ͨ��
String json ="{\"status\":\"0\",\"message\":\""+acctMap.get("ERRDESC")+"\",\"result\":\""+acctMap.toString()+"\"}";
return new TextRenderer(json);
}
if(responseInfo!=null&&responseInfo.indexOf("<KEY>")==-1){//���ʺź�������֤ͨ�������ش��˺��б�
//���Ͷ���У���뵽�û�
String smsRespInfo = this.getSMKey(username,ipAddr,macAddr,cpuSerial);
//�������Ż�ȡ������Ϣ
Map<String,Object> map = VpnXmlParser.parseSMSResponseInfo(smsRespInfo);
if(!map.get("RSP").equals("0")){
String json ="{\"status\":\"0\",\"message\":\""+map.get("ERRDESC")+"\",\"result\":\""+map.toString()+"\"}";
return new TextRenderer(json);
}
List<Map<String,Object>> subAcctList = (List<Map<String,Object>>)acctMap.get("SUBACCTS");
if(subAcctList==null||subAcctList.size()==0){
String json ="{\"status\":\"0\",\"message\":\"��ӦBOMC�ʺ�!\",\"result\":\""+acctMap.toString()+"\"}";
return new TextRenderer(json);
}
//�����˺��б��ŵ�Request��
HttpSession session = ActionContext.getActionContext().getHttpSession();
session.setAttribute("acctMap", acctMap);
String json ="{\"status\":\"1\",\"message\":\"���ʺ���֤ͨ��!\",\"result\":\""+acctMap.toString()+"\"}";
return new TextRenderer(json);
}
}
//�������ʺź�������֤
if(!StringUtils.isEmpty(smspasswd)){
//����ǿ��֤
String respInfo = this.step2Login(username, smspasswd,ipAddr,macAddr,cpuSerial);
Map<String,Object> retMap = VpnXmlParser.parseMainAcctStrongResponseInfo(respInfo);
if((retMap!=null&&retMap.size()==0)||(retMap.get("RSP")!=null&&!retMap.get("RSP").equals("0"))){
String json ="{\"status\":\"0\",\"message\":\"���������"+retMap.get("ERRDESC")+"\",\"result\":\""+retMap.toString()+"\"}";
return new TextRenderer(json);
}
//�����û���Ϣ��SESSION��
try{
this.initSession(username, password, smspasswd);
}catch(Exception e){
String json ="{\"status\":\"0\",\"message\":\"ϵͳ��������ϵ����Ա\",\"result\":\""+e.getMessage()+"\"}";
return new TextRenderer();
}
//String json ="{\"status\":\"2\",\"message\":\"������֤ͨ��!\",\"result\":\""+retMap.toString()+"\"}";
String json ="{\"status\":\"2\",\"message\":\"������֤ͨ��!\",\"result\":\"\"}";
return new TextRenderer(json);
}
return new TextRenderer("{\"status\":\"0\",\"message\":\"��֤��ͨ��!\",\"result\":\"{}\"}");
}