Package org.nutz.ngqa.bean

Examples of org.nutz.ngqa.bean.App


  @At("/user/login/app")
  @Ok("ajax")
  public Object appLogin(@Param("appId") String appId, HttpSession session)
      throws Exception {
    if (appId != null) {
      App app = dao.findById(App.class, appId);
      if (app != null) {
        if (!app.isActive())
          return Ajax.fail().setData("app isn't active!");
        String value = UUID.randomUUID().toString() + "_"
            + Math.random();
        session.setAttribute("app.token", value);
        MessageDigest sha1 = MessageDigest.getInstance("sha1");
        sha1.update(value.getBytes());
        sha1.update(app.getKey().getBytes());
        session.setAttribute("app.token", getHexString(sha1.digest()));
        session.setAttribute("app.id", appId);
        return Ajax.ok().setData(value);
      }
    }
View Full Code Here


  public Object appLoginCallback(@Param("token") String token,
      HttpSession session) {
    String _token = (String) session.getAttribute("app.token");
    session.removeAttribute("app.token");
    if (_token != null && _token.equals(token)) {
      App app = dao.findOne(App.class,
          new BasicDBObject("_id", session.getAttribute("app.id")));
      if (app != null) {
        session.setAttribute("app", app);
        return Ajax.ok();
      }
View Full Code Here

  @Filters({@By(type=ActionFilter.class, args={"ioc:authFilter"})})
  @Auth("app.create")
  public Object createApp(final String name) {
    if (Strings.isBlank(name))
      return Ajax.fail().setMsg("name is emtry!");
    App app = dao.findOne(App.class, new BasicDBObject("name", name));
    if (app != null)
      return Ajax.fail().setMsg("Name exist!!");
    app = new App();
    app.setName(name);
    app.setKey(R.sg(48).next());
    final App _app = app;
    dao.runNoError(new Callback<DB>() {
     
      @Override
      public void invoke(DB arg0) {
        dao.save(_app);
View Full Code Here

TOP

Related Classes of org.nutz.ngqa.bean.App

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.