Package com.ikanow.infinit.e.data_model.store.social.cookies

Examples of com.ikanow.infinit.e.data_model.store.social.cookies.CookiePojo


      rp.setData(ap, new AuthenticationPojoApiMap());
     
      // OK we're all good, finally for API key users create a persistent cookie:
      if (null != ap.getApiKey()) {
        // (if we're here then we're already admin so can always do this - unlike the update)
        CookiePojo cp = new CookiePojo();
        cp.set_id(profileId);
        cp.setCookieId(cp.get_id());
        cp.setApiKey(wpa.getApiKey());
        cp.setStartDate(ap.getCreated());
        cp.setProfileId(profileId);
        DbManager.getSocial().getCookies().save(cp.toDb());
      }//TOTEST
    }
    catch (Exception ex )
    {
      logger.error("Exception Message: " + ex.getMessage(), ex);
View Full Code Here


     
      if ((null != wpa.getApiKey()) && (0 == wpa.getApiKey().length()) && (null != ap.getApiKey()))     
      {
        // Delete existing API key
        // (We'll allow a user to update their own API key - just not create it, see below)
        CookiePojo removeMe = new CookiePojo();
        removeMe.setApiKey(ap.getApiKey());
        ap.setApiKey(null);       
        DbManager.getSocial().getCookies().remove(removeMe.toDb());
      }
      else if (null != wpa.getApiKey()) {
        // Change or create API key
        // Only admins can do this:
        if (null != personIdStr) { // (this is != null iff user isn't admin)
          // Check security settings
          PropertiesManager pm = new PropertiesManager();
          if (pm.getHarvestSecurity()) {
            rp.setResponse(new ResponseObject("WP Update User",false,"You must be admin in secure mode to set an API key"));
            return rp;
          }
        }//TESTED (admin, admin-enabled, non-admin - harvest.secure on and off)
       
        ap.setApiKey(wpa.getApiKey());
        CookiePojo cp = new CookiePojo();
        cp.set_id(ap.getProfileId());
        cp.setCookieId(cp.get_id());
        cp.setApiKey(wpa.getApiKey());
        cp.setStartDate(ap.getCreated());
        cp.setProfileId(ap.getProfileId());
        DbManager.getSocial().getCookies().save(cp.toDb());               
      }//TESTED
      //else if api key is null then leave alone, assume hasn't changed
     
      //update old entries
      DbManager.getSocial().getPerson().update(new BasicDBObject("_id", pp.get_id()), pp.toDb());
View Full Code Here

    }
    // (else we'll just have to leave that object in there unfortunately)
    //TESTED
   
    // Delete any cookies the user might have
    CookiePojo cookieQuery = new CookiePojo();
    if (null != pp.get_id()) {
      cookieQuery.setProfileId(pp.get_id());
      DbManager.getSocial().getCookies().remove(cookieQuery.toDb());
    }
    //TOTEST
   
    rp.setResponse(new ResponseObject("WP Delete User",true,"User Deleted Successfully"));
    return rp;
View Full Code Here

          return null;
        }//TESTED
      }
      //Find user
      //create a new entry
      CookiePojo cp = new CookiePojo();
      cp.set_id(new ObjectId());
      cp.setCookieId(cp.get_id());
      cp.setLastActivity(new Date());
      cp.setProfileId(userid);
      cp.setStartDate(new Date());
      cookieColl.insert(cp.toDb());
      //return cookieid
      return cp.getCookieId();
    }
    catch (Exception e )
    {
      logger.error("Line: [" + e.getStackTrace()[2].getLineNumber() + "] " + e.getMessage());
      e.printStackTrace();
View Full Code Here

    if ((null == cookieIdStr) || cookieIdStr.equalsIgnoreCase("null") || cookieIdStr.isEmpty())
      return null;
    try
    {
      //remove any old cookie for this user
      CookiePojo cookieQuery = new CookiePojo();
      if (cookieIdStr.startsWith("api:")) {
        cookieQuery.setApiKey(cookieIdStr.substring(4));
      }
      else {
        cookieQuery.set_id(new ObjectId(cookieIdStr));
      }
      BasicDBObject cookieQueryDbo = (BasicDBObject) cookieQuery.toDb();
      DBObject dbo = DbManager.getSocial().getCookies().findOne(cookieQueryDbo);
      ObjectId userid = null;
      if ( dbo != null )
      {
        CookiePojo cp = CookiePojo.fromDb(dbo, CookiePojo.class);
        if (null != cp.getApiKey()) {
          userid = cp.getProfileId();
          // (no activity/timeout)
        }//TESTED
        else {
          PropertiesManager props = new PropertiesManager();
          Long timeout_s = props.getApiTimeoutSeconds();
          long nTimeout_ms = (null == timeout_s)? COOKIE_TIMEOUT : 1000L*timeout_s;
          if ( (new Date().getTime() - cp.getLastActivity().getTime()) < nTimeout_ms)
          {
            //less than 15min, update activity time
            cp.setLastActivity(new Date());
            DbManager.getSocial().getCookies().update(cookieQueryDbo, cp.toDb());
            userid = cp.getProfileId();
          }
          else
          {
            //to late, drop cookie
            DbManager.getSocial().getCookies().remove(dbo);
View Full Code Here

        if ( authuser != null )
        {
          // Since logging-in isn't time critical, we'll ensure that api users have their api cookie at this point...
          if (null != authuser.getApiKey()) {
            CookiePojo cp = new CookiePojo();
            cp.set_id(authuser.getProfileId());
            cp.setCookieId(cp.get_id());
            cp.setApiKey(authuser.getApiKey());
            cp.setStartDate(authuser.getCreated());
            cp.setProfileId(authuser.getProfileId());
            DbManager.getSocial().getCookies().save(cp.toDb());            
          }//TESTED

          if ((authuser.getAccountType() == null) ||
              !(authuser.getAccountType().equalsIgnoreCase("admin") || authuser.getAccountType().equalsIgnoreCase("admin-enabled")))
          {
View Full Code Here

TOP

Related Classes of com.ikanow.infinit.e.data_model.store.social.cookies.CookiePojo

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.