javapns.communication
Class ProxyManager

java.lang.Object
  extended by javapns.communication.ProxyManager

public class ProxyManager
extends Object

Main class for dealing with proxies.

Author:
Sylvain Pedneault

Method Summary
static String encodeProxyAuthorization(String username, String password)
           
static String getProxyAuthorization(AppleServer server)
          Get the proxy authorization currently configured.
static String getProxyHost(AppleServer server)
          Get the proxy host address currently configured.
static int getProxyPort(AppleServer server)
          Get the proxy port currently configured.
static boolean isUsingProxy(AppleServer server)
          Determine if a proxy is currently configured.
static void setJVMProxy(String host, String port)
          Configure a proxy to use for HTTPS connections created anywhere in the JVM (not recommended).
static void setProxy(String host, String port)
          Configure a proxy to use for HTTPS connections created by JavaPNS.
static void setProxyAuthorization(String authorization)
          Configure the authorization for the proxy configured through the setProxy method.
static void setProxyBasicAuthorization(String username, String password)
          Configure the authorization for the proxy configured through the setProxy method.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

setProxy

public static void setProxy(String host,
                            String port)
Configure a proxy to use for HTTPS connections created by JavaPNS.

Parameters:
host - the proxyHost
port - the proxyPort

setProxyBasicAuthorization

public static void setProxyBasicAuthorization(String username,
                                              String password)
Configure the authorization for the proxy configured through the setProxy method.

Parameters:
username - the user name to use
password - the password to use

setProxyAuthorization

public static void setProxyAuthorization(String authorization)
Configure the authorization for the proxy configured through the setProxy method.

Parameters:
authorization - the pre-encoded value for the Proxy-Authorization header sent to the proxy

encodeProxyAuthorization

public static String encodeProxyAuthorization(String username,
                                              String password)

setJVMProxy

public static void setJVMProxy(String host,
                               String port)
Configure a proxy to use for HTTPS connections created anywhere in the JVM (not recommended).

Parameters:
host - the proxyHost
port - the proxyPort

getProxyHost

public static String getProxyHost(AppleServer server)
Get the proxy host address currently configured. This method checks if a server-specific proxy has been configured, then checks if a proxy has been configured for the entire library, and finally checks if a JVM-wide proxy setting is available for HTTPS.

Parameters:
server - a specific server to check for proxy settings (may be null)
Returns:
a proxy host, or null if none is configured

getProxyAuthorization

public static String getProxyAuthorization(AppleServer server)
Get the proxy authorization currently configured. This method checks if a server-specific proxy has been configured, then checks if a proxy has been configured for the entire library, and finally checks if a JVM-wide proxy setting is available for HTTPS.

Parameters:
server - a specific server to check for proxy settings (may be null)
Returns:
a proxy authorization, or null if none is configured

getProxyPort

public static int getProxyPort(AppleServer server)
Get the proxy port currently configured. This method first locates a proxy host setting, then returns the proxy port from the same location.

Parameters:
server - a specific server to check for proxy settings (may be null)
Returns:
a network port, or 0 if no proxy is configured

isUsingProxy

public static boolean isUsingProxy(AppleServer server)
Determine if a proxy is currently configured.

Parameters:
server - a specific server to check for proxy settings (may be null)
Returns:
true if a proxy is set, false otherwise