Package org.hfuu.uaadac.dto

Examples of org.hfuu.uaadac.dto.ResponseMessage


  @RequestMapping(value="/authen")
  @ResponseBody
  public void authen(@RequestParam("T")String ticket, HttpServletRequest req, HttpServletResponse resp) {
    System.out.println("访问通过");
   
    ResponseMessage respMsg = new ResponseMessage();
    respMsg.setStatus(true);
    respMsg.setCause("验证通过!");
   
    User user = new User();
    user.setId(1L);
    user.setAccounts("hyksdjkf@if.cld");
    user.setSimpleName("张三");
   
    respMsg.setUser(user);
   
    resp.setCharacterEncoding("UTF-8");
   
    Resource resource = new ClassPathResource("sso.properties");
    Writer outWriter = null;
View Full Code Here


   
    // 通过session验证用户是否已经登录过了
    boolean isRedirectLogin = true;
    if (null == user) {
      if (null != ticketStr) {
        ResponseMessage respMsg = SendRequest.checkTicket(new RequestMessage(ticketStr));
        if (respMsg.isStatus()) {
          user = respMsg.getUser();
          session.setAttribute(props.getProperty("USER_INFO_SESSION"), user);
          isRedirectLogin = false;
          System.out.println("验证通过!");
        }
      }
View Full Code Here

   * <p>
   * @param msg 校验消息
   * @return 响应消息
   */
  public static ResponseMessage checkTicket(RequestMessage msg) {
    ResponseMessage respMsg = new ResponseMessage();
   
    try {
      String url = CommonConfig.getProp().getProperty("SSO_AUTHEN_URL") + "?T=" + msg.getTicket();
     
      HttpClient client = new DefaultHttpClient();
      HttpGet httpGet = new HttpGet(url);
      HttpResponse resp = client.execute(httpGet);
     
      HttpEntity entity = resp.getEntity();
      if (null != entity) {
        byte[] data = EntityUtils.toByteArray(entity);
       
        String plainData = CipherHelper.decrypt(data, CommonConfig.getProp().getProperty("D_KEY"));
        if (null != plainData) {
          respMsg = JsonHelper.jsonDeserialize(plainData, ResponseMessage.class);
        }
        else {
          respMsg.setStatus(false);
          respMsg.setCause("由于密码错误,导致解密失败!");
        }
       
        EntityUtils.consume(entity);
      }
      else {
        respMsg.setStatus(false);
        respMsg.setCause("没有响应数据!");
      }
    }
    catch (Exception e) {
      respMsg.setStatus(false);
      respMsg.setCause("请求异常或响应解析失败!");
      e.printStackTrace();
    }
   
    return respMsg;
  }
View Full Code Here

TOP

Related Classes of org.hfuu.uaadac.dto.ResponseMessage

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.