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;
}
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);
}
}
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);
}
}
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));
}
}
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));
}
}
Aggregations