< prev index next >

src/java.base/windows/classes/sun/net/www/protocol/http/ntlm/NTLMAuthentication.java

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


  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package sun.net.www.protocol.http.ntlm;
  27 
  28 import java.io.IOException;
  29 import java.net.InetAddress;
  30 import java.net.PasswordAuthentication;
  31 import java.net.UnknownHostException;
  32 import java.net.URL;
  33 import sun.net.www.HeaderParser;
  34 import sun.net.www.protocol.http.AuthenticationInfo;
  35 import sun.net.www.protocol.http.AuthScheme;
  36 import sun.net.www.protocol.http.HttpURLConnection;

  37 
  38 /**
  39  * NTLMAuthentication:
  40  *
  41  * @author Michael McMahon
  42  */
  43 
  44 public class NTLMAuthentication extends AuthenticationInfo {
  45 
  46     private static final long serialVersionUID = 100L;
  47 
  48     private static final NTLMAuthenticationCallback NTLMAuthCallback =
  49         NTLMAuthenticationCallback.getNTLMAuthenticationCallback();
  50 
  51     private String hostname;
  52     private static String defaultDomain; /* Domain to use if not specified by user */
  53 
  54     static {
  55         defaultDomain = java.security.AccessController.doPrivileged(
  56             new sun.security.action.GetPropertyAction("http.auth.ntlm.domain",
  57                                                       "domain"));
  58     };
  59 
  60     private void init0() {
  61 
  62         hostname = java.security.AccessController.doPrivileged(
  63             new java.security.PrivilegedAction<String>() {
  64             public String run() {
  65                 String localhost;
  66                 try {
  67                     localhost = InetAddress.getLocalHost().getHostName().toUpperCase();
  68                 } catch (UnknownHostException e) {
  69                      localhost = "localhost";
  70                 }
  71                 return localhost;
  72             }
  73         });
  74         int x = hostname.indexOf ('.');
  75         if (x != -1) {
  76             hostname = hostname.substring (0, x);
  77         }




  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package sun.net.www.protocol.http.ntlm;
  27 
  28 import java.io.IOException;
  29 import java.net.InetAddress;
  30 import java.net.PasswordAuthentication;
  31 import java.net.UnknownHostException;
  32 import java.net.URL;
  33 import sun.net.www.HeaderParser;
  34 import sun.net.www.protocol.http.AuthenticationInfo;
  35 import sun.net.www.protocol.http.AuthScheme;
  36 import sun.net.www.protocol.http.HttpURLConnection;
  37 import sun.security.action.GetPropertyAction;
  38 
  39 /**
  40  * NTLMAuthentication:
  41  *
  42  * @author Michael McMahon
  43  */
  44 
  45 public class NTLMAuthentication extends AuthenticationInfo {
  46 
  47     private static final long serialVersionUID = 100L;
  48 
  49     private static final NTLMAuthenticationCallback NTLMAuthCallback =
  50         NTLMAuthenticationCallback.getNTLMAuthenticationCallback();
  51 
  52     private String hostname;
  53     private static String defaultDomain; /* Domain to use if not specified by user */
  54 
  55     static {
  56         defaultDomain = GetPropertyAction.getProperty("http.auth.ntlm.domain",
  57                                                       "domain");

  58     };
  59 
  60     private void init0() {
  61 
  62         hostname = java.security.AccessController.doPrivileged(
  63             new java.security.PrivilegedAction<String>() {
  64             public String run() {
  65                 String localhost;
  66                 try {
  67                     localhost = InetAddress.getLocalHost().getHostName().toUpperCase();
  68                 } catch (UnknownHostException e) {
  69                      localhost = "localhost";
  70                 }
  71                 return localhost;
  72             }
  73         });
  74         int x = hostname.indexOf ('.');
  75         if (x != -1) {
  76             hostname = hostname.substring (0, x);
  77         }


< prev index next >