Package com.comcast.cmb.common.persistence

Examples of com.comcast.cmb.common.persistence.IUserPersistence


        List<String> userList = new ArrayList<String>();
        int index = 1;
       
        String userId = request.getParameter(CQSConstants.AWS_ACCOUNT_ID + ".member." + index);

        IUserPersistence userHandler = PersistenceFactory.getUserPersistence();
       
        while (userId != null) {

          if (userId.equals("*") || userHandler.getUserById(userId) != null) { // only add user if they exist
                userList.add(userId);
            }
           
          index++;
            userId = request.getParameter(CQSConstants.AWS_ACCOUNT_ID + ".member." + index);
View Full Code Here


     
      if (initialized) {
        return;
      }
     
    IUserPersistence userHandler = PersistenceFactory.getUserPersistence();

    if (CMBProperties.getInstance().getCNSUserAccessKey() != null && CMBProperties.getInstance().getCNSUserAccessSecret() != null) {
     
      //TODO: should add user id to cmb properties file
     
        awsCredentials = new BasicAWSCredentials(CMBProperties.getInstance().getCNSUserAccessKey(), CMBProperties.getInstance().getCNSUserAccessSecret());
      cnsInternal = userHandler.getUserByAccessKey(awsCredentials.getAWSAccessKeyId());

    } else {
   
      cnsInternal = userHandler.getUserByName(CMBProperties.getInstance().getCNSUserName());

      if (cnsInternal == null) {           
          cnsInternal =  userHandler.createDefaultUser();
        }

        awsCredentials = new BasicAWSCredentials(cnsInternal.getAccessKey(), cnsInternal.getAccessSecret());
    }
   
View Full Code Here

   
    Util.initLog4jTest();
    CMBControllerServlet.valueAccumulator.initializeAllCounters();
    PersistenceFactory.reset();
   
    IUserPersistence userHandler = PersistenceFactory.getUserPersistence();
   
    AWSCredentials credentials1 = null;
    AWSCredentials credentials2 = null;
    AWSCredentials credentials3 = null;
   
    if (accessKey1 != null && accessSecret1 != null) {
      credentials1 = new BasicAWSCredentials(accessKey1, accessSecret1);
    } else {
      user1 = userHandler.getUserByName(userName1);
      if (user1 == null) {           
        user1 =  userHandler.createUser(userName1, userName1);
      }
      credentials1 = new BasicAWSCredentials(user1.getAccessKey(), user1.getAccessSecret());
      accessKey1 = user1.getAccessKey();
      accessSecret1 = user1.getAccessSecret();
    }
   
    if (accessKey2 != null && accessSecret2 != null) {
      credentials2 = new BasicAWSCredentials(accessKey2, accessSecret2);
    } else {
      user2 = userHandler.getUserByName(userName2);
      if (user2 == null) {            
        user2 =  userHandler.createUser(userName2, userName2);
      }
      credentials2 = new BasicAWSCredentials(user2.getAccessKey(), user2.getAccessSecret());
      accessKey2 = user2.getAccessKey();
      accessSecret2 = user2.getAccessSecret();
    }   
   
    if (accessKey3 != null && accessSecret3 != null) {
      credentials3 = new BasicAWSCredentials(accessKey3, accessSecret3);
    } else {
      user3 = userHandler.getUserByName(userName3);
      if (user3 == null) {            
        user3 =  userHandler.createUser(userName3, userName3);
      }
      credentials3 = new BasicAWSCredentials(user3.getAccessKey(), user3.getAccessSecret());
      accessKey3 = user3.getAccessKey();
      accessSecret3 = user3.getAccessSecret();
    }   
View Full Code Here

  @Test
  public void testCreateDeleteUser() {

    try {
      IUserPersistence persistence = new UserCassandraPersistence()
      User user = createUser(persistence, "vvenkatraman1234", "venu1234");
     
      persistence.deleteUser(user.getUserName());
      verifyUserCleanup((new ArrayList<User>(Arrays.asList(user))), persistence);
            logger.info("testCreateDeleteUser succeeded");

    } catch (Exception ex) {
            logger.error("test failed", ex);
View Full Code Here

  }
 
  @Test
  public void testGetAllUsers() {
    try {
      IUserPersistence persistence = new UserCassandraPersistence()
     
            List<User> users = new LinkedList<User>();
            User user = createUser(persistence, "vvenkatraman1234", "venu1234");
            users.add(user);
            user = createUser(persistence, "bcheng1234", "baosen1234");
            users.add(user);
      user = createUser(persistence, "mchiang1234", "mchiang1234");
            users.add(user);
     
      List<User> userList = persistence.getAllUsers();
      assertTrue(userList != null && userList.size() >= 3);
     
      for (User user1 : users) {
        persistence.deleteUser(user1.getUserName());
      }
     
      userList = persistence.getAllUsers();
      verifyUserCleanup(users, persistence);

            logger.info("testGetAllUsers succeeded");
     
View Full Code Here

  @Test
  public void testCreateAdmin(){
    try{
      String ADMIN_NAME = "cns_admin";
      String ADMIN_PASSWORD = "cns_admin";
      IUserPersistence persistence = new UserCassandraPersistence()
      User user = persistence.getUserByName(ADMIN_NAME);
      if (user != null) {
        persistence.deleteUser(ADMIN_NAME);
      }
      user = persistence.createUser(ADMIN_NAME, ADMIN_PASSWORD, true);
      assertAdmin(ADMIN_NAME, user);
      persistence.deleteUser(ADMIN_NAME);
    }catch(Exception ex){
      logger.error("test failed", ex);
      fail("Test failed: " + ex.toString());
    }
  }
View Full Code Here

    return false;
  }
 
  @Test
  public void testgetUserByIdNameAndKey() throws Exception {
    IUserPersistence persistence = new UserCassandraPersistence();     
    User user;
    try {
        List<User> users = new LinkedList<User>();
      user = createUser(persistence, "vvenkatraman1234", "venu1234");
      users.add(user);
      user = createUser(persistence, "bcheng1234", "boasen1234");
      users.add(user);
      String accessKey = user.getAccessKey();
      user = persistence.createUser("mchiang1234", "mchiang1234");
      users.add(user);
      String userId = user.getUserId();
     
      String userName = "vvenkatraman1234";
      user = persistence.getUserByName(userName);
      assertUser(userName, user);
     
      user = persistence.getUserById(userId);
      assertUser("mchiang1234", user);
      assertTrue(user.getUserId().equals(userId));
     
      user = persistence.getUserByAccessKey(accessKey);
      assertUser("bcheng1234", user);
      assertTrue(user.getAccessKey().equals(accessKey));
     
     
      for (User u : users) {
          persistence.deleteUser(u.getUserName());
      }
     
      verifyUserCleanup(users, persistence);

            logger.info("testgetUserByIdNameAndKey succeeded");
View Full Code Here

        CQSHttpServletRequest request = (CQSHttpServletRequest)asyncContext.getRequest();
        HttpServletResponse response = (HttpServletResponse)asyncContext.getResponse();
   
    if (cnsInternalUser == null) {

      IUserPersistence userHandler = PersistenceFactory.getUserPersistence();
          cnsInternalUser = userHandler.getUserByName(CMBProperties.getInstance().getCNSUserName());

          if (cnsInternalUser == null) {           
            cnsInternalUser =  userHandler.createDefaultUser();
          }
    }
   
    if (awsCredentials == null) {
          awsCredentials = new BasicAWSCredentials(cnsInternalUser.getAccessKey(), cnsInternalUser.getAccessSecret());
View Full Code Here

    Map<?, ?> parameters = request.getParameterMap();

    //String userId = request.getParameter("userId");
    //connect(userId);
   
    IUserPersistence userHandler = PersistenceFactory.getUserPersistence();
    User cnsAdminUser;
    try {
      cnsAdminUser = userHandler.getUserByName(CMBProperties.getInstance().getCNSUserName());
    } catch (PersistenceException ex) {
      throw new ServletException(ex);
    }

    String currentDataCenter = null;
View Full Code Here

      Util.initLog4jTest();
        CMBControllerServlet.valueAccumulator.initializeAllCounters();
        PersistenceFactory.reset();

        IUserPersistence userHandler = new UserCassandraPersistence();
        user = userHandler.getUserByName("cqs_unit_test");

        if (user == null) {
            user =  userHandler.createUser("cqs_unit_test", "cqs_unit_test");
        }

    topicHandler = new CNSTopicCassandraPersistence();
    subscriptionHandler = new CNSSubscriptionCassandraPersistence();
    attributeHandler = new CNSAttributesCassandraPersistence();
View Full Code Here

TOP

Related Classes of com.comcast.cmb.common.persistence.IUserPersistence

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.