use of ddf.action.Action in project ddf by codice.
the class TestMetacardTransformerActionProvider method createMetacardAction.
@Test
public void createMetacardAction() throws MalformedURLException {
Action action = actionProvider.getAction(metacard);
assertThat(action.getId(), is(ACTION_PROVIDER_ID));
assertThat(action.getTitle(), is("Export as " + SAMPLE_TRANSFORMER_ID));
assertThat(action.getDescription(), is("Provides a URL to the metacard that transforms the return value via the " + SAMPLE_TRANSFORMER_ID + " transformer"));
assertThat(action.getUrl(), is(actionUrl));
}
use of ddf.action.Action in project ddf by codice.
the class TestViewMetacardActionProvider method createMetacardAction.
@Test
public void createMetacardAction() throws MalformedURLException {
Action action = actionProvider.getAction(metacard);
assertThat(action.getId(), is(ACTION_PROVIDER_ID));
assertThat(action.getTitle(), is("Export Metacard XML"));
assertThat(action.getDescription(), is("Provides a URL to the metacard"));
assertThat(action.getUrl(), is(actionUrl));
}
use of ddf.action.Action in project ddf by codice.
the class LogoutService method getActionProviders.
@GET
@Path("/actions")
public Response getActionProviders(@Context HttpServletRequest request) throws SecurityServiceException {
HttpSession session = httpSessionFactory.getOrCreateSession(request);
Map<String, SecurityToken> realmTokenMap = ((SecurityTokenHolder) session.getAttribute(SecurityConstants.SAML_ASSERTION)).getRealmTokenMap();
Map<String, Subject> realmSubjectMap = new HashMap<>();
for (Map.Entry<String, SecurityToken> entry : realmTokenMap.entrySet()) {
realmSubjectMap.put(entry.getKey(), securityManager.getSubject(entry.getValue()));
}
List<Map<String, String>> realmToPropMaps = new ArrayList<>();
for (ActionProvider actionProvider : logoutActionProviders) {
Action action = actionProvider.getAction(realmSubjectMap);
if (action != null) {
String realm = StringUtils.substringAfterLast(action.getId(), ".");
//if the user is logged in and isn't a guest, add them
if (realmTokenMap.get(realm) != null) {
Map<String, String> actionProperties = new HashMap<>();
String displayName = SubjectUtils.getName(realmSubjectMap.get(realm), "", true);
if (displayName != null && !displayName.equals(SubjectUtils.GUEST_DISPLAY_NAME)) {
actionProperties.put("title", action.getTitle());
actionProperties.put("realm", realm);
actionProperties.put("auth", displayName);
actionProperties.put("description", action.getDescription());
actionProperties.put("url", action.getUrl().toString());
realmToPropMaps.add(actionProperties);
}
}
}
}
return Response.ok(new ByteArrayInputStream(toJson(realmToPropMaps).getBytes(StandardCharsets.UTF_8))).build();
}
use of ddf.action.Action in project ddf by codice.
the class TestLogoutService method testLogout.
@Test
public void testLogout() throws IOException, ParseException, SecurityServiceException {
KarafLogoutAction karafLogoutActionProvider = new KarafLogoutAction();
LdapLogoutAction ldapLogoutActionProvider = new LdapLogoutAction();
Action karafLogoutAction = karafLogoutActionProvider.getAction(null);
Action ldapLogoutAction = ldapLogoutActionProvider.getAction(null);
LogoutService logoutService = new LogoutService();
logoutService.setHttpSessionFactory(sessionFactory);
logoutService.setSecurityManager(sm);
logoutService.setLogoutActionProviders(Arrays.asList(karafLogoutActionProvider, ldapLogoutActionProvider));
String responseMessage = IOUtils.toString((ByteArrayInputStream) logoutService.getActionProviders(null).getEntity());
JSONArray actionProperties = (JSONArray) new JSONParser().parse(responseMessage);
assertEquals(2, actionProperties.size());
JSONObject karafActionProperty = ((JSONObject) actionProperties.get(0));
assertEquals(karafActionProperty.get("description"), karafLogoutAction.getDescription());
assertEquals(karafActionProperty.get("realm"), karafLogoutAction.getId().substring(karafLogoutAction.getId().lastIndexOf(".") + 1));
assertEquals(karafActionProperty.get("title"), karafLogoutAction.getTitle());
assertEquals(karafActionProperty.get("url"), karafLogoutAction.getUrl().toString());
JSONObject ldapActionProperty = ((JSONObject) actionProperties.get(1));
assertEquals(ldapActionProperty.get("description"), ldapLogoutAction.getDescription());
assertEquals(ldapActionProperty.get("realm"), ldapLogoutAction.getId().substring(ldapLogoutAction.getId().lastIndexOf(".") + 1));
assertEquals(ldapActionProperty.get("title"), ldapLogoutAction.getTitle());
assertEquals(ldapActionProperty.get("url"), ldapLogoutAction.getUrl().toString());
}
use of ddf.action.Action in project ddf by codice.
the class AdminPollerTest method testAllSourceInfo.
@Test
public void testAllSourceInfo() {
Action operatorActionOne = getTestAction("operationIdOne", "operationTitle1", "operationDescription1", "https://localhost:8993/provider/someAction");
Action operatorActionTwo = getTestAction("operationIdTwo", "operationTitleTwo", "operationDescriptionTwo", "https://localhost:8993/provider/someAction");
ImmutableList<MultiActionProvider> operationActions = ImmutableList.of(getHandleableTestActionProvider(operatorActionOne), getNotHandleableTestActionProvider(), getHandleableTestActionProvider(operatorActionTwo));
poller.setOperationActionProviders(operationActions);
Action reportActionOne = getTestAction("reportId", "reportTitle", "reportDescription", "https://localhost:8993/provider/someAction");
ImmutableList<MultiActionProvider> reportActions = ImmutableList.of(getHandleableTestActionProvider(reportActionOne), getNotHandleableTestActionProvider(), getNotHandleableTestActionProvider());
poller.setReportActionProviders(reportActions);
List<Map<String, Object>> sources = poller.allSourceInfo();
assertThat(sources, notNullValue());
assertThat(sources.size(), is(2));
assertThat(sources.get(0), not(hasKey("configurations")));
assertThat(sources.get(1), hasKey("configurations"));
List<Map<String, Object>> configurations = (List) sources.get(1).get("configurations");
assertThat(configurations, hasSize(1));
Map<String, Object> configurationMap = configurations.get(0);
assertThat(configurationMap, hasKey("operation_actions"));
assertThat(configurationMap, hasKey("report_actions"));
List<Map<String, Object>> operationActionsList = (List) configurationMap.get("operation_actions");
Map<String, String> operatorActionOneMap = getMapFromAction(operatorActionOne);
Map<String, String> operatorActionTwoMap = getMapFromAction(operatorActionTwo);
assertThat(operationActionsList, contains(operatorActionOneMap, operatorActionTwoMap));
List<Map<String, Object>> reportActionsList = (List) configurationMap.get("report_actions");
Map<String, String> reportActionMap = getMapFromAction(reportActionOne);
assertThat(reportActionsList, contains(reportActionMap));
}
Aggregations