Java Code Examples for javax.ws.rs.core.UriBuilder#fromUri()
The following examples show how to use
javax.ws.rs.core.UriBuilder#fromUri() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OAuthProofKeyForCodeExchangeTest.java From keycloak with Apache License 2.0 | 6 votes |
@Test public void accessTokenRequestInPKCEInvalidCodeChallengeWithS256CodeChallengeMethod() throws Exception { // test case : failure : A-1-13 String codeVerifier = "1234567890123456789=12345678901234567890123"; String codeChallenge = codeVerifier; oauth.codeChallenge(codeChallenge); oauth.codeChallengeMethod(OAuth2Constants.PKCE_METHOD_S256); UriBuilder b = UriBuilder.fromUri(oauth.getLoginFormUrl()); driver.navigate().to(b.build().toURL()); OAuthClient.AuthorizationEndpointResponse errorResponse = new OAuthClient.AuthorizationEndpointResponse(oauth); Assert.assertTrue(errorResponse.isRedirected()); Assert.assertEquals(errorResponse.getError(), OAuthErrorException.INVALID_REQUEST); Assert.assertEquals(errorResponse.getErrorDescription(), "Invalid parameter: code_challenge"); events.expectLogin().error(Errors.INVALID_REQUEST).user((String) null).session((String) null).clearDetails().assertEvent(); }
Example 2
Source File: UserApi.java From openapi-generator with Apache License 2.0 | 6 votes |
public HttpResponse updateUserForHttpResponse(String username, java.io.InputStream body, String mediaType) throws IOException { // verify the required parameter 'username' is set if (username == null) { throw new IllegalArgumentException("Missing the required parameter 'username' when calling updateUser"); }// verify the required parameter 'body' is set if (body == null) { throw new IllegalArgumentException("Missing the required parameter 'body' when calling updateUser"); } // create a map of path variables final Map<String, Object> uriVariables = new HashMap<String, Object>(); uriVariables.put("username", username); UriBuilder uriBuilder = UriBuilder.fromUri(apiClient.getBasePath() + "/user/{username}"); String localVarUrl = uriBuilder.buildFromMap(uriVariables).toString(); GenericUrl genericUrl = new GenericUrl(localVarUrl); HttpContent content = body == null ? apiClient.new JacksonJsonHttpContent(null) : new InputStreamContent(mediaType == null ? Json.MEDIA_TYPE : mediaType, body); return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.PUT, genericUrl, content).execute(); }
Example 3
Source File: PetApi.java From openapi-generator with Apache License 2.0 | 6 votes |
public HttpResponse updatePetWithFormForHttpResponse(Long petId, String name, String status) throws IOException { // verify the required parameter 'petId' is set if (petId == null) { throw new IllegalArgumentException("Missing the required parameter 'petId' when calling updatePetWithForm"); } // create a map of path variables final Map<String, Object> uriVariables = new HashMap<String, Object>(); uriVariables.put("petId", petId); UriBuilder uriBuilder = UriBuilder.fromUri(apiClient.getBasePath() + "/pet/{petId}"); String localVarUrl = uriBuilder.buildFromMap(uriVariables).toString(); GenericUrl genericUrl = new GenericUrl(localVarUrl); HttpContent content = new EmptyContent(); return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content).execute(); }
Example 4
Source File: IdpServiceImpl.java From cxf-fediz with Apache License 2.0 | 6 votes |
@Override public Response addIdp(UriInfo ui, Idp idp) { LOG.info("add IDP config"); if (idp.getApplications() != null && !idp.getApplications().isEmpty()) { LOG.warn("IDP resource contains sub resource 'applications'"); throw new WebApplicationException(Status.BAD_REQUEST); } if (idp.getTrustedIdps() != null && !idp.getTrustedIdps().isEmpty()) { LOG.warn("IDP resource contains sub resource 'trusted-idps'"); throw new WebApplicationException(Status.BAD_REQUEST); } Idp createdIdp = idpDAO.addIdp(idp); UriBuilder uriBuilder = UriBuilder.fromUri(ui.getRequestUri()); uriBuilder.path("{index}"); URI location = uriBuilder.build(createdIdp.getRealm()); return Response.created(location).entity(idp).build(); }
Example 5
Source File: PayrollAuApi.java From Xero-Java with MIT License | 5 votes |
public HttpResponse createTimesheetForHttpResponse(String accessToken, String xeroTenantId, List<Timesheet> timesheet) throws IOException { // verify the required parameter 'xeroTenantId' is set if (xeroTenantId == null) { throw new IllegalArgumentException("Missing the required parameter 'xeroTenantId' when calling createTimesheet"); }// verify the required parameter 'timesheet' is set if (timesheet == null) { throw new IllegalArgumentException("Missing the required parameter 'timesheet' when calling createTimesheet"); } if (accessToken == null) { throw new IllegalArgumentException("Missing the required parameter 'accessToken' when calling createTimesheet"); } HttpHeaders headers = new HttpHeaders(); headers.set("Xero-Tenant-Id", xeroTenantId); headers.setAccept("application/json"); headers.setUserAgent(this.getUserAgent()); UriBuilder uriBuilder = UriBuilder.fromUri(apiClient.getBasePath() + "/Timesheets"); String url = uriBuilder.build().toString(); GenericUrl genericUrl = new GenericUrl(url); if (logger.isDebugEnabled()) { logger.debug("POST " + genericUrl.toString()); } HttpContent content = null; content = apiClient.new JacksonJsonHttpContent(timesheet); Credential credential = new Credential(BearerToken.authorizationHeaderAccessMethod()).setAccessToken(accessToken); HttpTransport transport = apiClient.getHttpTransport(); HttpRequestFactory requestFactory = transport.createRequestFactory(credential); return requestFactory.buildRequest(HttpMethods.POST, genericUrl, content).setHeaders(headers) .setConnectTimeout(apiClient.getConnectionTimeout()) .setReadTimeout(apiClient.getReadTimeout()).execute(); }
Example 6
Source File: AuthorizationCodeGrantService.java From cxf with Apache License 2.0 | 5 votes |
protected UriBuilder getRedirectUriBuilder(String state, String redirectUri) { UriBuilder ub = UriBuilder.fromUri(redirectUri); if (state != null) { ub.queryParam(OAuthConstants.STATE, state); } return ub; }
Example 7
Source File: FakeApi.java From openapi-generator with Apache License 2.0 | 5 votes |
public HttpResponse createXmlItemForHttpResponse(java.io.InputStream xmlItem, String mediaType) throws IOException { // verify the required parameter 'xmlItem' is set if (xmlItem == null) { throw new IllegalArgumentException("Missing the required parameter 'xmlItem' when calling createXmlItem"); } UriBuilder uriBuilder = UriBuilder.fromUri(apiClient.getBasePath() + "/fake/create_xml_item"); String localVarUrl = uriBuilder.build().toString(); GenericUrl genericUrl = new GenericUrl(localVarUrl); HttpContent content = xmlItem == null ? apiClient.new JacksonJsonHttpContent(null) : new InputStreamContent(mediaType == null ? Json.MEDIA_TYPE : mediaType, xmlItem); return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content).execute(); }
Example 8
Source File: AbstractGatewayRequestBuilder.java From jrestless with Apache License 2.0 | 5 votes |
public final T build() { Map<String, String> actualHeaders = null; if (headers != null || domain != null) { actualHeaders = new HashMap<>(); if (domain != null) { actualHeaders.put(HttpHeaders.HOST, domain); } if (headers != null) { actualHeaders.putAll(headers); } } if (resource == null) { throw new IllegalStateException("resource must be set"); } // proxy param to ordinary param String resourceTemplate = resource.replaceAll("\\+\\}", "}"); UriBuilder pathUriBuilder = UriBuilder.fromUri(URI.create("/")); if (basePath != null) { pathUriBuilder.path(basePath); } // avoid single trailing slash if (!"/".equals(resourceTemplate)) { pathUriBuilder.path(resourceTemplate); } String actualPath; if (path != null) { actualPath = path; } else if (pathParams != null) { actualPath = pathUriBuilder.buildFromEncodedMap(pathParams).toString(); } else { actualPath = pathUriBuilder.build().toString(); } return createGatewayRequest(body, actualHeaders, pathParams, queryParams, httpMethod, resource, actualPath, requestContextStage, isBase64Encoded, authorizerData); }
Example 9
Source File: FakeClassnameTags123Api.java From openapi-generator with Apache License 2.0 | 5 votes |
public HttpResponse testClassnameForHttpResponse(Client body, Map<String, Object> params) throws IOException { // verify the required parameter 'body' is set if (body == null) { throw new IllegalArgumentException("Missing the required parameter 'body' when calling testClassname"); } UriBuilder uriBuilder = UriBuilder.fromUri(apiClient.getBasePath() + "/fake_classname_test"); // Copy the params argument if present, to allow passing in immutable maps Map<String, Object> allParams = params == null ? new HashMap<String, Object>() : new HashMap<String, Object>(params); for (Map.Entry<String, Object> entry: allParams.entrySet()) { String key = entry.getKey(); Object value = entry.getValue(); if (key != null && value != null) { if (value instanceof Collection) { uriBuilder = uriBuilder.queryParam(key, ((Collection) value).toArray()); } else if (value instanceof Object[]) { uriBuilder = uriBuilder.queryParam(key, (Object[]) value); } else { uriBuilder = uriBuilder.queryParam(key, value); } } } String localVarUrl = uriBuilder.build().toString(); GenericUrl genericUrl = new GenericUrl(localVarUrl); HttpContent content = apiClient.new JacksonJsonHttpContent(body); return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.PATCH, genericUrl, content).execute(); }
Example 10
Source File: FakeApi.java From openapi-generator with Apache License 2.0 | 5 votes |
public HttpResponse testBodyWithQueryParamsForHttpResponse(String query, User body, Map<String, Object> params) throws IOException { // verify the required parameter 'query' is set if (query == null) { throw new IllegalArgumentException("Missing the required parameter 'query' when calling testBodyWithQueryParams"); }// verify the required parameter 'body' is set if (body == null) { throw new IllegalArgumentException("Missing the required parameter 'body' when calling testBodyWithQueryParams"); } UriBuilder uriBuilder = UriBuilder.fromUri(apiClient.getBasePath() + "/fake/body-with-query-params"); // Copy the params argument if present, to allow passing in immutable maps Map<String, Object> allParams = params == null ? new HashMap<String, Object>() : new HashMap<String, Object>(params); // Add the required query param 'query' to the map of query params allParams.put("query", query); for (Map.Entry<String, Object> entry: allParams.entrySet()) { String key = entry.getKey(); Object value = entry.getValue(); if (key != null && value != null) { if (value instanceof Collection) { uriBuilder = uriBuilder.queryParam(key, ((Collection) value).toArray()); } else if (value instanceof Object[]) { uriBuilder = uriBuilder.queryParam(key, (Object[]) value); } else { uriBuilder = uriBuilder.queryParam(key, value); } } } String localVarUrl = uriBuilder.build().toString(); GenericUrl genericUrl = new GenericUrl(localVarUrl); HttpContent content = apiClient.new JacksonJsonHttpContent(body); return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.PUT, genericUrl, content).execute(); }
Example 11
Source File: AnotherFakeApi.java From openapi-generator with Apache License 2.0 | 5 votes |
public HttpResponse call123testSpecialTagsForHttpResponse(Client body, Map<String, Object> params) throws IOException { // verify the required parameter 'body' is set if (body == null) { throw new IllegalArgumentException("Missing the required parameter 'body' when calling call123testSpecialTags"); } UriBuilder uriBuilder = UriBuilder.fromUri(apiClient.getBasePath() + "/another-fake/dummy"); // Copy the params argument if present, to allow passing in immutable maps Map<String, Object> allParams = params == null ? new HashMap<String, Object>() : new HashMap<String, Object>(params); for (Map.Entry<String, Object> entry: allParams.entrySet()) { String key = entry.getKey(); Object value = entry.getValue(); if (key != null && value != null) { if (value instanceof Collection) { uriBuilder = uriBuilder.queryParam(key, ((Collection) value).toArray()); } else if (value instanceof Object[]) { uriBuilder = uriBuilder.queryParam(key, (Object[]) value); } else { uriBuilder = uriBuilder.queryParam(key, value); } } } String localVarUrl = uriBuilder.build().toString(); GenericUrl genericUrl = new GenericUrl(localVarUrl); HttpContent content = apiClient.new JacksonJsonHttpContent(body); return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.PATCH, genericUrl, content).execute(); }
Example 12
Source File: PetApi.java From openapi-generator with Apache License 2.0 | 5 votes |
public HttpResponse getPetByIdForHttpResponse(Long petId, Map<String, Object> params) throws IOException { // verify the required parameter 'petId' is set if (petId == null) { throw new IllegalArgumentException("Missing the required parameter 'petId' when calling getPetById"); } // create a map of path variables final Map<String, Object> uriVariables = new HashMap<String, Object>(); uriVariables.put("petId", petId); UriBuilder uriBuilder = UriBuilder.fromUri(apiClient.getBasePath() + "/pet/{petId}"); // Copy the params argument if present, to allow passing in immutable maps Map<String, Object> allParams = params == null ? new HashMap<String, Object>() : new HashMap<String, Object>(params); for (Map.Entry<String, Object> entry: allParams.entrySet()) { String key = entry.getKey(); Object value = entry.getValue(); if (key != null && value != null) { if (value instanceof Collection) { uriBuilder = uriBuilder.queryParam(key, ((Collection) value).toArray()); } else if (value instanceof Object[]) { uriBuilder = uriBuilder.queryParam(key, (Object[]) value); } else { uriBuilder = uriBuilder.queryParam(key, value); } } } String localVarUrl = uriBuilder.buildFromMap(uriVariables).toString(); GenericUrl genericUrl = new GenericUrl(localVarUrl); HttpContent content = null; return apiClient.getHttpRequestFactory().buildRequest(HttpMethods.GET, genericUrl, content).execute(); }
Example 13
Source File: PayrollAuApi.java From Xero-Java with MIT License | 5 votes |
public HttpResponse createPayrollCalendarForHttpResponse(String accessToken, String xeroTenantId, List<PayrollCalendar> payrollCalendar) throws IOException { // verify the required parameter 'xeroTenantId' is set if (xeroTenantId == null) { throw new IllegalArgumentException("Missing the required parameter 'xeroTenantId' when calling createPayrollCalendar"); }// verify the required parameter 'payrollCalendar' is set if (payrollCalendar == null) { throw new IllegalArgumentException("Missing the required parameter 'payrollCalendar' when calling createPayrollCalendar"); } if (accessToken == null) { throw new IllegalArgumentException("Missing the required parameter 'accessToken' when calling createPayrollCalendar"); } HttpHeaders headers = new HttpHeaders(); headers.set("Xero-Tenant-Id", xeroTenantId); headers.setAccept("application/json"); headers.setUserAgent(this.getUserAgent()); UriBuilder uriBuilder = UriBuilder.fromUri(apiClient.getBasePath() + "/PayrollCalendars"); String url = uriBuilder.build().toString(); GenericUrl genericUrl = new GenericUrl(url); if (logger.isDebugEnabled()) { logger.debug("POST " + genericUrl.toString()); } HttpContent content = null; content = apiClient.new JacksonJsonHttpContent(payrollCalendar); Credential credential = new Credential(BearerToken.authorizationHeaderAccessMethod()).setAccessToken(accessToken); HttpTransport transport = apiClient.getHttpTransport(); HttpRequestFactory requestFactory = transport.createRequestFactory(credential); return requestFactory.buildRequest(HttpMethods.POST, genericUrl, content).setHeaders(headers) .setConnectTimeout(apiClient.getConnectionTimeout()) .setReadTimeout(apiClient.getReadTimeout()).execute(); }
Example 14
Source File: BankFeedsApi.java From Xero-Java with MIT License | 5 votes |
public HttpResponse createFeedConnectionsForHttpResponse(String accessToken, String xeroTenantId, FeedConnections feedConnections) throws IOException { // verify the required parameter 'xeroTenantId' is set if (xeroTenantId == null) { throw new IllegalArgumentException("Missing the required parameter 'xeroTenantId' when calling createFeedConnections"); }// verify the required parameter 'feedConnections' is set if (feedConnections == null) { throw new IllegalArgumentException("Missing the required parameter 'feedConnections' when calling createFeedConnections"); } if (accessToken == null) { throw new IllegalArgumentException("Missing the required parameter 'accessToken' when calling createFeedConnections"); } HttpHeaders headers = new HttpHeaders(); headers.set("Xero-Tenant-Id", xeroTenantId); headers.setAccept("application/json"); headers.setUserAgent(this.getUserAgent()); UriBuilder uriBuilder = UriBuilder.fromUri(apiClient.getBasePath() + "/FeedConnections"); String url = uriBuilder.build().toString(); GenericUrl genericUrl = new GenericUrl(url); if (logger.isDebugEnabled()) { logger.debug("POST " + genericUrl.toString()); } HttpContent content = null; content = apiClient.new JacksonJsonHttpContent(feedConnections); Credential credential = new Credential(BearerToken.authorizationHeaderAccessMethod()).setAccessToken(accessToken); HttpTransport transport = apiClient.getHttpTransport(); HttpRequestFactory requestFactory = transport.createRequestFactory(credential); return requestFactory.buildRequest(HttpMethods.POST, genericUrl, content).setHeaders(headers) .setConnectTimeout(apiClient.getConnectionTimeout()) .setReadTimeout(apiClient.getReadTimeout()).execute(); }
Example 15
Source File: BankFeedsApi.java From Xero-Java with MIT License | 5 votes |
public HttpResponse getStatementForHttpResponse(String accessToken, String xeroTenantId, UUID statementId) throws IOException { // verify the required parameter 'xeroTenantId' is set if (xeroTenantId == null) { throw new IllegalArgumentException("Missing the required parameter 'xeroTenantId' when calling getStatement"); }// verify the required parameter 'statementId' is set if (statementId == null) { throw new IllegalArgumentException("Missing the required parameter 'statementId' when calling getStatement"); } if (accessToken == null) { throw new IllegalArgumentException("Missing the required parameter 'accessToken' when calling getStatement"); } HttpHeaders headers = new HttpHeaders(); headers.set("Xero-Tenant-Id", xeroTenantId); headers.setAccept("application/json"); headers.setUserAgent(this.getUserAgent()); // create a map of path variables final Map<String, Object> uriVariables = new HashMap<String, Object>(); uriVariables.put("statementId", statementId); UriBuilder uriBuilder = UriBuilder.fromUri(apiClient.getBasePath() + "/Statements/{statementId}"); String url = uriBuilder.buildFromMap(uriVariables).toString(); GenericUrl genericUrl = new GenericUrl(url); if (logger.isDebugEnabled()) { logger.debug("GET " + genericUrl.toString()); } HttpContent content = null; Credential credential = new Credential(BearerToken.authorizationHeaderAccessMethod()).setAccessToken(accessToken); HttpTransport transport = apiClient.getHttpTransport(); HttpRequestFactory requestFactory = transport.createRequestFactory(credential); return requestFactory.buildRequest(HttpMethods.GET, genericUrl, content).setHeaders(headers) .setConnectTimeout(apiClient.getConnectionTimeout()) .setReadTimeout(apiClient.getReadTimeout()).execute(); }
Example 16
Source File: PayrollAuApi.java From Xero-Java with MIT License | 5 votes |
public HttpResponse getSuperfundForHttpResponse(String accessToken, String xeroTenantId, UUID superFundID) throws IOException { // verify the required parameter 'xeroTenantId' is set if (xeroTenantId == null) { throw new IllegalArgumentException("Missing the required parameter 'xeroTenantId' when calling getSuperfund"); }// verify the required parameter 'superFundID' is set if (superFundID == null) { throw new IllegalArgumentException("Missing the required parameter 'superFundID' when calling getSuperfund"); } if (accessToken == null) { throw new IllegalArgumentException("Missing the required parameter 'accessToken' when calling getSuperfund"); } HttpHeaders headers = new HttpHeaders(); headers.set("Xero-Tenant-Id", xeroTenantId); headers.setAccept("application/json"); headers.setUserAgent(this.getUserAgent()); // create a map of path variables final Map<String, Object> uriVariables = new HashMap<String, Object>(); uriVariables.put("SuperFundID", superFundID); UriBuilder uriBuilder = UriBuilder.fromUri(apiClient.getBasePath() + "/Superfunds/{SuperFundID}"); String url = uriBuilder.buildFromMap(uriVariables).toString(); GenericUrl genericUrl = new GenericUrl(url); if (logger.isDebugEnabled()) { logger.debug("GET " + genericUrl.toString()); } HttpContent content = null; Credential credential = new Credential(BearerToken.authorizationHeaderAccessMethod()).setAccessToken(accessToken); HttpTransport transport = apiClient.getHttpTransport(); HttpRequestFactory requestFactory = transport.createRequestFactory(credential); return requestFactory.buildRequest(HttpMethods.GET, genericUrl, content).setHeaders(headers) .setConnectTimeout(apiClient.getConnectionTimeout()) .setReadTimeout(apiClient.getReadTimeout()).execute(); }
Example 17
Source File: Skolemizer.java From Processor with Apache License 2.0 | 5 votes |
public URI build(Resource resource, OntClass typeClass) { if (resource == null) throw new IllegalArgumentException("Resource cannot be null"); if (typeClass == null) throw new IllegalArgumentException("OntClass cannot be null"); // skolemization template builds with absolute path builder (e.g. "{slug}") String path = getStringValue(typeClass, LDT.path); if (path == null) throw new IllegalStateException("Cannot skolemize resource of class " + typeClass + " which does not have ldt:path annotation"); final UriBuilder builder; // treat paths starting with / as absolute, others as relative (to the current absolute path) // JAX-RS URI templates do not have this distinction (leading slash is irrelevant) if (path.startsWith("/")) builder = getBaseUriBuilder().clone(); else { Resource parent = getParent(typeClass); if (parent != null) builder = UriBuilder.fromUri(parent.getURI()); else builder = getAbsolutePathBuilder().clone(); } Map<String, String> nameValueMap = getNameValueMap(resource, new UriTemplateParser(path)); builder.path(path); // add fragment identifier String fragment = getStringValue(typeClass, LDT.fragment); return builder.fragment(fragment).buildFromMap(nameValueMap); // TO-DO: wrap into SkolemizationException }
Example 18
Source File: RoboZonkyFilter.java From robozonky with Apache License 2.0 | 4 votes |
static URI addQueryParams(final URI info, final Map<String, Object[]> params) { final UriBuilder builder = UriBuilder.fromUri(info); builder.uri(info); params.forEach(builder::queryParam); return builder.build(); }
Example 19
Source File: Hawtio2Page.java From keycloak with Apache License 2.0 | 4 votes |
@Override public UriBuilder createUriBuilder() { return UriBuilder.fromUri(getUrl()); }
Example 20
Source File: PizzaClient.java From jersey-hmac-auth with Apache License 2.0 | 4 votes |
public PizzaClient(URI serviceUrl, String apiKey, String secretKey) { this.uriBuilder = UriBuilder.fromUri(serviceUrl); this.jerseyClient = createClient(apiKey, secretKey); }