< prev index next >

src/java.base/share/classes/javax/net/ssl/SSLSocketFactory.java

Print this page
rev 14210 : 8154231: Simplify access to System properties from JDK code
Reviewed-by: rriggs


  34 import java.util.Locale;
  35 
  36 import sun.security.action.GetPropertyAction;
  37 
  38 /**
  39  * <code>SSLSocketFactory</code>s create <code>SSLSocket</code>s.
  40  *
  41  * @since 1.4
  42  * @see SSLSocket
  43  * @author David Brownell
  44  */
  45 public abstract class SSLSocketFactory extends SocketFactory
  46 {
  47     private static SSLSocketFactory theFactory;
  48 
  49     private static boolean propertyChecked;
  50 
  51     static final boolean DEBUG;
  52 
  53     static {
  54         String s = java.security.AccessController.doPrivileged(
  55             new GetPropertyAction("javax.net.debug", "")).toLowerCase(
  56                                                             Locale.ENGLISH);
  57         DEBUG = s.contains("all") || s.contains("ssl");
  58     }
  59 
  60     private static void log(String msg) {
  61         if (DEBUG) {
  62             System.out.println(msg);
  63         }
  64     }
  65 
  66     /**
  67      * Constructor is used only by subclasses.
  68      */
  69     public SSLSocketFactory() {
  70     }
  71 
  72     /**
  73      * Returns the default SSL socket factory.
  74      *
  75      * <p>The first time this method is called, the security property
  76      * "ssl.SocketFactory.provider" is examined. If it is non-null, a class by




  34 import java.util.Locale;
  35 
  36 import sun.security.action.GetPropertyAction;
  37 
  38 /**
  39  * <code>SSLSocketFactory</code>s create <code>SSLSocket</code>s.
  40  *
  41  * @since 1.4
  42  * @see SSLSocket
  43  * @author David Brownell
  44  */
  45 public abstract class SSLSocketFactory extends SocketFactory
  46 {
  47     private static SSLSocketFactory theFactory;
  48 
  49     private static boolean propertyChecked;
  50 
  51     static final boolean DEBUG;
  52 
  53     static {
  54         String s = GetPropertyAction.getProperty("javax.net.debug", "")
  55                 .toLowerCase(Locale.ENGLISH);
  56 
  57         DEBUG = s.contains("all") || s.contains("ssl");
  58     }
  59 
  60     private static void log(String msg) {
  61         if (DEBUG) {
  62             System.out.println(msg);
  63         }
  64     }
  65 
  66     /**
  67      * Constructor is used only by subclasses.
  68      */
  69     public SSLSocketFactory() {
  70     }
  71 
  72     /**
  73      * Returns the default SSL socket factory.
  74      *
  75      * <p>The first time this method is called, the security property
  76      * "ssl.SocketFactory.provider" is examined. If it is non-null, a class by


< prev index next >