Package org.palo.viewapi

Examples of org.palo.viewapi.Account


          data.addError(UserSession.trans(locale, "couldNotFindView", view));             
          continue;
        }
       
        String connectionId = v.getAccount().getConnection().getId();
        Account neededAccount = null;
        for (Account a: authUser.getAccounts()) {
          if (a.getConnection().getId().equals(connectionId)) {
            PaloConnection paloCon = a.getConnection();
            if (paloCon.getType() == PaloConnection.TYPE_WSS) {
              continue;
View Full Code Here


      /*end*/
     
      if (v != null) {
        String connectionId = v.getAccount().getConnection().getId();
        Account neededAccount = null;
        for (Account a: authUser.getAccounts()) {
          if (a.getConnection().getId().equals(connectionId)) {
            PaloConnection paloCon = a.getConnection();
            if (paloCon.getType() == PaloConnection.TYPE_WSS) {
              continue;
View Full Code Here

        }
        if (con == null) {
          log.warn("No connection found for " + cd.host + ":" + cd.port + ". Ignoring.");
          continue;
        }
        Account acc = null;
        if (cd.type.equalsIgnoreCase("palo")) {
          if (cd.useLoginCredentials) {
            log.debug("Creating account (dynamic) " + userName + ", " + decodedPass + " for user " + user.getLoginName());
            admService.createAccount(userName, decodedPass, authenticatedUser, con);
          } else {
View Full Code Here

    }
    return false;
  }
 
  private final XDirectLinkData findPaloSuiteView(AuthUser authenticatedUser, String viewId, SimpleLogger log, XDirectLinkData data, ArrayList <ConnectionDescriptor> connections, String locale) {
    Account accountToUse = null;
    View viewToUse = null;
    IViewManagement mgmt = MapperRegistry.getInstance().getViewManagement();
    Account bestMatch = null;
    View bestView = null;
    View viewIdFound = null;
   
    log.debug("Listing all existing views:");
    try {
      for (View v: mgmt.listViews()) {
        log.debug("  " + v.getName() + " does it match?");
        if (checkPaloSuiteId(v, viewId, log)) {
          log.debug("   => it has the correct paloSuiteId, so go on... List accounts:");
          viewIdFound = v;
          for (Account acc: authenticatedUser.getAccounts()) {
            String host = acc.getConnection().getHost();
            String service = acc.getConnection().getService();
            String user = acc.getLoginName();
            boolean found = false;
            for (ConnectionDescriptor desc: connections) {
              if (desc.host.equals(host) &&
                desc.port.equals(service)) {
                found = true;
                break;
              }
            }
            if (!found) {
              // User has no rights for this connection (anymore).
              continue;
            }
            PaloConnection c = v.getAccount().getConnection();
            log.debug("       account: " + acc.getLoginName() + ", " + acc.getPassword() + " [" + host + ", " + service + ", " + user + "]");
            log.debug("       looking for: " + c.getHost() + ", " + c.getService() + ", " + v.getAccount().getUser().getLoginName());
            if (c.getHost().equals(host) && c.getService().equals(service)) {
              if (v.getAccount().getUser().getLoginName().equals(user)) {
                log.debug("             => HIT! All's well.");
                accountToUse = acc;
                viewToUse = v;
                break;
              }
              log.debug("            => Close match. All's well.");
              bestMatch = acc;
              bestView = v;
            }
          }
        }
        if (viewToUse != null && accountToUse != null) {
          break;
        }
      }
    } catch (SQLException e) {       
    }
    data.setUserPassword(authenticatedUser.getPassword());
    data.setPaloSuiteViewId(viewId);
   
    if (accountToUse == null && bestMatch == null) {
      log.debug("No account or no view found. Either the view does not exist, or something's rotten in the state of Denmark.");
    }
   
    if (accountToUse == null && bestMatch != null) {
      log.debug("No exact account match found, but something close enough: " + bestMatch.getLoginName() + ", " + bestMatch.getConnection().getHost() + ", " + bestMatch.getConnection().getService());
      accountToUse = bestMatch;
      viewToUse = bestView;
    }
    if (accountToUse != null) {
      AccountConverter co = new AccountConverter();
View Full Code Here

      }
      if (conToUse == null) {
        conToUse = admService.createConnection("PaloCon", psd.host, psd.port, PaloConnection.TYPE_HTTP);
        admService.save(conToUse);
      }
      Account accountToUse = null;
      AuthUser authenticatedUser = null;
      try {
        if (viewApiUser.getLoginName().equals("admin")) {
          authenticatedUser = ServiceProvider.getAuthenticationService().authenticateAdmin();
        } else {
          authenticatedUser = ServiceProvider.getAuthenticationService().authenticate(viewApiUser.getLoginName(), pass);
        }
        if (!viewApiUser.getLoginName().equals("admin")) {
          admService.setPassword(pass, viewApiUser);
          admService.save(viewApiUser);
        }
      } catch (AuthenticationFailedException e) {
        if (!viewApiUser.getLoginName().equals("admin")) {
          admService.setPassword(pass, viewApiUser);         
          admService.save(viewApiUser);
        }
        authenticatedUser = ServiceProvider.getAuthenticationService().authenticate(viewApiUser.getLoginName(), pass);
      }
     
      if (authenticatedUser != null) {
        for (Account acc: authenticatedUser.getAccounts()) {
          if (acc.getConnection().getId().equals(conToUse.getId())) {
            accountToUse = acc;
          }
        }
        if (accountToUse == null) {
          accountToUse = admService.createAccount(user, pass, viewApiUser, conToUse);
          admService.save(accountToUse);
        }
      }
      if (accountToUse != null && authenticatedUser != null) {
        AccountConverter co = new AccountConverter();
        XAccount xAccount = (XAccount) co.toXObject(accountToUse);
        data.setXAccount(xAccount);
        data.setUserPassword(accountToUse.getUser().getPassword());
        log.debug("AccountToUse:");
        log.debug("  Name: " + xAccount.getLogin());
        log.debug("  Pass: " + data.getUserPassword());
        data.setAuthenticated(true);
        data.setPaloSuiteViewId(viewId);
View Full Code Here

 
  public WPaloCubeViewConverter(AuthUser user) {
    this.user = user;
  }
  private final Account getAccount(String accountId) {
    Account account = null;
    if (isAdmin(user)) {
      AdministrationService adminService = ServiceProvider
          .getAdministrationService(user);
      account = adminService.getAccount(accountId);
    } else
View Full Code Here

    AdministrationService adminService =
      ServiceProvider.getAdministrationService(user);
    Account account = adminService.getAccountById(accountId);
    return ((PaloAccount) account).login();
    */
    Account account = getAccount(accountId);
    if (account instanceof PaloAccount) {
      Connection con = null;
      ServerConnectionPool pool = ConnectionPoolManager.getInstance().
        getPool(account, sessionId);
      con = pool.getConnection("WPaloCubeViewConverter.getConnection")
View Full Code Here

        List <String> accountErrors = new ArrayList<String>();
        IAccountManagement accountManagement = MapperRegistry.getInstance().getAccountManagement();
        for (Account a: accountManagement.getAccounts(user.getId())) {
          allViews = viewManagement.findViews(a);
          for (View v: allViews) {
            Account acc = v.getAccount();
            Account replaceAccount = findReplaceAccount(sessionId, user, acc);
            if (replaceAccount == null) {
              accountErrors.add(v.getName());
            }                       
          }
        }
       
        if (!accountErrors.isEmpty()) {
          accountErrors.add(0, "_NO_ACCOUNT_ERROR_");
          return accountErrors.toArray(new String[0]);
        }
        return viewNames.toArray(new String[0]);
       
      } catch (SQLException e) {
        e.printStackTrace();
      }   
    } else if (type.equals(XAccount.TYPE)) {
      List <String> accountErrors = new ArrayList<String>();
      Account a = getNative(sessionId, (XAccount) xObj);     
      IViewManagement viewManagement = MapperRegistry.getInstance().getViewManagement();       
      try {
        List <View> allViews = viewManagement.findViews(a);
        for (View v: allViews) {
          Account acc = v.getAccount();
          Account replaceAccount = findReplaceAccount(sessionId, a.getUser(), acc);
          if (replaceAccount == null) {
            accountErrors.add(v.getName());
          }                       
        }
      } catch (SQLException e) {
View Full Code Here

 
  public void delete(String sessionId, XObject xObj) throws DbOperationFailedException, SessionExpiredException {
    try {
      String type = xObj.getType();
      if (type.equals(XAccount.TYPE)) {
        Account a = getNative(sessionId, (XAccount) xObj);
        IViewManagement viewManagement = MapperRegistry.getInstance().getViewManagement();       
        try {
          List <View> allViews = viewManagement.findViews(a);
          ViewService viewService = ServiceProvider.getViewService(getLoggedInUser(sessionId));
          try {
            CubeViewReader.CHECK_RIGHTS = false;
            for (View v: allViews) {
              Account acc = v.getAccount();
              Account replaceAccount = findReplaceAccount(sessionId, a.getUser(), acc);
              if (replaceAccount != null && !v.getAccount().getId().equals(replaceAccount.getId())) {
                ((ViewImpl) v).setAccount(replaceAccount);
                viewService.save(v);
              }
            }
          } finally {
            CubeViewReader.CHECK_RIGHTS = true;
          }
        } catch (SQLException e) {
          e.printStackTrace();
        }
        delete(sessionId, getNative(sessionId, (XAccount) xObj));
      }
      else if (type.equals(XConnection.TYPE))
        delete(sessionId, getNative(sessionId, (XConnection) xObj));
      else if (type.equals(XGroup.TYPE))
        delete(sessionId, getNative(sessionId, (XGroup) xObj));
      else if (type.equals(XRole.TYPE))
        delete(sessionId, getNative(sessionId, (XRole) xObj));
      else if (type.equals(XUser.TYPE)) {
        User user = getNative(sessionId, (XUser) xObj);
        IViewManagement viewManagement = MapperRegistry.getInstance().getViewManagement();
        try {
          try {
            IFolderManagement folders = MapperRegistry.getInstance().
              getFolderManagement();         
            AuthUser aUser = ServiceProvider.getAuthenticationService().authenticateHash(user.getLoginName(),
                user.getPassword());
            List <ExplorerTreeNode> nodes = folders.reallyGetFolders(aUser);
            for (ExplorerTreeNode nd: nodes) {
              folders.delete(nd);
            }
          } catch (SQLException e) {
            e.printStackTrace();
          } catch (AuthenticationFailedException e) {
            e.printStackTrace();
          }       
          List <View> allViews = viewManagement.findViews(user);
          ViewService viewService = ServiceProvider.getViewService(getLoggedInUser(sessionId));
          // At this point, the user has agreed to map all his views to admin...
          if (!viewManagement.findViews(user).isEmpty()) {           
            User adminUser = getLoggedInUser(sessionId);
            try {
              CubeViewReader.CHECK_RIGHTS = false;
              for (View v: allViews) {                           
                viewService.setOwner(adminUser, v);
                viewService.save(v);
              }
            } finally {
              CubeViewReader.CHECK_RIGHTS = true;
            }
          }
          IAccountManagement accountManagement = MapperRegistry.getInstance().getAccountManagement();
          for (Account a: accountManagement.getAccounts(user.getId())) {
            allViews = viewManagement.findViews(a);
            try {                 
              CubeViewReader.CHECK_RIGHTS = false;
              for (View v: allViews) {
                Account acc = v.getAccount();
                Account replaceAccount = findReplaceAccount(sessionId, user, acc);
                if (replaceAccount != null && !v.getAccount().getId().equals(replaceAccount.getId())) {
                  ((ViewImpl) v).setAccount(replaceAccount);
                  viewService.save(v);
                }                       
              }
            } finally {
View Full Code Here

      v = (View) MapperRegistry.getInstance().getViewManagement().find(viewId);
    } catch (SQLException e1) {
    }
    if (v != null) {     
      try {
        Account acc = v.getAccount();
        if (acc != null) {
          String conId = acc.getConnection().getId();
          List <Account> allAccounts = MapperRegistry.getInstance().getAccountManagement().getAccountsBy(conId);
          for (Account a: allAccounts) {
            users.add(a.getUser());
          }
        }
View Full Code Here

TOP

Related Classes of org.palo.viewapi.Account

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.