no.ntnu.vegare.visualizer.client.connection
Class ConnectionHelper

java.lang.Object
  extended by no.ntnu.vegare.visualizer.client.connection.ConnectionHelper

public class ConnectionHelper
extends java.lang.Object

Thread safe singleton implementation by Bill Pugh: http://en.wikipedia.org/wiki/Singleton_pattern

Provides an interface towards the HTTP or HTTPS connection established in the authentication phase. Plain text access can be disabled in the configuration class.

Author:
vegare

Method Summary
 void disableCertificateChainVerification()
          This application is likely to be used in a local environment, where certificates are self-signed.
static ConnectionHelper getInstance()
           
 HttpsResponse request(HttpsRequest req)
          Make a HTTPS request, receive a response.
 java.security.cert.X509Certificate requestCertificate(java.lang.String url)
          Request the certificate from a HTTPS server.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static ConnectionHelper getInstance()

requestCertificate

public java.security.cert.X509Certificate requestCertificate(java.lang.String url)
                                                      throws java.io.IOException,
                                                             javax.net.ssl.SSLException

Request the certificate from a HTTPS server. In this prototype the certificate is not validated, but simply shown to the user as a basic identification effort.

This is not meant as a security measure, but as a usability enhancement. In a production system, proper security should be implemented.

Because no Authorization request property is added, the results will be a 401 error page, which is immediately discarded.

Throws:
java.io.IOException - Malformed URL (should be impossible) or connection timeout
javax.net.ssl.SSLException - Unverified certificate trust path

request

public HttpsResponse request(HttpsRequest req)
                      throws java.io.IOException

Make a HTTPS request, receive a response. Currently keep-alive is not implemented, thus each request is a separate connection.

Throws:
java.io.IOException - Malformed URL, connection timeout or unverified certificate, if validation is not disabled.

disableCertificateChainVerification

public void disableCertificateChainVerification()

This application is likely to be used in a local environment, where certificates are self-signed. Therefore, this class provides a measure to disable chain verification.

Should not be used in a production setting.