use of org.apache.http.client.utils.URIBuilder in project helios by spotify.
the class HeliosClient method uri.
private URI uri(final String path, final Multimap<String, String> query) {
checkArgument(path.startsWith("/"));
final URIBuilder builder = new URIBuilder().setScheme("http").setHost("helios").setPath(path);
for (final Map.Entry<String, String> q : query.entries()) {
builder.addParameter(q.getKey(), q.getValue());
}
builder.addParameter("user", user);
try {
return builder.build();
} catch (URISyntaxException e) {
throw Throwables.propagate(e);
}
}
use of org.apache.http.client.utils.URIBuilder in project cas by apereo.
the class BaseSamlRegisteredServiceAttributeReleasePolicy method getAttributesInternal.
@Override
protected Map<String, Object> getAttributesInternal(final Map<String, Object> attrs, final RegisteredService service) {
if (service instanceof SamlRegisteredService) {
final SamlRegisteredService saml = (SamlRegisteredService) service;
final HttpServletRequest request = WebUtils.getHttpServletRequestFromRequestAttributes();
if (request == null) {
LOGGER.warn("Could not locate the request context to process attributes");
return super.getAttributesInternal(attrs, service);
}
String entityId = request.getParameter(SamlProtocolConstants.PARAMETER_ENTITY_ID);
if (StringUtils.isBlank(entityId)) {
final String svcParam = request.getParameter(CasProtocolConstants.PARAMETER_SERVICE);
if (StringUtils.isNotBlank(svcParam)) {
try {
final URIBuilder builder = new URIBuilder(svcParam);
entityId = builder.getQueryParams().stream().filter(p -> p.getName().equals(SamlProtocolConstants.PARAMETER_ENTITY_ID)).map(NameValuePair::getValue).findFirst().orElse(StringUtils.EMPTY);
} catch (final Exception e) {
LOGGER.error(e.getMessage());
}
}
}
final ApplicationContext ctx = ApplicationContextProvider.getApplicationContext();
if (ctx == null) {
LOGGER.warn("Could not locate the application context to process attributes");
return super.getAttributesInternal(attrs, service);
}
final SamlRegisteredServiceCachingMetadataResolver resolver = ctx.getBean("defaultSamlRegisteredServiceCachingMetadataResolver", SamlRegisteredServiceCachingMetadataResolver.class);
final Optional<SamlRegisteredServiceServiceProviderMetadataFacade> facade = SamlRegisteredServiceServiceProviderMetadataFacade.get(resolver, saml, entityId);
if (facade == null || !facade.isPresent()) {
LOGGER.warn("Could not locate metadata for [{}] to process attributes", entityId);
return super.getAttributesInternal(attrs, service);
}
final EntityDescriptor input = facade.get().getEntityDescriptor();
if (input == null) {
LOGGER.warn("Could not locate entity descriptor for [{}] to process attributes", entityId);
return super.getAttributesInternal(attrs, service);
}
return getAttributesForSamlRegisteredService(attrs, saml, ctx, resolver, facade.get(), input);
}
return super.getAttributesInternal(attrs, service);
}
use of org.apache.http.client.utils.URIBuilder in project cas by apereo.
the class WSFederationAuthenticationServiceSelectionStrategy method getRealmAsParameter.
private static Optional<NameValuePair> getRealmAsParameter(final Service service) {
try {
final URIBuilder builder = new URIBuilder(service.getId());
final Optional param = builder.getQueryParams().stream().filter(p -> p.getName().equals(WSFederationConstants.WTREALM)).findFirst();
return param;
} 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 WSFederationAuthenticationServiceSelectionStrategy method getReplyAsParameter.
private static Optional<NameValuePair> getReplyAsParameter(final Service service) {
try {
final URIBuilder builder = new URIBuilder(service.getId());
final Optional param = builder.getQueryParams().stream().filter(p -> p.getName().equals(WSFederationConstants.WREPLY)).findFirst();
return param;
} catch (final Exception e) {
LOGGER.error(e.getMessage(), e);
}
return Optional.empty();
}
use of org.apache.http.client.utils.URIBuilder in project musiccabinet by hakko.
the class AbstractMusicBrainzClient method getURI.
protected URI getURI(String path, List<NameValuePair> params) throws ApplicationException {
URI uri = null;
try {
URIBuilder uriBuilder = new URIBuilder();
uriBuilder.setScheme(HTTP);
uriBuilder.setHost(HOST);
uriBuilder.setPath(path);
for (NameValuePair param : params) {
uriBuilder.addParameter(param.getName(), param.getValue());
}
uri = uriBuilder.build();
} catch (URISyntaxException e) {
throw new ApplicationException("Could not create MusicBrainz URI!", e);
}
return uri;
}
Aggregations