use of com.cubrid.cubridmanager.core.cubrid.user.model.DBAuth 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.DBAuth in project cubrid-manager by CUBRID.
the class DBAuthComparator method getColumnImage.
public Image getColumnImage(Object element, int columnIndex) {
if (element != null && element instanceof DBAuth) {
DBAuth dbAuth = (DBAuth) element;
Boolean flag = false;
switch(columnIndex) {
case 2:
flag = AuthType.isHasAuth(dbAuth.getAuthType(), AuthType.SELECT);
return getCheckImage(flag);
case 3:
flag = AuthType.isHasAuth(dbAuth.getAuthType(), AuthType.INSERT);
return getCheckImage(flag);
case 4:
flag = AuthType.isHasAuth(dbAuth.getAuthType(), AuthType.UPDATE);
return getCheckImage(flag);
case 5:
flag = AuthType.isHasAuth(dbAuth.getAuthType(), AuthType.DELETE);
return getCheckImage(flag);
case 6:
flag = AuthType.isHasAuth(dbAuth.getAuthType(), AuthType.ALTER);
return getCheckImage(flag);
case 7:
flag = AuthType.isHasAuth(dbAuth.getAuthType(), AuthType.INDEX);
return getCheckImage(flag);
case 8:
flag = AuthType.isHasAuth(dbAuth.getAuthType(), AuthType.EXECUTE);
return getCheckImage(flag);
case 9:
flag = AuthType.isHasAuth(dbAuth.getAuthType(), AuthType.SELECTGRANT);
return getCheckImage(flag);
case 10:
flag = AuthType.isHasAuth(dbAuth.getAuthType(), AuthType.INDEXGRANT);
return getCheckImage(flag);
case 11:
flag = AuthType.isHasAuth(dbAuth.getAuthType(), AuthType.UPDATEGRANT);
return getCheckImage(flag);
case 12:
flag = AuthType.isHasAuth(dbAuth.getAuthType(), AuthType.DELETEGRANT);
return getCheckImage(flag);
case 13:
flag = AuthType.isHasAuth(dbAuth.getAuthType(), AuthType.ALTERGTANT);
return getCheckImage(flag);
case 14:
flag = AuthType.isHasAuth(dbAuth.getAuthType(), AuthType.INDEXGRANT);
return getCheckImage(flag);
case 15:
flag = AuthType.isHasAuth(dbAuth.getAuthType(), AuthType.EXECUTEGRANT);
return getCheckImage(flag);
}
}
return null;
}
Aggregations