Package org.apache.commons.httpclient

Examples of org.apache.commons.httpclient.Header


  
   public String registerMessagingService(String consumerKey) throws Exception
   {
      HttpClient client = new HttpClient();
      PostMethod method = new PostMethod(ConsumerRegistrationURL);
      method.addRequestHeader(new Header("Authorization", "OpenId " + SubscriberOpenIdIdentifier));
      method.addParameter(OAuth.OAUTH_CONSUMER_KEY, consumerKey);
      int status = client.executeMethod(method);
      if (HttpResponseCodes.SC_OK != status) {
          throw new RuntimeException("Registration failed");
      }
View Full Code Here


  
   public void registerMessagingServiceScopes(String consumerKey, String scope) throws Exception
   {
       HttpClient client = new HttpClient();
       PostMethod method = new PostMethod(ConsumerScopesRegistrationURL);
       method.addRequestHeader(new Header("Authorization", "OpenId " + SubscriberOpenIdIdentifier));
       method.addParameter(OAuth.OAUTH_CONSUMER_KEY, consumerKey);
       method.addParameter("xoauth_scope", scope);
       method.addParameter("xoauth_permission", "sendMessages");
       int status = client.executeMethod(method);
       if (HttpResponseCodes.SC_OK != status) {
View Full Code Here

   public void registerMessagingServiceCallback(String consumerKey, String consumerSecret, String callback)
       throws Exception
   {
      HttpClient client = new HttpClient();
      PostMethod method = new PostMethod(MessagingServiceCallbackRegistrationURL);
      method.addRequestHeader(new Header("Authorization", "OpenId " + SubscriberOpenIdIdentifier));
      method.addParameter("consumer_id", consumerKey);
      method.addParameter("consumer_secret", consumerSecret);
      method.addParameter("callback_uri", callback);
      int status = client.executeMethod(method);
      if (HttpResponseCodes.SC_OK != status) {
View Full Code Here

   public void produceMessages()
      throws Exception
   {
      HttpClient client = new HttpClient();
      PostMethod method = new PostMethod(MessagingServiceMessagesURL);
      method.addRequestHeader(new Header("Authorization", "OpenId " + SubscriberOpenIdIdentifier));
      method.setRequestEntity(new StringRequestEntity("Hello !", "text/plain", "UTF-8"));
      int status = client.executeMethod(method);
      if (HttpResponseCodes.SC_OK != status) {
          throw new RuntimeException("Messages can not be sent");
      }
View Full Code Here

   public void getMessages()
       throws Exception
   {
       HttpClient client = new HttpClient();
       GetMethod method = new GetMethod(MessageReceiverGetURL);
       method.addRequestHeader(new Header("Authorization", "OpenId " + SubscriberOpenIdIdentifier));
       int status = client.executeMethod(method);
       if (HttpResponseCodes.SC_OK != status) {
           throw new RuntimeException("Messages can not be received");
       }
       String message = method.getResponseBodyAsString();
View Full Code Here

    {
       HttpClient client = new HttpClient();
       PostMethod method = new PostMethod(OpenIdTrustedRealmsURL);
       Base64 base64 = new Base64();
       String base64Credentials = new String(base64.encode("admin:admin".getBytes()));
       method.addRequestHeader(new Header("Authorization", "Basic " + base64Credentials));
       method.addParameter("xopenid.realm", OpenIdTrustedRealm);
       int status = client.executeMethod(method);
       if (HttpResponseCodes.SC_OK != status) {
           throw new RuntimeException("OpenId realms can not be registered");
       }
View Full Code Here

       HttpClient client = new HttpClient();
       GetMethod method = new GetMethod(EndUserResourceURL + relativeURI);
      
       Base64 base64 = new Base64();
       String base64Credentials = new String(base64.encode("admin:admin".getBytes()));
       method.addRequestHeader(new Header("Authorization", "Basic " + base64Credentials));
      
       int status = client.executeMethod(method);
       if ("/invisible".equals(relativeURI)) {
           if (status != 401) {
               throw new RuntimeException("End user can access the invisible resource");
View Full Code Here

   public String authorizeConsumerRequestToken(String url) throws Exception
   {
      HttpClient client = new HttpClient();
      GetMethod method = new GetMethod(url);
      // request that XML formatted authorization request is presented
      method.addRequestHeader(new Header("Accept", "application/xml"));
      Base64 base64 = new Base64();
      String base64Credentials = new String(base64.encode("admin:admin".getBytes()));
      method.addRequestHeader(new Header("Authorization", "Basic " + base64Credentials));
     
      int status = client.executeMethod(method);
      if (200 != status) {
          throw new RuntimeException("No authorization request data is available");
      }
View Full Code Here

   {
      HttpClient client = new HttpClient();
      PostMethod method = new PostMethod(url);
      Base64 base64 = new Base64();
      String base64Credentials = new String(base64.encode("admin:admin".getBytes()));
      method.addRequestHeader(new Header("Authorization", "Basic " + base64Credentials));
     
      int status = client.executeMethod(method);
      if (302 != status) {
          throw new RuntimeException("Initiation failed");
      }
View Full Code Here

      HttpClient client = new HttpClient();
      HeadMethod method = new HeadMethod(TestPortProvider.generateURL("/GetTest"));
      method.addRequestHeader("Accept", "text/plain");
      int status = client.executeMethod(method);
      Assert.assertEquals(200, status);
      Header header = method.getResponseHeader("CTS-HEAD");
      Assert.assertNotNull(header);
      Assert.assertEquals("text-plain", header.getValue());
   }
View Full Code Here

TOP

Related Classes of org.apache.commons.httpclient.Header

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.