harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ghar...@apache.org
Subject svn commit: r418484 - in /incubator/harmony/enhanced/classlib/trunk/modules/luni: make/ src/main/java/org/apache/harmony/luni/internal/net/www/protocol/https/
Date Sat, 01 Jul 2006 15:07:23 GMT
Author: gharley
Date: Sat Jul  1 08:07:23 2006
New Revision: 418484

URL: http://svn.apache.org/viewvc?rev=418484&view=rev
Log:
HARMONY 717 : Harmony lacks of HttpsURLConnection implementation

Added:
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/https/
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/https/Handler.java
  (with props)
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/https/HttpsURLConnection.java
  (with props)
Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/luni/make/patternset.txt

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/make/patternset.txt
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/make/patternset.txt?rev=418484&r1=418483&r2=418484&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/make/patternset.txt (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/make/patternset.txt Sat Jul  1
08:07:23 2006
@@ -22,6 +22,7 @@
 org/apache/harmony/luni/internal/net/www/protocol/file/*
 org/apache/harmony/luni/internal/net/www/protocol/ftp/*
 org/apache/harmony/luni/internal/net/www/protocol/http/*
+org/apache/harmony/luni/internal/net/www/protocol/https/*
 org/apache/harmony/luni/internal/net/www/protocol/jar/*
 
 java/io/*

Added: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/https/Handler.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/https/Handler.java?rev=418484&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/https/Handler.java
(added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/https/Handler.java
Sat Jul  1 08:07:23 2006
@@ -0,0 +1,46 @@
+/* Copyright 1998, 2006 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed 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.
+ */
+
+package org.apache.harmony.luni.internal.net.www.protocol.https;
+
+import java.io.IOException;
+import java.net.Proxy;
+import java.net.URL;
+import java.net.URLConnection;
+import java.net.URLStreamHandler;
+
+/**
+ * Handler for HttpsURLConnection implementation.
+ */
+public class Handler extends URLStreamHandler {
+
+    protected URLConnection openConnection(URL url) throws IOException {
+        return new HttpsURLConnection(url, getDefaultPort());
+    }
+
+    protected URLConnection openConnection(URL url, Proxy proxy)
+                                                    throws IOException {
+        if((url == null) || (proxy == null)) {
+            throw new IllegalArgumentException(
+                    "Some of the parameters is null");
+        }
+        return new HttpsURLConnection(url, getDefaultPort(), proxy);
+    }
+
+    protected int getDefaultPort() {
+        return 443;
+    }
+}
+

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/https/Handler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/https/HttpsURLConnection.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/https/HttpsURLConnection.java?rev=418484&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/https/HttpsURLConnection.java
(added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/https/HttpsURLConnection.java
Sat Jul  1 08:07:23 2006
@@ -0,0 +1,328 @@
+/* Copyright 1998, 2006 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed 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.
+ */
+
+package org.apache.harmony.luni.internal.net.www.protocol.https;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.ProtocolException;
+import java.net.Proxy;
+import java.net.Socket;
+import java.net.URL;
+import java.security.Permission;
+import java.security.Principal;
+import java.security.cert.Certificate;
+import java.util.List;
+import java.util.Map;
+import javax.net.ssl.SSLPeerUnverifiedException;
+import javax.net.ssl.SSLSocket;
+
+import org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnection;
+
+/**
+ * HttpsURLConnection implementation.
+ */
+public class HttpsURLConnection extends javax.net.ssl.HttpsURLConnection {
+
+    // Https engine to be wrapped
+    private final HttpsEngine httpsEngine;
+    // SSLSocket to be used for connection
+    private SSLSocket sslSocket;
+
+    protected HttpsURLConnection(URL url, int port) {
+        super(url);
+        httpsEngine = new HttpsEngine(url, port);
+    }
+
+    protected HttpsURLConnection(URL url, int port, Proxy proxy) {
+        super(url);
+        httpsEngine = new HttpsEngine(url, port, proxy);
+    }
+
+    // ---------------------------------------------------------------------
+    // ----------- HttpsURLConnection methods implementation ---------------
+    // ---------------------------------------------------------------------
+
+    public String getCipherSuite() {
+        if (sslSocket == null) {
+            throw new IllegalStateException(
+                    "Connection has not been established yet.");
+        }
+        return sslSocket.getSession().getCipherSuite();
+    }
+
+    public Certificate[] getLocalCertificates() {
+        if (sslSocket == null) {
+            throw new IllegalStateException(
+                    "Connection has not been established yet.");
+        }
+        return sslSocket.getSession().getLocalCertificates();
+    }
+
+    public Certificate[] getServerCertificates()
+                                         throws SSLPeerUnverifiedException {
+        if (sslSocket == null) {
+            throw new IllegalStateException(
+                    "Connection has not been established yet.");
+        }
+        return sslSocket.getSession().getPeerCertificates();
+    }
+
+    public Principal getPeerPrincipal() throws SSLPeerUnverifiedException {
+        if (sslSocket == null) {
+            throw new IllegalStateException(
+                    "Connection has not been established yet.");
+        }
+        return sslSocket.getSession().getPeerPrincipal();
+    }
+
+    public Principal getLocalPrincipal() {
+        if (sslSocket == null) {
+            throw new IllegalStateException(
+                    "Connection has not been established yet.");
+        }
+        return sslSocket.getSession().getLocalPrincipal();
+    }
+
+    // ---------------------------------------------------------------------
+    // ------------ HttpURLConnection methods implementation ---------------
+    // ---------------------------------------------------------------------
+
+    public void disconnect() {
+        httpsEngine.disconnect();
+    }
+
+    public InputStream getErrorStream() {
+        return httpsEngine.getErrorStream();
+    }
+
+    public String getRequestMethod() {
+        return httpsEngine.getRequestMethod();
+    }
+
+    public int getResponseCode() throws IOException {
+        return httpsEngine.getResponseCode();
+    }
+
+    public String getResponseMessage() throws IOException {
+        return httpsEngine.getResponseMessage();
+    }
+
+    public void setRequestMethod(String method) throws ProtocolException {
+        httpsEngine.setRequestMethod(method);
+    }
+
+    public boolean usingProxy() {
+        return httpsEngine.usingProxy();
+    }
+
+    public boolean getInstanceFollowRedirects() {
+        return httpsEngine.getInstanceFollowRedirects();
+    }
+
+    public void setInstanceFollowRedirects(boolean followRedirects) {
+        httpsEngine.setInstanceFollowRedirects(followRedirects);
+    }
+
+    // ---------------------------------------------------------------------
+    // --------------- URLConnection methods implementation ----------------
+    // ---------------------------------------------------------------------
+
+    public void connect() throws IOException {
+        httpsEngine.connect();
+    };
+
+    public boolean getAllowUserInteraction() {
+        return httpsEngine.getAllowUserInteraction();
+    }
+
+    public Object getContent() throws IOException {
+        return httpsEngine.getContent();
+    }
+
+    public Object getContent(Class[] types) throws IOException {
+        return httpsEngine.getContent(types);
+    }
+
+    public String getContentEncoding() {
+        return httpsEngine.getContentEncoding();
+    }
+
+    public int getContentLength() {
+        return httpsEngine.getContentLength();
+    }
+
+    public String getContentType() {
+        return httpsEngine.getContentType();
+    }
+
+    public long getDate() {
+        return httpsEngine.getDate();
+    }
+
+    public boolean getDefaultUseCaches() {
+        return httpsEngine.getDefaultUseCaches();
+    }
+
+    public boolean getDoInput() {
+        return httpsEngine.getDoInput();
+    }
+
+    public boolean getDoOutput() {
+        return httpsEngine.getDoOutput();
+    }
+
+    public long getExpiration() {
+        return httpsEngine.getExpiration();
+    }
+
+    public String getHeaderField(int pos) {
+        return httpsEngine.getHeaderField(pos);
+    }
+
+    public Map<String, List<String>> getHeaderFields() {
+        return httpsEngine.getHeaderFields();
+    }
+
+    public Map<String, List<String>> getRequestProperties() {
+        return httpsEngine.getRequestProperties();
+    }
+
+    public void addRequestProperty(String field, String newValue) {
+        httpsEngine.addRequestProperty(field, newValue);
+    }
+
+    public String getHeaderField(String key) {
+        return httpsEngine.getHeaderField(key);
+    }
+
+    public long getHeaderFieldDate(String field, long defaultValue) {
+        return httpsEngine.getHeaderFieldDate(field, defaultValue);
+    }
+
+    public int getHeaderFieldInt(String field, int defaultValue) {
+        return httpsEngine.getHeaderFieldInt(field, defaultValue);
+    }
+
+    public String getHeaderFieldKey(int posn) {
+        return httpsEngine.getHeaderFieldKey(posn);
+    }
+
+    public long getIfModifiedSince() {
+        return httpsEngine.getIfModifiedSince();
+    }
+
+    public InputStream getInputStream() throws IOException {
+        return httpsEngine.getInputStream();
+    }
+
+    public long getLastModified() {
+        return httpsEngine.getLastModified();
+    }
+
+    public OutputStream getOutputStream() throws IOException {
+        return httpsEngine.getOutputStream();
+    }
+
+    public Permission getPermission() throws IOException {
+        return httpsEngine.getPermission();
+    }
+
+    public String getRequestProperty(String field) {
+        return httpsEngine.getRequestProperty(field);
+    }
+
+    public URL getURL() {
+        return httpsEngine.getURL();
+    }
+
+    public boolean getUseCaches() {
+        return httpsEngine.getUseCaches();
+    }
+
+    public void setAllowUserInteraction(boolean newValue) {
+        httpsEngine.setAllowUserInteraction(newValue);
+    }
+
+    public void setDefaultUseCaches(boolean newValue) {
+        httpsEngine.setDefaultUseCaches(newValue);
+    }
+
+    public void setDoInput(boolean newValue) {
+        httpsEngine.setDoInput(newValue);
+    }
+
+    public void setDoOutput(boolean newValue) {
+        httpsEngine.setDoOutput(newValue);
+    }
+
+    public void setIfModifiedSince(long newValue) {
+        httpsEngine.setIfModifiedSince(newValue);
+    }
+
+    public void setRequestProperty(String field, String newValue) {
+        httpsEngine.setRequestProperty(field, newValue);
+
+    }
+
+    public void setUseCaches(boolean newValue) {
+        httpsEngine.setUseCaches(newValue);
+    }
+
+    public void setConnectTimeout(int timeout) {
+        httpsEngine.setConnectTimeout(timeout);
+    }
+
+    public int getConnectTimeout() {
+        return httpsEngine.getConnectTimeout();
+    }
+
+    public void setReadTimeout(int timeout) {
+        httpsEngine.setReadTimeout(timeout);
+    }
+
+    public int getReadTimeout() {
+        return httpsEngine.getReadTimeout();
+    }
+
+    public String toString() {
+        return httpsEngine.toString();
+    }
+
+    // ---------------------------------------------------------------------
+    // ---------------------------------------------------------------------
+    // ---------------------------------------------------------------------
+
+    /*
+     * HttpsEngine
+     */
+    private class HttpsEngine extends HttpURLConnection {
+
+        protected HttpsEngine(URL url, int port) {
+            super(url, port);
+        }
+
+        protected HttpsEngine(URL url, int port, Proxy proxy) {
+            super(url, port, proxy);
+        }
+
+        public void connect() throws IOException {
+            super.connect();
+            // TODO wrap established Socket into SSLSocket
+        }
+    }
+}
+

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/https/HttpsURLConnection.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message