mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-09-24 06:28:41 +00:00
making more adjustments, accounting for removal of some DTO types
Change-Id: Id841e1de6aeb50c45672dd30d2847935eb654acd
This commit is contained in:
+2
-2
@@ -109,7 +109,7 @@ import com.sap.sse.common.impl.MillisecondsTimePoint;
|
||||
import com.sap.sse.common.util.RoundingUtil;
|
||||
import com.sap.sse.datamining.shared.impl.PredefinedQueryIdentifier;
|
||||
import com.sap.sse.security.SecurityService;
|
||||
import com.sap.sse.security.shared.SecurityUser;
|
||||
import com.sap.sse.security.shared.User;
|
||||
|
||||
@Path("/v1/regattas")
|
||||
public class RegattasResource extends AbstractSailingServerResource {
|
||||
@@ -327,7 +327,7 @@ public class RegattasResource extends AbstractSailingServerResource {
|
||||
} else if (boatClassName == null) {
|
||||
response = getBadBoatClassResponse(boatClassName);
|
||||
} else {
|
||||
final SecurityUser user = getService(SecurityService.class).getCurrentUser();
|
||||
final User user = getService(SecurityService.class).getCurrentUser();
|
||||
final Competitor competitor = getService().getCompetitorStore().getOrCreateCompetitor(UUID.randomUUID(),
|
||||
user.getFullName() == null ? user.getName() : user.getFullName(),
|
||||
/* displayColor */ null, user.getEmail(), /* flagImageURI */ null,
|
||||
|
||||
@@ -37,7 +37,8 @@ Require-Bundle: com.sap.sailing.domain,
|
||||
org.apache.shiro.web;bundle-version="1.2.2",
|
||||
org.apache.shiro.core;bundle-version="1.2.2",
|
||||
javax.servlet;bundle-version="3.1.0",
|
||||
com.sap.sse.mail
|
||||
com.sap.sse.mail,
|
||||
com.sap.sse.security.common
|
||||
Bundle-ClassPath: .
|
||||
Export-Package: com.sap.sailing.server,
|
||||
com.sap.sailing.server.impl;
|
||||
|
||||
+2
-2
@@ -18,7 +18,7 @@ import com.sap.sse.mail.SerializableImageMimeBodyPartSupplier;
|
||||
import com.sap.sse.mail.SerializableMultipartSupplier;
|
||||
import com.sap.sse.mail.queue.MailNotification;
|
||||
import com.sap.sse.security.PreferenceObjectBasedNotificationSet;
|
||||
import com.sap.sse.security.UserImpl;
|
||||
import com.sap.sse.security.shared.User;
|
||||
|
||||
public abstract class NotificationSetNotification<T> implements MailNotification {
|
||||
private static final Logger logger = Logger.getLogger(NotificationSetNotification.class.getName());
|
||||
@@ -89,7 +89,7 @@ public abstract class NotificationSetNotification<T> implements MailNotification
|
||||
});
|
||||
}
|
||||
|
||||
private String getMailContent(NotificationMailTemplate notificationMailTemplate, UserImpl user, Locale locale) {
|
||||
private String getMailContent(NotificationMailTemplate notificationMailTemplate, User user, Locale locale) {
|
||||
StringBuilder bodyContent = new StringBuilder();
|
||||
if (notificationMailTemplate.getTitle() != null) {
|
||||
bodyContent.append("<h1>")
|
||||
|
||||
+3
-2
@@ -2,8 +2,9 @@ package com.sap.sse.security.ui.authentication.app;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.sap.sse.security.shared.Role;
|
||||
import com.sap.sse.security.shared.WildcardPermission;
|
||||
import com.sap.sse.security.ui.shared.AccountDTO;
|
||||
import com.sap.sse.security.ui.shared.RolePermissionModelDTO;
|
||||
import com.sap.sse.security.ui.shared.UserDTO;
|
||||
@@ -15,7 +16,7 @@ public class AuthenticationContextImpl implements AuthenticationContext {
|
||||
|
||||
private final UserDTO currentUser;
|
||||
private final static UserDTO ANONYMOUS = new UserDTO("Anonymous", "", "", "", null, false, new ArrayList<AccountDTO>(),
|
||||
new ArrayList<UUID>(), new RolePermissionModelDTO(new HashMap<>()), null, new ArrayList<String>());
|
||||
new ArrayList<Role>(), new RolePermissionModelDTO(new HashMap<>()), /* default tenant */ null, new ArrayList<WildcardPermission>());
|
||||
|
||||
/**
|
||||
* Creating an {@link AuthenticationContextImpl} containing an anonymous {@link UserDTO} object.
|
||||
|
||||
+4
-4
@@ -12,8 +12,8 @@ import com.sap.sse.security.shared.AccessControlList;
|
||||
import com.sap.sse.security.shared.Tenant;
|
||||
import com.sap.sse.security.shared.TenantManagementException;
|
||||
import com.sap.sse.security.shared.UnauthorizedException;
|
||||
import com.sap.sse.security.shared.UserGroup;
|
||||
import com.sap.sse.security.shared.UserManagementException;
|
||||
import com.sap.sse.security.shared.WildcardPermission;
|
||||
import com.sap.sse.security.ui.oauth.client.CredentialDTO;
|
||||
import com.sap.sse.security.ui.oauth.shared.OAuthException;
|
||||
import com.sap.sse.security.ui.shared.SuccessInfo;
|
||||
@@ -34,9 +34,9 @@ public interface UserManagementService extends RemoteService {
|
||||
|
||||
Tenant createTenant(String name, String tenantOwner) throws TenantManagementException, UnauthorizedException;
|
||||
|
||||
UserGroup addUserToTenant(String tenantIdAsString, String username) throws UnauthorizedException;
|
||||
void addUserToTenant(String tenantIdAsString, String username) throws UnauthorizedException;
|
||||
|
||||
UserGroup removeUserFromTenant(String tenantIdAsString, String username) throws UnauthorizedException;
|
||||
void removeUserFromTenant(String idAsString, String user) throws UnauthorizedException;
|
||||
|
||||
SuccessInfo deleteTenant(String tenantIdAsString) throws UnauthorizedException;
|
||||
|
||||
@@ -70,7 +70,7 @@ public interface UserManagementService extends RemoteService {
|
||||
|
||||
SuccessInfo setRolesForUser(String username, Iterable<UUID> roles) throws UnauthorizedException;
|
||||
|
||||
SuccessInfo setPermissionsForUser(String username, Iterable<String> permissions) throws UnauthorizedException;
|
||||
SuccessInfo setPermissionsForUser(String username, Iterable<WildcardPermission> permissions) throws UnauthorizedException;
|
||||
|
||||
Map<String, String> getSettings();
|
||||
|
||||
|
||||
+2
-3
@@ -9,7 +9,6 @@ import java.util.UUID;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
import com.sap.sse.security.shared.AccessControlList;
|
||||
import com.sap.sse.security.shared.Tenant;
|
||||
import com.sap.sse.security.shared.UserGroup;
|
||||
import com.sap.sse.security.ui.oauth.client.CredentialDTO;
|
||||
import com.sap.sse.security.ui.shared.SuccessInfo;
|
||||
import com.sap.sse.security.ui.shared.UserDTO;
|
||||
@@ -29,9 +28,9 @@ public interface UserManagementServiceAsync {
|
||||
|
||||
void createTenant(String name, String owner, AsyncCallback<Tenant> callback);
|
||||
|
||||
void addUserToTenant(String tenantIdAsString, String username, AsyncCallback<UserGroup> asyncCallback);
|
||||
void addUserToTenant(String tenantIdAsString, String username, AsyncCallback<Void> asyncCallback);
|
||||
|
||||
void removeUserFromTenant(String idAsString, String user, AsyncCallback<UserGroup> asyncCallback);
|
||||
void removeUserFromTenant(String idAsString, String user, AsyncCallback<Void> asyncCallback);
|
||||
|
||||
void deleteTenant(String name, AsyncCallback<SuccessInfo> callback);
|
||||
|
||||
|
||||
+20
-18
@@ -32,14 +32,15 @@ import com.google.gwt.view.client.Range;
|
||||
import com.google.gwt.view.client.SelectionChangeEvent;
|
||||
import com.google.gwt.view.client.SelectionChangeEvent.Handler;
|
||||
import com.google.gwt.view.client.SingleSelectionModel;
|
||||
import com.sap.sse.security.shared.SecurityUser;
|
||||
import com.sap.sse.security.shared.UserGroup;
|
||||
import com.sap.sse.security.ui.client.UserManagementServiceAsync;
|
||||
import com.sap.sse.security.ui.client.component.TenantListDataProvider.TenantListDataProviderChangeHandler;
|
||||
import com.sap.sse.security.ui.shared.UserDTO;
|
||||
import com.sap.sse.security.ui.shared.UserGroupDTO;
|
||||
|
||||
public class TenantDetailPanel extends HorizontalPanel implements Handler, ChangeHandler, KeyUpHandler, TenantListDataProviderChangeHandler {
|
||||
private final TextBox filterBox;
|
||||
private final SingleSelectionModel<UserGroupDTO> tenantSelectionModel;
|
||||
private final SingleSelectionModel<UserGroup> tenantSelectionModel;
|
||||
|
||||
private final CellList<String> tenantUsersList;
|
||||
private final MultiSelectionModel<String> tenantUsersSelectionModel;
|
||||
@@ -72,16 +73,16 @@ public class TenantDetailPanel extends HorizontalPanel implements Handler, Chang
|
||||
private class TenantUsersListDataProvider extends AbstractDataProvider<String> {
|
||||
@Override
|
||||
protected void onRangeChanged(HasData<String> display) {
|
||||
UserGroupDTO tenant = tenantSelectionModel.getSelectedObject();
|
||||
UserGroup tenant = tenantSelectionModel.getSelectedObject();
|
||||
List<String> result = new ArrayList<>();
|
||||
List<String> show = new ArrayList<>();
|
||||
final Range range = display.getVisibleRange();
|
||||
int start = range.getStart();
|
||||
int end = range.getStart() + range.getLength();
|
||||
if (tenant != null) {
|
||||
for (String username : tenant.getUsers()) {
|
||||
if (username.contains(filterBox.getText())) {
|
||||
result.add(username);
|
||||
for (final SecurityUser user : tenant.getUsers()) {
|
||||
if (user.getName().contains(filterBox.getText())) {
|
||||
result.add(user.getName());
|
||||
}
|
||||
}
|
||||
for (int i = start; i < end && i < result.size(); i++) {
|
||||
@@ -104,13 +105,14 @@ public class TenantDetailPanel extends HorizontalPanel implements Handler, Chang
|
||||
private class AllUsersListDataProvider extends AbstractDataProvider<UserDTO> {
|
||||
@Override
|
||||
protected void onRangeChanged(HasData<UserDTO> display) {
|
||||
UserGroupDTO tenant = tenantSelectionModel.getSelectedObject();
|
||||
final List<String> alreadyAddedUsers = new ArrayList<>();
|
||||
UserGroup tenant = tenantSelectionModel.getSelectedObject();
|
||||
final List<String> namesOfAlreadyAddedUsers = new ArrayList<>();
|
||||
if (tenant != null) {
|
||||
alreadyAddedUsers.addAll(tenant.getUsers());
|
||||
for (final SecurityUser tenantUser : tenant.getUsers()) {
|
||||
namesOfAlreadyAddedUsers.add(tenantUser.getName());
|
||||
}
|
||||
}
|
||||
final Range range = display.getVisibleRange();
|
||||
|
||||
userManagementService.getUserList(new AsyncCallback<Collection<UserDTO>>() {
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
@@ -121,7 +123,7 @@ public class TenantDetailPanel extends HorizontalPanel implements Handler, Chang
|
||||
public void onSuccess(Collection<UserDTO> result) {
|
||||
List<UserDTO> resultList = new ArrayList<>();
|
||||
for (UserDTO user : result) {
|
||||
if (!alreadyAddedUsers.contains(user.getName()) &&
|
||||
if (!namesOfAlreadyAddedUsers.contains(user.getName()) &&
|
||||
user.getName().contains(filterBox.getText())) {
|
||||
resultList.add(user);
|
||||
}
|
||||
@@ -146,7 +148,7 @@ public class TenantDetailPanel extends HorizontalPanel implements Handler, Chang
|
||||
}
|
||||
}
|
||||
|
||||
public TenantDetailPanel(TextBox filterBox, SingleSelectionModel<UserGroupDTO> tenantSelectionModel,
|
||||
public TenantDetailPanel(TextBox filterBox, SingleSelectionModel<UserGroup> tenantSelectionModel,
|
||||
TenantListDataProvider tenantListDataProvider, UserManagementServiceAsync userManagementService) {
|
||||
this.filterBox = filterBox;
|
||||
filterBox.addChangeHandler(this);
|
||||
@@ -191,20 +193,20 @@ public class TenantDetailPanel extends HorizontalPanel implements Handler, Chang
|
||||
addBtn.addClickHandler(new ClickHandler() {
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
UserGroupDTO tenant = tenantSelectionModel.getSelectedObject();
|
||||
UserGroup tenant = tenantSelectionModel.getSelectedObject();
|
||||
Set<UserDTO> users = allUsersSelectionModel.getSelectedSet();
|
||||
if (tenant == null) {
|
||||
Window.alert("You have to select a tenant.");
|
||||
return;
|
||||
}
|
||||
for (UserDTO user : users) {
|
||||
userManagementService.addUserToTenant(tenant.getId().toString(), user.getName(), new AsyncCallback<UserGroupDTO>() {
|
||||
userManagementService.addUserToTenant(tenant.getId().toString(), user.getName(), new AsyncCallback<Void>() {
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
Window.alert("Could not add user " + user.getName() + " to tenant.");
|
||||
}
|
||||
@Override
|
||||
public void onSuccess(UserGroupDTO result) {
|
||||
public void onSuccess(Void result) {
|
||||
tenantListDataProvider.updateDisplays();
|
||||
}
|
||||
});
|
||||
@@ -214,20 +216,20 @@ public class TenantDetailPanel extends HorizontalPanel implements Handler, Chang
|
||||
removeBtn.addClickHandler(new ClickHandler() {
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
UserGroupDTO tenant = tenantSelectionModel.getSelectedObject();
|
||||
UserGroup tenant = tenantSelectionModel.getSelectedObject();
|
||||
Set<String> users = tenantUsersSelectionModel.getSelectedSet();
|
||||
if (tenant == null) {
|
||||
Window.alert("You have to select a tenant.");
|
||||
return;
|
||||
}
|
||||
for (String username : users) {
|
||||
userManagementService.removeUserFromTenant(tenant.getId().toString(), username, new AsyncCallback<UserGroupDTO>() {
|
||||
userManagementService.removeUserFromTenant(tenant.getId().toString(), username, new AsyncCallback<Void>() {
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
Window.alert("Could not remove user " + username + " from tenant.");
|
||||
}
|
||||
@Override
|
||||
public void onSuccess(UserGroupDTO result) {
|
||||
public void onSuccess(Void result) {
|
||||
tenantListDataProvider.updateDisplays();
|
||||
}
|
||||
});
|
||||
|
||||
+10
-10
@@ -14,10 +14,10 @@ import com.google.gwt.user.client.ui.TextBox;
|
||||
import com.google.gwt.view.client.AbstractDataProvider;
|
||||
import com.google.gwt.view.client.HasData;
|
||||
import com.google.gwt.view.client.Range;
|
||||
import com.sap.sse.security.shared.Tenant;
|
||||
import com.sap.sse.security.ui.client.UserManagementServiceAsync;
|
||||
import com.sap.sse.security.ui.shared.TenantDTO;
|
||||
|
||||
public class TenantListDataProvider extends AbstractDataProvider<TenantDTO> {
|
||||
public class TenantListDataProvider extends AbstractDataProvider<Tenant> {
|
||||
private UserManagementServiceAsync userManagementService;
|
||||
private TextBox filterBox;
|
||||
|
||||
@@ -47,27 +47,27 @@ public class TenantListDataProvider extends AbstractDataProvider<TenantDTO> {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onRangeChanged(final HasData<TenantDTO> display) {
|
||||
protected void onRangeChanged(final HasData<Tenant> display) {
|
||||
final Range range = display.getVisibleRange();
|
||||
userManagementService.getTenants(new AsyncCallback<Collection<TenantDTO>>() {
|
||||
userManagementService.getTenants(new AsyncCallback<Collection<Tenant>>() {
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
Window.alert(caught.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(Collection<TenantDTO> result) {
|
||||
List<TenantDTO> resultList = new ArrayList<>();
|
||||
for (TenantDTO tenant : result) {
|
||||
public void onSuccess(Collection<Tenant> result) {
|
||||
List<Tenant> resultList = new ArrayList<>();
|
||||
for (Tenant tenant : result) {
|
||||
if (tenant.getName().contains(filterBox.getText())) {
|
||||
resultList.add(tenant);
|
||||
}
|
||||
}
|
||||
List<TenantDTO> show = new ArrayList<>();
|
||||
List<Tenant> show = new ArrayList<>();
|
||||
int start = range.getStart();
|
||||
int end = range.getStart() + range.getLength();
|
||||
for (int i = start; show.size() < end && i < resultList.size(); i++) {
|
||||
final TenantDTO e = resultList.get(i);
|
||||
final Tenant e = resultList.get(i);
|
||||
show.add(e);
|
||||
}
|
||||
updateRowData(start, show);
|
||||
@@ -80,7 +80,7 @@ public class TenantListDataProvider extends AbstractDataProvider<TenantDTO> {
|
||||
}
|
||||
|
||||
public void updateDisplays() {
|
||||
for (HasData<TenantDTO> hd : getDataDisplays()) {
|
||||
for (HasData<Tenant> hd : getDataDisplays()) {
|
||||
onRangeChanged(hd);
|
||||
}
|
||||
}
|
||||
|
||||
+6
-6
@@ -17,15 +17,15 @@ import com.google.gwt.user.client.ui.ScrollPanel;
|
||||
import com.google.gwt.user.client.ui.TextBox;
|
||||
import com.google.gwt.user.client.ui.VerticalPanel;
|
||||
import com.google.gwt.view.client.SingleSelectionModel;
|
||||
import com.sap.sse.security.shared.Tenant;
|
||||
import com.sap.sse.security.shared.UserGroup;
|
||||
import com.sap.sse.security.ui.client.UserManagementServiceAsync;
|
||||
import com.sap.sse.security.ui.client.UserService;
|
||||
import com.sap.sse.security.ui.client.i18n.StringMessages;
|
||||
import com.sap.sse.security.ui.shared.SuccessInfo;
|
||||
import com.sap.sse.security.ui.shared.TenantDTO;
|
||||
import com.sap.sse.security.ui.shared.UserGroupDTO;
|
||||
|
||||
public class TenantManagementPanel extends DockPanel {
|
||||
private SingleSelectionModel<UserGroupDTO> tenantSingleSelectionModel;
|
||||
private SingleSelectionModel<UserGroup> tenantSingleSelectionModel;
|
||||
private TenantListDataProvider tenantListDataProvider;
|
||||
private TenantDetailPanel tenantDetailPanel;
|
||||
|
||||
@@ -51,7 +51,7 @@ public class TenantManagementPanel extends DockPanel {
|
||||
buttonPanel.add(new Button("Remove tenant", new ClickHandler() {
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
UserGroupDTO tenant = tenantSingleSelectionModel.getSelectedObject();
|
||||
UserGroup tenant = tenantSingleSelectionModel.getSelectedObject();
|
||||
if (tenant == null) {
|
||||
Window.alert("You have to select a tenant.");
|
||||
return;
|
||||
@@ -75,9 +75,9 @@ public class TenantManagementPanel extends DockPanel {
|
||||
tenantSingleSelectionModel = new SingleSelectionModel<>();
|
||||
TextBox filterBox = new TextBox();
|
||||
filterBox.getElement().setPropertyString("placeholder", "Filter tenants...");
|
||||
final CellList<TenantDTO> tenantList = new CellList<TenantDTO>(new AbstractCell<TenantDTO>() {
|
||||
final CellList<Tenant> tenantList = new CellList<Tenant>(new AbstractCell<Tenant>() {
|
||||
@Override
|
||||
public void render(Context context, TenantDTO value, SafeHtmlBuilder sb) {
|
||||
public void render(Context context, Tenant value, SafeHtmlBuilder sb) {
|
||||
if (value == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
+19
-22
@@ -45,6 +45,7 @@ import com.sap.sse.security.shared.Account;
|
||||
import com.sap.sse.security.shared.Account.AccountType;
|
||||
import com.sap.sse.security.shared.Ownership;
|
||||
import com.sap.sse.security.shared.Role;
|
||||
import com.sap.sse.security.shared.RoleImpl;
|
||||
import com.sap.sse.security.shared.SocialUserAccount;
|
||||
import com.sap.sse.security.shared.Tenant;
|
||||
import com.sap.sse.security.shared.TenantManagementException;
|
||||
@@ -54,16 +55,15 @@ import com.sap.sse.security.shared.UserGroup;
|
||||
import com.sap.sse.security.shared.UserGroupManagementException;
|
||||
import com.sap.sse.security.shared.UserManagementException;
|
||||
import com.sap.sse.security.shared.UsernamePasswordAccount;
|
||||
import com.sap.sse.security.shared.WildcardPermission;
|
||||
import com.sap.sse.security.ui.client.UserManagementService;
|
||||
import com.sap.sse.security.ui.oauth.client.CredentialDTO;
|
||||
import com.sap.sse.security.ui.oauth.client.SocialUserDTO;
|
||||
import com.sap.sse.security.ui.oauth.shared.OAuthException;
|
||||
import com.sap.sse.security.ui.shared.AccountDTO;
|
||||
import com.sap.sse.security.ui.shared.RoleDTO;
|
||||
import com.sap.sse.security.ui.shared.RolePermissionModelDTO;
|
||||
import com.sap.sse.security.ui.shared.SuccessInfo;
|
||||
import com.sap.sse.security.ui.shared.UserDTO;
|
||||
import com.sap.sse.security.ui.shared.UserGroupDTO;
|
||||
import com.sap.sse.security.ui.shared.UsernamePasswordAccountDTO;
|
||||
|
||||
public class UserManagementServiceImpl extends RemoteServiceServlet implements UserManagementService {
|
||||
@@ -209,22 +209,22 @@ public class UserManagementServiceImpl extends RemoteServiceServlet implements U
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserGroup addUserToTenant(String tenantIdAsString, String username) throws UnauthorizedException {
|
||||
public void addUserToTenant(String tenantIdAsString, String username) throws UnauthorizedException {
|
||||
if (SecurityUtils.getSubject().isPermitted("tenant:add_user:" + tenantIdAsString)) {
|
||||
return createUserGroupDTOFromUserGroup(getSecurityService().addUserToUserGroup(
|
||||
getSecurityService().getTenant(UUID.fromString(tenantIdAsString)),
|
||||
getSecurityService().getUserByName(username)));
|
||||
final Tenant tenant = getSecurityService().getTenant(UUID.fromString(tenantIdAsString));
|
||||
getSecurityService().addUserToTenant(tenant, getSecurityService().getUserByName(username));
|
||||
createUserGroupDTOFromUserGroup(tenant);
|
||||
} else {
|
||||
throw new UnauthorizedException("Not permitted to add user to tenant");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserGroup removeUserFromTenant(String tenantIdAsString, String username) throws UnauthorizedException {
|
||||
public void removeUserFromTenant(String tenantIdAsString, String username) throws UnauthorizedException {
|
||||
if (SecurityUtils.getSubject().isPermitted("tenant:remove_user:" + tenantIdAsString)) {
|
||||
return createUserGroupDTOFromUserGroup(getSecurityService().removeUserFromUserGroup(
|
||||
getSecurityService().getTenant(UUID.fromString(tenantIdAsString)),
|
||||
getSecurityService().getUserByName(username)));
|
||||
final Tenant tenant = getSecurityService().getTenant(UUID.fromString(tenantIdAsString));
|
||||
getSecurityService().removeUserFromTenant(tenant, getSecurityService().getUserByName(username));
|
||||
createUserGroupDTOFromUserGroup(tenant);
|
||||
} else {
|
||||
throw new UnauthorizedException("Not permitted to remove user from tenant");
|
||||
}
|
||||
@@ -445,22 +445,22 @@ public class UserManagementServiceImpl extends RemoteServiceServlet implements U
|
||||
}
|
||||
|
||||
@Override
|
||||
public SuccessInfo setPermissionsForUser(String username, Iterable<String> permissions) throws UnauthorizedException {
|
||||
public SuccessInfo setPermissionsForUser(String username, Iterable<WildcardPermission> permissions) throws UnauthorizedException {
|
||||
if (SecurityUtils.getSubject().isPermitted("user:grant_permission,revoke_permission:" + username)) {
|
||||
UserImpl u = getSecurityService().getUserByName(username);
|
||||
if (u == null) {
|
||||
return new SuccessInfo(false, "User does not exist.", /* redirectURL */null, null);
|
||||
}
|
||||
Set<String> permissionsToRemove = new HashSet<>();
|
||||
Set<WildcardPermission> permissionsToRemove = new HashSet<>();
|
||||
Util.addAll(u.getPermissions(), permissionsToRemove);
|
||||
Util.removeAll(permissions, permissionsToRemove);
|
||||
for (String permissionToRemove : permissionsToRemove) {
|
||||
for (WildcardPermission permissionToRemove : permissionsToRemove) {
|
||||
getSecurityService().removePermissionFromUser(username, permissionToRemove);
|
||||
}
|
||||
Set<String> permissionsToAdd = new HashSet<>();
|
||||
Set<WildcardPermission> permissionsToAdd = new HashSet<>();
|
||||
Util.addAll(permissions, permissionsToAdd);
|
||||
Util.removeAll(u.getPermissions(), permissionsToAdd);
|
||||
for (String permissionToAdd : permissionsToAdd) {
|
||||
for (WildcardPermission permissionToAdd : permissionsToAdd) {
|
||||
getSecurityService().addPermissionForUser(username, permissionToAdd);
|
||||
}
|
||||
return new SuccessInfo(true, "Set roles " + permissions + " for user " + username, /* redirectURL */null,
|
||||
@@ -486,12 +486,9 @@ public class UserManagementServiceImpl extends RemoteServiceServlet implements U
|
||||
}
|
||||
}
|
||||
|
||||
private RoleDTO createRoleDTOFromRole(Role role) {
|
||||
HashSet<String> stringPermissions = new HashSet<>();
|
||||
for (com.sap.sse.security.shared.WildcardPermission wildcardPermission : role.getPermissions()) {
|
||||
stringPermissions.add(wildcardPermission.toString());
|
||||
}
|
||||
return new RoleDTO((UUID) role.getId(), role.getName(), stringPermissions);
|
||||
private Role createRoleDTOFromRole(Role role) {
|
||||
// TODO strip down the role object graph to what the client needs...
|
||||
return new RoleImpl(role.getId(), role.getName(), role.getPermissions());
|
||||
}
|
||||
|
||||
private UserDTO createUserDTOFromUser(User user) {
|
||||
@@ -510,7 +507,7 @@ public class UserManagementServiceImpl extends RemoteServiceServlet implements U
|
||||
break;
|
||||
}
|
||||
}
|
||||
HashMap<UUID, RoleDTO> roleMap = new HashMap<>();
|
||||
HashMap<UUID, Role> roleMap = new HashMap<>();
|
||||
for (Role role : getSecurityService().getRoles()) {
|
||||
roleMap.put((UUID) role.getId(), createRoleDTOFromRole(role));
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ public class TenantImpl extends UserGroupImpl implements Tenant {
|
||||
super(id, name);
|
||||
}
|
||||
|
||||
public TenantImpl(UUID id, String name, Set<SecurityUser> users) {
|
||||
public TenantImpl(UUID id, String name, Iterable<SecurityUser> users) {
|
||||
super(id, name, users);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user