use of com.cubrid.cubridmanager.core.common.model.ServerUserInfo in project cubrid-manager by CUBRID.
the class GetCMUserListTask method buildUserInfo.
/**
*
* Build user info
*
* @param serverUserInfoList List<ServerUserInfo> The given list that stored
* some instance of ServerUserInfo
* @param node TreeNode
*/
private void buildUserInfo(List<ServerUserInfo> serverUserInfoList, TreeNode node) {
for (int j = 0; j < node.childrenSize(); j++) {
TreeNode node1 = node.getChildren().get(j);
if (node1.getValue("open") == null || !node1.getValue("open").trim().equals("user")) {
continue;
}
String userId = node1.getValue("id");
if (userId == null) {
continue;
}
String password = node1.getValue("passwd");
String casAuthInfo = node1.getValue("casauth");
String dbCreater = node1.getValue("dbcreate");
String statusMonitorAuthInfo = node1.getValue("statusmonitorauth");
ServerUserInfo userInfo = new ServerUserInfo(userId, password);
CasAuthType casAuthType = CasAuthType.AUTH_NONE;
if (casAuthInfo != null && casAuthInfo.trim().equals(CasAuthType.AUTH_ADMIN.getText())) {
casAuthType = CasAuthType.AUTH_ADMIN;
} else if (casAuthInfo != null && casAuthInfo.trim().equals(CasAuthType.AUTH_MONITOR.getText())) {
casAuthType = CasAuthType.AUTH_MONITOR;
}
userInfo.setCasAuth(casAuthType);
StatusMonitorAuthType statusMonitorAuth = StatusMonitorAuthType.AUTH_NONE;
if (statusMonitorAuthInfo != null && statusMonitorAuthInfo.trim().equals(StatusMonitorAuthType.AUTH_ADMIN.getText())) {
statusMonitorAuth = StatusMonitorAuthType.AUTH_ADMIN;
} else if (statusMonitorAuthInfo != null && statusMonitorAuthInfo.trim().equals(StatusMonitorAuthType.AUTH_MONITOR.getText())) {
statusMonitorAuth = StatusMonitorAuthType.AUTH_MONITOR;
}
userInfo.setStatusMonitorAuth(statusMonitorAuth);
if (userInfo.isAdmin()) {
userInfo.setStatusMonitorAuth(StatusMonitorAuthType.AUTH_ADMIN);
}
if (dbCreater != null && dbCreater.equals(DbCreateAuthType.AUTH_ADMIN.getText())) {
userInfo.setDbCreateAuthType(DbCreateAuthType.AUTH_ADMIN);
} else {
userInfo.setDbCreateAuthType(DbCreateAuthType.AUTH_NONE);
}
if (userInfo.getUserName().equals(serverInfo.getUserName())) {
userInfo.setPassword(serverInfo.getUserPassword());
}
buildDbAuthInfo(node1, userInfo);
serverUserInfoList.add(userInfo);
}
}
use of com.cubrid.cubridmanager.core.common.model.ServerUserInfo in project cubrid-manager by CUBRID.
the class UserManagementTableViewerSorter method createDialogArea.
/**
* Create dialog area content
*
* @param parent the parent composite
* @return the control
*/
protected Control createDialogArea(Composite parent) {
Composite parentComp = (Composite) super.createDialogArea(parent);
Composite composite = new Composite(parentComp, SWT.NONE);
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
GridLayout layout = new GridLayout();
layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
composite.setLayout(layout);
Label tipLabel = new Label(composite, SWT.LEFT | SWT.WRAP);
tipLabel.setText(Messages.msgUserManagementList);
tipLabel.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
// create CUBRID Manager user information table
String[] columnNameArr = new String[] { Messages.tblColumnUserId, Messages.tblColumnDbAuth, Messages.tblColumnBrokerAuth, Messages.tblColumnMonitorAuth };
final ServerType serverType = server.getServerInfo().getServerType();
if (serverType == ServerType.DATABASE) {
columnNameArr = new String[] { Messages.tblColumnUserId, Messages.tblColumnDbAuth, Messages.tblColumnMonitorAuth };
} else if (serverType == ServerType.BROKER) {
columnNameArr = new String[] { Messages.tblColumnUserId, Messages.tblColumnBrokerAuth, Messages.tblColumnMonitorAuth };
}
tableViewer = CommonUITool.createCommonTableViewer(composite, new UserManagementTableViewerSorter(), columnNameArr, CommonUITool.createGridData(GridData.FILL_BOTH, 1, 1, -1, 200));
userManageTable = tableViewer.getTable();
initialTableModel();
tableViewer.setInput(serverUserInfoTableList);
for (int i = 0; i < userManageTable.getColumnCount(); i++) {
userManageTable.getColumn(i).pack();
}
userManageTable.addSelectionListener(new SelectionAdapter() {
@SuppressWarnings("rawtypes")
public void widgetSelected(SelectionEvent event) {
if (userManageTable.getSelectionCount() > 0) {
StructuredSelection selection = (StructuredSelection) tableViewer.getSelection();
boolean isHasAdmin = false;
if (selection != null && !selection.isEmpty()) {
Iterator it = selection.iterator();
while (it.hasNext()) {
Map map = (Map) it.next();
if (map.get("0").equals("admin")) {
isHasAdmin = true;
break;
}
}
}
deleteButton.setEnabled(!isHasAdmin);
} else {
deleteButton.setEnabled(false);
}
if (userManageTable.getSelectionCount() == 1) {
editButton.setEnabled(true);
} else {
editButton.setEnabled(false);
}
}
});
// create button
Composite buttonComp = new Composite(composite, SWT.NONE);
RowLayout rowLayout = new RowLayout();
rowLayout.spacing = 5;
buttonComp.setLayout(rowLayout);
GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
gridData.horizontalAlignment = GridData.END;
buttonComp.setLayoutData(gridData);
Button addButton = new Button(buttonComp, SWT.PUSH);
addButton.setText(Messages.btnAdd);
addButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
UserManagementWizard userManagementWizard = new UserManagementWizard(server, null, serverUserInfoList);
CMWizardDialog dialog = new CMWizardDialog(getShell(), userManagementWizard);
int returnCode = dialog.open();
if (returnCode == IDialogConstants.OK_ID) {
ServerUserInfo userInfo = userManagementWizard.getServerUserInfo();
Map<String, Object> map = new HashMap<String, Object>();
map.put("0", userInfo.getUserName());
if (serverType == ServerType.BOTH) {
map.put("1", userInfo.getDbCreateAuthType().getText());
map.put("2", userInfo.getCasAuth().getText());
map.put("3", userInfo.getStatusMonitorAuth().getText());
map.put("4", userInfo);
}
if (serverType == ServerType.DATABASE) {
map.put("1", userInfo.getDbCreateAuthType().getText());
map.put("2", userInfo.getStatusMonitorAuth().getText());
map.put("3", userInfo);
} else if (serverType == ServerType.BROKER) {
map.put("1", userInfo.getCasAuth().getText());
map.put("2", userInfo.getStatusMonitorAuth().getText());
map.put("3", userInfo);
}
serverUserInfoTableList.add(map);
serverUserInfoList.add(userInfo);
tableViewer.refresh();
for (int i = 0; i < userManageTable.getColumnCount(); i++) {
userManageTable.getColumn(i).pack();
}
}
}
});
editButton = new Button(buttonComp, SWT.PUSH);
editButton.setText(Messages.btnEdit);
editButton.addSelectionListener(new SelectionAdapter() {
@SuppressWarnings({ "rawtypes", "unchecked" })
public void widgetSelected(SelectionEvent event) {
StructuredSelection selection = (StructuredSelection) tableViewer.getSelection();
ServerUserInfo serverUserInfo = null;
if (selection != null && !selection.isEmpty()) {
Map map = (Map) selection.getFirstElement();
if (serverType == ServerType.BOTH) {
serverUserInfo = (ServerUserInfo) map.get("4");
} else {
serverUserInfo = (ServerUserInfo) map.get("3");
}
UserManagementWizard userManagementWizard = new UserManagementWizard(server, serverUserInfo, serverUserInfoList);
CMWizardDialog dialog = new CMWizardDialog(getShell(), userManagementWizard);
int returnCode = dialog.open();
if (returnCode == IDialogConstants.OK_ID) {
ServerUserInfo userInfo = userManagementWizard.getServerUserInfo();
map.put("0", userInfo.getUserName());
if (serverType == ServerType.BOTH) {
map.put("1", userInfo.getDbCreateAuthType().getText());
map.put("2", userInfo.getCasAuth().getText());
map.put("3", userInfo.getStatusMonitorAuth().getText());
map.put("4", userInfo);
}
if (serverType == ServerType.DATABASE) {
map.put("1", userInfo.getDbCreateAuthType().getText());
map.put("2", userInfo.getStatusMonitorAuth().getText());
map.put("3", userInfo);
} else if (serverType == ServerType.BROKER) {
map.put("1", userInfo.getCasAuth().getText());
map.put("2", userInfo.getStatusMonitorAuth().getText());
map.put("3", userInfo);
}
tableViewer.refresh();
for (int i = 0; i < userManageTable.getColumnCount(); i++) {
userManageTable.getColumn(i).pack();
}
}
}
}
});
editButton.setEnabled(userManageTable.getSelectionCount() == 1);
deleteButton = new Button(buttonComp, SWT.PUSH);
deleteButton.setText(Messages.btnDelete);
deleteButton.addSelectionListener(new SelectionAdapter() {
@SuppressWarnings("rawtypes")
public void widgetSelected(SelectionEvent event) {
boolean isDelete = CommonUITool.openConfirmBox(getShell(), Messages.msgDeleteUserConfirm);
if (!isDelete) {
return;
}
StructuredSelection selection = (StructuredSelection) tableViewer.getSelection();
if (selection != null && !selection.isEmpty()) {
Map[] userInfoMapArr = new Map[selection.size()];
Iterator it = selection.iterator();
int i = 0;
while (it.hasNext()) {
Map map = (Map) it.next();
userInfoMapArr[i] = map;
i++;
}
deleteUser(userInfoMapArr);
}
tableViewer.refresh();
}
});
deleteButton.setEnabled(userManageTable.getSelectionCount() == 1);
setTitle(Messages.titleUserManagementDialog);
setMessage(Messages.msgUserManagementDialog);
return parentComp;
}
use of com.cubrid.cubridmanager.core.common.model.ServerUserInfo in project cubrid-manager by CUBRID.
the class CreateDatabaseAction method isSupported.
public boolean isSupported(Object obj) {
if (obj instanceof ICubridNode) {
ICubridNode node = (ICubridNode) obj;
if (node.getServer() == null) {
return false;
}
ServerUserInfo userInfo = node.getServer().getServerInfo().getLoginedUserInfo();
if (userInfo != null && userInfo.getDbCreateAuthType() == DbCreateAuthType.AUTH_ADMIN) {
return true;
}
}
return false;
}
use of com.cubrid.cubridmanager.core.common.model.ServerUserInfo in project cubrid-manager by CUBRID.
the class ChangeMasterDbAction method isSupported.
/**
* @see com.cubrid.common.ui.spi.action.ISelectionAction#isSupported(java
* .lang.Object)
* @param obj Object
* @return boolean(whether to support)
*/
public boolean isSupported(Object obj) {
if (obj instanceof CubridDatabase) {
CubridDatabase database = (CubridDatabase) obj;
if (!database.isLogined()) {
return false;
}
ServerUserInfo serverUserInfo = database.getServer().getServerInfo().getLoginedUserInfo();
if (serverUserInfo == null || !serverUserInfo.isAdmin()) {
return false;
}
return database.isDistributorDb();
}
return false;
}
use of com.cubrid.cubridmanager.core.common.model.ServerUserInfo in project cubrid-manager by CUBRID.
the class ChangeReplicationSchemaAction method isSupported.
/**
* @see com.cubrid.common.ui.spi.action.ISelectionAction#isSupported(java
* .lang.Object)
* @param obj Object
* @return boolean(whether to support)
*/
public boolean isSupported(Object obj) {
if (obj instanceof CubridDatabase) {
CubridDatabase database = (CubridDatabase) obj;
if (!database.isLogined()) {
return false;
}
ServerUserInfo serverUserInfo = database.getServer().getServerInfo().getLoginedUserInfo();
if (serverUserInfo == null || !serverUserInfo.isAdmin()) {
return false;
}
return database.isDistributorDb();
}
return false;
}
Aggregations