use of com.cubrid.cubridmanager.core.cubrid.user.model.UserDetailInfo in project cubrid-manager by CUBRID.
the class DBAuthComparator method dropUser.
/**
* drop User
*/
public void dropUser() {
TableItem[] items = userTableViewer.getTable().getSelection();
if (items.length == 1) {
TableItem item = items[0];
UserDetailInfo userInfo = (UserDetailInfo) item.getData();
String msg = Messages.bind(Messages.msgDoYouWantToDeleteUser, userInfo.getUserName());
if (!CommonUITool.openConfirmBox(msg)) {
return;
}
Set<String> typeSet = new HashSet<String>();
typeSet.add(NodeType.USER);
ICubridNode userNode = CommonUITool.findNode(database, typeSet, userInfo.getUserName());
if (userNode != null) {
DeleteUserAction action = (DeleteUserAction) ActionManager.getInstance().getAction(DeleteUserAction.ID);
action.doRun((ISchemaNode) userNode);
refresh();
}
} else {
CommonUITool.openWarningBox(Messages.errNoUserSelected);
}
}
use of com.cubrid.cubridmanager.core.cubrid.user.model.UserDetailInfo in project cubrid-manager by CUBRID.
the class GetAllUserAuthorizationsTask method execute.
public void execute() {
String sql = "SELECT grantor_name, grantee_name, class_name, auth_type, is_grantable FROM db_auth";
sql = databaseInfo.wrapShardQuery(sql);
try {
stmt = connection.createStatement();
rs = stmt.executeQuery(sql);
while (rs.next()) {
//String grantorName = rs.getString("grantor_name");
String granteeName = rs.getString("grantee_name");
String className = rs.getString("class_name");
String authType = rs.getString("auth_type");
boolean isGrantable = StringUtil.booleanValueWithYN(rs.getString("is_grantable"));
// }
if (StringUtil.isEmpty(className)) {
continue;
}
if (granteeName != null) {
granteeName = granteeName.toLowerCase(Locale.getDefault());
}
UserDetailInfo userInfo = allAuthMap.get(granteeName);
if (userInfo == null) {
userInfo = new UserDetailInfo();
userInfo.setUserName(granteeName);
allAuthMap.put(granteeName, userInfo);
}
AuthType type = AuthType.getAuthType(authType, isGrantable);
userInfo.addAuth(className, type);
}
} catch (SQLException e) {
errorMsg = e.getMessage();
} finally {
QueryUtil.freeQuery(stmt, rs);
}
loadDetailInfo();
finish();
}
use of com.cubrid.cubridmanager.core.cubrid.user.model.UserDetailInfo in project cubrid-manager by CUBRID.
the class GetAllUserAuthorizationsTask method loadDetailInfo.
private void loadDetailInfo() {
String sql = "SELECT class_name, owner_name, class_type " + "FROM db_class " + "WHERE is_system_class = 'NO' AND partitioned = 'NO' ";
sql = databaseInfo.wrapShardQuery(sql);
Statement stmt = null;
/*Add dba user first*/
UserDetailInfo dbaUserInfo = allAuthMap.get("dba");
if (dbaUserInfo == null) {
dbaUserInfo = new UserDetailInfo();
dbaUserInfo.setUserName("dba");
}
try {
stmt = connection.createStatement();
rs = stmt.executeQuery(sql);
while (rs.next()) {
String className = rs.getString("class_name");
String ownerName = rs.getString("owner_name");
String classType = rs.getString("class_type");
boolean isTable = "CLASS".equals(classType);
if (ConstantsUtil.isExtensionalSystemTable(className)) {
continue;
}
if (ownerName != null) {
ownerName = ownerName.toLowerCase(Locale.getDefault());
}
UserDetailInfo userDetailInfo = allAuthMap.get(ownerName);
if (!allAuthMap.containsKey(ownerName)) {
userDetailInfo = new UserDetailInfo();
userDetailInfo.setUserName(ownerName);
allAuthMap.put(ownerName, userDetailInfo);
}
/*Add auth to dba*/
DBAuth dbaAuth = dbaUserInfo.getAuth(className);
if (dbaAuth == null) {
dbaAuth = new DBAuth(className, AuthType.ALL);
dbaAuth.setOwner(ownerName);
dbaAuth.setTable(isTable);
dbaUserInfo.addAuth(dbaAuth);
} else {
dbaAuth.setOwner(ownerName);
dbaAuth.setTable(isTable);
dbaUserInfo.addAuth(className, AuthType.ALL);
}
/*add auth to public user*/
for (UserDetailInfo userInfo : allAuthMap.values()) {
DBAuth dbAuth = userInfo.getAuth(className);
if (dbAuth == null) {
if (StringUtil.isEqual(ownerName, userInfo.getUserName())) {
dbAuth = new DBAuth(className, AuthType.ALL);
dbAuth.setOwner(ownerName);
dbAuth.setTable(isTable);
userInfo.addAuth(dbAuth);
} else {
continue;
}
} else {
dbAuth.setOwner(ownerName);
dbAuth.setTable(isTable);
}
}
}
} catch (SQLException e) {
errorMsg = e.getMessage();
} finally {
QueryUtil.freeQuery(stmt, rs);
}
allAuthMap.put(dbaUserInfo.getUserName(), dbaUserInfo);
}
use of com.cubrid.cubridmanager.core.cubrid.user.model.UserDetailInfo in project cubrid-manager by CUBRID.
the class DBAuthComparator method createUsersTable.
/**
* create user table
*
* @param parent
*/
public void createUsersTable(Composite parent) {
userTableViewer = new TableViewer(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);
userTableViewer.getTable().setHeaderVisible(false);
userTableViewer.getTable().setLinesVisible(false);
userTableViewer.getTable().setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 1, 1, -1, -1));
final TableViewerColumn nameColumn = new TableViewerColumn(userTableViewer, SWT.LEFT);
nameColumn.getColumn().setWidth(200);
userTableViewer.setContentProvider(new UserContentProvider());
userTableViewer.setLabelProvider(new UserLabelProvider());
registerContextMenu();
userTableViewer.getTable().addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
widgetDefaultSelected(e);
}
public void widgetDefaultSelected(SelectionEvent e) {
TableItem[] items = userTableViewer.getTable().getSelection();
if (items.length == 1) {
UserDetailInfo userInfo = (UserDetailInfo) items[0].getData();
setAuthDetailInfoTableViewer(userInfo);
}
}
});
}
use of com.cubrid.cubridmanager.core.cubrid.user.model.UserDetailInfo 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);
}
Aggregations