mirror of
https://github.com/dbeaver/cloudbeaver.git
synced 2026-09-24 16:04:36 +08:00
CB-108 Admin service API
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
package io.cloudbeaver;
|
||||
|
||||
import io.cloudbeaver.model.session.WebSession;
|
||||
import io.cloudbeaver.model.user.WebPermission;
|
||||
import io.cloudbeaver.model.user.WebRole;
|
||||
import io.cloudbeaver.model.user.WebUser;
|
||||
import io.cloudbeaver.registry.WebAuthProviderDescriptor;
|
||||
@@ -42,10 +43,14 @@ public interface DBWSecurityController {
|
||||
|
||||
void setUserRoles(String userId, String[] roleIds, String grantorId) throws DBCException;
|
||||
|
||||
@NotNull
|
||||
WebRole[] getUserRoles(String userId) throws DBCException;
|
||||
|
||||
WebUser getUserById(String userId) throws DBCException;
|
||||
|
||||
@NotNull
|
||||
WebUser[] findUsers(String userNameMask) throws DBCException;
|
||||
|
||||
///////////////////////////////////////////
|
||||
// Credentials
|
||||
|
||||
@@ -69,8 +74,11 @@ public interface DBWSecurityController {
|
||||
///////////////////////////////////////////
|
||||
// Roles
|
||||
|
||||
@NotNull
|
||||
WebRole[] readAllRoles() throws DBCException;
|
||||
|
||||
WebRole[] findRoles(String roleName) throws DBCException;
|
||||
|
||||
void createRole(WebRole role) throws DBCException;
|
||||
|
||||
void deleteRole(String roleId) throws DBCException;
|
||||
@@ -80,10 +88,15 @@ public interface DBWSecurityController {
|
||||
|
||||
void setSubjectPermissions(String subjectId, String[] permissionIds, String grantorId) throws DBCException;
|
||||
|
||||
@NotNull
|
||||
Set<String> getSubjectPermissions(String subjectId) throws DBCException;
|
||||
|
||||
@NotNull
|
||||
Set<String> getUserPermissions(String userId) throws DBCException;
|
||||
|
||||
@NotNull
|
||||
WebPermission[] getAllPermissions();
|
||||
|
||||
///////////////////////////////////////////
|
||||
// Sessions
|
||||
|
||||
@@ -94,7 +107,8 @@ public interface DBWSecurityController {
|
||||
void updateSession(WebSession session) throws DBCException;
|
||||
|
||||
///////////////////////////////////////////
|
||||
// Meta info
|
||||
// Permissions
|
||||
|
||||
|
||||
///////////////////////////////////////////
|
||||
// Utils
|
||||
|
||||
@@ -30,7 +30,6 @@ public class WebRole implements WebAuthSubject {
|
||||
|
||||
private String roleId;
|
||||
private String name;
|
||||
private String icon;
|
||||
private String description;
|
||||
|
||||
private Set<String> permissions = new LinkedHashSet<>();
|
||||
@@ -43,10 +42,6 @@ public class WebRole implements WebAuthSubject {
|
||||
return roleId;
|
||||
}
|
||||
|
||||
public void setRoleId(String id) {
|
||||
this.roleId = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
@@ -55,14 +50,6 @@ public class WebRole implements WebAuthSubject {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getIcon() {
|
||||
return icon;
|
||||
}
|
||||
|
||||
public void setIcon(String icon) {
|
||||
this.icon = icon;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ public class WebUser implements WebAuthSubject {
|
||||
private Map<String, Object> metaParameters = new LinkedHashMap<>();
|
||||
private Map<String, Object> configurationParameters = new LinkedHashMap<>();
|
||||
|
||||
private Set<WebRole> roles = new LinkedHashSet<>();
|
||||
private WebRole[] roles = null;
|
||||
|
||||
private String activeAuthModel;
|
||||
private Map<String, Map<String, Object>> authCredentials = new HashMap<>();
|
||||
@@ -61,7 +61,7 @@ public class WebUser implements WebAuthSubject {
|
||||
}
|
||||
|
||||
public String[] getGrantedRoles() {
|
||||
return roles.stream().map(WebRole::getRoleId).toArray(String[]::new);
|
||||
return Arrays.stream(roles).map(WebRole::getRoleId).toArray(String[]::new);
|
||||
}
|
||||
|
||||
public Map<String, Object> getMetaParameters() {
|
||||
@@ -72,8 +72,12 @@ public class WebUser implements WebAuthSubject {
|
||||
return Collections.unmodifiableMap(configurationParameters);
|
||||
}
|
||||
|
||||
public Set<WebRole> getRoles() {
|
||||
return Collections.unmodifiableSet(roles);
|
||||
public WebRole[] getRoles() {
|
||||
return roles;
|
||||
}
|
||||
|
||||
public void setRoles(WebRole[] roles) {
|
||||
this.roles = roles;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+38
@@ -18,6 +18,7 @@ package io.cloudbeaver.server;
|
||||
|
||||
import io.cloudbeaver.DBWSecurityController;
|
||||
import io.cloudbeaver.model.session.WebSession;
|
||||
import io.cloudbeaver.model.user.WebPermission;
|
||||
import io.cloudbeaver.model.user.WebRole;
|
||||
import io.cloudbeaver.model.user.WebUser;
|
||||
import io.cloudbeaver.registry.WebAuthProviderDescriptor;
|
||||
@@ -102,6 +103,7 @@ class CBSecurityController implements DBWSecurityController {
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public WebRole[] getUserRoles(String userId) throws DBCException {
|
||||
try (Connection dbCon = database.openConnection()) {
|
||||
@@ -137,6 +139,28 @@ class CBSecurityController implements DBWSecurityController {
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public WebUser[] findUsers(String userNameMask) throws DBCException {
|
||||
try (Connection dbCon = database.openConnection()) {
|
||||
try (PreparedStatement dbStat = dbCon.prepareStatement("SELECT * FROM CB_USER" +
|
||||
(CommonUtils.isEmpty(userNameMask) ? "" : " WHERE USER_ID=?"))) {
|
||||
if (!CommonUtils.isEmpty(userNameMask)) {
|
||||
dbStat.setString(1, userNameMask);
|
||||
}
|
||||
try (ResultSet dbResult = dbStat.executeQuery()) {
|
||||
List<WebUser> result = new ArrayList<>();
|
||||
while (dbResult.next()) {
|
||||
result.add(new WebUser(dbResult.getString(1)));
|
||||
}
|
||||
return result.toArray(new WebUser[0]);
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
throw new DBCException("Error while searching credentials", e);
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////
|
||||
// Credentials
|
||||
|
||||
@@ -273,6 +297,7 @@ class CBSecurityController implements DBWSecurityController {
|
||||
///////////////////////////////////////////
|
||||
// Roles
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public WebRole[] readAllRoles() throws DBCException {
|
||||
try (Connection dbCon = database.openConnection()) {
|
||||
@@ -301,6 +326,11 @@ class CBSecurityController implements DBWSecurityController {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public WebRole[] findRoles(String roleName) throws DBCException {
|
||||
return readAllRoles();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private WebRole fetchRole(ResultSet dbResult) throws SQLException {
|
||||
WebRole role = new WebRole(dbResult.getString("ROLE_ID"));
|
||||
@@ -357,6 +387,7 @@ class CBSecurityController implements DBWSecurityController {
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<String> getSubjectPermissions(String subjectId) throws DBCException {
|
||||
try (Connection dbCon = database.openConnection()) {
|
||||
@@ -375,6 +406,7 @@ class CBSecurityController implements DBWSecurityController {
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<String> getUserPermissions(String userId) throws DBCException {
|
||||
try (Connection dbCon = database.openConnection()) {
|
||||
@@ -404,6 +436,12 @@ class CBSecurityController implements DBWSecurityController {
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public WebPermission[] getAllPermissions() {
|
||||
return new WebPermission[0];
|
||||
}
|
||||
|
||||
///////////////////////////////////////////
|
||||
// Sessions
|
||||
|
||||
|
||||
+5
@@ -99,6 +99,11 @@ public abstract class WebServiceBindingBase<API_TYPE extends DBWService> impleme
|
||||
getServletRequest(env));
|
||||
}
|
||||
|
||||
protected static WebSession getWebSession(DataFetchingEnvironment env, boolean errorOnNotFound) throws DBWebException {
|
||||
return CBPlatform.getInstance().getSessionManager().getWebSession(
|
||||
getServletRequest(env), errorOnNotFound);
|
||||
}
|
||||
|
||||
protected static WebSession findWebSession(DataFetchingEnvironment env) {
|
||||
return CBPlatform.getInstance().getSessionManager().findWebSession(
|
||||
getServletRequest(env));
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
|
||||
type AdminUserInfo {
|
||||
userName: ID!
|
||||
userId: ID!
|
||||
|
||||
metaParameters: Object!
|
||||
configurationParameters: Object!
|
||||
@@ -8,7 +8,8 @@ type AdminUserInfo {
|
||||
}
|
||||
|
||||
type AdminRoleInfo {
|
||||
roleName: ID!
|
||||
roleId: ID!
|
||||
roleName: String
|
||||
|
||||
rolePermissions: [ID]!
|
||||
}
|
||||
@@ -24,15 +25,15 @@ type AdminPermissionInfo {
|
||||
|
||||
extend type Query {
|
||||
|
||||
listUsers(userName: ID): [AdminUserInfo]!
|
||||
listRoles(roleName: ID): [AdminRoleInfo]!
|
||||
listPermissions(permissionId: ID): [AdminPermissionInfo]!
|
||||
listUsers(userId: ID): [AdminUserInfo]!
|
||||
listRoles(roleId: ID): [AdminRoleInfo]!
|
||||
listPermissions: [AdminPermissionInfo]!
|
||||
|
||||
createUser(userName: ID!): AdminUserInfo!
|
||||
deleteUser(userName: ID!): Boolean
|
||||
createUser(userId: ID!): AdminUserInfo!
|
||||
deleteUser(userId: ID!): Boolean
|
||||
|
||||
createRole(roleName: ID!): AdminRoleInfo!
|
||||
deleteRole(roleName: ID!): Boolean
|
||||
createRole(roleId: ID!): AdminRoleInfo!
|
||||
deleteRole(roleId: ID!): Boolean
|
||||
|
||||
grantUserRole(user: ID!, role: ID!): Boolean
|
||||
revokeUserRole(user: ID!, role: ID!): Boolean
|
||||
|
||||
+8
-5
@@ -16,18 +16,21 @@
|
||||
*/
|
||||
package io.cloudbeaver.service.admin;
|
||||
|
||||
import io.cloudbeaver.model.user.WebPermission;
|
||||
|
||||
/**
|
||||
* Web permission ID
|
||||
*/
|
||||
public class AdminPermissionInfo {
|
||||
|
||||
private String id;
|
||||
private final WebPermission permission;
|
||||
|
||||
public AdminPermissionInfo(WebPermission permission) {
|
||||
this.permission = permission;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
return permission.getId();
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package io.cloudbeaver.service.admin.impl;
|
||||
package io.cloudbeaver.service.admin;
|
||||
|
||||
/**
|
||||
* Web service implementation
|
||||
+11
-5
@@ -16,6 +16,8 @@
|
||||
*/
|
||||
package io.cloudbeaver.service.admin;
|
||||
|
||||
import io.cloudbeaver.model.user.WebRole;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -23,15 +25,19 @@ import java.util.List;
|
||||
*/
|
||||
public class AdminRoleInfo {
|
||||
|
||||
private String roleName;
|
||||
private final WebRole role;
|
||||
private List<String> rolePermissions;
|
||||
|
||||
public String getRoleName() {
|
||||
return roleName;
|
||||
public AdminRoleInfo(WebRole role) {
|
||||
this.role = role;
|
||||
}
|
||||
|
||||
public void setRoleName(String roleName) {
|
||||
this.roleName = roleName;
|
||||
public String getRoleId() {
|
||||
return role.getRoleId();
|
||||
}
|
||||
|
||||
public String getRoleName() {
|
||||
return role.getName();
|
||||
}
|
||||
|
||||
public List<String> getRolePermissions() {
|
||||
|
||||
+16
-21
@@ -16,7 +16,11 @@
|
||||
*/
|
||||
package io.cloudbeaver.service.admin;
|
||||
|
||||
import java.util.List;
|
||||
import io.cloudbeaver.model.user.WebRole;
|
||||
import io.cloudbeaver.model.user.WebUser;
|
||||
import io.cloudbeaver.server.CBPlatform;
|
||||
import org.jkiss.dbeaver.model.exec.DBCException;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@@ -24,42 +28,33 @@ import java.util.Map;
|
||||
*/
|
||||
public class AdminUserInfo {
|
||||
|
||||
private String userName;
|
||||
private final WebUser user;
|
||||
|
||||
private Map<String, Object> metaParameters;
|
||||
private Map<String, Object> configurationParameters;
|
||||
|
||||
private List<String> grantedRoles;
|
||||
|
||||
public String getUserName() {
|
||||
return userName;
|
||||
public AdminUserInfo(WebUser user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
public void setUserName(String userName) {
|
||||
this.userName = userName;
|
||||
public String getUserId() {
|
||||
return user.getUserId();
|
||||
}
|
||||
|
||||
public Map<String, Object> getMetaParameters() {
|
||||
return metaParameters;
|
||||
}
|
||||
|
||||
public void setMetaParameters(Map<String, Object> metaParameters) {
|
||||
this.metaParameters = metaParameters;
|
||||
}
|
||||
|
||||
public Map<String, Object> getConfigurationParameters() {
|
||||
return configurationParameters;
|
||||
}
|
||||
|
||||
public void setConfigurationParameters(Map<String, Object> configurationParameters) {
|
||||
this.configurationParameters = configurationParameters;
|
||||
public String[] getGrantedRoles() throws DBCException {
|
||||
if (user.getRoles() == null) {
|
||||
WebRole[] userRoles = CBPlatform.getInstance().getApplication().getSecurityController().getUserRoles(getUserId());
|
||||
user.setRoles(userRoles);
|
||||
}
|
||||
return user.getGrantedRoles();
|
||||
}
|
||||
|
||||
public List<String> getGrantedRoles() {
|
||||
return grantedRoles;
|
||||
}
|
||||
|
||||
public void setGrantedRoles(List<String> grantedRoles) {
|
||||
this.grantedRoles = grantedRoles;
|
||||
}
|
||||
}
|
||||
|
||||
+34
-10
@@ -18,6 +18,10 @@ package io.cloudbeaver.service.admin;
|
||||
|
||||
import io.cloudbeaver.DBWService;
|
||||
import io.cloudbeaver.DBWebException;
|
||||
import io.cloudbeaver.WebAction;
|
||||
import io.cloudbeaver.model.session.WebSession;
|
||||
import org.jkiss.code.NotNull;
|
||||
import org.jkiss.code.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -26,19 +30,39 @@ import java.util.List;
|
||||
*/
|
||||
public interface DBWServiceAdmin extends DBWService {
|
||||
|
||||
List<AdminUserInfo> listUsers(String userName) throws DBWebException;
|
||||
List<AdminRoleInfo> listRoles(String roleName) throws DBWebException;
|
||||
List<AdminPermissionInfo> listPermissions(String permissionId) throws DBWebException;
|
||||
@WebAction(requirePermissions = AdminPermissions.PERMISSION_ADMIN)
|
||||
@NotNull
|
||||
List<AdminUserInfo> listUsers(@NotNull WebSession webSession, @Nullable String userName) throws DBWebException;
|
||||
|
||||
AdminUserInfo createUser(String userName) throws DBWebException;
|
||||
boolean deleteUser(String userName) throws DBWebException;
|
||||
@WebAction(requirePermissions = AdminPermissions.PERMISSION_ADMIN)
|
||||
@NotNull
|
||||
List<AdminRoleInfo> listRoles(@NotNull WebSession webSession, @Nullable String roleName) throws DBWebException;
|
||||
|
||||
AdminRoleInfo createRole(String roleName) throws DBWebException;
|
||||
boolean deleteRole(String roleName) throws DBWebException;
|
||||
@WebAction(requirePermissions = AdminPermissions.PERMISSION_ADMIN)
|
||||
@NotNull
|
||||
List<AdminPermissionInfo> listPermissions(@NotNull WebSession webSession) throws DBWebException;
|
||||
|
||||
boolean grantUserRole(String user, String role) throws DBWebException;
|
||||
boolean revokeUserRole(String user, String role) throws DBWebException;
|
||||
@WebAction(requirePermissions = AdminPermissions.PERMISSION_ADMIN)
|
||||
@NotNull
|
||||
AdminUserInfo createUser(@NotNull WebSession webSession, String userName) throws DBWebException;
|
||||
|
||||
boolean setRolePermissions(String roleID, String[] permissions) throws DBWebException;
|
||||
@WebAction(requirePermissions = AdminPermissions.PERMISSION_ADMIN)
|
||||
boolean deleteUser(@NotNull WebSession webSession, String userName) throws DBWebException;
|
||||
|
||||
@WebAction(requirePermissions = AdminPermissions.PERMISSION_ADMIN)
|
||||
@NotNull
|
||||
AdminRoleInfo createRole(@NotNull WebSession webSession, String roleName) throws DBWebException;
|
||||
|
||||
@WebAction(requirePermissions = AdminPermissions.PERMISSION_ADMIN)
|
||||
boolean deleteRole(@NotNull WebSession webSession, String roleName) throws DBWebException;
|
||||
|
||||
@WebAction(requirePermissions = AdminPermissions.PERMISSION_ADMIN)
|
||||
boolean grantUserRole(@NotNull WebSession webSession, String user, String role) throws DBWebException;
|
||||
|
||||
@WebAction(requirePermissions = AdminPermissions.PERMISSION_ADMIN)
|
||||
boolean revokeUserRole(@NotNull WebSession webSession, String user, String role) throws DBWebException;
|
||||
|
||||
@WebAction(requirePermissions = AdminPermissions.PERMISSION_ADMIN)
|
||||
boolean setRolePermissions(@NotNull WebSession webSession, String roleID, String[] permissions) throws DBWebException;
|
||||
|
||||
}
|
||||
|
||||
+10
-4
@@ -16,7 +16,6 @@
|
||||
*/
|
||||
package io.cloudbeaver.service.admin;
|
||||
|
||||
import graphql.schema.idl.TypeDefinitionRegistry;
|
||||
import io.cloudbeaver.DBWebException;
|
||||
import io.cloudbeaver.service.DBWBindingContext;
|
||||
import io.cloudbeaver.service.WebServiceBindingBase;
|
||||
@@ -35,9 +34,16 @@ public class WebServiceBindingAdmin extends WebServiceBindingBase<DBWServiceAdmi
|
||||
|
||||
@Override
|
||||
public void bindWiring(DBWBindingContext model) throws DBWebException {
|
||||
model.getQueryType().dataFetcher("listUsers", env -> {
|
||||
throw new DBWebException("Not implemented");
|
||||
});
|
||||
model.getQueryType().dataFetcher("listUsers",
|
||||
env -> getService(env).listUsers(getWebSession(env), env.getArgument("userName")));
|
||||
model.getQueryType().dataFetcher("listRoles",
|
||||
env -> getService(env).listRoles(getWebSession(env), env.getArgument("roleName")));
|
||||
model.getQueryType().dataFetcher("listPermissions",
|
||||
env -> getService(env).listPermissions(getWebSession(env)));
|
||||
model.getQueryType().dataFetcher("createUser",
|
||||
env -> getService(env).createUser(getWebSession(env), env.getArgument("userId")));
|
||||
model.getQueryType().dataFetcher("deleteUser",
|
||||
env -> getService(env).deleteUser(getWebSession(env), env.getArgument("userId")));
|
||||
|
||||
}
|
||||
|
||||
|
||||
+77
-30
@@ -17,11 +17,18 @@
|
||||
package io.cloudbeaver.service.admin.impl;
|
||||
|
||||
import io.cloudbeaver.DBWebException;
|
||||
import io.cloudbeaver.model.session.WebSession;
|
||||
import io.cloudbeaver.model.user.WebPermission;
|
||||
import io.cloudbeaver.model.user.WebRole;
|
||||
import io.cloudbeaver.model.user.WebUser;
|
||||
import io.cloudbeaver.server.CBPlatform;
|
||||
import io.cloudbeaver.service.admin.AdminPermissionInfo;
|
||||
import io.cloudbeaver.service.admin.AdminRoleInfo;
|
||||
import io.cloudbeaver.service.admin.AdminUserInfo;
|
||||
import io.cloudbeaver.service.admin.DBWServiceAdmin;
|
||||
import org.jkiss.code.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -30,53 +37,93 @@ import java.util.List;
|
||||
public class WebServiceAdmin implements DBWServiceAdmin {
|
||||
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public List<AdminUserInfo> listUsers(String userName) throws DBWebException {
|
||||
public List<AdminUserInfo> listUsers(@NotNull WebSession webSession, String userName) throws DBWebException {
|
||||
try {
|
||||
List<AdminUserInfo> webUsers = new ArrayList<>();
|
||||
for (WebUser user : CBPlatform.getInstance().getApplication().getSecurityController().findUsers(userName)) {
|
||||
webUsers.add(new AdminUserInfo(user));
|
||||
}
|
||||
return webUsers;
|
||||
} catch (Exception e) {
|
||||
throw new DBWebException("Error reading users", e);
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public List<AdminRoleInfo> listRoles(@NotNull WebSession webSession, String roleName) throws DBWebException {
|
||||
try {
|
||||
List<AdminRoleInfo> webUsers = new ArrayList<>();
|
||||
for (WebRole role : CBPlatform.getInstance().getApplication().getSecurityController().findRoles(roleName)) {
|
||||
webUsers.add(new AdminRoleInfo(role));
|
||||
}
|
||||
return webUsers;
|
||||
} catch (Exception e) {
|
||||
throw new DBWebException("Error reading users", e);
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public List<AdminPermissionInfo> listPermissions(@NotNull WebSession webSession) throws DBWebException {
|
||||
try {
|
||||
List<AdminPermissionInfo> permissionInfos = new ArrayList<>();
|
||||
for (WebPermission permission : CBPlatform.getInstance().getApplication().getSecurityController().getAllPermissions()) {
|
||||
permissionInfos.add(new AdminPermissionInfo(permission));
|
||||
}
|
||||
return permissionInfos;
|
||||
} catch (Exception e) {
|
||||
throw new DBWebException("Error reading users", e);
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public AdminUserInfo createUser(@NotNull WebSession webSession, String userName) throws DBWebException {
|
||||
try {
|
||||
WebUser newUser = new WebUser(userName);
|
||||
CBPlatform.getInstance().getApplication().getSecurityController().createUser(newUser);
|
||||
return new AdminUserInfo(newUser);
|
||||
} catch (Exception e) {
|
||||
throw new DBWebException("Error reading users", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteUser(@NotNull WebSession webSession, String userName) throws DBWebException {
|
||||
try {
|
||||
CBPlatform.getInstance().getApplication().getSecurityController().deleteUser(userName);
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
throw new DBWebException("Error reading users", e);
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public AdminRoleInfo createRole(@NotNull WebSession webSession, String roleName) throws DBWebException {
|
||||
throw new DBWebException("Feature not supported");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AdminRoleInfo> listRoles(String roleName) throws DBWebException {
|
||||
public boolean deleteRole(@NotNull WebSession webSession, String roleName) throws DBWebException {
|
||||
throw new DBWebException("Feature not supported");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AdminPermissionInfo> listPermissions(String permissionId) throws DBWebException {
|
||||
public boolean grantUserRole(@NotNull WebSession webSession, String user, String role) throws DBWebException {
|
||||
throw new DBWebException("Feature not supported");
|
||||
}
|
||||
|
||||
@Override
|
||||
public AdminUserInfo createUser(String userName) throws DBWebException {
|
||||
public boolean revokeUserRole(@NotNull WebSession webSession, String user, String role) throws DBWebException {
|
||||
throw new DBWebException("Feature not supported");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteUser(String userName) throws DBWebException {
|
||||
throw new DBWebException("Feature not supported");
|
||||
}
|
||||
|
||||
@Override
|
||||
public AdminRoleInfo createRole(String roleName) throws DBWebException {
|
||||
throw new DBWebException("Feature not supported");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteRole(String roleName) throws DBWebException {
|
||||
throw new DBWebException("Feature not supported");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean grantUserRole(String user, String role) throws DBWebException {
|
||||
throw new DBWebException("Feature not supported");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean revokeUserRole(String user, String role) throws DBWebException {
|
||||
throw new DBWebException("Feature not supported");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setRolePermissions(String roleID, String[] permissions) throws DBWebException {
|
||||
public boolean setRolePermissions(@NotNull WebSession webSession, String roleID, String[] permissions) throws DBWebException {
|
||||
throw new DBWebException("Feature not supported");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user