HTTPS connections  EAServer’s HttpsURLConnection class

Chapter 5: Using SSL in Java Clients

Installing the HTTPS protocol handler

The EAServer HTTPS protocol handler can be installed two ways:


Configuring the default protocol handlers

The java.protocol.handler.pkgs Java system property configures the Java virtual machine default URL protocol handlers. To use the EAServer handlers, you must add com.sybase.jaguar.net to the list. For more information on this property, see the documentation for java.net.URL in JDK 1.2.

In a client application, specify this property on the command line; for example:

jre -Djava.protocol.handler.pkgs=com.sybase.jaguar.net ...

For an EAServer, set the JVM options property using the Advanced tab in the Server Properties dialog box:

Property

Value

com.sybase.jaguar.server.jvm.options

If not already set, set to:

-Djava.protocol.handler.pkgs=com.sybase.jaguar.net

If already set, verify that the value includes this option. JVM options must be separated with a comma.

You can specify more than one package by separating package names with a | (pipe) character, but you can configure only one handler per protocol.


Specifying protocol handlers at runtime

If you must use more than one HTTPS protocol handler in one EAServer or in one client application, you must call one of the java.net.URL constructors that takes a java.net.URLStreamHandler as a parameter. The specified java.net.URLStreamHandler instance overrides the default handler for the protocol specified by the URL. For example, to specify the EAServer HTTPS handler, use code like this:

import java.net.*;
import com.sybase.jaguar.net.JagURLStreamHandlerFactory;
import com.sybase.jaguar.net.HttpsURLConnection;

....

String url_string = "https://localhost:8081/index.html";

// The URL stream handler factory is required to create a stream
// handler.
JagURLStreamHandlerFactory fact = new JagURLStreamHandlerFactory();

// Extract the protocol from the front of the URL string
String protocol = url_string.substring(0, url_string.indexOf(":"));

// If the protocol is HTTPS, use the EAServer HTTPS handler. Otherwise,
// use the default handler
java.net.URL url;
if (protocol.equals("https"))
{
    url = new URL((URL)null, url_string,
        fact.createURLStreamHandler(protocol));
} else
{
    url = new URL(url_string);
}




Copyright © 2005. Sybase Inc. All rights reserved. EAServer’s HttpsURLConnection class

View this book as PDF