use of ddf.action.impl.ActionImpl in project ddf by codice.
the class IdpLogoutActionProvider method getAction.
/**
* *
*
* @param <T> is a Map<String, Subject>
* @param subjectMap containing the corresponding subject
* @return IdpLogoutActionProvider containing the logout url
*/
@Override
public <T> Action getAction(T subjectMap) {
if (!canHandle(subjectMap)) {
return null;
}
String logoutUrlString = "";
URL logoutUrl = null;
try {
@SuppressWarnings("unchecked") Object subject = ((Map) subjectMap).get(SecurityConstants.SECURITY_SUBJECT);
String nameId = subjectOperations.getName((Subject) subject, "You", true);
String nameIdTimestamp = nameId + "\n" + System.currentTimeMillis();
nameIdTimestamp = URLEncoder.encode(encryptionService.encrypt(nameIdTimestamp), StandardCharsets.UTF_8.name());
logoutUrlString = SystemBaseUrl.EXTERNAL.constructUrl("/saml/logout/request?EncryptedNameIdTime=" + nameIdTimestamp, true);
logoutUrl = new URL(logoutUrlString);
} catch (MalformedURLException e) {
LOGGER.info("Unable to resolve URL: {}", LogSanitizer.sanitize(logoutUrlString));
} catch (ClassCastException e) {
LOGGER.debug("Unable to cast parameter to Map<String, Object>, {}", LogSanitizer.sanitize(subjectMap), e);
} catch (UnsupportedEncodingException e) {
LOGGER.debug("Unable to encode the encrypted timestamp.", e);
}
return new ActionImpl(ID, TITLE, DESCRIPTION, logoutUrl);
}
use of ddf.action.impl.ActionImpl in project ddf by codice.
the class OverlayActionProvider method getAction.
@Override
public <T> Action getAction(T subject) {
if (canHandle(subject)) {
final Metacard metacard = (Metacard) subject;
try {
final String sourceId = URLEncoder.encode(metacard.getSourceId(), UTF_8);
final String metacardId = URLEncoder.encode(metacard.getId(), UTF_8);
final String encodedTransformerId = URLEncoder.encode(transformerId, UTF_8);
final URI uri = new URI(SystemBaseUrl.EXTERNAL.constructUrl("/catalog/sources/" + sourceId + "/" + metacardId + "?transform=" + encodedTransformerId, true));
final String overlayName = transformerId.substring(OVERLAY_PREFIX.length());
return new ActionImpl(ID + transformerId, TITLE + overlayName + " overlay", DESCRIPTION + overlayName + " overlay transformer", uri.toURL());
} catch (URISyntaxException | MalformedURLException | UnsupportedEncodingException e) {
LOGGER.debug("Error constructing URL", e);
}
} else {
LOGGER.debug("Cannot handle the input [{}]", subject);
}
return null;
}
use of ddf.action.impl.ActionImpl in project ddf by codice.
the class DerivedContentActionProviderTest method testGetActionsNonContentUriDefault.
@Test
public void testGetActionsNonContentUriDefault() throws Exception {
ActionImpl expectedAction = new ActionImpl("expected", "expected", "expected", actionUri.toURL());
when(mockResourceActionProvider.getAction(any(Metacard.class))).thenReturn(expectedAction);
when(attribute.getValues()).thenReturn(Arrays.asList(EXAMPLE_URL));
List<Action> actions = actionProvider.getActions(metacard);
assertThat(actions, hasSize(1));
assertThat(actions.get(0), notNullValue());
assertThat(actions.get(0).getUrl(), notNullValue());
assertThat(actions.get(0).getUrl(), is(new URL(EXAMPLE_URL)));
}
use of ddf.action.impl.ActionImpl in project ddf by codice.
the class RegistryPublicationActionProvider method getAction.
private Action getAction(String regId, String destinationId, String destinationName, boolean publish) {
URL url;
String title = publish ? PUBLISH_TITLE + destinationName : UNPUBLISH_TITLE + destinationName;
String description = publish ? PUBLISH_DESCRIPTION + destinationName : UNPUBLISH_DESCRIPTION + destinationName;
String operation = publish ? PUBLISH_OPERATION : UNPUBLISH_OPERATION;
String httpOp = publish ? HTTP_POST : HTTP_DELETE;
try {
String path = String.format("%s/%s/%s/%s", REGISTRY_PATH, regId, PUBLICATION_PATH, URLEncoder.encode(destinationId, "UTF-8"));
URI uri = new URI(SystemBaseUrl.constructUrl(path, true));
url = uri.toURL();
} catch (MalformedURLException | URISyntaxException | UnsupportedEncodingException e) {
LOGGER.debug("Malformed URL exception", e);
return null;
}
String id = String.format("%s.%s.%s", getId(), operation, httpOp);
return new ActionImpl(id, title, description, url);
}
use of ddf.action.impl.ActionImpl in project ddf by codice.
the class RegistryReportActionProvider method getAction.
private Action getAction(String metacardId, String sourceId) {
if (StringUtils.isNotBlank(sourceId)) {
sourceId = SOURCE_ID_QUERY_PARAM + sourceId;
}
URL url;
try {
URI uri = new URI(SystemBaseUrl.constructUrl(String.format("%s/%s%s%s%s", REGISTRY_PATH, metacardId, REPORT_PATH, FORMAT, sourceId), true));
url = uri.toURL();
} catch (MalformedURLException e) {
LOGGER.debug("Malformed URL exception", e);
return null;
} catch (URISyntaxException e) {
LOGGER.debug("URI Syntax exception", e);
return null;
}
return new ActionImpl(getId(), title, description, url);
}
Aggregations