use of ddf.security.permission.KeyValuePermission in project ddf by codice.
the class WorkspaceAccessPluginTest method testPermittedWhenOwnerOnUpdatedRoles.
@Test
public void testPermittedWhenOwnerOnUpdatedRoles() throws Exception {
String id = "0";
WorkspaceMetacardImpl before = WorkspaceMetacardImpl.from(ImmutableMap.of(Metacard.ID, id, Core.METACARD_OWNER, "before", WorkspaceAttributes.WORKSPACE_SHARING, ImmutableList.of()));
WorkspaceMetacardImpl after = WorkspaceMetacardImpl.from(ImmutableMap.of(Metacard.ID, id, Core.METACARD_OWNER, "after", WorkspaceAttributes.WORKSPACE_SHARING, ImmutableList.of("<xml/>")));
UpdateRequest update = mockUpdateRequest(ImmutableMap.of(id, after));
ArgumentCaptor<KeyValueCollectionPermission> args = ArgumentCaptor.forClass(KeyValueCollectionPermission.class);
doReturn(true).when(subject).isPermitted(args.capture());
accessPlugin.processPreUpdate(update, ImmutableMap.of(id, before));
KeyValuePermission permission = (KeyValuePermission) args.getValue().getKeyValuePermissionList().get(0);
assertThat(permission.getKey(), is(Constants.EMAIL_ADDRESS_CLAIM_URI));
// NOTE: the permission should contain the owner of the before metacard, not after
assertThat(permission.getValues(), is(ImmutableSet.of(before.getOwner())));
}
use of ddf.security.permission.KeyValuePermission in project ddf by codice.
the class Policy method getAllowedAttributePermissions.
@Override
public CollectionPermission getAllowedAttributePermissions() {
List<KeyValuePermission> perms = new ArrayList<>();
for (ContextAttributeMapping mapping : attributeMappings) {
perms.add(mapping.getAttributePermission());
}
KeyValueCollectionPermission permissions = new KeyValueCollectionPermission(getContextPath());
permissions.addAll(perms);
return permissions;
}
Aggregations