Examples of WordPressUserPojo


Examples of com.ikanow.infinit.e.data_model.api.authentication.WordPressUserPojo

      String today = formatter.format(date);
      String encrypted_password;

      encrypted_password = encryptWithoutEncode(password);

      WordPressUserPojo wpuser = new WordPressUserPojo();
      WordPressAuthPojo wpauth = new WordPressAuthPojo();

      wpuser.setCreated(today);
      wpuser.setModified(today);
      wpuser.setFirstname(first_name);
      wpuser.setLastname(last_name);
      wpuser.setPhone(phone);

      ArrayList<String> emailArray = new ArrayList<String>();
      emailArray.add(email);
      wpuser.setEmail(emailArray);

      //wpauth.setWPUserID(email);
      wpauth.setPassword(encrypted_password);
      wpauth.setAccountType(accountType);
      wpauth.setCreated(today);
View Full Code Here

Examples of com.ikanow.infinit.e.data_model.api.authentication.WordPressUserPojo

     
      if ( password != null )
        encrypted_password = encryptWithoutEncode(password);


      WordPressUserPojo wpuser = new WordPressUserPojo();
      WordPressAuthPojo wpauth = new WordPressAuthPojo();
     
      wpuser.setModified(today);
      wpuser.setFirstname(first_name);
      wpuser.setLastname(last_name);
      wpuser.setPhone(phone);
      ArrayList<String> emailArray = new ArrayList<String>();
      emailArray.add(email);     
      wpuser.setEmail(emailArray);
      wpauth.setWPUserID(email);
      wpauth.setPassword(encrypted_password);
      wpauth.setAccountType(accountType);
      wpauth.setModified(today);
View Full Code Here

Examples of com.ikanow.infinit.e.data_model.api.authentication.WordPressUserPojo

  public ResponsePojo registerWPUser(String cookieLookup, String wpuser, String wpauth, String wpsetup)
  {   
    ResponsePojo rp = new ResponsePojo();
   
    //Step 0 Read wordpress objects
    WordPressUserPojo wpu = null;
    WordPressAuthPojo wpa = null;
    if (null != wpsetup) {
      WordPressSetupPojo setup = WordPressSetupPojo.fromApi(wpsetup, WordPressSetupPojo.class);
      wpu = setup.getUser();
      wpa = setup.getAuth();
      if ((null == wpu) || (null == wpa)) {
        rp.setResponse(new ResponseObject("WP Register User",false,"Need to specify both user and auth objects"));
        return rp;
      }
    }//TESTED
    else {
      wpu = WordPressUserPojo.fromApi(wpuser,WordPressUserPojo.class);
      wpa = WordPressAuthPojo.fromApi(wpauth,WordPressAuthPojo.class);
    }
   
    //Step 1 Create the person object
    //NOTE we use to store subscription info (i.e. in the peoplepojo)
    //but it was never used anywhere (validating subscription?)
    //its in the WPUserPojo that comes across
    ObjectId profileId = new ObjectId();
    PersonPojo pp = new PersonPojo();
    pp.set_id(profileId);
    pp.setAccountStatus("active");
    if ((null == wpu.getEmail()) || (0 == wpu.getEmail().size())) {
      rp.setResponse(new ResponseObject("WP Register User",false,"Need to specify email"));
      return rp;
    }//TESTED (2c)
    pp.setEmail(wpu.getEmail().get(0));
    pp.setFirstName(wpu.getFirstname()); // (optional but one of this + last name must be set)
    pp.setLastName(wpu.getLastname()); // (optional but one of this + first name must be set)
    if ((null == wpu.getFirstname()) || wpu.getFirstname().isEmpty()){
      if (null == wpu.getLastname()) {
        rp.setResponse(new ResponseObject("WP Register User",false,"Need to specify one of firstname,lastname"));
        return rp;
      }
      pp.setDisplayName(wpu.getLastname());
    }//TESTED (2d)
    else if ((null == wpu.getLastname()) || wpu.getLastname().isEmpty()) {
      pp.setDisplayName(wpu.getFirstname());     
    }
    else {
      pp.setDisplayName(wpu.getFirstname() + " " + wpu.getLastname());           
    }
   
    // Check if user is already present (+set "primary keys"):
   
    if (null == wpu.getWPUserID()) { // WPUserId is optional, uses email if not present
      wpu.setWPUserID(pp.getEmail());
    }
    else { // Check WPU (+email later)
      PersonPojo personQuery = new PersonPojo();
      personQuery.setWPUserID(wpu.getWPUserID()); // (can be null, that's fine)           
      DBObject dboperson = DbManager.getSocial().getPerson().findOne(personQuery.toDb());
      if (null != dboperson) {
        rp.setResponse(new ResponseObject("WP Register User",false,"User already exists, both WPUserId and first email must be unique"));
        return rp;       
      }//TESTED (2e)
    }   
    pp.setWPUserID(wpu.getWPUserID());
   
    PersonPojo personQuery = new PersonPojo();
    personQuery.setEmail(pp.getEmail());
    DBObject dboperson = DbManager.getSocial().getPerson().findOne(personQuery.toDb());
    if (null != dboperson) {
      rp.setResponse(new ResponseObject("WP Register User",false,"User already exists, both WPUserId and first email must be unique"));
      return rp;       
    }//TESTED (2f)
   
    //(The rest of this code has not significantly changed)
   
    // Optional fields:
    pp.setPhone(wpu.getPhone());
    pp.setSubscriptionEndDate(wpu.getSubscriptionEndDate());
    pp.setSubscriptionID(wpu.getSubscriptionID());
    pp.setSubscriptionStartDate(wpu.getSubscriptionStartDate());
    pp.setSubscriptionTypeID(wpu.getSubscriptionTypeID());
   
    //Step 3 add communities to my list (self and system)
    List<PersonCommunityPojo> communities = new ArrayList<PersonCommunityPojo>();
    pp.setCommunities(communities);
   
    //these fields may need set one day
    pp.setAvatar(null);
    pp.setBiography(null);   
    pp.setContacts(null);
    pp.setLanguages(null);
    pp.setLinks(null);
    pp.setLocation(null);
    pp.setOrganization(null);
    pp.setTags(null);
    pp.setTitle(null);
    //end set of fields i didn't use
       
    //Step 4 Create the new auth object so user can login
    AuthenticationPojo ap = new AuthenticationPojo();
    ap.setId(profileId);
    ap.setProfileId(profileId);
    ap.setUsername(pp.getEmail());
    ap.setAccountStatus(AccountStatus.ACTIVE);
    if (null == wpa.getPassword()) { // Obligatory
      rp.setResponse(new ResponseObject("WP Register User",false,"Need to specify password"));
      return rp;
    }
    try
    {
      if (44 != wpa.getPassword().length()) { // hash if in the clear
        wpa.setPassword(PasswordEncryption.encrypt(wpa.getPassword()));
      }
      ap.setPassword(wpa.getPassword());
      if (null == wpa.getAccountType()) { // (optional, defaults to "user"
        wpa.setAccountType("user");
      }
      ap.setAccountType(wpa.getAccountType());
        // to create an account you must be admin, so this is fine....
     
      ap.setWPUserID(wpa.getWPUserID());   
       
      DateFormat df = new SimpleDateFormat("MMM dd, yyyy kk:mm:ss aa");
      //Handle copying dates from wordpress objects
      // (These are all optional, just use now if not specified)
      if (null == wpu.getCreated()) {
        pp.setCreated(new Date());       
      }
      else {
        pp.setCreated(df.parse(wpu.getCreated()));       
      }
      if (null == wpu.getModified()) {
        pp.setModified(new Date());       
      }
      else {
        pp.setModified(df.parse(wpu.getModified()));       
      }
      if (null == wpa.getCreated()) {
        ap.setCreated(new Date());       
      }
      else {
View Full Code Here

Examples of com.ikanow.infinit.e.data_model.api.authentication.WordPressUserPojo

  {
    ResponsePojo rp = new ResponsePojo();
       
    boolean bNeedToUpdateCommunities = false;
   
    WordPressUserPojo wpu = null;
    WordPressAuthPojo wpa = null;
    if (null != wpsetup) {
      WordPressSetupPojo setup = WordPressSetupPojo.fromApi(wpsetup, WordPressSetupPojo.class);
      wpu = setup.getUser();
      wpa = setup.getAuth();
      if ((null == wpu) || (null == wpa)) {
        rp.setResponse(new ResponseObject("WP Update User",false,"Need to specify both user and auth objects"));
        return rp;
      }
    }
    else {
      wpu = WordPressUserPojo.fromApi(wpuser,WordPressUserPojo.class);
      wpa = WordPressAuthPojo.fromApi(wpauth,WordPressAuthPojo.class);
    }
   
    //Save both these objects to the DB
    try
    {         
      PersonPojo personQuery = new PersonPojo();
      if (null != personIdStr) {
        personQuery.set_id(new ObjectId(personIdStr));       
      }
      else {
        if (null == wpu.getWPUserID()) {
          if ((null == wpu.getEmail()) || wpu.getEmail().isEmpty()) {
            rp.setResponse(new ResponseObject("WP Update User",false,"Need to specify WPUserID (or email address if not integrated via WordPress)"));
            return rp;
          }
          else // If authentication username is set, use that because it means that we're trying to change
              // the email (and we're an admin user)
           
            if (null != wpa.getUsername()) { // I may be changing someone's name
              personQuery.setEmail(wpa.getUsername());
            }
            else { // I'm not changing anybody's name
              personQuery.setEmail(wpu.getEmail().get(0));
            }
          }
        }
        else {
          personQuery.setWPUserID(wpu.getWPUserID());
        }
      }     
      BasicDBObject dboperson = (BasicDBObject) DbManager.getSocial().getPerson().findOne(personQuery.toDb());
      if (null == dboperson) {
        rp.setResponse(new ResponseObject("WP Update User",false,"Can't find user specified by WPUserID"));
        return rp;       
      }
     
      PersonPojo pp = PersonPojo.fromDb(dboperson,PersonPojo.class);
     
      if ((null != wpu.getEmail()) && !wpu.getEmail().isEmpty()) {
        if (!pp.getEmail().equalsIgnoreCase(wpu.getEmail().get(0))) { // Email has changed...
          pp.setEmail(wpu.getEmail().get(0));
       
          // Check this is allowed (ie haven't taken a username already in use):
          personQuery = new PersonPojo();
          personQuery.setEmail(pp.getEmail());
          dboperson = (BasicDBObject) DbManager.getSocial().getPerson().findOne(personQuery.toDb());
          if (null != dboperson) {
            rp.setResponse(new ResponseObject("WP Update User",false,"This primary email address is not unique"));
            return rp;       
          }//TOTEST
         
          bNeedToUpdateCommunities = true;
        }
      }
      if (null != wpu.getFirstname()) {
        if ((null == pp.getFirstName()) || !pp.getFirstName().equals(wpu.getFirstname())) {
          pp.setFirstName(wpu.getFirstname());
          bNeedToUpdateCommunities = true;
        }
      }
      if (null != wpu.getLastname()) {
        if ((null == pp.getLastName()) || !pp.getLastName().equals(wpu.getLastname())) {
          pp.setLastName(wpu.getLastname());
          bNeedToUpdateCommunities = true;
        }
      }
      // Update display name
      StringBuffer displayName = new StringBuffer();
      if ((null != pp.getFirstName()) && !pp.getFirstName().isEmpty()) {
        displayName.append(pp.getFirstName());
      }
      if ((null != pp.getLastName()) && !pp.getLastName().isEmpty()) {
        if (displayName.length() > 0) {
          displayName.append(' ');
        }
        displayName.append(pp.getLastName());
      }//TOTESTx2
      pp.setDisplayName(displayName.toString());
     
      if (null != wpu.getPhone()) {
        pp.setPhone(wpu.getPhone());
      }
      if (null != wpu.getSubscriptionEndDate()) {
        pp.setSubscriptionEndDate(wpu.getSubscriptionEndDate());
      }
      if (null != wpu.getSubscriptionID()) {
        pp.setSubscriptionID(wpu.getSubscriptionID());
      }
      if (null != wpu.getSubscriptionStartDate()) {
        pp.setSubscriptionStartDate(wpu.getSubscriptionStartDate());
      }
      if (null != wpu.getSubscriptionTypeID()) {
        pp.setSubscriptionTypeID(wpu.getSubscriptionTypeID());
      }
      // (can't change WPUserId obv)
     
      AuthenticationPojo authQuery = new AuthenticationPojo();
      if (null != pp.get_id()) {
        authQuery.setProfileId(pp.get_id());
      }
      else {
        rp.setResponse(new ResponseObject("WP Update User",false,"Internal authentication error 1"));
        return rp;       
      }
      DBObject dboauth = DbManager.getSocial().getAuthentication().findOne(authQuery.toDb());
      if (null == dboauth) {
        rp.setResponse(new ResponseObject("WP Update User",false,"Internal authentication error 2"));
        return rp;       
      }     
      AuthenticationPojo ap = AuthenticationPojo.fromDb(dboauth, AuthenticationPojo.class);
     
      if ((null != wpu.getEmail()) && !wpu.getEmail().isEmpty()) {
        ap.setUsername(wpu.getEmail().get(0)); // (ap.username == email address, make life easy when resetting password)
      }
      if (null != wpa.getPassword()) {
        if (44 != wpa.getPassword().length()) { // hash if in the clear
          wpa.setPassword(PasswordEncryption.encrypt(wpa.getPassword()));
        }
View Full Code Here

Examples of com.ikanow.infinit.e.data_model.api.authentication.WordPressUserPojo

         }
         if (null == wpauth) {
           wpauth = parameters.getWpauth();          
         }
         if (urlStr.contains("/person/update/password/")) { //special case: update password
           WordPressUserPojo user = new WordPressUserPojo();
           WordPressAuthPojo auth = new WordPressAuthPojo();
           user.setWPUserID(wpuser); // (this is ignored if a normal user is logged in)
           auth.setPassword(wpauth);
           wpuser = user.toApi();
           wpauth = auth.toApi();
         }
         else if (urlStr.contains("/person/update/email/")) { //special case: update email
           WordPressUserPojo user = new WordPressUserPojo();
           WordPressAuthPojo auth = new WordPressAuthPojo();
           user.setWPUserID(wpuser); // (this is ignored if a normal user is logged in)
           String[] emails = wpauth.split("\\s*,\\s*");
           user.setEmail(Arrays.asList(emails));
           wpuser = user.toApi();
           wpauth = auth.toApi();
         }
         action = "wpupdate";
       }
     }  
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.