javax.ws.rs.core.UriBuilder#fromUri()源码实例Demo

下面列出了javax.ws.rs.core.UriBuilder#fromUri() 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

@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();
}
 
源代码2 项目: openapi-generator   文件: UserApi.java
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();
}
 
源代码3 项目: openapi-generator   文件: PetApi.java
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();
}
 
源代码4 项目: cxf-fediz   文件: IdpServiceImpl.java
@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();
}
 
源代码5 项目: cxf   文件: AuthorizationCodeGrantService.java
protected UriBuilder getRedirectUriBuilder(String state, String redirectUri) {
    UriBuilder ub = UriBuilder.fromUri(redirectUri);
    if (state != null) {
        ub.queryParam(OAuthConstants.STATE, state);
    }
    return ub;
}
 
源代码6 项目: Processor   文件: Skolemizer.java
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
}
 
源代码7 项目: Xero-Java   文件: PayrollAuApi.java
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();  
}
 
源代码8 项目: Xero-Java   文件: BankFeedsApi.java
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();  
}
 
源代码9 项目: Xero-Java   文件: BankFeedsApi.java
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();  
}
 
源代码10 项目: Xero-Java   文件: PayrollAuApi.java
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();  
}
 
源代码11 项目: openapi-generator   文件: PetApi.java
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();
}
 
源代码12 项目: openapi-generator   文件: AnotherFakeApi.java
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();
}
 
源代码13 项目: openapi-generator   文件: FakeApi.java
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();
}
 
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();
}
 
源代码15 项目: jrestless   文件: AbstractGatewayRequestBuilder.java
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);
	}
 
源代码16 项目: openapi-generator   文件: FakeApi.java
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();
}
 
源代码17 项目: Xero-Java   文件: PayrollAuApi.java
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();  
}
 
源代码18 项目: keycloak   文件: Hawtio2Page.java
@Override
public UriBuilder createUriBuilder() {
    return UriBuilder.fromUri(getUrl());
}
 
源代码19 项目: robozonky   文件: RoboZonkyFilter.java
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();
}
 
源代码20 项目: jersey-hmac-auth   文件: PizzaClient.java
public PizzaClient(URI serviceUrl, String apiKey, String secretKey) {
    this.uriBuilder = UriBuilder.fromUri(serviceUrl);
    this.jerseyClient = createClient(apiKey, secretKey);
}