Examples of EnterpriseUserPassword


Examples of org.any_openeai_enterprise.moa.jmsobjects.coreapplication.v1_0.EnterpriseUserPassword

    try {
      NetId netId = (NetId)getAppConfig().getObject("NetId");

      EnterpriseUser entUser = (EnterpriseUser)getAppConfig()
        .getObject("EnterpriseUser");
      EnterpriseUserPassword entUserPassword =
        (EnterpriseUserPassword)getAppConfig()
        .getObject("EnterpriseUserPassword");
    }
    catch (EnterpriseConfigurationObjectException eoce) {
      // An error occurred retrieving a required object from AppConfig. Log it
      // and throw an exception.
      String errMsg = "An error occurred retrieving a required object from " +
        "AppConfig. The exception is: " + eoce.getMessage();
      logger.fatal("[PasswordSyncCommand] " + errMsg);
      throw new InstantiationException(errMsg);
    }
   
    // Get the producer from AppConfig.
  try {
    p2p4BpQuery = (PointToPointProducer) getAppConfig().getObject("BasicPersonQuery");
    logger.info("p2p4BpQuery is "+p2p4BpQuery.getClass());
  } catch (EnterpriseConfigurationObjectException e) {
        String errMsg = "[PasswordSyncCommand] Error configuring producer for BasicPersonQuery. The exception is: " + e.getMessage();
        logger.error(errMsg);
        throw new InstantiationException(errMsg);       
  }
 
    // Make sure all objects needed are configured and available for use.
  // LightweightPerson, BasicPersion, EnterpriseUserPassword
     try {
      LightweightPerson lPerson =
            (LightweightPerson)getAppConfig().getObject("LightweightPerson");
        BasicPerson aeo = (BasicPerson)getAppConfig().getObject("BasicPerson");
        EnterpriseUserPassword newEntUserPassword = (EnterpriseUserPassword)getAppConfig()
          .getObject("EnterpriseUserPassword");
    }
    catch (EnterpriseConfigurationObjectException ecoe) {
      String errMsg = "[PasswordSyncCommand] An error occurred getting an  object from " +
          "AppConfig. the exception is: " + ecoe.getMessage();
View Full Code Here

Examples of org.any_openeai_enterprise.moa.jmsobjects.coreapplication.v1_0.EnterpriseUserPassword

      publishSyncError(eControlArea, errors);
      return;
    }

    // Get two configured EnterpriseUserPassword from AppConfig.
    EnterpriseUserPassword currentEntUserPassword = null;
    EnterpriseUserPassword newEntUserPassword = null;
    try {
      currentEntUserPassword = (EnterpriseUserPassword)getAppConfig()
        .getObject("EnterpriseUserPassword");
      newEntUserPassword = (EnterpriseUserPassword)getAppConfig()
        .getObject("EnterpriseUserPassword");
    }
    catch (EnterpriseConfigurationObjectException ecoe) {
      // An error occurred getting an object from AppConfig. Log it and
      // publish a sync error message.
      Error error = new Error();
      error.setType("application");
      error.setErrorNumber("OpenEAI-3001");
      error.setErrorDescription("An error occurred getting an object from " +
        "AppConfig. the exception is: " + ecoe.getMessage());
      errors = new ArrayList();
      errors.add(error);
      publishSyncError(eControlArea, errors, ecoe);
      return;
    }

    // Handle an EnterpriseUserPassword.CreateSync
    if (messageAction.equalsIgnoreCase("Create")) {
     
      // Get the new state of the EnterpriseUserPassword and build an
      // EnterpriseUserPassword object.
      Element eNewPassword = inDoc.getRootElement().getChild("DataArea")
        .getChild("NewData").getChild("EnterpriseUserPassword");
      try
        newEntUserPassword.buildObjectFromInput(eNewPassword);
      }
      catch (EnterpriseLayoutException ele) {
        // An error occurred building the EnterpriseUserPassword object from the
        // EnterpriseUserPassword element contained in the NewData element of
        // the message. Log it and publish a sync error message.
        Error error = new Error();
        error.setType("system");
        error.setErrorNumber("SakaiGateway-1002");
        error.setErrorDescription("An error occurred building the " +
          "EnterpriseUserPassword object from the EnterpriseUserPassword " +
          "element contained in the NewData element of the message. The " +
          "exception is: " + ele.getMessage());
        errors = new ArrayList();
        errors.add(error);
        publishSyncError(eControlArea, errors, ele);
        return;
      }

      // Determine whether the user exists in the database.
      String userId = getUserId(newEntUserPassword);
      String instId = newEntUserPassword.getEnterpriseUser()
        .getLightweightPerson().getInstitutionalId();
      BasicPerson bp=null;
      try {
        logger.info("[PasswordSyncCommand.execute] Querying for BasicPerson.");
        bp = getBasicPerson(instId);
        logger.info("[PasswordSyncCommand.execute] Queried for BasicPerson.");
    } catch (EnterpriseConfigurationObjectException e) {
        // Log it, publish a error message, and return.
        String errMsg = "EnterpriseConfigurationObjectException: " + e.getMessage();
        logger.error("[PasswordSyncCommand.execute] " + errMsg);
        Error error = new Error();
        error.setType("system");
        error.setErrorNumber("SakaiGateway-1014");
        error.setErrorDescription(errMsg);
        errors = new ArrayList();
        errors.add(error);
        logger.info("[PasswordSyncCommand.execute] Publishing Sync.Error-Sync.");
        publishSyncError(eControlArea, errors);
        return
     } catch (EnterpriseFieldException e) {
        // Log it, publish a error message, and return.
        String errMsg = "EnterpriseFieldException: " + e.getMessage();
        logger.error("[PasswordSyncCommand.execute] " + errMsg);
        Error error = new Error();
        error.setType("system");
        error.setErrorNumber("SakaiGateway-1014");
        error.setErrorDescription(errMsg);
        errors = new ArrayList();
        errors.add(error);
       logger.info("[PasswordSyncCommand.execute] Publishing Sync.Error-Sync.");
        publishSyncError(eControlArea, errors);
        return
     } catch (EnterpriseObjectQueryException e) {
        // Log it, publish a error message, and return.
        String errMsg = "EnterpriseObjectQueryException: " + e.getMessage();
        logger.error("[PasswordSyncCommand.execute] " + errMsg);
        Error error = new Error();
        error.setType("system");
        error.setErrorNumber("SakaiGateway-1014");
        error.setErrorDescription(errMsg);
        errors = new ArrayList();
        errors.add(error);
        logger.info("[PasswordSyncCommand.execute] Publishing Sync.Error-Sync.");
        publishSyncError(eControlArea, errors);
        return
     }
  if (bp==null) {
        // No BasicPerson exists for this instId.
        // Log it, publish a error message, and return.
        String errMsg = "No BasicPerson exists for " + instId;
        logger.debug("[PasswordSyncCommand.execute] " + errMsg);
        Error error = new Error();
        error.setType("application");
        error.setErrorNumber("SakaiGateway-1012");
        error.setErrorDescription(errMsg);
        errors = new ArrayList();
        errors.add(error);
        publishSyncError(eControlArea, errors);
        return
      }
      PortalPerson portalPerson = null
      try { portalPerson = retrievePortalPersonByUserId(userId); }
      catch (CommandException ce) {
        // An error occurred querying the portal database to determine whether
        // the user exists. Log it, publish a error message, and return.
        String errMsg = "An error occurred querying the portal database to " +
          "determine whether the user exists.";
        logger.debug("[PasswordSyncCommand.execute] " + errMsg);
        Error error = new Error();
        error.setType("system");
        error.setErrorNumber("SakaiGateway-2001");
        error.setErrorDescription(errMsg);
        errors = new ArrayList();
        errors.add(error);
        publishSyncError(eControlArea, errors, ce);
        return;
      }

      // If the user does exist, publish a error message indicating
      // that the user already exists.
      if (portalPerson != null) {
        Error error = new Error();
        error.setType("application");
        error.setErrorNumber("SakaiGateway-1011");
        error.setErrorDescription("User with user ID " + userId +
          ") exists in the portal. Cannot reset the password for this user.");
        logger.fatal("[PasswordSyncCommand.execute] " +
          error.getErrorDescription());
        errors = new ArrayList();
        errors.add(error);
        publishSyncError(eControlArea, errors);
        return;
      }

      // Create the portal user with info from BasicPerson and the
      // user's password to be the new value indicated in the message.
      else {
        logger.info("[PasswordSyncCommand.execute] BasicPerson="+bp);
        portalPerson = new PortalPerson();
        portalPerson.setEmailAddress(getEmailAddress(bp.getEmail()));
        portalPerson.setUserId(userId);
        portalPerson.setInstId(instId);
        portalPerson.setFirstName(bp.getName().getFirstName());
        portalPerson.setLastName(bp.getName().getLastName());
       
        // Encypt the password.
        String encryptedPassword=null;
        String cleartextPassword = newEntUserPassword.getPassword().getValue();
        try {
          encryptedPassword = hashPassword(cleartextPassword);
          logger.info("[PasswordSyncCommand.execute] cleartext password is: " +
                  cleartextPassword);
          logger.info("[PasswordSyncCommand.execute] excrypted password is: " +
                  encryptedPassword);
        } catch (NoSuchAlgorithmException nsae) {
          Error error = new Error();
          error.setType("application");
          error.setErrorNumber("SakaiGateway-1002");
          error.setErrorDescription("A NoSuchAlgorithmException occurred encrypting the user " +
            "password. The exception is: " + nsae.getMessage());
          logger.fatal("[PasswordSyncCommand.execute] " +
            error.getErrorDescription());
          errors = new ArrayList();
          errors.add(error);
          publishSyncError(eControlArea, errors, nsae);
          return;
        } catch (MessagingException nsae) {
            Error error = new Error();
            error.setType("application");
            error.setErrorNumber("SakaiGateway-1002");
            error.setErrorDescription("A MessagingException occurred encrypting the user " +
              "password. The exception is: " + nsae.getMessage());
            logger.fatal("[PasswordSyncCommand.execute] " +
              error.getErrorDescription());
            errors = new ArrayList();
            errors.add(error);
            publishSyncError(eControlArea, errors, nsae);
            return;
    } catch (IOException nsae) {
            Error error = new Error();
            error.setType("application");
            error.setErrorNumber("SakaiGateway-2022");
            error.setErrorDescription("An IOException occurred encrypting the user " +
              "password. The exception is: " + nsae.getMessage());
            logger.fatal("[PasswordSyncCommand.execute] " +
              error.getErrorDescription());
            errors = new ArrayList();
            errors.add(error);
            publishSyncError(eControlArea, errors, nsae);
            return;
    }       
       
        portalPerson.setPassword(encryptedPassword);
        try {
      createPortalPerson(portalPerson);
    } catch (CommandException e) {
          Error error = new Error();
          error.setType("system");
          error.setErrorNumber("SakaiGateway-1020");
          String errmsg = "An error occurred building the portal person. The exception is: " +
              e.getMessage();
          error.setErrorDescription(errmsg);
          errors = new ArrayList();
          errors.add(error);
          publishSyncError(eControlArea, errors, e);
          logger.error("[PasswordSyncCommand.execute] Can't create portal person. \n"+errmsg);
          return;
    }
      }
    }

   
    // Handle an EnterpriseUserPassword.Update-Sync.
    if (messageAction.equalsIgnoreCase("Update")) {
     
      // Get the new state of the EnterpriseUserPassword and build an
      // EnterpriseUserPassword object.
      Element eNewPassword = inDoc.getRootElement().getChild("DataArea")
        .getChild("NewData").getChild("EnterpriseUserPassword");
      try
        newEntUserPassword.buildObjectFromInput(eNewPassword);
      }
      catch (EnterpriseLayoutException ele) {
        // An error occurred building the EnterpriseUserPassword object from the
        // EnterpriseUserPassword element contained in the NewData element of
        // the message. Log it and publish a sync error message.
        Error error = new Error();
        error.setType("system");
        error.setErrorNumber("SakaiGateway-1002");
        error.setErrorDescription("An error occurred building the " +
          "EnterpriseUserPassword object from the EnterpriseUserPassword " +
          "element contained in the NewData element of the message. The " +
          "exception is: " + ele.getMessage());
        errors = new ArrayList();
        errors.add(error);
        publishSyncError(eControlArea, errors, ele);
        return;
      }

      // Determine whether the user exists in the database.
      String userId = getUserId(newEntUserPassword);
      PortalPerson portalPerson = null
      try {
        portalPerson = retrievePortalPersonByUserId(userId);
      }
      catch (CommandException ce) {
        // An error occurred querying the portal database to determine whether
        // the user exists. Log it, publish a error message, and return.
        String errMsg = "An error occurred querying the portal database to " +
          "determine whether the user exists.";
        logger.debug("[PasswordSyncCommand.execute] " + errMsg);
        Error error = new Error();
        error.setType("system");
        error.setErrorNumber("SakaiGateway-2001");
        error.setErrorDescription(errMsg);
        errors = new ArrayList();
        errors.add(error);
        publishSyncError(eControlArea, errors, ce);
        return;
      }

      // If the user does not exist, publish a error message indicating
      // that the user does not exist.
      if (portalPerson == null) {
        Error error = new Error();
        error.setType("application");
        error.setErrorNumber("SakaiGateway-1001");
        error.setErrorDescription("No user with user ID " + userId +
          ") exists in the portal. Cannot reset the password for this user.");
        logger.fatal("[PasswordSyncCommand.execute] " +
          error.getErrorDescription());
        errors = new ArrayList();
        errors.add(error);
        publishSyncError(eControlArea, errors);
        return;
      }

      // Otherwise, the user already exists in the portal, so reset the
      // user's password to be the new value indicated in the message.
      else {
        // Encypt the password.
        String encryptedPassword=null;
        String cleartextPassword = newEntUserPassword.getPassword().getValue();
        try {
          encryptedPassword = hashPassword(cleartextPassword);
          logger.info("[PasswordSyncCommand.execute] cleartext password is: " +
                  cleartextPassword);
          logger.info("[PasswordSyncCommand.execute] excrypted password is: " +
View Full Code Here

Examples of org.any_openeai_enterprise.moa.jmsobjects.coreapplication.v1_0.EnterpriseUserPassword

      } else {
        eu = (EnterpriseUser) euQueryList.get(0);
        logger.info("["+portletName+"] Found EnterpriseUser: " + eu);
      }
     
      EnterpriseUserPassword eup=(EnterpriseUserPassword)appConfig.getObject(ENTERPRISE_USER_PASSWORD);
      eup.setEnterpriseUser(eu);
      Password p = eup.newPassword();
      p.setValue(newPassword);
      p.setType("secure credential");
      p.setEncryption("cleartext");
     
      java.util.List returnedEup = eup.query(eu, p2p);
      if (returnedEup.size() == 0) {
        //create the password
        eup.setPassword(p);
        eup.create(p2p);
      logger.info("["+portletName+"] Created the EntepriseUserPassword");               
        return eup;
      } else {
        //update the password
        EnterpriseUserPassword baselineEup = (EnterpriseUserPassword) returnedEup.get(0);
      logger.info("["+portletName+"] baseline="+baselineEup);       
        eup.setBaseline(baselineEup);
        eup.setPassword(p);
        eup.update(p2p);
        return eup;
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.