Search in sources :

Example 11 with DbUserInfo

use of com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo in project cubrid-manager by CUBRID.

the class LoginDatabaseTaskExecutor method exec.

/**
	 * Execute to login database
	 * 
	 * @param monitor the IProgressMonitor
	 * @return <code>true</code> if successful;<code>false</code>otherwise;
	 */
public boolean exec(final IProgressMonitor monitor) {
    if (monitor.isCanceled()) {
        return false;
    }
    String taskName = Messages.bind(Messages.loginDbTaskName, dbName);
    monitor.beginTask(taskName, IProgressMonitor.UNKNOWN);
    DbUserInfo dbUserInfo = null;
    DatabaseInfo dbInfo = serverInfo.getLoginedUserInfo().getDatabaseInfo(dbName);
    DbUserInfo preDbUserInfo = dbInfo.getAuthLoginedDbUserInfo();
    boolean isOldLogined = dbInfo.isLogined();
    for (ITask task : taskList) {
        if (task instanceof UpdateCMUserTask) {
            UpdateCMUserTask updateCMUserTask = (UpdateCMUserTask) task;
            ServerInfo serverInfo = dbInfo.getServerInfo();
            if (serverInfo != null && serverInfo.isConnected()) {
                ServerUserInfo userInfo = serverInfo.getLoginedUserInfo();
                updateCMUserTask.setCasAuth(userInfo.getCasAuth().getText());
                updateCMUserTask.setDbCreator(userInfo.getDbCreateAuthType().getText());
                updateCMUserTask.setStatusMonitorAuth(userInfo.getStatusMonitorAuth().getText());
                List<String> dbNameList = new ArrayList<String>();
                List<String> dbUserList = new ArrayList<String>();
                List<String> dbPasswordList = new ArrayList<String>();
                List<String> dbBrokerPortList = new ArrayList<String>();
                List<DatabaseInfo> authDatabaseList = userInfo.getDatabaseInfoList();
                for (int i = 0; authDatabaseList != null && i < authDatabaseList.size(); i++) {
                    DatabaseInfo databaseInfo = authDatabaseList.get(i);
                    dbNameList.add(databaseInfo.getDbName());
                    dbUserList.add(databaseInfo.getAuthLoginedDbUserInfo().getName());
                    dbBrokerPortList.add(QueryOptions.getBrokerIp(databaseInfo) + "," + databaseInfo.getBrokerPort());
                    String password = databaseInfo.getAuthLoginedDbUserInfo().getNoEncryptPassword();
                    dbPasswordList.add(password == null ? "" : password);
                }
                String[] dbNameArr = new String[dbNameList.size()];
                String[] dbUserArr = new String[dbUserList.size()];
                String[] dbPasswordArr = new String[dbPasswordList.size()];
                String[] dbBrokerPortArr = new String[dbBrokerPortList.size()];
                updateCMUserTask.setDbAuth(dbNameList.toArray(dbNameArr), dbUserList.toArray(dbUserArr), dbPasswordList.toArray(dbPasswordArr), dbBrokerPortList.toArray(dbBrokerPortArr));
            }
        }
        task.execute();
        final String msg = task.getErrorMsg();
        if (showErrMsg) {
            if (openErrorBox(shell, msg, monitor)) {
                dbInfo.setLogined(isOldLogined);
                dbInfo.setAuthLoginedDbUserInfo(preDbUserInfo);
                //					LOGGER.error("loggin failed task : " + infoMessage);
                return false;
            }
        } else if (!monitor.isCanceled()) {
            setErrMsg(msg);
            dbInfo.setLogined(isOldLogined);
            dbInfo.setAuthLoginedDbUserInfo(preDbUserInfo);
            return false;
        }
        if (monitor.isCanceled()) {
            return false;
        }
        if (task instanceof LoginDatabaseTask) {
            dbUserInfo = ((LoginDatabaseTask) task).getLoginedDbUserInfo();
            dbInfo.setLogined(true);
            dbUserInfo.setNoEncryptPassword(dbPassword);
            dbInfo.setAuthLoginedDbUserInfo(dbUserInfo);
        }
    }
    return true;
}
Also used : ITask(com.cubrid.common.core.task.ITask) LoginDatabaseTask(com.cubrid.cubridmanager.core.cubrid.database.task.LoginDatabaseTask) DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) ArrayList(java.util.ArrayList) DbUserInfo(com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo) UpdateCMUserTask(com.cubrid.cubridmanager.core.common.task.UpdateCMUserTask) ServerUserInfo(com.cubrid.cubridmanager.core.common.model.ServerUserInfo)

Example 12 with DbUserInfo

use of com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo in project cubrid-manager by CUBRID.

the class CQBUserEditor method initial.

/**
	 * Initial the data
	 */
private void initial() {
    if (ownerClassTableViewer == null || ownerClassTableViewer.getControl() == null || ownerClassTableViewer.getControl().isDisposed()) {
        return;
    }
    if (memberList == null) {
        memberList = new ArrayList<String>();
    }
    while (!memberList.isEmpty()) {
        memberList.remove(0);
    }
    for (DbUserInfo bean : userListInfo.getUserList()) {
        if (bean.getName().equalsIgnoreCase(userName)) {
            userInfo = bean;
        }
        List<String> groups = bean.getGroups().getGroup();
        if (groups != null) {
            for (String g : groups) {
                if (userName != null && userName.equalsIgnoreCase(g)) {
                    memberList.add(bean.getName());
                    break;
                }
            }
        }
    }
    List<String> groupList = userInfo.getGroups().getGroup();
    while (!ownerClassListData.isEmpty()) {
        ownerClassListData.remove(0);
    }
    if (allClassInfoList != null) {
        for (ClassInfo c : allClassInfoList) {
            if (!c.getOwnerName().equalsIgnoreCase(userInfo.getName())) {
                continue;
            }
            Map<String, String> map = new HashMap<String, String>();
            map.put("0", c.getClassName());
            map.put("1", c.isSystemClass() ? Messages.msgSystemSchema : Messages.msgUserSchema);
            map.put("2", c.getClassType() == ClassType.VIEW ? Messages.msgVirtualClass : Messages.msgClass);
            ownerClassListData.add(map);
        }
    }
    while (!authListData.isEmpty()) {
        authListData.remove(0);
    }
    Map<String, ClassAuthorizations> classGrantMap = userInfo.getUserAuthorizations();
    Iterator<String> authIter = classGrantMap.keySet().iterator();
    while (authIter.hasNext()) {
        String className = authIter.next();
        if (!partitionClassMap.containsKey(className)) {
            authListData.add(getItemAuthMap(classGrantMap.get(className)));
        }
    }
    ownerClassTableViewer.refresh();
    if (!DB_DBA_USERNAME.equalsIgnoreCase(userName)) {
        authTableViewer.refresh();
    }
    for (int i = 0; i < ownerClassTableViewer.getTable().getColumnCount(); i++) {
        ownerClassTableViewer.getTable().getColumn(i).pack();
    }
    if (!DB_DBA_USERNAME.equalsIgnoreCase(userName)) {
        for (int i = 0; i < authTableViewer.getTable().getColumnCount(); i++) {
            authTableViewer.getTable().getColumn(i).pack();
        }
    }
    StringBuffer sb = new StringBuffer();
    if (groupList != null) {
        for (int i = 0, n = groupList.size(); i < n; i++) {
            if (i > 0) {
                sb.append(", ");
            }
            sb.append(groupList.get(i));
        }
    }
    lblUserGroup.setText(Messages.bind(Messages.lblGroupList, sb.length() < 1 ? Messages.lblGroupNotExist : sb.toString()));
    sb = new StringBuffer();
    if (memberList != null) {
        for (int i = 0, n = memberList.size(); i < n; i++) {
            if (i > 0) {
                sb.append(", ");
            }
            sb.append(memberList.get(i));
        }
    }
    lblUserMember.setText(Messages.bind(Messages.lblMemberList, sb.length() < 1 ? Messages.lblMemberNotExist : sb.toString()));
    if (checkIsDba()) {
        authTableViewer.getTable().setVisible(false);
        GridData tableGd = (GridData) authTableViewer.getTable().getLayoutData();
        tableGd.exclude = true;
        CLabel clbl = new CLabel(authComp, SWT.NONE);
        clbl.setBackground(topComp.getBackground());
        clbl.setText(Messages.lblDbaAllAuth);
    }
}
Also used : CLabel(org.eclipse.swt.custom.CLabel) ClassAuthorizations(com.cubrid.cubridmanager.core.cubrid.table.model.ClassAuthorizations) HashMap(java.util.HashMap) DbUserInfo(com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo) GridData(org.eclipse.swt.layout.GridData) ClassInfo(com.cubrid.cubridmanager.core.cubrid.table.model.ClassInfo)

Example 13 with DbUserInfo

use of com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo in project cubrid-manager by CUBRID.

the class AddFunctionAction method run.

/**
	 * Open addFunctionDialog
	 */
public void run() {
    // FIXME logic code move to core module
    Shell shell = getShell();
    Object[] obj = this.getSelectedObj();
    if (!isSupported(obj[0])) {
        setEnabled(false);
        return;
    }
    ISchemaNode node = (ISchemaNode) obj[0];
    CubridDatabase database = node.getDatabase();
    EditFunctionDialog dlg = new EditFunctionDialog(shell);
    dlg.setDatabase(database);
    dlg.setNewFlag(true);
    ISelectionProvider provider = getSelectionProvider();
    if (dlg.open() == IDialogConstants.OK_ID && (provider instanceof TreeViewer)) {
        ICubridNode folderNode = database.getChild(database.getId() + ICubridNodeLoader.NODE_SEPARATOR + CubridSPFolderLoader.SP_FOLDER_ID);
        folderNode = folderNode.getChild(folderNode.getId() + ICubridNodeLoader.NODE_SEPARATOR + CubridSPFolderLoader.FUNCTION_FOLDER_ID);
        TreeViewer treeViewer = (TreeViewer) provider;
        if (folderNode == null || !folderNode.getLoader().isLoaded()) {
            return;
        }
        String functionName = dlg.getFunctionName().toLowerCase(Locale.getDefault());
        String id = folderNode.getId() + ICubridNodeLoader.NODE_SEPARATOR + functionName;
        DbUserInfo userInfo = database.getDatabaseInfo().getAuthLoginedDbUserInfo();
        SPInfo spInfo = new SPInfo(functionName);
        spInfo.setOwner(userInfo.getName());
        ICubridNode newNode = CubridFunctionFolderLoader.createFunctionNode(id, spInfo);
        CommonUITool.addNodeToTree(treeViewer, folderNode, newNode);
    }
}
Also used : DbUserInfo(com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo) Shell(org.eclipse.swt.widgets.Shell) ISelectionProvider(org.eclipse.jface.viewers.ISelectionProvider) ISchemaNode(com.cubrid.common.ui.spi.model.ISchemaNode) TreeViewer(org.eclipse.jface.viewers.TreeViewer) SPInfo(com.cubrid.cubridmanager.core.cubrid.sp.model.SPInfo) EditFunctionDialog(com.cubrid.common.ui.cubrid.procedure.dialog.EditFunctionDialog) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase)

Example 14 with DbUserInfo

use of com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo in project cubrid-manager by CUBRID.

the class CubridFunctionFolderLoader method load.

/**
	 * 
	 * Load children object for parent
	 * 
	 * @param parent the parent node
	 * @param monitor the IProgressMonitor object
	 */
public void load(ICubridNode parent, final IProgressMonitor monitor) {
    synchronized (this) {
        if (isLoaded()) {
            return;
        }
        CubridDatabase database = ((ISchemaNode) parent).getDatabase();
        if (!database.isLogined() || database.getRunningType() == DbRunningType.STANDALONE) {
            database.getDatabaseInfo().setSpFunctionInfoList(null);
            parent.removeAllChild();
            CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
            return;
        }
        DatabaseInfo databaseInfo = database.getDatabaseInfo();
        final GetSPInfoListTask task = new GetSPInfoListTask(databaseInfo);
        task.setSpType(SPType.FUNCTION);
        monitorCancel(monitor, new ITask[] { task });
        task.execute();
        final String errorMsg = task.getErrorMsg();
        if (!monitor.isCanceled() && errorMsg != null && errorMsg.trim().length() > 0) {
            parent.removeAllChild();
            openErrorBox(errorMsg);
            setLoaded(true);
            return;
        }
        if (monitor.isCanceled()) {
            setLoaded(true);
            return;
        }
        parent.removeAllChild();
        List<SPInfo> spInfoList = task.getSPInfoList();
        DbUserInfo userInfo = database.getDatabaseInfo().getAuthLoginedDbUserInfo();
        boolean isDBA = false;
        String loginUserName = "";
        if (userInfo != null && userInfo.isDbaAuthority()) {
            isDBA = true;
        }
        if (userInfo != null) {
            loginUserName = userInfo.getName();
        }
        List<SPInfo> authSpInfoList = new ArrayList<SPInfo>();
        if (spInfoList != null && !spInfoList.isEmpty()) {
            for (SPInfo spInfo : spInfoList) {
                if (!isDBA && !loginUserName.equalsIgnoreCase(spInfo.getOwner())) {
                    continue;
                }
                authSpInfoList.add(spInfo);
                String id = parent.getId() + NODE_SEPARATOR + spInfo.getSpName();
                ICubridNode spNode = createFunctionNode(id, spInfo);
                parent.addChild(spNode);
            }
        }
        databaseInfo.setSpFunctionInfoList(authSpInfoList);
        Collections.sort(parent.getChildren());
        setLoaded(true);
        CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
    }
}
Also used : DbUserInfo(com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo) ISchemaNode(com.cubrid.common.ui.spi.model.ISchemaNode) DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) SPInfo(com.cubrid.cubridmanager.core.cubrid.sp.model.SPInfo) ArrayList(java.util.ArrayList) CubridNodeChangedEvent(com.cubrid.common.ui.spi.event.CubridNodeChangedEvent) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase) GetSPInfoListTask(com.cubrid.cubridmanager.core.cubrid.sp.task.GetSPInfoListTask)

Example 15 with DbUserInfo

use of com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo in project cubrid-manager by CUBRID.

the class CubridProcedureFolderLoader method load.

/**
	 * 
	 * Load children object for parent
	 * 
	 * @param parent the parent node
	 * @param monitor the IProgressMonitor object
	 */
public void load(ICubridNode parent, final IProgressMonitor monitor) {
    synchronized (this) {
        if (isLoaded()) {
            return;
        }
        CubridDatabase database = ((ISchemaNode) parent).getDatabase();
        if (!database.isLogined() || database.getRunningType() == DbRunningType.STANDALONE) {
            database.getDatabaseInfo().setSpProcedureInfoList(null);
            parent.removeAllChild();
            CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
            return;
        }
        DatabaseInfo databaseInfo = database.getDatabaseInfo();
        final GetSPInfoListTask task = new GetSPInfoListTask(databaseInfo);
        task.setSpType(SPType.PROCEDURE);
        monitorCancel(monitor, new ITask[] { task });
        task.execute();
        final String errorMsg = task.getErrorMsg();
        if (!monitor.isCanceled() && errorMsg != null && errorMsg.trim().length() > 0) {
            parent.removeAllChild();
            openErrorBox(errorMsg);
            setLoaded(true);
            return;
        }
        if (monitor.isCanceled()) {
            setLoaded(true);
            return;
        }
        parent.removeAllChild();
        List<SPInfo> spInfoList = task.getSPInfoList();
        DbUserInfo userInfo = database.getDatabaseInfo().getAuthLoginedDbUserInfo();
        boolean isDBA = false;
        String loginUserName = "";
        if (userInfo != null && userInfo.isDbaAuthority()) {
            isDBA = true;
        }
        if (userInfo != null) {
            loginUserName = userInfo.getName();
        }
        List<SPInfo> authSpInfoList = new ArrayList<SPInfo>();
        if (spInfoList != null && !spInfoList.isEmpty()) {
            for (SPInfo spInfo : spInfoList) {
                if (!isDBA && !loginUserName.equalsIgnoreCase(spInfo.getOwner())) {
                    continue;
                }
                authSpInfoList.add(spInfo);
                String id = parent.getId() + NODE_SEPARATOR + spInfo.getSpName();
                ICubridNode spNode = createProcedureNode(id, spInfo);
                parent.addChild(spNode);
            }
        }
        databaseInfo.setSpProcedureInfoList(authSpInfoList);
        Collections.sort(parent.getChildren());
        setLoaded(true);
        CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
    }
}
Also used : DbUserInfo(com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo) ISchemaNode(com.cubrid.common.ui.spi.model.ISchemaNode) DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) SPInfo(com.cubrid.cubridmanager.core.cubrid.sp.model.SPInfo) ArrayList(java.util.ArrayList) CubridNodeChangedEvent(com.cubrid.common.ui.spi.event.CubridNodeChangedEvent) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase) GetSPInfoListTask(com.cubrid.cubridmanager.core.cubrid.sp.task.GetSPInfoListTask)

Aggregations

DbUserInfo (com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo)80 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)36 DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)30 ISchemaNode (com.cubrid.common.ui.spi.model.ISchemaNode)22 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)16 ArrayList (java.util.ArrayList)14 CubridServer (com.cubrid.common.ui.spi.model.CubridServer)10 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)10 ServerUserInfo (com.cubrid.cubridmanager.core.common.model.ServerUserInfo)10 CubridNodeChangedEvent (com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)9 DbUserInfoList (com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfoList)8 ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)7 DatabaseEditorConfig (com.cubrid.common.ui.spi.model.DatabaseEditorConfig)6 ICubridNodeLoader (com.cubrid.common.ui.spi.model.ICubridNodeLoader)6 TaskExecutor (com.cubrid.common.ui.spi.progress.TaskExecutor)6 IsDBAUserTask (com.cubrid.cubridmanager.core.cubrid.user.task.IsDBAUserTask)6 CQBDbConnectionLoader (com.cubrid.cubridmanager.ui.spi.model.loader.CQBDbConnectionLoader)6 HashMap (java.util.HashMap)6 CubridNodeLoader (com.cubrid.common.ui.spi.model.CubridNodeLoader)5 UpdateCMUserTask (com.cubrid.cubridmanager.core.common.task.UpdateCMUserTask)5