org.jboss.resteasy.specimpl.ResteasyUriBuilder Java Examples

The following examples show how to use org.jboss.resteasy.specimpl.ResteasyUriBuilder. 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: ActiveMQPushStrategy.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
protected void initialize() throws Exception {
   super.start();
   initialized = true;
   initAuthentication();
   ClientRequest request = executor.createRequest(registration.getTarget().getHref());
   for (XmlHttpHeader header : registration.getHeaders()) {
      request.header(header.getName(), header.getValue());
   }
   ClientResponse<?> res = request.head();
   if (res.getStatus() != 200) {
      throw new RuntimeException("Failed to query REST destination for init information.  Status: " + res.getStatus());
   }
   String url = (String) res.getHeaders().getFirst("msg-create-with-id");
   if (url == null) {
      if (res.getLinkHeader() == null) {
         throw new RuntimeException("Could not find create-with-id URL");
      }
      Link link = res.getLinkHeader().getLinkByTitle("create-with-id");
      if (link == null) {
         throw new RuntimeException("Could not find create-with-id URL");
      }
      url = link.getHref();
   }
   targetUri = ResteasyUriBuilder.fromTemplate(url);
}
 
Example #2
Source File: UmaClientFactory.java    From oxAuth with MIT License 6 votes vote down vote up
public UmaPermissionService createPermissionService(UmaMetadata metadata, ClientHttpEngine engine) {
    ResteasyWebTarget target = newClient(engine).target(new ResteasyUriBuilder().uri(metadata.getPermissionEndpoint()));
    return target.proxy(UmaPermissionService.class);
}
 
Example #3
Source File: UmaClientFactory.java    From oxAuth with MIT License 6 votes vote down vote up
public UmaTokenService createTokenService(UmaMetadata metadata, ClientHttpEngine engine) {
    ResteasyWebTarget target = newClient(engine).target(new ResteasyUriBuilder().uri(metadata.getTokenEndpoint()));
    return target.proxy(UmaTokenService.class);
}
 
Example #4
Source File: DefaultPowerBiConnection.java    From powerbi-rest-java with MIT License 5 votes vote down vote up
@Override
public T call() throws Exception {
    UriBuilder uri = new ResteasyUriBuilder().path(baseUrl);
    command.buildUri(uri);

    Client client = null;
    try {
        client = clientBuilder.build();
        WebTarget target = client.target(uri.build());

        Invocation.Builder request = target.request();
        request.header("Authorization", "Bearer " + authenticator.authenticate());
        request.accept(MediaType.APPLICATION_JSON_TYPE);

        PowerBiRequest r = new PowerBiRequestImpl(request);
        // delegate to the command to perform the processing now.
        command.execute(r);
    } catch (RequestAuthenticationException e) {
        // we are intentionally resetting the authenticator here as the previous token has expired, so the next time
        // through this call the authenticator will not used the cached token and will retrieve a new one.
        if (e.isTokenExpired()) {
            authenticator.reset();
        }
        throw e;
    } finally {
        if (client != null) {
            client.close();
        }
    }

    return command.get();
}
 
Example #5
Source File: UriStrategy.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
@Override
public void start() throws Exception {
   initAuthentication();
   method = registration.getTarget().getMethod();
   if (method == null)
      method = "POST";
   contentType = registration.getTarget().getType();
   targetUri = ResteasyUriBuilder.fromTemplate(registration.getTarget().getHref());
}
 
Example #6
Source File: KeycloakUriInfo.java    From keycloak with Apache License 2.0 5 votes vote down vote up
@Override
public URI relativize(URI uri) {
    URI from = this.getRequestUri();
    URI to = uri;
    if (uri.getScheme() == null && uri.getHost() == null) {
        to = this.getBaseUriBuilder().replaceQuery(null).path(uri.getPath()).replaceQuery(uri.getQuery()).fragment(uri.getFragment()).build(new Object[0]);
    }

    return ResteasyUriBuilder.relativize(from, to);
}
 
Example #7
Source File: UmaClientFactory.java    From oxAuth with MIT License 4 votes vote down vote up
public UmaResourceService createResourceService(UmaMetadata metadata, ClientHttpEngine engine) {
    ResteasyWebTarget target = newClient(engine).target(new ResteasyUriBuilder().uri(metadata.getResourceRegistrationEndpoint()));
    return target.proxy(UmaResourceService.class);
}
 
Example #8
Source File: UmaClientFactory.java    From oxAuth with MIT License 4 votes vote down vote up
public UmaRptIntrospectionService createRptStatusService(UmaMetadata metadata, ClientHttpEngine engine) {
    ResteasyWebTarget target = newClient(engine).target(new ResteasyUriBuilder().uri(metadata.getIntrospectionEndpoint()));
    return target.proxy(UmaRptIntrospectionService.class);
}
 
Example #9
Source File: UmaClientFactory.java    From oxAuth with MIT License 4 votes vote down vote up
public UmaMetadataService createMetadataService(String umaMetadataUri, ClientHttpEngine engine) {
    ResteasyWebTarget target = newClient(engine).target(new ResteasyUriBuilder().uri(umaMetadataUri));
    return target.proxy(UmaMetadataService.class);
}
 
Example #10
Source File: UmaClientFactory.java    From oxAuth with MIT License 4 votes vote down vote up
public UmaScopeService createScopeService(String scopeEndpointUri, ClientHttpEngine engine) {
    ResteasyWebTarget target = newClient(engine).target(new ResteasyUriBuilder().uri(scopeEndpointUri));
    return target.proxy(UmaScopeService.class);
}