use of org.apache.http.client.utils.URIBuilder in project sling by apache.
the class HttpTransportUtils method getDeleteUri.
private static URI getDeleteUri(URI uri, String id) throws URISyntaxException {
URIBuilder uriBuilder = new URIBuilder(uri);
uriBuilder.addParameter("operation", "delete");
uriBuilder.addParameter("id", id);
return uriBuilder.build();
}
use of org.apache.http.client.utils.URIBuilder in project sling by apache.
the class RequestUtils method appendDistributionRequest.
public static URI appendDistributionRequest(URI uri, DistributionRequest distributionRequest) throws URISyntaxException {
URIBuilder uriBuilder = new URIBuilder(uri);
uriBuilder.addParameter(DistributionParameter.ACTION.toString(), distributionRequest.getRequestType().name());
String[] paths = distributionRequest.getPaths();
if (paths != null) {
for (String path : paths) {
uriBuilder.addParameter(DistributionParameter.PATH.toString(), path);
}
}
return uriBuilder.build();
}
use of org.apache.http.client.utils.URIBuilder in project sling by apache.
the class AbstractSlingClient method getUrl.
/**
* Creates a full URL for a given path with additional parameters. Same as {@link #getUrl(String)}, but adds the parameters in the URI.
*
* @param path path relative to server url; can start with / but should not include the server context path
* @param parameters url parameters to be added to the url
* @return full url as URI
* @throws IllegalArgumentException if path or parameters cannot be parsed into an URI
* @throws NullPointerException if path is null
*/
public URI getUrl(String path, List<NameValuePair> parameters) {
// add server url and path
URIBuilder uriBuilder = new URIBuilder(getUrl(path));
// add parameters
parameters = (parameters != null) ? parameters : new ArrayList<NameValuePair>(0);
uriBuilder.addParameters(parameters);
try {
return uriBuilder.build();
} catch (URISyntaxException e) {
throw new IllegalArgumentException(e);
}
}
use of org.apache.http.client.utils.URIBuilder in project cas by apereo.
the class ShibbolethIdPEntityIdAuthenticationServiceSelectionStrategy method getEntityIdAsParameter.
/**
* Gets entity id as parameter.
*
* @param service the service
* @return the entity id as parameter
*/
protected static Optional<String> getEntityIdAsParameter(final Service service) {
try {
final URIBuilder builder = new URIBuilder(service.getId());
final Optional<NameValuePair> param = builder.getQueryParams().stream().filter(p -> p.getName().equals(SamlProtocolConstants.PARAMETER_ENTITY_ID)).findFirst();
if (param.isPresent()) {
return Optional.of(param.get().getValue());
}
final HttpServletRequest request = WebUtils.getHttpServletRequestFromExternalWebflowContext();
if (request != null && StringUtils.isNotBlank(request.getQueryString())) {
final String[] query = request.getQueryString().split("&");
final Optional<String> paramRequest = Arrays.stream(query).map(p -> {
final List<String> params = Splitter.on("=").splitToList(p);
return Pair.of(params.get(0), params.get(1));
}).filter(p -> p.getKey().equals(SamlProtocolConstants.PARAMETER_ENTITY_ID)).map(Pair::getValue).findFirst();
return paramRequest;
}
} catch (final Exception e) {
LOGGER.error(e.getMessage(), e);
}
return Optional.empty();
}
use of org.apache.http.client.utils.URIBuilder in project cas by apereo.
the class BaseWSFederationRequestController method constructServiceUrl.
/**
* Construct service url string.
*
* @param request the request
* @param response the response
* @param wsfedRequest the ws federation request
* @return the service url
*/
protected String constructServiceUrl(final HttpServletRequest request, final HttpServletResponse response, final WSFederationRequest wsfedRequest) {
try {
final URIBuilder builder = new URIBuilder(this.callbackService.getId());
builder.addParameter(WSFederationConstants.WA, wsfedRequest.getWa());
builder.addParameter(WSFederationConstants.WREPLY, wsfedRequest.getWreply());
builder.addParameter(WSFederationConstants.WTREALM, wsfedRequest.getWtrealm());
if (StringUtils.isNotBlank(wsfedRequest.getWctx())) {
builder.addParameter(WSFederationConstants.WCTX, wsfedRequest.getWctx());
}
if (StringUtils.isNotBlank(wsfedRequest.getWfresh())) {
builder.addParameter(WSFederationConstants.WREFRESH, wsfedRequest.getWfresh());
}
if (StringUtils.isNotBlank(wsfedRequest.getWhr())) {
builder.addParameter(WSFederationConstants.WHR, wsfedRequest.getWhr());
}
if (StringUtils.isNotBlank(wsfedRequest.getWreq())) {
builder.addParameter(WSFederationConstants.WREQ, wsfedRequest.getWreq());
}
final URI url = builder.build();
LOGGER.trace("Built service callback url [{}]", url);
return org.jasig.cas.client.util.CommonUtils.constructServiceUrl(request, response, url.toString(), casProperties.getServer().getName(), CasProtocolConstants.PARAMETER_SERVICE, CasProtocolConstants.PARAMETER_TICKET, false);
} catch (final Exception e) {
throw new SamlException(e.getMessage(), e);
}
}
Aggregations