Examples of BasicAuthentication


Examples of org.eclipse.jetty.client.util.BasicAuthentication

    @Test
    public void testAuthPost() {
        ClientConfig config = new ClientConfig();
        config.property(JettyClientProperties.PREEMPTIVE_BASIC_AUTHENTICATION,
                new BasicAuthentication(getBaseUri(), "WallyWorld", "name", "password"));
        config.connectorProvider(new JettyConnectorProvider());
        Client client = ClientBuilder.newClient(config);

        Response response = client.target(getBaseUri()).path(PATH).request().post(Entity.text("POST"));
        assertEquals("POST", response.readEntity(String.class));
View Full Code Here

Examples of org.eclipse.jetty.client.util.BasicAuthentication

    @Test
    public void testAuthDelete() {
        ClientConfig config = new ClientConfig();
        config.property(JettyClientProperties.PREEMPTIVE_BASIC_AUTHENTICATION,
                new BasicAuthentication(getBaseUri(), "WallyWorld", "name", "password"));
        config.connectorProvider(new JettyConnectorProvider());
        Client client = ClientBuilder.newClient(config);

        Response response = client.target(getBaseUri()).path(PATH).request().delete();
        assertEquals(response.getStatus(), 204);
View Full Code Here

Examples of org.jboss.resteasy.client.jaxrs.BasicAuthentication

  private static ResteasyClient createRestClient(DatabaseIdentifier database) {
    ResteasyClientBuilder clientBuilder = new ResteasyClientBuilder();

    if ( database.getUserName() != null ) {
      clientBuilder.register( new BasicAuthentication( database.getUserName(), database.getPassword() ) );
    }

    // using a connection pool size > 1 causes a thread-safe pool implementation to be used under the hoods
    return clientBuilder
        .connectionPoolSize( CONNECTION_POOL_SIZE )
View Full Code Here

Examples of org.jboss.resteasy.client.jaxrs.BasicAuthentication

  private static ResteasyClient createRestClient(DatabaseIdentifier database) {
    ResteasyClientBuilder clientBuilder = new ResteasyClientBuilder();

    if ( database.getUserName() != null ) {
      clientBuilder.register( new BasicAuthentication( database.getUserName(), database.getPassword() ) );
    }

    // using a connection pool size > 1 causes a thread-safe pool implementation to be used under the hoods
    return clientBuilder
        .connectionPoolSize( CONNECTION_POOL_SIZE )
View Full Code Here

Examples of org.jboss.resteasy.client.jaxrs.BasicAuthentication

  private static ResteasyClient createRestClient(DatabaseIdentifier database) {
    ResteasyClientBuilder clientBuilder = new ResteasyClientBuilder();

    if ( database.getUserName() != null ) {
      clientBuilder.register( new BasicAuthentication( database.getUserName(), database.getPassword() ) );
    }

    // using a connection pool size > 1 causes a thread-safe pool implementation to be used under the hoods
    return clientBuilder
        .connectionPoolSize( CONNECTION_POOL_SIZE )
View Full Code Here

Examples of org.jboss.resteasy.client.jaxrs.BasicAuthentication

                 .build();

      Form form = new Form().param("grant_type", "client_credentials");
      ResteasyWebTarget target = client.target("https://localhost:8443/auth-server/j_oauth_token_grant");
      // this is resteasy specific, check spec to make sure it hasn't added a way to do basic auth
      target.register(new BasicAuthentication("bburke@redhat.com", "password"));
      AccessTokenResponse res = target
              .request()
              .post(Entity.form(form), AccessTokenResponse.class);
      try
      {
View Full Code Here

Examples of org.jboss.resteasy.client.jaxrs.BasicAuthentication

  private static ResteasyClient createRestClient(DatabaseIdentifier database) {
    ResteasyClientBuilder clientBuilder = new ResteasyClientBuilder();

    if ( database.getUserName() != null ) {
      clientBuilder.register( new BasicAuthentication( database.getUserName(), database.getPassword() ) );
    }

    // using a connection pool size > 1 causes a thread-safe pool implementation to be used under the hoods
    return clientBuilder
        .connectionPoolSize( CONNECTION_POOL_SIZE )
View Full Code Here

Examples of org.jboss.resteasy.client.jaxrs.BasicAuthentication

   */
  public BTSyncClient(String address, String port, String username, String password) {
    this.baseUrl = String.format("http://%s:%s/api?", address, port);
   
    client = new ResteasyClientBuilder().build();
    client.register(new BasicAuthentication(username, password))
          .register(JsonContentTypeResponseFilter.class);
  }
View Full Code Here

Examples of pivot.web.BasicAuthentication

    final static int PORT = 8080;
    final static boolean SECURE = false;

    public void startup(Display display, Dictionary<String, String> properties)
      throws Exception {
        final BasicAuthentication authentication = new BasicAuthentication("foo", "bar");

        // GET
        final GetQuery getQuery = new GetQuery(HOSTNAME, PORT, PATH, SECURE);
        getQuery.getArguments().put("a", "b");
        getQuery.setSerializer(new BinarySerializer());
        authentication.authenticate(getQuery);

        getQuery.execute(new TaskListener<Object>() {
            @SuppressWarnings("unchecked")
            public void taskExecuted(Task<Object> task) {
                Dictionary<String, Object> result = (Dictionary<String, Object>)task.getResult();

                System.out.println("GET result: "
                    + "username: " + result.get("username") + ", "
                    + "pathInfo: " + result.get("pathInfo") + ", "
                    + "queryString: " + result.get("queryString"));
            }

            public void executeFailed(Task<Object> task) {
                System.out.println("GET fault: " + task.getFault());
            }
        });

        // POST
        PostQuery postQuery = new PostQuery(HOSTNAME, PORT, PATH, SECURE);
        authentication.authenticate(postQuery);
        postQuery.setValue(JSONSerializer.parseList("[1, 2, 3]"));

        postQuery.execute(new TaskListener<URL>() {
            public void taskExecuted(Task<URL> task) {
                System.out.println("POST result: " + task.getResult());
            }

            public void executeFailed(Task<URL> task) {
                System.out.println("POST fault: " + task.getFault());
            }
        });

        // PUT
        PutQuery putQuery = new PutQuery(HOSTNAME, PORT, PATH, SECURE);
        authentication.authenticate(putQuery);
        putQuery.setValue(JSONSerializer.parseMap("{a:100, b:200, c:300}"));

        putQuery.execute(new TaskListener<Void>() {
            public void taskExecuted(Task<Void> task) {
                System.out.println("PUT result");
            }

            public void executeFailed(Task<Void> task) {
                System.out.println("PUT fault: " + task.getFault());
            }
        });

        // POST
        DeleteQuery deleteQuery = new DeleteQuery(HOSTNAME, PORT, PATH, SECURE);
        authentication.authenticate(deleteQuery);

        deleteQuery.execute(new TaskListener<Void>() {
            public void taskExecuted(Task<Void> task) {
                System.out.println("DELETE result");
            }
View Full Code Here

Examples of pivot.web.BasicAuthentication

    final static String PATH = (useProxy ? "/pivot_web_test/proxy" : "/pivot_web_test/webquery") + "/bar/quux";
    final static int PORT = 8080;
    final static boolean SECURE = false;

    public static void main(String[] args) throws Exception {
        final BasicAuthentication authentication = new BasicAuthentication("foo", "bar");

        // GET
        final GetQuery getQuery = new GetQuery(HOSTNAME, PORT, PATH, SECURE);
        getQuery.getParameters().put("a", "b");
        getQuery.setSerializer(new BinarySerializer());
        getQuery.getRequestHeaders().add("bar", "hello");
        getQuery.getRequestHeaders().add("bar", "world");
        authentication.authenticate(getQuery);

        getQuery.execute(new TaskListener<Object>() {
            @SuppressWarnings("unchecked")
            public void taskExecuted(Task<Object> task) {
                GetQuery getQuery = (GetQuery)task;
                Dictionary<String, Object> result = (Dictionary<String, Object>)getQuery.getResult();

                System.out.println("GET result: "
                    + "username: " + result.get("username") + ", "
                    + "pathInfo: " + result.get("pathInfo") + ", "
                    + "queryString: " + result.get("queryString") + ", "
                    + "status: " + getQuery.getStatus());

                QueryDictionary responseHeaders = getQuery.getResponseHeaders();
                for (String headerName : responseHeaders) {
                    System.out.print(headerName + "=");

                    for (int i = 0, n = responseHeaders.getLength(headerName); i < n; i++) {
                        System.out.print(responseHeaders.get(headerName, i) + ";");
                    }

                    System.out.print("\n");
                }
            }

            public void executeFailed(Task<Object> task) {
                System.out.println("GET fault: " + task.getFault());
            }
        });

        // POST
        PostQuery postQuery = new PostQuery(HOSTNAME, PORT, PATH, SECURE);
        authentication.authenticate(postQuery);
        postQuery.setValue(JSONSerializer.parseList("[1, 2, 3]"));

        postQuery.execute(new TaskListener<URL>() {
            public void taskExecuted(Task<URL> task) {
                System.out.println("POST result: " + task.getResult());
            }

            public void executeFailed(Task<URL> task) {
                System.out.println("POST fault: " + task.getFault());
            }
        });

        // PUT
        PutQuery putQuery = new PutQuery(HOSTNAME, PORT, PATH, SECURE);
        authentication.authenticate(putQuery);
        putQuery.setValue(JSONSerializer.parseMap("{a:100, b:200, c:300}"));

        putQuery.execute(new TaskListener<Void>() {
            public void taskExecuted(Task<Void> task) {
                System.out.println("PUT result");
            }

            public void executeFailed(Task<Void> task) {
                System.out.println("PUT fault: " + task.getFault());
            }
        });

        // POST
        DeleteQuery deleteQuery = new DeleteQuery(HOSTNAME, PORT, PATH, SECURE);
        authentication.authenticate(deleteQuery);

        deleteQuery.execute(new TaskListener<Void>() {
            public void taskExecuted(Task<Void> task) {
                System.out.println("DELETE result");
            }
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.