Package org.palo.viewapi

Examples of org.palo.viewapi.AuthUser


 
  public XView setVisibility(String sessionId, XFolderElement element,
      boolean visible, boolean editable, String ownerId,
      String accountId, String dbId, String cubeId) throws SessionExpiredException {
    XView xView = (XView) element.getSourceObject();   
    AuthUser user = getLoggedInUser(sessionId);   
    ViewService vService = ServiceProvider.getViewService(user);
    View view = vService.getView(xView.getId());   
   
    if (!accountId.equals(xView.getAccountId())) {
      try {
View Full Code Here


    return xView;
  }

  public Boolean isOwner(String sessionId, String viewId)
      throws SessionExpiredException {
    AuthUser user = getLoggedInUser(sessionId);   
    View view = ServiceProvider.getViewService(user).getView(viewId);   
    if (user.getId().equals(view.getOwner().getId())) {
      if (checkPermission(sessionId, 2)) {
        return true;
      }
    }
    return false;
View Full Code Here

  public final XUser loginHash(String login, String password, String locale)
      throws AuthenticationFailedException {
    // try to authenticate:
    try {

      AuthUser usr = ServiceProvider.getAuthenticationService()
          .authenticateHash(login, password);

      registerListeners();
      UserSession userSession = setLoggedInUser(usr);
      configureNumberFormat(userSession.getSessionId(), usr);
View Full Code Here

      UserSession userSession = getUserSession(sessionId);
      try {
        CubeViewController.removeAllViewsAndShutdownConnectionPool(userSession);
      } catch (Throwable t) {
      }
      AuthUser user = getLoggedInUser(sessionId);     
      logout(user);
      terminateSession();
      try {
        CubeViewController.removeAllViewsAndShutdownConnectionPool(userSession);
      } catch (Throwable t) {
View Full Code Here

  public XObject[] loadChildren(XObject parent, UserSession userSession) {
//    XNode node = (XNode) parent;
    String type = parent.getType();
   
    AuthUser admin = userSession.getUser();
    if(admin == null)
      return new XObject[0];
       
    AdministrationService adminService =
      ServiceProvider.getAdministrationService(admin);
View Full Code Here

 
  /** loads all accounts assigned to the currently logged in user
   * @throws SessionExpiredException */
  public XAccount[] loadAccounts(String sessionId) throws SessionExpiredException {
    List<Account> accounts = null;
    AuthUser user = getLoggedInUser(sessionId);
    if (isAdmin(user)) {
      AdministrationService adminService = ServiceProvider
          .getAdministrationService(user);
      accounts = adminService.getAccounts(user);
    } else
      accounts = user.getAccounts();
    XAccount[] xAccounts = new XAccount[accounts.size()];
    int index = 0;
    for(Account account : accounts)
      xAccounts[index++] = (XAccount) XConverter.createX(account);
    return xAccounts;
View Full Code Here

  }
 
  public XDirectLinkData openViewAfterLogin(String locale, String sessionId, String link) {
    myInitDbConnection(getServletContext(), true);
    XDirectLinkData data = new XDirectLinkData();
    AuthUser user = null;
    try {
      user = getLoggedInUser(sessionId);
    } catch (SessionExpiredException e) {
    }
    if (user == null) {
View Full Code Here

    return readConnections(user, decPass, psd, viewId, data, new SimpleLogger(1));    
  }
 
  public XAccount[] loadPaloSuiteAccounts(String sessionId, String link) throws SessionExpiredException {
    List<Account> acc = null;
    AuthUser user = getLoggedInUser(sessionId);
    if (isAdmin(user)) {
      AdministrationService adminService = ServiceProvider
          .getAdministrationService(user);
      acc = adminService.getAccounts(user);
    } else {
      acc = user.getAccounts();
    }
    List <Account> accounts = new ArrayList<Account>();
    List <ConnectionDescriptor> descriptors = getConnectionDescriptors(link);
    for (Account a: acc) {
      for (ConnectionDescriptor c: descriptors) {
View Full Code Here

      }
    }
  }
 
  private final AuthUser attachAccounts(String userName, String decodedPass, AdministrationService admService, AuthUser admin, User user, String pass, ArrayList <ConnectionDescriptor> connections, SimpleLogger log) throws SQLException, OperationFailedException, AuthenticationFailedException {
    AuthUser authenticatedUser = null;
    try {
      if (user.getLoginName().equals("admin")) {
        authenticatedUser = ServiceProvider.getAuthenticationService().authenticateAdmin();
      } else {
        authenticatedUser = ServiceProvider.getAuthenticationService().authenticate(user.getLoginName(), pass);
      }
      if (!user.getLoginName().equals("admin")) {
        admService.setPassword(AuthUserImpl.encrypt(pass), user);
        admService.save(user);
      }
    } catch (AuthenticationFailedException e) {
      if (!user.getLoginName().equals("admin")) {
        admService.setPassword(AuthUserImpl.encrypt(pass), user);         
        admService.save(user);
      }
      authenticatedUser = ServiceProvider.getAuthenticationService().authenticate(user.getLoginName(), pass);
    }
   
    if (authenticatedUser == null) {
      log.error("Authentication of PaloPivot user failed! Aborting.", new NullPointerException());
      return authenticatedUser;
    }
    for (ConnectionDescriptor cd: connections) {
      boolean found = false;   
      for (Account acc: authenticatedUser.getAccounts()) {
        if (acc.getConnection().getHost() != null && acc.getConnection().getHost().equals(cd.host) &&
          acc.getConnection().getService() != null && acc.getConnection().getService().equals(cd.port)) {
//          if (acc.getConnection() != null && acc.getConnection().getName().equals(cd.name)) {
//            found = true;
//            break;
//          }
          if (/*cd.type.equalsIgnoreCase("dynamic") ||*/
            cd.useLoginCredentials) {
            admService.setLoginName(userName, acc);
            admService.setPassword(decodedPass, acc);
            admService.save(acc);           
          }
          log.debug("Account already exists: " + acc.getConnection().getHost() + ", " + acc.getConnection().getService());
          found = true;
          break;
        }
      }
      if (!found) {
        PaloConnection con = null;
        for (PaloConnection conn: admService.getConnections()) {       
          if (cd.host.equals(conn.getHost()) &&
            cd.port.equals(conn.getService())) {
            con = conn;
            break;       
          }
        }
        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 {
            log.debug("Creating account (palo) " + cd.user + ", " + cd.pass + " for user " + user.getLoginName());
            admService.createAccount(cd.user, cd.pass, authenticatedUser, con);           
          }
        }
//        else if (cd.type.equalsIgnoreCase("dynamic")) {
//          log.debug("Creating account (dynamic) " + userName + ", " + decodedPass + " for user " + user.getLoginName());
//          admService.createAccount(userName, decodedPass, authenticatedUser, con);
//        }       
        admService.save(acc);
        admService.save(user);
      }     
    }
    log.debug("  ==> After account creation, the authenticated user has the following accounts:");
    for (Account a: authenticatedUser.getAccounts()) {
      log.debug("       => " + a.getLoginName() + ", " + a.getConnection().getHost() + ", " + a.getConnection().getService());
    }
    return authenticatedUser;
  }
View Full Code Here

        connections.add(cd);
        log.debug("Adding connection descriptor: " + type + ", " + name + ", " + host + ", " + port + ", " + user + ", " + pass + ", " + active + ", " + useLogin);
      }
      // Create account for every connection...
      try {
        AuthUser admin = ServiceProvider.getAuthenticationService().authenticateAdmin();
        AdministrationService admService = ServiceProvider.getAdministrationService(admin);

        // Step 1: GetUser:
        User viewApiUser = getUser(admService, admin, paloSuiteUser, paloSuitePass);
        if (viewApiUser == null) {
          log.error("Null view API User", new NullPointerException());
          return null;
        }
        log.debug("ViewAPIUSer = " + viewApiUser.getLoginName());
       
        // Step 2: Make sure all connections exist, add new ones:
        attachConnections(admService, admin, connections, paloSuiteHost, paloSuitePort, log);
       
        // Step 3: Make sure all accounts exist, add new ones:
        AuthUser authUser = attachAccounts(paloSuiteUser, paloSuitePass, admService, admin, viewApiUser, paloSuitePass, connections, log);
       
        // Step 4: Now find the view with the Id x and open it...
        if (authUser != null) {
          log.debug("AuthUser != null; " + authUser.getLoginName() + " => finding Views.");
          return findPaloSuiteView(authUser, viewId, log, data, connections, locale);
        } else {
          log.warn("==> authUser == null, so no view could be found?!");
        }
      } catch (Exception e) {
View Full Code Here

TOP

Related Classes of org.palo.viewapi.AuthUser

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.