aboutsummaryrefslogtreecommitdiff
path: root/src/windows/classes/sun
diff options
context:
space:
mode:
Diffstat (limited to 'src/windows/classes/sun')
-rw-r--r--src/windows/classes/sun/awt/windows/WPrinterJob.java6
-rw-r--r--src/windows/classes/sun/net/www/protocol/file/Handler.java4
-rw-r--r--src/windows/classes/sun/net/www/protocol/file/UNCFileURLConnection.java52
-rw-r--r--src/windows/classes/sun/net/www/protocol/http/ntlm/NTLMAuthentication.java14
-rw-r--r--src/windows/classes/sun/print/PrintServiceLookupProvider.java (renamed from src/windows/classes/sun/print/Win32PrintServiceLookup.java)128
-rw-r--r--src/windows/classes/sun/print/services/javax.print.PrintServiceLookup2
-rw-r--r--src/windows/classes/sun/print/services/javax.print.StreamPrintServiceFactory2
-rw-r--r--src/windows/classes/sun/security/krb5/internal/tools/Klist.java38
8 files changed, 218 insertions, 28 deletions
diff --git a/src/windows/classes/sun/awt/windows/WPrinterJob.java b/src/windows/classes/sun/awt/windows/WPrinterJob.java
index 3b7c5f3c98..e32bd50999 100644
--- a/src/windows/classes/sun/awt/windows/WPrinterJob.java
+++ b/src/windows/classes/sun/awt/windows/WPrinterJob.java
@@ -93,7 +93,7 @@ import sun.print.SunAlternateMedia;
import sun.print.SunPageSelection;
import sun.print.Win32MediaTray;
import sun.print.Win32PrintService;
-import sun.print.Win32PrintServiceLookup;
+import sun.print.PrintServiceLookupProvider;
import sun.print.ServiceDialog;
import sun.print.DialogOwner;
@@ -454,7 +454,7 @@ public final class WPrinterJob extends RasterPrinterJob
// native printer is different !
// we update the current PrintService
try {
- setPrintService(Win32PrintServiceLookup.
+ setPrintService(PrintServiceLookupProvider.
getWin32PrintLUS().
getPrintServiceByName(printerName));
} catch (PrinterException e) {
@@ -628,7 +628,7 @@ public final class WPrinterJob extends RasterPrinterJob
String printerName = getNativePrintService();
if (printerName != null) {
- myService = Win32PrintServiceLookup.getWin32PrintLUS().
+ myService = PrintServiceLookupProvider.getWin32PrintLUS().
getPrintServiceByName(printerName);
// no need to call setNativePrintService as this name is
// currently set in native
diff --git a/src/windows/classes/sun/net/www/protocol/file/Handler.java b/src/windows/classes/sun/net/www/protocol/file/Handler.java
index 8a5531268d..7a331a0c5e 100644
--- a/src/windows/classes/sun/net/www/protocol/file/Handler.java
+++ b/src/windows/classes/sun/net/www/protocol/file/Handler.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2003, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -95,7 +95,7 @@ public class Handler extends URLStreamHandler {
path = "\\\\" + host + path;
File f = new File(path);
if (f.exists()) {
- return createFileURLConnection(url, f);
+ return new UNCFileURLConnection(url, f, path);
}
/*
diff --git a/src/windows/classes/sun/net/www/protocol/file/UNCFileURLConnection.java b/src/windows/classes/sun/net/www/protocol/file/UNCFileURLConnection.java
new file mode 100644
index 0000000000..c36b84aa4d
--- /dev/null
+++ b/src/windows/classes/sun/net/www/protocol/file/UNCFileURLConnection.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.net.www.protocol.file;
+
+import java.io.File;
+import java.io.FilePermission;
+import java.net.URL;
+import java.security.Permission;
+
+final class UNCFileURLConnection extends FileURLConnection {
+
+ private final String effectivePath;
+ private volatile Permission permission;
+
+ UNCFileURLConnection(URL u, File file, String effectivePath) {
+ super(u, file);
+ this.effectivePath = effectivePath;
+ }
+
+ @Override
+ public Permission getPermission() {
+ Permission perm = permission;
+ if (perm == null) {
+ permission = perm = new FilePermission(effectivePath, "read");
+ }
+ return perm;
+ }
+}
+
diff --git a/src/windows/classes/sun/net/www/protocol/http/ntlm/NTLMAuthentication.java b/src/windows/classes/sun/net/www/protocol/http/ntlm/NTLMAuthentication.java
index 1b2c874e72..535adc0591 100644
--- a/src/windows/classes/sun/net/www/protocol/http/ntlm/NTLMAuthentication.java
+++ b/src/windows/classes/sun/net/www/protocol/http/ntlm/NTLMAuthentication.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -194,7 +194,17 @@ public class NTLMAuthentication extends AuthenticationInfo {
}
}
- static native boolean isTrustedSite(String url);
+ private static final boolean isTrustedSiteAvailable = isTrustedSiteAvailable();
+
+ private static native boolean isTrustedSiteAvailable();
+
+ private static boolean isTrustedSite(String url) {
+ if (isTrustedSiteAvailable)
+ return isTrustedSite0(url);
+ return false;
+ }
+
+ private static native boolean isTrustedSite0(String url);
/**
* Not supported. Must use the setHeaders() method
diff --git a/src/windows/classes/sun/print/Win32PrintServiceLookup.java b/src/windows/classes/sun/print/PrintServiceLookupProvider.java
index 06d4b0840d..9e7a329913 100644
--- a/src/windows/classes/sun/print/Win32PrintServiceLookup.java
+++ b/src/windows/classes/sun/print/PrintServiceLookupProvider.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,14 +25,10 @@
package sun.print;
-import java.io.BufferedReader;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.IOException;
-import java.util.ArrayList;
import java.security.AccessController;
-import java.security.PrivilegedActionException;
-import java.security.PrivilegedExceptionAction;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Comparator;
import javax.print.DocFlavor;
import javax.print.MultiDocPrintService;
import javax.print.PrintService;
@@ -47,14 +43,38 @@ import javax.print.attribute.PrintServiceAttribute;
import javax.print.attribute.PrintServiceAttributeSet;
import javax.print.attribute.standard.PrinterName;
-public class Win32PrintServiceLookup extends PrintServiceLookup {
+public class PrintServiceLookupProvider extends PrintServiceLookup {
private String defaultPrinter;
private PrintService defaultPrintService;
private String[] printers; /* excludes the default printer */
private PrintService[] printServices; /* includes the default printer */
+ private static final int DEFAULT_REFRESH_TIME = 240; // 4 minutes
+ private static final int MINIMUM_REFRESH_TIME = 120; // 2 minutes
+ private static final boolean pollServices;
+ private static final int refreshTime;
+
static {
+ /* The system property "sun.java2d.print.polling"
+ * can be used to force the printing code to poll or not poll
+ * for PrintServices.
+ */
+ String pollStr = java.security.AccessController.doPrivileged(
+ new sun.security.action.GetPropertyAction("sun.java2d.print.polling"));
+ pollServices = !("false".equalsIgnoreCase(pollStr));
+
+ /* The system property "sun.java2d.print.minRefreshTime"
+ * can be used to specify minimum refresh time (in seconds)
+ * for polling PrintServices. The default is 240.
+ */
+ String refreshTimeStr = java.security.AccessController.doPrivileged(
+ new sun.security.action.GetPropertyAction(
+ "sun.java2d.print.minRefreshTime"));
+ refreshTime = (refreshTimeStr != null)
+ ? getRefreshTime(refreshTimeStr)
+ : DEFAULT_REFRESH_TIME;
+
java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction<Void>() {
public Void run() {
@@ -64,16 +84,27 @@ public class Win32PrintServiceLookup extends PrintServiceLookup {
});
}
+ private static int getRefreshTime(final String refreshTimeStr) {
+ try {
+ int minRefreshTime = Integer.parseInt(refreshTimeStr);
+ return (minRefreshTime < MINIMUM_REFRESH_TIME)
+ ? MINIMUM_REFRESH_TIME
+ : minRefreshTime;
+ } catch (NumberFormatException e) {
+ return DEFAULT_REFRESH_TIME;
+ }
+ }
+
/* The singleton win32 print lookup service.
* Code that is aware of this field and wants to use it must first
* see if its null, and if so instantiate it by calling a method such as
* javax.print.PrintServiceLookup.defaultPrintService() so that the
* same instance is stored there.
*/
- private static Win32PrintServiceLookup win32PrintLUS;
+ private static PrintServiceLookupProvider win32PrintLUS;
/* Think carefully before calling this. Preferably don't call it. */
- public static Win32PrintServiceLookup getWin32PrintLUS() {
+ public static PrintServiceLookupProvider getWin32PrintLUS() {
if (win32PrintLUS == null) {
/* This call is internally synchronized.
* When it returns an instance of this class will have
@@ -84,7 +115,7 @@ public class Win32PrintServiceLookup extends PrintServiceLookup {
return win32PrintLUS;
}
- public Win32PrintServiceLookup() {
+ public PrintServiceLookupProvider() {
if (win32PrintLUS == null) {
win32PrintLUS = this;
@@ -96,10 +127,17 @@ public class Win32PrintServiceLookup extends PrintServiceLookup {
if (osName != null && osName.startsWith("Windows 98")) {
return;
}
- // start the printer listener thread
- PrinterChangeListener thr = new PrinterChangeListener();
+ // start the local printer listener thread
+ Thread thr = new PrinterChangeListener();
thr.setDaemon(true);
thr.start();
+
+ if (pollServices) {
+ // start the remote printer listener thread
+ Thread remThr = new RemotePrinterChangeListener();
+ remThr.setDaemon(true);
+ remThr.start();
+ }
} /* else condition ought to never happen! */
}
@@ -340,9 +378,71 @@ public class Win32PrintServiceLookup extends PrintServiceLookup {
}
}
+ /* Windows provides *PrinterChangeNotification* functions that provides
+ information about printer status changes of the local printers but not
+ network printers.
+ Alternatively, Windows provides a way through which one can get the
+ network printer status changes by using WMI, RegistryKeyChange combination,
+ which is a slightly complex mechanism.
+ The Windows WMI offers an async and sync method to read through registry
+ via the WQL query. The async method is considered dangerous as it leaves
+ open a channel until we close it. But the async method has the advantage of
+ being notified of a change in registry by calling callback without polling for it.
+ The sync method uses the polling mechanism to notify.
+ RegistryValueChange cannot be used in combination with WMI to get registry
+ value change notification because of an error that may be generated because the
+ scope of the query would be too big to handle(at times).
+ Hence an alternative mechanism is chosen via the EnumPrinters by polling for the
+ count of printer status changes(add\remove) and based on it update the printers
+ list.
+ */
+ class RemotePrinterChangeListener extends Thread implements Comparator<String>{
+ RemotePrinterChangeListener() {
+ }
+
+ @Override
+ public int compare(String o1, String o2) {
+ return ((o1 == null)
+ ? ((o2 == null) ? 0 : 1)
+ : ((o2 == null) ? -1 : o1.compareTo(o2)));
+ }
+
+ @Override
+ public void run() {
+ // Init the list of remote printers
+ String[] prevRemotePrinters = getRemotePrintersNames();
+ if (prevRemotePrinters != null) {
+ Arrays.sort(prevRemotePrinters, this);
+ }
+
+ while (true) {
+ try {
+ Thread.sleep(refreshTime * 1000);
+ } catch (InterruptedException e) {
+ break;
+ }
+
+ String[] currentRemotePrinters = getRemotePrintersNames();
+ if (currentRemotePrinters != null) {
+ Arrays.sort(currentRemotePrinters, this);
+ }
+ if (!Arrays.equals(prevRemotePrinters, currentRemotePrinters)) {
+ // The list of remote printers got updated,
+ // so update the cached list printers which
+ // includes both local and network printers
+ refreshServices();
+
+ // store the current data for next comparison
+ prevRemotePrinters = currentRemotePrinters;
+ }
+ }
+ }
+ }
+
private native String getDefaultPrinterName();
private native String[] getAllPrinterNames();
private native long notifyFirstPrinterChange(String printer);
private native void notifyClosePrinterChange(long chgObj);
private native int notifyPrinterChange(long chgObj);
+ private native String[] getRemotePrintersNames();
}
diff --git a/src/windows/classes/sun/print/services/javax.print.PrintServiceLookup b/src/windows/classes/sun/print/services/javax.print.PrintServiceLookup
deleted file mode 100644
index b3844117e0..0000000000
--- a/src/windows/classes/sun/print/services/javax.print.PrintServiceLookup
+++ /dev/null
@@ -1,2 +0,0 @@
-# Provider for Java Print Service
-sun.print.Win32PrintServiceLookup
diff --git a/src/windows/classes/sun/print/services/javax.print.StreamPrintServiceFactory b/src/windows/classes/sun/print/services/javax.print.StreamPrintServiceFactory
deleted file mode 100644
index 6ab63408bc..0000000000
--- a/src/windows/classes/sun/print/services/javax.print.StreamPrintServiceFactory
+++ /dev/null
@@ -1,2 +0,0 @@
-# Providers for Java 2D/JPS Stream print services.
-sun.print.PSStreamPrinterFactory
diff --git a/src/windows/classes/sun/security/krb5/internal/tools/Klist.java b/src/windows/classes/sun/security/krb5/internal/tools/Klist.java
index ca5a473cba..37f59adae8 100644
--- a/src/windows/classes/sun/security/krb5/internal/tools/Klist.java
+++ b/src/windows/classes/sun/security/krb5/internal/tools/Klist.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -31,6 +31,8 @@
package sun.security.krb5.internal.tools;
import java.net.InetAddress;
+import java.util.List;
+
import sun.security.krb5.*;
import sun.security.krb5.internal.*;
import sun.security.krb5.internal.ccache.*;
@@ -241,6 +243,8 @@ public class Klist {
String endtime;
String renewTill;
String servicePrincipal;
+ PrincipalName servicePrincipal2;
+ String clientPrincipal;
if (creds[i].getStartTime() != null) {
starttime = format(creds[i].getStartTime());
} else {
@@ -252,6 +256,18 @@ public class Klist {
System.out.println("[" + (i + 1) + "] " +
" Service Principal: " +
servicePrincipal);
+ servicePrincipal2 =
+ creds[i].getServicePrincipal2();
+ if (servicePrincipal2 != null) {
+ System.out.println(" Second Service: "
+ + servicePrincipal2);
+ }
+ clientPrincipal =
+ creds[i].getClientPrincipal().toString();
+ if (!clientPrincipal.equals(defaultPrincipal)) {
+ System.out.println(" Client Principal: " +
+ clientPrincipal);
+ }
System.out.println(" Valid starting: " + starttime);
System.out.println(" Expires: " + endtime);
if (creds[i].getRenewTill() != null) {
@@ -262,8 +278,15 @@ public class Klist {
if (options[0] == 'e') {
String eskey = EType.toString(creds[i].getEType());
String etkt = EType.toString(creds[i].getTktEType());
- System.out.println(" EType (skey, tkt): "
- + eskey + ", " + etkt);
+ if (creds[i].getTktEType2() == 0) {
+ System.out.println(" EType (skey, tkt): "
+ + eskey + ", " + etkt);
+ } else {
+ String etkt2 = EType.toString(creds[i].getTktEType2());
+ System.out.println(" EType (skey, tkts): "
+ + eskey + ", " + etkt
+ + ", " + etkt2);
+ }
}
if (options[1] == 'f') {
System.out.println(" Flags: " +
@@ -302,6 +325,15 @@ public class Klist {
} else {
System.out.println("\nNo entries found.");
}
+
+ List<CredentialsCache.ConfigEntry> configEntries
+ = cache.getConfigEntries();
+ if (configEntries != null && !configEntries.isEmpty()) {
+ System.out.println("\nConfig entries:");
+ for (CredentialsCache.ConfigEntry e : configEntries) {
+ System.out.println(" " + e);
+ }
+ }
}
void displayMessage(String target) {