Package com.sun.jersey.api.client

Examples of com.sun.jersey.api.client.WebResource.header()


        WebResource wr = restClient.client.resource(UriBuilder.fromPath(eventUrl).build());
        wr.addFilter(new BearerTokenFilter(accessToken));

        try {
            wr.header("Authorization", createBearerAuthorizationHeader(accessToken));
        } catch (UnsupportedEncodingException e) {
            throw new EventApiException(e.getMessage(), e);
        }
        ClientResponse cr = wr.delete(ClientResponse.class);
        logger.info("Delete status: "+cr.getStatus());
View Full Code Here


    WebResource resource = service.path(entities.path)
        .path(entityType).path(entityName);
    if (colo != null) {
      resource = resource.queryParam("colo", colo);
    }
    ClientResponse clientResponse = resource.header(REMOTE_USER, USER)
        .accept(entities.mimeType).type(MediaType.TEXT_XML)
        .method(entities.method, ClientResponse.class);

    checkIfSuccessfull(clientResponse);
View Full Code Here

    WebResource resource = service.path(entities.path)
        .path(entityType);
    if (colo != null) {
      resource = resource.queryParam("colo", colo);
    }
    ClientResponse clientResponse = resource.header(REMOTE_USER, USER)
        .accept(entities.mimeType).type(MediaType.TEXT_XML)
        .method(entities.method, ClientResponse.class, requestObject);

    checkIfSuccessfull(clientResponse);
View Full Code Here

        resource = resource.queryParam("start", start);
        if(end != null)
            resource = resource.queryParam("end", end);
        resource = resource.queryParam("colo", colo);
       
        return resource.header(REMOTE_USER, USER).accept(instances.mimeType).method(instances.method, InstancesResult.class);
  }
 
  private String sendInstanceRequest(Instances instances, String type,
      String entity, String start, String end, InputStream props,
      String runid, String colo) throws IvoryCLIException {
View Full Code Here

    }
   

    ClientResponse clientResponse = null;
    if (props == null) {
      clientResponse = resource.header(REMOTE_USER, USER)
          .accept(instances.mimeType)
          .method(instances.method, ClientResponse.class);
    } else {
      clientResponse = resource.header(REMOTE_USER, USER)
          .accept(instances.mimeType)
View Full Code Here

    if (props == null) {
      clientResponse = resource.header(REMOTE_USER, USER)
          .accept(instances.mimeType)
          .method(instances.method, ClientResponse.class);
    } else {
      clientResponse = resource.header(REMOTE_USER, USER)
          .accept(instances.mimeType)
          .method(instances.method, ClientResponse.class, props);
    }
    checkIfSuccessfull(clientResponse);
   
View Full Code Here

    public void testAuthenticationAdmin() {
        String credentials = adminCredentials();
        for (int i = 0; i < AUTHENTICATION_ERROR_URIS.length; i++) {
            WebResource resource = resource(AUTHENTICATION_ERROR_URIS[i]);
            try {
                Object result = resource.
                  header("Authorization", credentials).
                  get(AUTHENTICATION_ERROR_CLASSES[i]);
            } catch (UniformInterfaceException e) {
                fail("Status was " + e.getResponse().getStatus() + " instead of 200 for path '" + path(AUTHENTICATION_ERROR_URIS[i]) + "'");
            }
View Full Code Here

    public void testAuthenticationInvalid() {
        String credentials = Base64.encode("invalid-username:invalid-password".getBytes());
        for (String[] paths : AUTHENTICATION_ERROR_URIS) {
            WebResource resource = resource(paths);
            try {
                resource.
                  header("Authentication", "Basic " + credentials).
                  get(Object.class);
                fail("Should have returned status 401 for path '" + path(paths) + "'");
            } catch (UniformInterfaceException e) {
                if (e.getResponse().getStatus() == 401) {
View Full Code Here

    public void testAuthorizationAdminPositive() {
        String credentials = adminCredentials();
        for (int i = 0; i < ADMIN_POSITIVE_URIS.length; i++) {
            WebResource resource = resource(ADMIN_POSITIVE_URIS[i]);
            try {
                Object result = resource.
                  header("Authorization", credentials).
                  get(ADMIN_POSITIVE_CLASSES[i]);
            } catch (UniformInterfaceException e) {
                fail("Status was " + e.getResponse().getStatus() + " instead of 200 for path '" + path(ADMIN_POSITIVE_URIS[i]) + "'");
            }
View Full Code Here

    public void testAuthorizationUserNegative() {
        String credentials = userCredentials("newuser", "newpass");
        for (int i = 0; i < NEWUSER_NEGATIVE_URIS.length; i++) {
            WebResource resource = resource(NEWUSER_NEGATIVE_URIS[i]);
            try {
                Object result = resource.
                  header("Authorization", credentials).
                  get(NEWUSER_NEGATIVE_CLASSES[i]);
                fail("Should have returned 403 instead of 200 for path '" + path(NEWUSER_NEGATIVE_URIS[i]) + "'");
            } catch (UniformInterfaceException e) {
                if (e.getResponse().getStatus() == 403) {
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.