/**
  * 判断返回是否正确
  *
  * @param result
  * @return
  */
 protected <T> boolean isReturnSuc(EucApiResult<T> result) {
   if (!CodeConstant.OK.equals(result.getResultCode())
       || (result.getDescList() != null && result.getDescList().size() > 0)) { // 失败
     return false;
   } else { // 成功
     return true;
   }
 }
 /**
  * 用户名|手机号/密码登录
  *
  * @param userName 用户名|手机号
  * @param passwd 密码
  * @return
  * @throws Exception
  */
 protected EucAuthResult login(String userName, String passwd) throws Exception {
   EucApiResult<EucAuthResult> result =
       EucApiAuthCall.login(userName, passwd, "app", getRequestInfo());
   if (isReturnSuc(result)) {
     Assert.assertTrue("用户名|手机号/密码登录", result.getResult() != null);
   } else {
     Assert.assertFalse("用户名|手机号/密码登录【" + getErrorDesc(result) + "】", true);
   }
   return result.getResult();
 }
Exemplo n.º 3
0
 public static EucApiResult<ExpJUser> autoAKeyRegist(RequestInfo info) throws EucParserException {
   JBody jbody = new JBody();
   jbody.putContent("isNeedLogin", false);
   JBean jbean = eucService.getResult("/api/autoAKeyRegist", jbody, authPara, info);
   EucApiResult<ExpJUser> result = new EucApiResult<ExpJUser>(jbean);
   if (jbean.getBody() != null) {
     ExpJUser jUser = jbean.getBody().getObject("user", ExpJUser.class);
     result.setResult(jUser);
   }
   return result;
 }
Exemplo n.º 4
0
 /**
  * 按手机号获取用户
  *
  * @param mobile
  * @param info
  * @return
  * @throws EucParserException
  */
 public static EucApiResult<JUser> getUserbyMobile(String mobile, RequestInfo info)
     throws EucParserException {
   JBody jbody = new JBody();
   jbody.putContent("mobile", mobile);
   JBean jbean = eucService.getResult("/api/getUserByMobile", jbody, authPara, info);
   EucApiResult<JUser> result = new EucApiResult<JUser>(jbean);
   if (jbean.getBody() != null) {
     JUser jUser = jbean.getBody().getObject("user", JUser.class);
     result.setResult(jUser);
   }
   return result;
 }
Exemplo n.º 5
0
 /**
  * 登录名注册接口
  *
  * @param username 登录名
  * @param password 密码
  * @param info
  * @return 用户实体
  * @throws EucParserException
  */
 public static EucApiResult<JUser> registByName(String username, String password, RequestInfo info)
     throws EucParserException {
   JBody jbody = new JBody();
   jbody.putContent("username", username);
   jbody.putContent("password", password);
   JBean jbean = eucService.getResult("/api/registByName", jbody, authPara, info);
   EucApiResult<JUser> result = new EucApiResult<JUser>(jbean);
   if (jbean.getBody() != null) {
     JUser jUser = jbean.getBody().getObject("user", JUser.class);
     result.setResult(jUser);
   }
   return result;
 }
 protected EucAuthResult login() throws Exception {
   MockHttpServletRequest request = new MockHttpServletRequest();
   MockHttpServletResponse response = new MockHttpServletResponse();
   // TODO 登录
   EucApiResult<EucAuthResult> result =
       EucApiAuthCall.login(
           request, response, LOGIN_MOBILE, LOGIN_MOBILE_PASS_WD, true, getRequestInfo());
   if (CodeConstant.OK.equals(result.getResultCode())) {
     Assert.assertTrue("登录验证", result.getResult() != null);
   } else {
     Assert.assertFalse("登录验证失败【" + getErrorDesc(result) + "】", true);
   }
   return result.getResult();
 }
Exemplo n.º 7
0
 /**
  * 确认重置密码
  *
  * @param mobile 要重置密码的用户的绑定手机号
  * @param newpwd 新密码
  * @param veriCode 收到的验证码
  * @param info 用户请求信息
  * @return 是否重置成功
  * @throws EucParserException
  */
 public static EucApiResult<Boolean> applyResetPass(
     String mobile, String newpwd, String veriCode, RequestInfo info) throws EucParserException {
   JBody jbody = new JBody();
   jbody.putContent("mobile", mobile);
   jbody.putContent("newpwd", newpwd);
   jbody.putContent("veriCode", veriCode);
   JBean jbean = eucService.getResult("/api/applyResetPass", jbody, authPara, info);
   EucApiResult<Boolean> result = new EucApiResult<Boolean>(jbean);
   if (result.getResultCode().equals(CodeConstant.OK)) {
     result.setResult(true);
   } else {
     result.setResult(false);
   }
   return result;
 }
Exemplo n.º 8
0
 /**
  * 请求重置密码,将获得验证码
  *
  * @param mobile 提供一个已绑定的手机号
  * @param info 应用请求信息(esid,uid,source等)
  * @return 与手机号对应的验证码
  * @throws EucParserException
  */
 public static EucApiResult<String> requestResetPass(
     String mobile, boolean isSendMsg, RequestInfo info) throws EucParserException {
   JBody jbody = new JBody();
   jbody.putContent("mobile", mobile);
   if (isSendMsg) {
     jbody.putContent("sendMsg", true);
   }
   JBean jbean = eucService.getResult("/api/requestResetPass", jbody, authPara, info);
   EucApiResult<String> result = new EucApiResult<String>(jbean);
   JBody jb = jbean.getBody();
   if (null != jb) {
     result.setResult(jb.getString("veriCode"));
   }
   return result;
 }
Exemplo n.º 9
0
 /**
  * 带鉴权的更新用户信息接口
  *
  * @param token
  * @param juser
  * @return
  * @throws EucParserException
  * @author damon 2012.07.02
  */
 public static EucApiResult<JUser> updateUser(EucToken token, JUser juser, RequestInfo info)
     throws EucParserException {
   JBody jbody = new JBody();
   // 鉴权标识
   jbody.putContent("token", token);
   // 是否需要鉴权
   jbody.putContent("isAuth", true);
   jbody.putContent("user", juser);
   JBean jbean = eucService.getResult("/api/updateUser", jbody, authPara, info);
   EucApiResult<JUser> result = new EucApiResult<JUser>(jbean);
   if (jbean.getBody() != null) {
     JUser jUser = jbean.getBody().getObject("user", JUser.class);
     result.setResult(jUser);
   }
   return result;
 }
Exemplo n.º 10
0
 /**
  * 带鉴权的绑定接口(确认)
  *
  * @param token
  * @param mobile
  * @param veriCode
  * @return
  * @throws EucParserException
  * @author damon 2012.07.02
  */
 public static EucApiResult<JUser> applyBindMobile(
     EucToken token, String mobile, String veriCode, RequestInfo info) throws EucParserException {
   JBody jbody = new JBody();
   // 鉴权标识
   jbody.putContent("token", token);
   // 是否需要鉴权
   jbody.putContent("isAuth", true);
   jbody.putContent("mobile", mobile);
   jbody.putContent("veriCode", veriCode);
   JBean jbean = eucService.getResult("/api/applyBindMobile", jbody, authPara, info);
   EucApiResult<JUser> result = new EucApiResult<JUser>(jbean);
   if (jbean.getBody() != null) {
     JUser jUser = jbean.getBody().getObject("user", JUser.class);
     result.setResult(jUser);
   }
   return result;
 }
Exemplo n.º 11
0
 /**
  * 带鉴权的更新密码接口
  *
  * @param token
  * @param oldPass
  * @param newPass
  * @return
  * @throws EucParserException
  */
 public static EucApiResult<Boolean> updatePass(
     EucToken token, String oldPass, String newPass, RequestInfo info) throws EucParserException {
   JBody jbody = new JBody();
   // 鉴权标识
   jbody.putContent("token", token);
   // 是否需要鉴权
   jbody.putContent("isAuth", true);
   jbody.putContent("oldPass", oldPass);
   jbody.putContent("newPass", newPass);
   JBean jbean = eucService.getResult("/api/updatePasswd", jbody, authPara, info);
   EucApiResult<Boolean> result = new EucApiResult<Boolean>(jbean);
   if (result.getResultCode().equals(CodeConstant.OK)) {
     result.setResult(true);
   } else {
     result.setResult(false);
   }
   return result;
 }
Exemplo n.º 12
0
 /**
  * 返回错误描述信息
  *
  * @param result
  * @return
  */
 protected <T> String getErrorDesc(EucApiResult<T> result) {
   if (CodeConstant.NOT_AUTH.equals(result.getResultCode())) {
     return "无调用接口的权限";
   }
   return result.getDescList() != null ? result.getDescList().get(0).getD() : "无异常信息";
 }