use of com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo in project cubrid-manager by CUBRID.
the class EditUserDialog method groupChange.
/**
* whether change the group
*
* @return
*/
public boolean groupChange() {
boolean result = false;
List<String> newGroupList = new ArrayList<String>();
for (int i = 0; i < userGroupTable.getItemCount(); i++) {
newGroupList.add(userGroupTable.getItem(i).getText(0));
}
for (DbUserInfo bean : userListInfo.getUserList()) {
if (!(bean.getName().equalsIgnoreCase(userName))) {
continue;
}
userInfo = bean;
List<String> oldGoupsList = bean.getGroups().getGroup();
// When only Change the user's password, oldGroup object is set to be null.
if (oldGoupsList == null) {
return true;
}
result = Arrays.equals(newGroupList.toArray(), oldGoupsList.toArray());
break;
}
return result;
}
use of com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo in project cubrid-manager by CUBRID.
the class EditUserDialog method valid.
/**
* Check the data validation
*
* @return <code>true</code> if valid;<code>false</code>otherwise
*/
public boolean valid() {
String userName = userNameText.getText();
if (userName == null) {
userName = "";
}
if (newFlag) {
String pwd = pwdText.getText();
String pwdcfm = pwdCfmText.getText();
if (pwd == null || pwd.equals("")) {
CommonUITool.openErrorBox(parentComp.getShell(), Messages.errInputPassword);
return false;
}
if (!pwd.equals(pwdcfm)) {
CommonUITool.openErrorBox(parentComp.getShell(), Messages.errPasswordDiff);
return false;
}
if (userName == null || userName.equals("")) {
CommonUITool.openErrorBox(parentComp.getShell(), Messages.errInputName);
return false;
}
if (!ValidateUtil.isValidDBName(userName)) {
CommonUITool.openErrorBox(parentComp.getShell(), Messages.errInputNameValidate);
return false;
}
if (userName.length() > ValidateUtil.MAX_NAME_LENGTH) {
CommonUITool.openErrorBox(parentComp.getShell(), Messages.bind(Messages.errInputNameLength, ValidateUtil.MAX_NAME_LENGTH));
return false;
}
for (DbUserInfo user : userListInfo.getUserList()) {
if (user.getName().equalsIgnoreCase(userName)) {
CommonUITool.openErrorBox(parentComp.getShell(), Messages.errInputNameExist);
return false;
}
}
if (!pwd.equals(pwdcfm)) {
CommonUITool.openErrorBox(parentComp.getShell(), Messages.errPasswordDiff);
return false;
}
if (pwd.length() > ValidateUtil.MAX_PASSWORD_LENGTH) {
CommonUITool.openErrorBox(parentComp.getShell(), Messages.bind(Messages.errInputPassLength, ValidateUtil.MAX_PASSWORD_LENGTH));
return false;
}
if (pwd.length() < ValidateUtil.MIN_PASSWORD_LENGTH) {
CommonUITool.openErrorBox(parentComp.getShell(), Messages.bind(Messages.errInputPasswordMinLength, ValidateUtil.MIN_PASSWORD_LENGTH));
return false;
}
if (pwd.indexOf(" ") >= 0) {
CommonUITool.openErrorBox(parentComp.getShell(), Messages.errInvalidPassword);
return false;
}
if (("__NULL__").equals(pwd)) {
CommonUITool.openErrorBox(parentComp.getShell(), Messages.bind(Messages.errInputNameAccept, "__NULL__"));
return false;
}
} else if (changePwdBtn.getSelection()) {
String pwd = pwdText.getText();
String pwdcfm = pwdCfmText.getText();
String oldPwd = oldPwdText.getText();
if (pwd == null || pwd.equals("")) {
CommonUITool.openErrorBox(parentComp.getShell(), Messages.errInputPassword);
return false;
}
if (oldPwdText.getEnabled() && !oldLoginPassword.equals(oldPwd)) {
CommonUITool.openErrorBox(parentComp.getShell(), Messages.errOldPassword);
return false;
}
if (!pwd.equals(pwdcfm)) {
CommonUITool.openErrorBox(parentComp.getShell(), Messages.errPasswordDiff);
return false;
}
if (pwd.length() < ValidateUtil.MIN_PASSWORD_LENGTH) {
CommonUITool.openErrorBox(parentComp.getShell(), Messages.bind(Messages.errInputPasswordMinLength, ValidateUtil.MIN_PASSWORD_LENGTH));
return false;
}
if (pwd.length() > ValidateUtil.MAX_PASSWORD_LENGTH) {
CommonUITool.openErrorBox(parentComp.getShell(), Messages.bind(Messages.errInputPassLength, ValidateUtil.MAX_PASSWORD_LENGTH));
return false;
}
if (pwd.indexOf(" ") >= 0) {
CommonUITool.openErrorBox(parentComp.getShell(), Messages.errInvalidPassword);
return false;
}
if (("__NULL__").equals(pwd)) {
CommonUITool.openErrorBox(parentComp.getShell(), Messages.bind(Messages.errInputNameAccept, "__NULL__"));
return false;
}
}
return true;
}
use of com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo in project cubrid-manager by CUBRID.
the class AddUserAction 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 && dbUserInfo.isDbaAuthority()) {
return true;
}
}
return false;
}
use of com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo in project cubrid-manager by CUBRID.
the class DatabaseNavigatorMenu method setText.
/**
* Set the text.
*
* @param item DatabaseMenuItem
*/
public void setText(DatabaseMenuItem item) {
if (item == null) {
return;
}
String text = item.getText();
CubridDatabase cubridDatabase = item.getDatabase();
boolean isDbaAuth = false;
boolean isNullDb = false;
if (cubridDatabase != null) {
if (NULL_DATABASE_ID.equals(cubridDatabase.getId())) {
isNullDb = true;
} else {
DatabaseInfo dbInfo = cubridDatabase.getDatabaseInfo();
text = getDatabaseLabel(cubridDatabase);
String userName = cubridDatabase.getUserName();
if (userName != null && userName.trim().length() > 0) {
if (userName.equalsIgnoreCase("dba")) {
isDbaAuth = true;
}
}
DbUserInfo dbusrInfo = null;
if (dbInfo != null) {
dbusrInfo = dbInfo.getAuthLoginedDbUserInfo();
}
if (!isDbaAuth && dbusrInfo != null) {
isDbaAuth = dbusrInfo.isDbaAuthority();
}
}
}
if (isNullDb) {
selectDbLabel.setBackground(new Color[] { Display.getDefault().getSystemColor(SWT.COLOR_WHITE), Display.getDefault().getSystemColor(SWT.COLOR_RED), Display.getDefault().getSystemColor(SWT.COLOR_RED), Display.getDefault().getSystemColor(SWT.COLOR_WHITE) }, new int[] { 33, 67, 100 });
} else if (isDbaAuth) {
selectDbLabel.setBackground(new Color[] { Display.getDefault().getSystemColor(SWT.COLOR_WHITE), Display.getDefault().getSystemColor(SWT.COLOR_YELLOW), Display.getDefault().getSystemColor(SWT.COLOR_YELLOW), Display.getDefault().getSystemColor(SWT.COLOR_WHITE) }, new int[] { 33, 67, 100 });
} else {
selectDbLabel.setBackground((Color) null);
}
if (text.length() > 28) {
String showText = text.substring(0, 25) + "...";
selectDbLabel.setText(showText);
} else {
selectDbLabel.setText(text);
}
selectDbLabel.setToolTipText(text);
}
use of com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo in project cubrid-manager by CUBRID.
the class SetupEnvTestCase method loginTestDatabase.
protected void loginTestDatabase() {
if (databaseInfo.isLogined()) {
return;
}
LoginDatabaseTask loginDatabaseTask = new LoginDatabaseTask(serverInfo);
loginDatabaseTask.setCMUser(userName);
loginDatabaseTask.setDbName(testDbName);
loginDatabaseTask.setDbUser(dbaUserName);
loginDatabaseTask.setDbPassword(dbaPassword);
loginDatabaseTask.execute();
assertEquals(null, loginDatabaseTask.getErrorMsg());
DbUserInfo dbUserInfo = loginDatabaseTask.getLoginedDbUserInfo();
dbUserInfo.setNoEncryptPassword(dbaPassword);
databaseInfo.setLogined(true);
databaseInfo.setAuthLoginedDbUserInfo(dbUserInfo);
UpdateCMUserTask updateCMUserTask = new UpdateCMUserTask(serverInfo);
updateCMUserTask.setCmUserName(userName);
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();
if (authDatabaseList != null && !authDatabaseList.isEmpty()) {
int size = authDatabaseList.size();
for (int i = 0; i < size; i++) {
DatabaseInfo databaseInfo = authDatabaseList.get(i);
dbNameList.add(databaseInfo.getDbName());
dbUserList.add(databaseInfo.getAuthLoginedDbUserInfo().getName());
dbBrokerPortList.add(databaseInfo.getBrokerIP() + "," + 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));
updateCMUserTask.execute();
assertEquals(null, updateCMUserTask.getErrorMsg());
}
Aggregations