Package org.palo.viewapi

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


   
    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

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

    }
    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

  private final Account findReplaceAccount(String sessionId, User user, Account acc) throws SessionExpiredException {
    if (acc != null) {
      if (acc.getUser() != null) {
        if (acc.getUser().getId().equals(user.getId())) {
          // This account needs to be changed.
          AuthUser admin = getLoggedInUser(sessionId);
          AdministrationService admService = ServiceProvider.getAdministrationService(admin);         
          User admUser = admService.getUser(admin.getId());         
          if (!admUser.getId().equals(user.getId())) {
            for (Account a: admService.getAccounts(admUser)) {
              if (a.getConnection().getId().equals(acc.getConnection().getId())) {
                return a;
              }
View Full Code Here

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

    return null;
  }

  public synchronized XCube[] getCubes(String sessionId, XConnection xCon, XDatabase xDb)
      throws SessionExpiredException {
    AuthUser loggedInUser = getLoggedInUser(sessionId);   
    try {
      List <Account> accounts = MapperRegistry.getInstance().getAccountManagement().getAccounts(loggedInUser);
      if (accounts != null && !accounts.isEmpty()) {
        for (Account acc: accounts) {
          if (acc.getConnection().getId().equals(xCon.getId())) {
View Full Code Here

    return null;
  }

  public synchronized XDatabase[] getDatabases(String sessionId, XConnection xCon)
      throws SessionExpiredException, DbOperationFailedException {
    AuthUser loggedInUser = getLoggedInUser(sessionId);   
    try {
      List <Account> accounts = MapperRegistry.getInstance().getAccountManagement().getAccounts(loggedInUser);
      if (accounts != null && !accounts.isEmpty()) {
        for (Account acc: accounts) {
          if (acc.getConnection().getId().equals(xCon.getId())) {
View Full Code Here

  }

  public XObject[] loadChildren(XObject parent, UserSession userSession) {
    XObject xObj = ((XObjectWrapper)parent).getXObject();
    String sessionId = userSession.getSessionId();
    AuthUser loggedInUser = userSession.getUser();
    if (xObj instanceof XAccount)
      return load((XAccount) xObj, loggedInUser, sessionId);
    else if (xObj instanceof XDatabase)
      return load((XDatabase) xObj, loggedInUser, sessionId);
    else if (xObj instanceof XCube)
View Full Code Here

    View view = CubeViewController.getViewById(sessionId, viewId);   
    return checkPermission(userSession.getUser(), view, right);
  }
   
  public boolean checkPermission(String sessionId, int right) throws SessionExpiredException {
    AuthUser user = getLoggedInUser(sessionId);
    Right rr = null;
   
    switch (right) {
      case  0: rr = Right.NONE; break;
      case  1: rr = Right.READ; break;
      case  2: rr = Right.WRITE; break;
      case  4: rr = Right.DELETE; break;
      case  8: rr = Right.CREATE; break;
      case 16: rr = Right.GRANT; break;
    }
   
    if (rr != null) {
      for (Role r : user.getRoles()) {
        if (r.hasPermission(rr)) {
          return true;
        }
      }
      for (Group g: user.getGroups()) {
        for (Role r: g.getRoles()) {
          if (r.hasPermission(rr)) {
            return true;
          }         
        }
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.