Examples of AuthUser


Examples of org.palo.viewapi.AuthUser

      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

Examples of org.palo.viewapi.AuthUser

  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

Examples of org.palo.viewapi.AuthUser

 
  /** 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

Examples of org.palo.viewapi.AuthUser

  }
 
  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

Examples of org.palo.viewapi.AuthUser

    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

Examples of org.palo.viewapi.AuthUser

      }
    }
  }
 
  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

Examples of org.palo.viewapi.AuthUser

        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

Examples of org.palo.viewapi.AuthUser

    return null;
  }
 
  private final XDirectLinkData legacyAuthentication(Connection con, String user, String pass, PaloSuiteData psd, String viewId, XDirectLinkData data, SimpleLogger log) throws OperationFailedException, SQLException, AuthenticationFailedException {
    if (con.getDatabaseCount() > 0) {
      AuthUser admin = ServiceProvider.getAuthenticationService().authenticateAdmin();
      AdministrationService admService = ServiceProvider.getAdministrationService(admin);
      User viewApiUser = null;
      for (User usr: admService.getUsers()) {
        if (user.equals(usr.getLoginName())) {
          viewApiUser = usr;
          break;
        }     
      }
      if (viewApiUser == null) {
        if (user.equals("admin")) {
          viewApiUser = admin;
        } else {
          viewApiUser = admService.createUser("", "", user, pass);
          admService.save(viewApiUser);
        }         
        Role viewerRole = admService.getRoleByName("VIEWER");
        Role editorRole = admService.getRoleByName("EDITOR");
        IUserRoleManagement urAssoc = MapperRegistry.getInstance().getUserRoleAssociation();       
        urAssoc.insert(viewApiUser, viewerRole);
        urAssoc.insert(viewApiUser, editorRole);
        admService.add(viewerRole, viewApiUser);
        admService.add(editorRole, viewApiUser);
        admService.save(viewApiUser);
      }
      PaloConnection conToUse = null;
      for (PaloConnection conn: admService.getConnections()) {
        if (psd.host.equals(conn.getHost()) &&
          psd.port.equals(conn.getService())) {
          conToUse = conn;
          break;
        }
      }
      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) {
View Full Code Here

Examples of org.palo.viewapi.AuthUser

   
    int index = link.indexOf("pass=\"");
    int index2 = link.indexOf("\"", index + 6);
    String modifiedLink = link.substring(0, index) + link.substring(index2 + 1);
   
    AuthUser authUser = null;
    try {
      authUser = ServiceProvider.getAuthenticationService().authenticateHash(user, pass);
    } catch (AuthenticationFailedException e) {
      logger.error(e.getMessage());
    }
View Full Code Here

Examples of org.palo.viewapi.AuthUser

  /** generated default serial number */
  private static final long serialVersionUID = -6035121917190713696L;
 
  public XAccount[] getAccounts(String sessionId, XUser xUser) throws SessionExpiredException {
    AuthUser loggedInUser = getLoggedInUser(sessionId);
    AdministrationService adminService = ServiceProvider
        .getAdministrationService(loggedInUser);
    List<XAccount> xAccounts = new ArrayList<XAccount>();
    User forUser = getNativeUser(sessionId, xUser);
    if (forUser != null) {
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.