Examples of UserAccount


Examples of com.foxconn.gds.security.model.UserAccount

   */
  @Test
  public void testCreateUserAccount() {
    try {
      IUserAccountServices accMgr = UserAccountServices.getInstance();
      UserAccount acc;
      UserProfile pfl;
      String accId;
      for (int i = 0; i < 500; i++) {
        pfl = new UserProfile(
            ("eId-" + i), //unique
            ("name-" + i),
            ("name-" + i+ "@foxconn.com"),
            ("861350000" + i)
        );
        //
        accMgr.createUserProfile(pfl);
       
        for (int j = 0; j < 1; j++) {//Note: AS Cascade.PERSIST, only one !!!
          acc = new UserAccount(i + "-acc-" + j, "Foxconn88");
          acc.setProfile(pfl);
          //accMgr.createUserAccount(acc);
         
          //同時創建一個組與account相同,並將此account加到此組中
          Group group = new Group(acc.getAccount());
          accMgr.createGroup(group);
         
          //
          UserGroup userGroup = new UserGroup(acc, group);
          Collection<UserGroup> inGroups = new ArrayList<UserGroup>();
          inGroups.add(userGroup);
          //注:創建一個UserAccount,會同時創建UserProfile和UserGroup
          acc.setInGroups(inGroups);
          accMgr.createUserAccount(acc);
         
        }
      }
    } catch (Exception e) {
View Full Code Here

Examples of com.foxconn.gds.security.model.UserAccount

  }
 
  @Test
  public void testUserDiffAccountSameProfile() {
    String account = "0-acc-0";
    UserAccount user = UserAccountServices.getInstance().findUserAccountByID(account);
    UserAccount other = new UserAccount("0-acc-2", "Foxconn88");
   
    UserProfile profile = user.getProfile();
   
    other.setProfile( profile );
    try {
      UserAccountServices.getInstance().createUserAccount(other);
    } catch (Exception e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
View Full Code Here

Examples of com.foxconn.gds.security.model.UserAccount

   
  }
  // UserAccount (X), Profile(V)
  @Test
  public void testSaveOrUpdateUserAccount() {
    UserAccount user = new UserAccount("0-acc-2", "Foxconn88881234567");
    UserProfile profile = new UserProfile("eId-0", "name-0", "暮云春樹@foxconn.com", "11111111111" );
    user.setProfile(profile);
    user.setMyGroups("ADMIN,0-acc-1");
   
    boolean updated = true;
    try {
      boolean bool = UserAccountServices.getInstance().saveOrUpdateUserAccount(user, updated);
      Assert.assertTrue(bool);
View Full Code Here

Examples of com.foxconn.gds.security.model.UserAccount

  }
 
  // UserAccount (X), Profile(X)
  @Test
  public void testSaveOrUpdateUserAccount2() {
    UserAccount user = new UserAccount("3339-acc", "Foxconn88");
    UserProfile profile = new UserProfile("eId-3339", "name-0", "ds樹@foxconn.com", "11111111111" );
    user.setProfile(profile);
    user.setMyGroups("ADMIN,0-acc-1");
   
    boolean updated = true;
    try {
      boolean bool = UserAccountServices.getInstance().saveOrUpdateUserAccount(user, updated);
      Assert.assertTrue(bool);
View Full Code Here

Examples of com.foxconn.gds.security.model.UserAccount

   *
   * @see sample.facade.IUserAccountServices#findUserAccountByID(java.lang.String)
   */
  public UserAccount findUserAccountByID(String userid) {
    log.info("enter findUserAccountByID ...");
    UserAccount result;
    String hql = "from UserAccount where account=:account ";
    try {
      // 取得資料存取管道
      EntityManager em = entityManagerFactory.createEntityManager();
      // 建立物件導向查詢 (hql), 指定並執行查詢條件
View Full Code Here

Examples of com.foxconn.gds.security.model.UserAccount

   * @see sample.facade.IUserAccountServices#findUserAccount(java.lang.String,
   * java.lang.String)
   */
  public UserAccount findUserAccount(String userid, String password) {
    log.info("enter findUserAccount ...");
    UserAccount account = findUserAccountByID(userid);
    if (account != null && account.isValidPassword(password)) {
      return account;
    } else {
      return null;
    }
  }
View Full Code Here

Examples of com.foxconn.gds.security.model.UserAccount

   * @see sample.facade.IUserAccountServices#removeUserAccount(java.lang.String,
   * java.lang.String)
   */
  public boolean removeUserAccount(String userid, String password) throws Exception {
    log.info("enter removeUserAccount ...");
    UserAccount UserAccount = this.findUserAccount(userid, password);
    if (UserAccount != null) {
      log.info("ready to removeUserAccount ...");
      synchronized (UserAccount) {
        this.removeUserAccountById(UserAccount.getId());
      }
      return true;
    } else {
      return false;
    }
View Full Code Here

Examples of com.foxconn.gds.security.model.UserAccount

   * @see com.foxconn.gds.handsketch.facade.IUserAccountServices#findUserAccountByToken(java.lang.String)
   */
  @Override
  public UserAccount findUserAccountByToken(String token) {
    log.info("enter findUserAccounts ...");
    UserAccount result = null;
    String hql = "from UserAccount where token=:token ";
    // 取得資料存取管道
    EntityManager em = entityManagerFactory.createEntityManager();
    try {
      // 建立物件導向查詢 (hql), 指定並執行查詢條件
      result = (UserAccount) em.createQuery(hql).setParameter("token",
          token).getSingleResult();
      if (result!=null) {
        result.getProfile();
      }
    } catch (NoResultException err) {
      err.printStackTrace();
    } finally {
      // 回收資料存取管道
View Full Code Here

Examples of com.foxconn.gds.security.model.UserAccount

    }
    return result;
  }
 
  public boolean addUserToGroup(String account, String groupName) throws Exception{
    UserAccount userAccount = this.findUserAccountByID(account);
    Collection<UserGroup> inGroups = userAccount.getInGroups();
    if( inGroups.toString().contains(groupName) ) {
      log.warning("User has readly been in the Group!");
      return false;
    } else {
      Group group = this.findGroupByName(groupName);
View Full Code Here

Examples of com.foxconn.gds.security.model.UserAccount

    }
  }

  @Override
  public boolean deleteMark(String account, boolean deletedthrows Exception {
    UserAccount user = this.findUserAccountByID(account);
    if(user!=null) {
      EntityManager em = null;
      EntityTransaction tx = null;
      try {
        em = entityManagerFactory.createEntityManager();
        tx = em.getTransaction();
        tx.begin();
        user.setDeleteMark(deleted);
        em.merge(user);
        tx.commit();
      } catch (Exception err) {
        if(tx!=null) tx.rollback();
        log.severe( err.getMessage() );
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.