Package org.palo.viewapi.services

Examples of org.palo.viewapi.services.AdministrationService


        .getAdministrationService(getLoggedInUser(sessionId));
    return adminService.getRole(xRole.getId());
  }

  private final User getNative(String sessionId, XUser xUser) throws SessionExpiredException {
    AdministrationService adminService = ServiceProvider
        .getAdministrationService(getLoggedInUser(sessionId));
    return adminService.getUser(xUser.getId());
  }
View Full Code Here


   * @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)
View Full Code Here

 
  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);
View Full Code Here

        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());
View Full Code Here

  }
 
  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) {
          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);
View Full Code Here

    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
      account = getAccount(accountId, user);
    return account;
  }
View Full Code Here

    return null;
  }
  private final synchronized Connection getConnectionForAccount(String accountId, AuthUser user, String sessionId) {
    Account account = null;
    if (isAdmin(user)) {
      AdministrationService adminService = ServiceProvider
          .getAdministrationService(user);
      account = adminService.getAccount(accountId);
    } else
      account = getAccount(accountId, user);
    if (account instanceof PaloAccount) {
//      ((PaloAccount) account).login();
      ServerConnectionPool pool =
View Full Code Here

  /** 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) {
      for (Account account : adminService.getAccounts(forUser)) {
        XAccount xAccount = (XAccount) XConverter.createX(account);
        xAccounts.add(xAccount);
      }
    }
    return xAccounts.toArray(new XAccount[0]);
View Full Code Here

    return xAccounts.toArray(new XAccount[0]);
  }

  private final User getNativeUser(String sessionId, XUser xUser) throws SessionExpiredException {
    AuthUser loggedInUser = getLoggedInUser(sessionId);
    AdministrationService adminService = ServiceProvider
        .getAdministrationService(loggedInUser);
    return adminService.getUser(xUser.getId());
  }
View Full Code Here

        .getAdministrationService(loggedInUser);
    return adminService.getUser(xUser.getId());
  }
 
  public XConnection[] getConnections(String sessionId, XUser user) throws SessionExpiredException {
    AdministrationService adminService = ServiceProvider
        .getAdministrationService(getLoggedInUser(sessionId));
    List<XConnection> xConnections = new ArrayList<XConnection>();
    for(PaloConnection connection : adminService.getConnections()) {
      XConnection xConnection = (XConnection)XConverter.createX(connection);
      xConnections.add(xConnection);
    }
    return xConnections.toArray(new XConnection[0]);
    // TODO throw exception or return empty array !?!?!?
View Full Code Here

TOP

Related Classes of org.palo.viewapi.services.AdministrationService

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.