use of com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo in project cubrid-manager by CUBRID.
the class CubridWorkbenchContrItem method connectDatabase.
/**
* Connect the database
*
* @param dbInfo DatabaseInfo
* @param showErrMsg boolean
* @return boolean
*/
public static boolean connectDatabase(DatabaseInfo dbInfo, boolean showErrMsg) {
if (dbInfo == null || dbInfo.getServerInfo() == null || dbInfo.getAuthLoginedDbUserInfo() == null) {
return false;
}
final String USER_DBA = "dba";
DbUserInfo dbUserInfo = dbInfo.getAuthLoginedDbUserInfo();
String dbUser = dbUserInfo.getName();
String dbPassword = dbUserInfo.getNoEncryptPassword();
if (dbUser == null || dbUser.trim().length() == 0 || dbPassword == null) {
return false;
}
TaskExecutor taskExcutor = new LoginDatabaseTaskExecutor(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), dbInfo.getServerInfo(), dbInfo.getDbName(), dbUser, dbPassword, showErrMsg);
new ExecTaskWithProgress(taskExcutor).busyCursorWhile();
boolean isSuccess = taskExcutor.isSuccess();
if (!isSuccess) {
LOGGER.error("login database failed");
}
/*For [TOOLS-3516]*/
if (dbInfo.getAuthLoginedDbUserInfo() != null && CompatibleUtil.isNeedCheckDbaAuthorityByJDBC(dbInfo)) {
IsDBAUserTask checkTask = new IsDBAUserTask(dbInfo);
checkTask.execute();
if (checkTask.isSuccess()) {
dbInfo.getAuthLoginedDbUserInfo().setDbaAuthority(checkTask.isDBAUser());
} else {
dbInfo.getAuthLoginedDbUserInfo().setDbaAuthority(USER_DBA.equals(dbUser.toLowerCase()));
}
}
/*Modify*/
CMDBNodePersistManager.getInstance().fireModifyDatabase(dbInfo, dbInfo);
return taskExcutor.isSuccess();
}
use of com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo in project cubrid-manager by CUBRID.
the class CubridWorkbenchContrItem method connectDatabaseWithErrMsg.
/**
* Connect the database
*
* @param dbInfo DatabaseInfo
* @param showErrMsg boolean
* @return string error messages
*/
public static String connectDatabaseWithErrMsg(DatabaseInfo dbInfo, boolean showErrMsg) {
if (dbInfo == null || dbInfo.getServerInfo() == null || dbInfo.getAuthLoginedDbUserInfo() == null) {
return "";
}
final String USER_DBA = "dba";
DbUserInfo dbUserInfo = dbInfo.getAuthLoginedDbUserInfo();
String dbUser = dbUserInfo.getName();
String dbPassword = dbUserInfo.getNoEncryptPassword();
if (dbUser == null || dbUser.trim().length() == 0 || dbPassword == null) {
return Messages.errMultiDatabaseLoginNoUsername;
}
LoginDatabaseTaskExecutor taskExcutor = new LoginDatabaseTaskExecutor(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), dbInfo.getServerInfo(), dbInfo.getDbName(), dbUser, dbPassword, showErrMsg);
new ExecTaskWithProgress(taskExcutor).busyCursorWhile();
/*For [TOOLS-3516]*/
if (dbInfo.getAuthLoginedDbUserInfo() != null && CompatibleUtil.isNeedCheckDbaAuthorityByJDBC(dbInfo)) {
IsDBAUserTask checkTask = new IsDBAUserTask(dbInfo);
checkTask.execute();
if (checkTask.isSuccess()) {
dbInfo.getAuthLoginedDbUserInfo().setDbaAuthority(checkTask.isDBAUser());
} else {
dbInfo.getAuthLoginedDbUserInfo().setDbaAuthority(USER_DBA.equals(dbUser.toLowerCase()));
}
}
/*Modify*/
CMDBNodePersistManager.getInstance().fireModifyDatabase(dbInfo, dbInfo);
return taskExcutor.getErrMsg();
}
use of com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo in project cubrid-manager by CUBRID.
the class EditUserDialog method setAuthBtnEnableDisable.
/**
* Set the auth button disable
*
*/
@SuppressWarnings("unchecked")
private void setAuthBtnEnableDisable() {
grantButton.setEnabled(false);
revokeButton.setEnabled(false);
/*Can't grant/revoke for current login user*/
if (StringUtil.isEqual(this.userName, currentUserInfo.getName())) {
return;
}
DbUserInfo currentUserInfo = database.getDatabaseInfo().getAuthLoginedDbUserInfo();
boolean isDbaAuthority = currentUserInfo.isDbaAuthority();
if (classTable.getSelectionCount() > 0 && classTable.isFocusControl()) {
boolean tag = true;
if (!isDbaAuthority) {
for (TableItem item : classTable.getSelection()) {
ClassAuthorizations authorizations = currentUserAuthorizations.get(item.getText());
boolean ownertag = false;
for (ClassInfo bean : allClassInfoList) {
if (item.getText().equals(bean.getClassName())) {
if (currentUserInfo.getName().equalsIgnoreCase(bean.getOwnerName())) {
ownertag = true;
}
break;
}
}
tag = tag && (ownertag || authorizations == null || authorizations.isGrantPriv());
if (!tag) {
break;
}
}
}
grantButton.setEnabled(tag);
} else if (authTable.getSelectionCount() > 0 && authTable.isFocusControl()) {
boolean tag = true;
if (!isDbaAuthority) {
for (TableItem item : authTable.getSelection()) {
ClassAuthorizations authorizations = currentUserAuthorizations.get(item.getText());
boolean ownertag = false;
for (ClassInfo bean : allClassInfoList) {
if (item.getText().equals(bean.getClassName())) {
if (currentUserInfo.getName().equalsIgnoreCase(bean.getOwnerName())) {
ownertag = true;
}
break;
}
}
tag = tag && (ownertag || authorizations == null || (authorizations.isAllPriv() || authorizations.isRevokePriv((Map<String, Object>) item.getData())));
if (!tag) {
break;
}
}
}
revokeButton.setEnabled(tag);
}
}
use of com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo in project cubrid-manager by CUBRID.
the class DBAuthComparator method loadData.
/**
* Load the data
*/
private void loadData() {
final GetUserListTask getUserTask = new GetUserListTask(database.getDatabaseInfo());
final GetAllUserAuthorizationsTask getUserAuthTask = new GetAllUserAuthorizationsTask(database.getDatabaseInfo());
TaskJobExecutor taskExec = new CommonTaskJobExec(new ITaskExecutorInterceptor() {
public void completeAll() {
final List<UserDetailInfo> userDetailList = new ArrayList<UserDetailInfo>();
DbUserInfoList userListInfo = getUserTask.getResultModel();
Map<String, UserDetailInfo> allUserAuthMap = getUserAuthTask.getAllAuthMap();
if (userListInfo != null) {
for (DbUserInfo userInfo : userListInfo.getUserList()) {
UserDetailInfo userDetailInfo = allUserAuthMap.get(userInfo.getName());
if (userDetailInfo == null) {
userDetailInfo = new UserDetailInfo();
userDetailInfo.setUserName(userInfo.getName());
}
userDetailList.add(userDetailInfo);
}
}
setTableData(userDetailList);
}
public IStatus postTaskFinished(ITask task) {
return Status.OK_STATUS;
}
});
taskExec.addTask(getUserTask);
taskExec.addTask(getUserAuthTask);
JobFamily jobFamily = new JobFamily();
String serverName = database.getServer().getName();
String dbName = database.getName();
jobFamily.setServerName(serverName);
jobFamily.setDbName(dbName);
String jobName = Messages.jobLoadUserData + " - " + "@" + dbName + "@" + serverName;
taskExec.schedule(jobName, jobFamily, false, Job.SHORT);
}
use of com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo in project cubrid-manager by CUBRID.
the class DeleteUserAction method isSupported.
/**
*
* @see com.cubrid.common.ui.spi.action.ISelectionAction#isSupported(java
* .lang.Object)
* @param obj the Object
* @return <code>true</code> if support this obj;<code>false</code>
* otherwise
*/
public boolean isSupported(Object obj) {
if (!(obj instanceof ISchemaNode)) {
return false;
}
ISchemaNode node = (ISchemaNode) obj;
CubridDatabase database = node.getDatabase();
if (database != null && database.getRunningType() == DbRunningType.CS && database.isLogined()) {
DbUserInfo dbUserInfo = database.getDatabaseInfo().getAuthLoginedDbUserInfo();
if (dbUserInfo == null) {
return false;
}
if (EditUserDialog.DB_DEFAULT_USERNAME.equalsIgnoreCase(node.getName()) || EditUserDialog.DB_DBA_USERNAME.equalsIgnoreCase(node.getName())) {
return false;
}
if (dbUserInfo.getName() != null && dbUserInfo.getName().equalsIgnoreCase(node.getName())) {
return false;
}
if (dbUserInfo != null && dbUserInfo.isDbaAuthority()) {
return true;
}
}
return false;
}
Aggregations