hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r554005 - in /jakarta/httpcomponents/httpclient/trunk/module-client/src/examples/org/apache/http/examples/client: ClientAbortMethod.java ClientConnectionRelease.java ClientCustomContext.java ClientCustomSSL.java
Date Fri, 06 Jul 2007 19:20:28 GMT
Author: olegk
Date: Fri Jul  6 12:20:26 2007
New Revision: 554005

URL: http://svn.apache.org/viewvc?view=rev&rev=554005
Log:
Added custom SSL sample

Added:
    jakarta/httpcomponents/httpclient/trunk/module-client/src/examples/org/apache/http/examples/client/ClientCustomSSL.java
  (with props)
Modified:
    jakarta/httpcomponents/httpclient/trunk/module-client/src/examples/org/apache/http/examples/client/ClientAbortMethod.java
    jakarta/httpcomponents/httpclient/trunk/module-client/src/examples/org/apache/http/examples/client/ClientConnectionRelease.java
    jakarta/httpcomponents/httpclient/trunk/module-client/src/examples/org/apache/http/examples/client/ClientCustomContext.java

Modified: jakarta/httpcomponents/httpclient/trunk/module-client/src/examples/org/apache/http/examples/client/ClientAbortMethod.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/module-client/src/examples/org/apache/http/examples/client/ClientAbortMethod.java?view=diff&rev=554005&r1=554004&r2=554005
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/module-client/src/examples/org/apache/http/examples/client/ClientAbortMethod.java
(original)
+++ jakarta/httpcomponents/httpclient/trunk/module-client/src/examples/org/apache/http/examples/client/ClientAbortMethod.java
Fri Jul  6 12:20:26 2007
@@ -38,12 +38,7 @@
 import org.apache.http.impl.client.DefaultHttpClient;
 
 /**
- * How to abort an HTTP method before its normal completion.
- *
- * <!-- empty lines above to avoid 'svn diff' context problems -->
- * @version $Revision$
- *
- * @since 4.0
+ * This example demonstrates how to abort an HTTP method before its normal completion.
  */
 public class ClientAbortMethod {
 

Modified: jakarta/httpcomponents/httpclient/trunk/module-client/src/examples/org/apache/http/examples/client/ClientConnectionRelease.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/module-client/src/examples/org/apache/http/examples/client/ClientConnectionRelease.java?view=diff&rev=554005&r1=554004&r2=554005
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/module-client/src/examples/org/apache/http/examples/client/ClientConnectionRelease.java
(original)
+++ jakarta/httpcomponents/httpclient/trunk/module-client/src/examples/org/apache/http/examples/client/ClientConnectionRelease.java
Fri Jul  6 12:20:26 2007
@@ -42,13 +42,8 @@
 import org.apache.http.impl.client.DefaultHttpClient;
 
 /**
- * This examples demonstrates the recommended way of using API to make sure 
+ * This example demonstrates the recommended way of using API to make sure 
  * the underlying connection gets released back to the connection manager.
- *
- * <!-- empty lines above to avoid 'svn diff' context problems -->
- * @version $Revision$
- *
- * @since 4.0
  */
 public class ClientConnectionRelease {
 

Modified: jakarta/httpcomponents/httpclient/trunk/module-client/src/examples/org/apache/http/examples/client/ClientCustomContext.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/module-client/src/examples/org/apache/http/examples/client/ClientCustomContext.java?view=diff&rev=554005&r1=554004&r2=554005
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/module-client/src/examples/org/apache/http/examples/client/ClientCustomContext.java
(original)
+++ jakarta/httpcomponents/httpclient/trunk/module-client/src/examples/org/apache/http/examples/client/ClientCustomContext.java
Fri Jul  6 12:20:26 2007
@@ -42,13 +42,8 @@
 import org.apache.http.protocol.HttpContext;
 
 /**
- * This examples demonstrates the use of a local HTTP context
- * populated with custom attributes.
- *
- * <!-- empty lines above to avoid 'svn diff' context problems -->
- * @version $Revision$
- *
- * @since 4.0
+ * This example demonstrates the use of a local HTTP context populated with 
+ * custom attributes.
  */
 public class ClientCustomContext {
 

Added: jakarta/httpcomponents/httpclient/trunk/module-client/src/examples/org/apache/http/examples/client/ClientCustomSSL.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/module-client/src/examples/org/apache/http/examples/client/ClientCustomSSL.java?view=auto&rev=554005
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/module-client/src/examples/org/apache/http/examples/client/ClientCustomSSL.java
(added)
+++ jakarta/httpcomponents/httpclient/trunk/module-client/src/examples/org/apache/http/examples/client/ClientCustomSSL.java
Fri Jul  6 12:20:26 2007
@@ -0,0 +1,84 @@
+/*
+ * $Header$
+ * $Revision$
+ * $Date$
+ * ====================================================================
+ *
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ * [Additional notices, if required by prior licensing conditions]
+ *
+ */
+
+package org.apache.http.examples.client;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.security.KeyStore;
+
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.conn.Scheme;
+import org.apache.http.conn.ssl.SSLSocketFactory;
+import org.apache.http.impl.client.DefaultHttpClient;
+
+/**
+ * This example demonstrates how to create secure connections with a custom SSL
+ * context.
+ */
+public class ClientCustomSSL {
+
+    public final static void main(String[] args) throws Exception {
+        DefaultHttpClient httpclient = new DefaultHttpClient();
+
+        KeyStore trustStore  = KeyStore.getInstance(KeyStore.getDefaultType());        
+        FileInputStream instream = new FileInputStream(new File("my.keystore")); 
+        try {
+            trustStore.load(instream, "nopassword".toCharArray());
+        } finally {
+            instream.close();
+        }
+        
+        SSLSocketFactory socketFactory = new SSLSocketFactory(trustStore);
+        Scheme sch = new Scheme("https", socketFactory, 443);
+        httpclient.getConnectionManager().getSchemeRegistry().register(sch);
+
+        HttpGet httpget = new HttpGet("https://localhost/");
+
+        System.out.println("executing request" + httpget.getRequestLine());
+        
+        HttpResponse response = httpclient.execute(httpget);
+        HttpEntity entity = response.getEntity();
+
+        System.out.println("----------------------------------------");
+        System.out.println(response.getStatusLine());
+        if (entity != null) {
+            System.out.println("Response content length: " + entity.getContentLength());
+            System.out.println("Chunked?: " + entity.isChunked());
+        }
+        if (entity != null) {
+            entity.consumeContent();
+        }
+    }
+
+}

Propchange: jakarta/httpcomponents/httpclient/trunk/module-client/src/examples/org/apache/http/examples/client/ClientCustomSSL.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/httpcomponents/httpclient/trunk/module-client/src/examples/org/apache/http/examples/client/ClientCustomSSL.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: jakarta/httpcomponents/httpclient/trunk/module-client/src/examples/org/apache/http/examples/client/ClientCustomSSL.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message