mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-11-16 07:10:48 +00:00
bug4811: added ownership info to SSH key pairs; added action column with ownership actions; added ownership columns
This commit is contained in:
1 parent
fd217b4dbf
commit
e59cbe92f3
6 files changed
+90
-8
No files matched your search
+1
-1
@@ -326,7 +326,7 @@ public class CompetitorTableWrapper<S extends RefreshableSelectionModel<Competit
|
||||
registerSelectionModelOnNewDataProvider(filterField.getAllListDataProvider());
|
||||
// CompetitorTableEditFeatures
|
||||
final HasPermissions type = SecuredDomainType.COMPETITOR;
|
||||
AccessControlledActionsColumn<CompetitorDTO, CompetitorConfigImagesBarCell> competitorActionColumn = create(
|
||||
final AccessControlledActionsColumn<CompetitorDTO, CompetitorConfigImagesBarCell> competitorActionColumn = create(
|
||||
new CompetitorConfigImagesBarCell(getStringMessages()), userService);
|
||||
competitorActionColumn.addAction(CompetitorConfigImagesBarCell.ACTION_UPDATE, HasPermissions.DefaultActions.UPDATE, this::editCompetitor);
|
||||
competitorActionColumn.addAction(CompetitorConfigImagesBarCell.ACTION_REFRESH, this::allowUpdate);
|
||||
|
||||
+37
-5
@@ -1,5 +1,8 @@
|
||||
package com.sap.sailing.landscape.ui.client;
|
||||
|
||||
import static com.sap.sse.security.shared.HasPermissions.DefaultActions.CHANGE_OWNERSHIP;
|
||||
import static com.sap.sse.security.ui.client.component.AccessControlledActionsColumn.create;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Optional;
|
||||
@@ -20,16 +23,18 @@ import com.sap.sse.gwt.client.controls.busyindicator.BusyIndicator;
|
||||
import com.sap.sse.gwt.client.controls.busyindicator.SimpleBusyIndicator;
|
||||
import com.sap.sse.gwt.client.dialog.DataEntryDialog.DialogCallback;
|
||||
import com.sap.sse.landscape.common.SecuredLandscapeTypes;
|
||||
import com.sap.sse.security.shared.HasPermissions.DefaultActions;
|
||||
import com.sap.sse.security.ui.client.UserService;
|
||||
import com.sap.sse.security.ui.client.component.AccessControlledActionsColumn;
|
||||
import com.sap.sse.security.ui.client.component.AccessControlledButtonPanel;
|
||||
import com.sap.sse.security.ui.client.component.EditOwnershipDialog;
|
||||
import com.sap.sse.security.ui.client.component.SecuredDTOOwnerColumn;
|
||||
import com.sap.sse.security.ui.client.component.EditOwnershipDialog.DialogConfig;
|
||||
import com.sap.sse.security.ui.client.component.editacl.EditACLDialog;
|
||||
|
||||
/**
|
||||
* A panel with a table that allows the user to manage a set of SSH key pairs for the landscape.
|
||||
*
|
||||
* TODO add ownership columns
|
||||
* TODO add action column with remove, change ownership and edit ACL actions
|
||||
* TODO add filter based on can UPDATE check
|
||||
*
|
||||
* @author Axel Uhl (D043530)
|
||||
*
|
||||
*/
|
||||
@@ -71,7 +76,8 @@ public class SshKeyManagementPanel extends VerticalPanel {
|
||||
return (t.getRegionId() == null ? 0 : t.getRegionId().hashCode()) ^
|
||||
(t.getName() == null ? 0 : t.getName().hashCode());
|
||||
}
|
||||
}), tableResources, Optional.empty(), /* filter label */ Optional.empty(), /* filter checkbox label */ null) {
|
||||
}), tableResources, Optional.of(sshKey -> userService.hasPermission(sshKey, DefaultActions.UPDATE)),
|
||||
/* filter label */ Optional.empty(), /* filter checkbox label */ stringMessages.hideElementsWithoutUpdateRights()) {
|
||||
@Override
|
||||
protected Iterable<String> getSearchableStrings(SSHKeyPairDTO t) {
|
||||
return Arrays.asList(t.getName(), t.getRegionId(), t.getCreatorName());
|
||||
@@ -81,6 +87,32 @@ public class SshKeyManagementPanel extends VerticalPanel {
|
||||
sshKeyTable.addColumn(object->object.getName(), stringMessages.name());
|
||||
sshKeyTable.addColumn(object->object.getCreatorName(), stringMessages.creator());
|
||||
sshKeyTable.addColumn(object->object.getCreationTime().toString(), stringMessages.creationTime());
|
||||
SecuredDTOOwnerColumn.configureOwnerColumns(sshKeyTable.getTable(), sshKeyTable.getColumnSortHandler(), stringMessages);
|
||||
final AccessControlledActionsColumn<SSHKeyPairDTO, SshKeyPairImagesBarCell> sshKeyPairActionColumn = create(
|
||||
new SshKeyPairImagesBarCell(stringMessages), userService);
|
||||
final DialogConfig<SSHKeyPairDTO> editOwnerShipDialog = EditOwnershipDialog.create(userService.getUserManagementWriteService(), SecuredLandscapeTypes.SSH_KEY,
|
||||
competitorDTO -> sshKeyTable.refresh(), stringMessages);
|
||||
sshKeyPairActionColumn.addAction(SshKeyPairImagesBarCell.ACTION_CHANGE_OWNERSHIP, CHANGE_OWNERSHIP,
|
||||
editOwnerShipDialog::openOwnershipDialog);
|
||||
final EditACLDialog.DialogConfig<SSHKeyPairDTO> configACL = EditACLDialog
|
||||
.create(userService.getUserManagementWriteService(), SecuredLandscapeTypes.SSH_KEY, null, stringMessages);
|
||||
sshKeyPairActionColumn.addAction(SshKeyPairImagesBarCell.ACTION_CHANGE_ACL, DefaultActions.CHANGE_ACL,
|
||||
configACL::openDialog);
|
||||
sshKeyPairActionColumn.addAction(SshKeyPairImagesBarCell.ACTION_REMOVE, DefaultActions.DELETE,
|
||||
sshKeyPairDTO->landscapeManagementService.removeSshKey(awsAccessKeyProvider.getAwsAccessKeyId(), awsAccessKeyProvider.getAwsSecret(),
|
||||
sshKeyPairDTO, new AsyncCallback<Void>() {
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
errorReporter.reportError(caught.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(Void result) {
|
||||
sshKeyTable.remove(sshKeyPairDTO);
|
||||
}
|
||||
|
||||
}));
|
||||
sshKeyTable.addColumn(sshKeyPairActionColumn);
|
||||
add(sshKeyTable);
|
||||
sshKeyLoadingBusy = new SimpleBusyIndicator();
|
||||
add(sshKeyLoadingBusy);
|
||||
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
package com.sap.sailing.landscape.ui.client;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import com.google.gwt.text.shared.SafeHtmlRenderer;
|
||||
import com.sap.sailing.landscape.ui.client.i18n.StringMessages;
|
||||
import com.sap.sse.gwt.client.IconResources;
|
||||
import com.sap.sse.gwt.client.celltable.ImagesBarCell;
|
||||
import com.sap.sse.security.shared.HasPermissions.DefaultActions;
|
||||
|
||||
public class SshKeyPairImagesBarCell extends ImagesBarCell {
|
||||
static final String ACTION_REMOVE = "ACTION_REMOVE";
|
||||
public static final String ACTION_CHANGE_OWNERSHIP = DefaultActions.CHANGE_OWNERSHIP.name();
|
||||
public static final String ACTION_CHANGE_ACL = DefaultActions.CHANGE_ACL.name();
|
||||
|
||||
private final StringMessages stringMessages;
|
||||
|
||||
public SshKeyPairImagesBarCell(StringMessages stringMessages) {
|
||||
super();
|
||||
this.stringMessages = stringMessages;
|
||||
}
|
||||
|
||||
public SshKeyPairImagesBarCell(SafeHtmlRenderer<String> renderer, StringMessages stringMessages) {
|
||||
super();
|
||||
this.stringMessages = stringMessages;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Iterable<ImageSpec> getImageSpecs() {
|
||||
return Arrays.asList(
|
||||
new ImageSpec(ACTION_REMOVE, stringMessages.remove(),
|
||||
IconResources.INSTANCE.removeIcon()),
|
||||
new ImageSpec(ACTION_CHANGE_OWNERSHIP, stringMessages.actionChangeOwnership(),
|
||||
IconResources.INSTANCE.changeOwnershipIcon()),
|
||||
new ImageSpec(ACTION_CHANGE_ACL, stringMessages.actionChangeACL(),
|
||||
IconResources.INSTANCE.changeACLIcon()));
|
||||
}
|
||||
}
|
||||
+4
-2
@@ -128,8 +128,10 @@ public class LandscapeManagementWriteServiceImpl extends ResultCachingProxiedRem
|
||||
final AwsRegion region = new AwsRegion(regionId);
|
||||
for (final KeyPairInfo keyPairInfo : landscape.getAllKeyPairInfos(region)) {
|
||||
final SSHKeyPair key = landscape.getSSHKeyPair(region, keyPairInfo.keyName());
|
||||
if (key != null && SecurityUtils.getSubject().isPermitted(key.getPermissionType().getStringPermission(DefaultActions.READ))) {
|
||||
result.add(new SSHKeyPairDTO(key.getRegionId(), key.getName(), key.getCreatorName(), key.getCreationTime()));
|
||||
if (key != null && SecurityUtils.getSubject().isPermitted(key.getIdentifier().getStringPermission(DefaultActions.READ))) {
|
||||
final SSHKeyPairDTO sshKeyPairDTO = new SSHKeyPairDTO(key.getRegionId(), key.getName(), key.getCreatorName(), key.getCreationTime());
|
||||
SecurityDTOUtil.addSecurityInformation(getSecurityService(), sshKeyPairDTO);
|
||||
result.add(sshKeyPairDTO);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
||||
@@ -225,4 +225,9 @@ public abstract class TableWrapper<T, S extends RefreshableSelectionModel<T>, SM
|
||||
return selectionModel.getSelectedSet() != null && selectionModel.getSelectedSet().size() == 1 ?
|
||||
selectionModel.getSelectedSet().iterator().next() : null;
|
||||
}
|
||||
|
||||
public void refresh() {
|
||||
// TODO Implement TableWrapper.refresh(...)
|
||||
|
||||
}
|
||||
}
|
||||
@@ -96,6 +96,11 @@ extends TableWrapper<T, S, SM, TR> {
|
||||
public void refresh(Iterable<T> newItems) {
|
||||
getFilterPanel().updateAll(newItems);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void refresh() {
|
||||
getFilterPanel().filter();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void add(T t) {
|
||||
|
||||
Reference in new issue
Block a user