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 blueocean-plugin by jenkinsci.
the class BitbucketServerApi method getBranch.
@Override
@CheckForNull
public BbBranch getBranch(@Nonnull String orgId, @Nonnull String repoSlug, @Nonnull String branch) {
try {
URIBuilder uriBuilder = new URIBuilder(String.format("%s/%s/repos/%s/branches/", baseUrl + "projects", orgId, repoSlug));
uriBuilder.addParameter("filterText", branch);
BbServerPage<BbServerBranch> branches = om.readValue(request.get(uriBuilder.build().toString()).getContent(), new TypeReference<BbServerPage<BbServerBranch>>() {
});
String expectedId = "refs/heads/" + branch;
for (BbServerBranch b : branches.getValues()) {
if (b.getId().equals(expectedId)) {
return b;
}
}
return null;
} catch (IOException | URISyntaxException e) {
throw handleException(e);
}
}
use of org.apache.http.client.utils.URIBuilder in project opennms by OpenNMS.
the class HttpCollector method buildUri.
private static URI buildUri(final HttpCollectorAgent collectorAgent) throws URISyntaxException {
HashMap<String, String> substitutions = new HashMap<String, String>();
substitutions.put("ipaddr", InetAddressUtils.str(collectorAgent.getAgent().getAddress()));
substitutions.put("nodeid", Integer.toString(collectorAgent.getAgent().getNodeId()));
final URIBuilder ub = new URIBuilder();
ub.setScheme(collectorAgent.getUriDef().getUrl().getScheme());
ub.setHost(substituteKeywords(substitutions, collectorAgent.getUriDef().getUrl().getHost(), "getHost"));
ub.setPort(collectorAgent.getPort());
ub.setPath(substituteKeywords(substitutions, collectorAgent.getUriDef().getUrl().getPath(), "getURL"));
final String query = substituteKeywords(substitutions, collectorAgent.getUriDef().getUrl().getQuery().orElse(null), "getQuery");
if (query != null) {
final List<NameValuePair> params = URLEncodedUtils.parse(query, StandardCharsets.UTF_8);
ub.setParameters(params);
}
ub.setFragment(substituteKeywords(substitutions, collectorAgent.getUriDef().getUrl().getFragment().orElse(null), "getFragment"));
return ub.build();
}
use of org.apache.http.client.utils.URIBuilder in project cas by apereo.
the class OAuth20AuthorizeEndpointController method buildCallbackUrlResponseType.
/**
* Build callback url response type string.
*
* @param authentication the authentication
* @param service the service
* @param redirectUri the redirect uri
* @param accessToken the access token
* @param params the params
* @return the string
* @throws Exception the exception
*/
protected String buildCallbackUrlResponseType(final Authentication authentication, final Service service, final String redirectUri, final AccessToken accessToken, final List<NameValuePair> params) throws Exception {
final String state = authentication.getAttributes().get(OAuthConstants.STATE).toString();
final String nonce = authentication.getAttributes().get(OAuthConstants.NONCE).toString();
final URIBuilder builder = new URIBuilder(redirectUri);
final StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append(OAuthConstants.ACCESS_TOKEN).append('=').append(accessToken.getId()).append('&').append(OAuthConstants.TOKEN_TYPE).append('=').append(OAuthConstants.TOKEN_TYPE_BEARER).append('&').append(OAuthConstants.EXPIRES_IN).append('=').append(casProperties.getTicket().getTgt().getTimeToKillInSeconds());
params.forEach(p -> stringBuilder.append('&').append(p.getName()).append('=').append(p.getValue()));
if (StringUtils.isNotBlank(state)) {
stringBuilder.append('&').append(OAuthConstants.STATE).append('=').append(EncodingUtils.urlEncode(state));
}
if (StringUtils.isNotBlank(nonce)) {
stringBuilder.append('&').append(OAuthConstants.NONCE).append('=').append(EncodingUtils.urlEncode(nonce));
}
builder.setFragment(stringBuilder.toString());
final String url = builder.toString();
return url;
}
Aggregations