use of javax.ws.rs.core.UriBuilder in project cxf by apache.
the class SamlRedirectBindingFilter method filter.
@Override
public void filter(ContainerRequestContext context) {
Message m = JAXRSUtils.getCurrentMessage();
if (checkSecurityContext(m)) {
return;
}
try {
SamlRequestInfo info = createSamlRequestInfo(m);
String urlEncodedRequest = URLEncoder.encode(info.getSamlRequest(), StandardCharsets.UTF_8.name());
UriBuilder ub = UriBuilder.fromUri(getIdpServiceAddress());
ub.queryParam(SSOConstants.SAML_REQUEST, urlEncodedRequest);
ub.queryParam(SSOConstants.RELAY_STATE, info.getRelayState());
if (isSignRequest()) {
signRequest(urlEncodedRequest, info.getRelayState(), ub);
}
String contextCookie = createCookie(SSOConstants.RELAY_STATE, info.getRelayState(), info.getWebAppContext(), info.getWebAppDomain());
context.abortWith(Response.seeOther(ub.build()).header(HttpHeaders.CACHE_CONTROL, "no-cache, no-store").header("Pragma", "no-cache").header(HttpHeaders.SET_COOKIE, contextCookie).build());
} catch (Exception ex) {
LOG.log(Level.FINE, ex.getMessage(), ex);
throw ExceptionUtils.toInternalServerErrorException(ex, null);
}
}
use of javax.ws.rs.core.UriBuilder in project cxf by apache.
the class OAuthClientUtils method getAuthorizationURIBuilder.
/**
* Creates the builder for building OAuth AuthorizationService URIs
* @param authorizationServiceURI the service endpoint address
* @param clientId client registration id
* @param scope the optional scope; if not specified then the authorization
* service will allocate the default scope
* @return the builder
*/
public static UriBuilder getAuthorizationURIBuilder(String authorizationServiceURI, String clientId, String scope) {
UriBuilder ub = UriBuilder.fromUri(authorizationServiceURI);
if (clientId != null) {
ub.queryParam(OAuthConstants.CLIENT_ID, clientId);
}
if (scope != null) {
ub.queryParam(OAuthConstants.SCOPE, scope);
}
ub.queryParam(OAuthConstants.RESPONSE_TYPE, OAuthConstants.CODE_RESPONSE_TYPE);
return ub;
}
use of javax.ws.rs.core.UriBuilder in project cxf by apache.
the class JAXBElementProvider method resolveXMLResourceURI.
protected String resolveXMLResourceURI(String path) {
MessageContext mc = getContext();
if (mc != null) {
String httpBasePath = (String) mc.get("http.base.path");
UriBuilder builder = null;
if (httpBasePath != null) {
builder = UriBuilder.fromPath(httpBasePath);
} else {
builder = mc.getUriInfo().getBaseUriBuilder();
}
return builder.path(path).path(xmlResourceOffset).build().toString();
}
return path;
}
use of javax.ws.rs.core.UriBuilder in project cxf by apache.
the class UriBuilderImplTest method testBuildWithNonEncodedSubstitutionValue6.
@Test
public void testBuildWithNonEncodedSubstitutionValue6() {
UriBuilder ub = UriBuilder.fromPath("/");
URI uri = ub.path("%").build();
assertEquals("/%25", uri.toString());
uri = ub.replacePath("/%/{token}").build("{}");
assertEquals("/%25/%7B%7D", uri.toString());
}
use of javax.ws.rs.core.UriBuilder in project cxf by apache.
the class UriBuilderImplTest method testResolveTemplatesMapBooleanSlashEncoded.
@Test
public void testResolveTemplatesMapBooleanSlashEncoded() throws Exception {
String expected = "path-rootless%2Ftest2/x%25yz/%2Fpath-absolute%2F%2525test1/fred@example.com/x%25yz";
Map<String, Object> map = new HashMap<>();
map.put("x", new StringBuilder("x%yz"));
map.put("y", new StringBuffer("/path-absolute/%25test1"));
map.put("z", new Object() {
public String toString() {
return "fred@example.com";
}
});
map.put("w", "path-rootless/test2");
UriBuilder builder = UriBuilder.fromPath("").path("{w}/{x}/{y}/{z}/{x}");
URI uri = builder.resolveTemplates(map, true).build();
assertEquals(expected, uri.getRawPath());
}
Aggregations