Examples of BasicScheme


Examples of org.apache.commons.httpclient.auth.BasicScheme

   * @return true if the client is authorized, false if not.
   * @param clientAuth
   */
  private boolean checkAuthorization(Header clientAuth) {
    // TODO Auto-generated method stub
    BasicScheme scheme;
    try {
      scheme = new BasicScheme("basic realm=test");
      String expectedAuthString = scheme.authenticate(credentials, null, null);
      return expectedAuthString.equals(clientAuth.getValue());
    } catch (MalformedChallengeException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (AuthenticationException e) {
View Full Code Here

Examples of org.apache.http.impl.auth.BasicScheme

                // Obtain credentials matching the target host
                Credentials creds = credsProvider.getCredentials(authScope);

                // If found, generate BasicScheme preemptively
                if(creds != null) {
                    authState.setAuthScheme(new BasicScheme());
                    authState.setCredentials(creds);
                }
            }
        }
View Full Code Here

Examples of org.apache.http.impl.auth.BasicScheme

                this.credentials);
       
          // Create AuthCache instance
          AuthCache authCache = new BasicAuthCache();
          // Generate BASIC scheme object and add it to the local auth cache
          BasicScheme basicAuth = new BasicScheme();
          authCache.put(targetHost, basicAuth);

          // Add AuthCache to the execution context
          BasicHttpContext localcontext = new BasicHttpContext();
          localcontext.setAttribute(ClientContext.AUTH_CACHE, authCache);
View Full Code Here

Examples of org.apache.http.impl.auth.BasicScheme

              this.credentials);
     
      // Create AuthCache instance
      AuthCache authCache = new BasicAuthCache();
      // Generate BASIC scheme object and add it to the local auth cache
      BasicScheme basicAuth = new BasicScheme();
   
      authCache.put(targetHost, basicAuth);

      // Add AuthCache to the execution context
      BasicHttpContext localcontext = new BasicHttpContext();
View Full Code Here

Examples of org.apache.http.impl.auth.BasicScheme

            // Obtain credentials matching the target host
            Credentials creds = credsProvider.getCredentials(authScope);

            // If found, generate BasicScheme preemptively
            if (creds != null) {
                authState.setAuthScheme(new BasicScheme());
                authState.setCredentials(creds);
            }
        }
    }
View Full Code Here

Examples of org.apache.http.impl.auth.BasicScheme

        );

    AuthCache authCache = new BasicAuthCache();
    authCache.put(
        new HttpHost( host, port, "http" ),
        new BasicScheme()
        );

    BasicHttpContext localContext = new BasicHttpContext();
    localContext.setAttribute( ClientContext.AUTH_CACHE, authCache );
View Full Code Here

Examples of org.apache.http.impl.auth.BasicScheme

  public static Map<String, Object> get(String url, Integer connectionTimeout, Integer soTimeout, Map<String, Object> authMap) throws Exception
  {
    HttpClient client = getHttpClient(url, connectionTimeout, soTimeout);
    HttpGet httpclient = new HttpGet(url);
    if (authMap != null)
      httpclient.addHeader(new BasicScheme().authenticate(new UsernamePasswordCredentials((String) authMap.get("user"), (String) authMap.get("password")), httpclient));
    HttpResponse response = client.execute(httpclient);
    HttpEntity resEntity = response.getEntity();
    String contentCharSet = EntityUtils.getContentCharSet(resEntity);
    HashMap<String, Object> map = new HashMap<String, Object>();
    map.put("status", response.getStatusLine().getStatusCode());
View Full Code Here

Examples of org.apache.http.impl.auth.BasicScheme

     * @throws IOException can be thrown
     */
    protected HttpResponse executeMethod(HttpUriRequest httpRequest) throws IOException {
        HttpContext localContext = new BasicHttpContext();
        if (getEndpoint().isAuthenticationPreemptive()) {
            BasicScheme basicAuth = new BasicScheme();
            localContext.setAttribute("preemptive-auth", basicAuth);
        }
        if (httpContext != null) {
            localContext = new BasicHttpContext(httpContext);
        }
View Full Code Here

Examples of org.apache.http.impl.auth.BasicScheme

        DefaultHttpClient httpclient = new DefaultHttpClient();
        try {
          HttpPost httpPost = new HttpPost(URL);
          System.out.println(URL);
            UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(username, password);
            BasicScheme scheme = new BasicScheme();
            Header authorizationHeader = scheme.authenticate(credentials, httpPost);
            httpPost.setHeader(authorizationHeader);
            httpPost.setEntity(input);
            //System.out.println("Executing request: " + httpGet.getRequestLine());
            //System.out.println(response);
//            response = httpclient.execute(httpGet,responseHandler);
View Full Code Here

Examples of org.apache.http.impl.auth.BasicScheme

        DefaultHttpClient httpclient = new DefaultHttpClient();
        try {
            HttpGet httpGet = new HttpGet(URL);

            UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(username, password);
            BasicScheme scheme = new BasicScheme();
            Header authorizationHeader = scheme.authenticate(credentials, httpGet);
            httpGet.setHeader(authorizationHeader);
            ResponseHandler<String> responseHandler = new BasicResponseHandler();
           
            //System.out.println("Executing request: " + httpGet.getRequestLine());
            //System.out.println(response);
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.