Package com.sun.jersey.api.client.filter

Examples of com.sun.jersey.api.client.filter.HTTPBasicAuthFilter


public class HttpClientFactory {

    public Client createClient() {
        Client client = ApacheHttpClient.create();
        client.setFollowRedirects(true);
        client.addFilter(new HTTPBasicAuthFilter("management/admin", "Pyi1bo1r"));
        client.addFilter(new ApplicationKeyFilter());
        return client;
    }
View Full Code Here


        getOptionValue( Messages.getInstance().getString( "CommandLineProcessor.INFO_OPTION_PASSWORD_KEY" ), Messages
            .getInstance().getString( "CommandLineProcessor.INFO_OPTION_PASSWORD_NAME" ), true, false );
    ClientConfig clientConfig = new DefaultClientConfig();
    clientConfig.getFeatures().put( JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE );
    client = Client.create( clientConfig );
    client.addFilter( new HTTPBasicAuthFilter( username, password ) );

    // check if the user has permissions to upload/download data
    String contextURL =
        getOptionValue( Messages.getInstance().getString( "CommandLineProcessor.INFO_OPTION_URL_KEY" ), Messages
            .getInstance().getString( "CommandLineProcessor.INFO_OPTION_URL_NAME" ), true, false );
View Full Code Here

    cc.getClasses().add(JacksonJsonProvider.class);

    Client client = ApacheHttpClient4.create(cc);

    client.setFollowRedirects(Boolean.TRUE);
    client.addFilter(new HTTPBasicAuthFilter(credsToUse.getKey(), credsToUse.getSecretKey()));

    return client;
  }
View Full Code Here

    }

    @Override
    public <T> Future<T> executeAsync(final Request<T> request, final Map<String,String> extraHeaders, final String apiKey) {
        final AsyncWebResource resource = client.asyncResource(ENDPOINT.value + request.getEndpoint());
        resource.addFilter(new HTTPBasicAuthFilter("", apiKey));

        final AsyncWebResource.Builder builder = resource.getRequestBuilder();

        builder.header(request.getResponseType().getHeaderName(), request.getResponseType().getHeaderValue());
        builder.header(Heroku.ApiVersion.HEADER, String.valueOf(Heroku.ApiVersion.v2.version));
View Full Code Here

        String username = config.getUsername();
        if (username != null && username.length() > 0) {
            String password = config.getPassword();
            client.removeFilter(null);
            client.addFilter(new HTTPBasicAuthFilter(username, password));
        }
        client.addFilter(new LoggingFilter(LOGGER));

        WebResource webResource = client.resource(config.getApiUrl());
        Markdown markdown = new Markdown(mdText);
View Full Code Here

        dcc.getProperties().put(HTTPSProperties.PROPERTY_HTTPS_PROPERTIES, prop);

        Client c = Client.create(dcc);

        // client basic auth demonstration
        c.addFilter(new HTTPBasicAuthFilter("user", "password"));

        System.out.println("Client: GET " + Server.BASE_URI);

        WebResource r = c.resource(Server.BASE_URI);
View Full Code Here

  private void addAuthentication( Client client ) {
    for( AuthenticationInfo authentication : authentications ) {
      ClientFilter filter = null;
      if( authentication.getType().equals( AuthenticationType.BASIC ) ) {
        filter = new HTTPBasicAuthFilter( authentication.getUser(), authentication.getPassword() );
      } else if( authentication.getType().equals( AuthenticationType.DIGEST ) ) {
        filter = new HTTPDigestAuthFilter( authentication.getUser(), authentication.getPassword() );
      }
      client.addFilter( filter );
    }
View Full Code Here

  private void addAuthentication( Client client ) {
    for( AuthenticationInfo authentication : authentications ) {
      ClientFilter filter = null;
      if( authentication.getType().equals( AuthenticationType.BASIC ) ) {
        filter = new HTTPBasicAuthFilter( authentication.getUser(), authentication.getPassword() );
      } else if( authentication.getType().equals( AuthenticationType.DIGEST ) ) {
        filter = new HTTPDigestAuthFilter( authentication.getUser(), authentication.getPassword() );
      }
      client.addFilter( filter );
    }
View Full Code Here

    public RestRequest(URI baseUri, String username, String password) {
        this.baseUri = uriWithoutSlash(baseUri);
        if (username != null) {
            client = Client.create();
            client.addFilter(new HTTPBasicAuthFilter(username, password));
        } else {
            client = DEFAULT_CLIENT;
        }
    }
View Full Code Here

    }

    private void addAuthFilter(String username, String password) {
        if (username == null) return;
        client.addFilter( new HTTPBasicAuthFilter( username, password ) );
    }
View Full Code Here

TOP

Related Classes of com.sun.jersey.api.client.filter.HTTPBasicAuthFilter

Copyright © 2018 www.massapicom. 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.