Skip to content

Commit 67f18cc

Browse files
committedDec 2, 2024
8345142: Remove uses of SecurityManager in Printing related classes
Reviewed-by: azvegint, psadhukhan
1 parent 352201d commit 67f18cc

16 files changed

+37
-309
lines changed
 

‎src/java.desktop/share/classes/java/awt/print/PrinterJob.java

-5
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,6 @@ public abstract class PrinterJob {
6464
* @return a new {@code PrinterJob}.
6565
*/
6666
public static PrinterJob getPrinterJob() {
67-
@SuppressWarnings("removal")
68-
SecurityManager security = System.getSecurityManager();
69-
if (security != null) {
70-
security.checkPrintJobAccess();
71-
}
7267
return sun.print.PlatformPrinterJobProxy.getPrinterJob();
7368
}
7469

‎src/java.desktop/share/classes/javax/print/PrintServiceLookup.java

+2-20
Original file line numberDiff line numberDiff line change
@@ -393,16 +393,7 @@ private static ArrayList<PrintService> getServices(DocFlavor flavor,
393393
/*
394394
* add any directly registered services
395395
*/
396-
ArrayList<PrintService> registeredServices = null;
397-
try {
398-
@SuppressWarnings("removal")
399-
SecurityManager security = System.getSecurityManager();
400-
if (security != null) {
401-
security.checkPrintJobAccess();
402-
}
403-
registeredServices = getRegisteredServices();
404-
} catch (SecurityException se) {
405-
}
396+
ArrayList<PrintService> registeredServices = getRegisteredServices();
406397
if (registeredServices != null) {
407398
PrintService[] services = registeredServices.toArray(
408399
new PrintService[registeredServices.size()]);
@@ -458,16 +449,7 @@ private static ArrayList<MultiDocPrintService> getMultiDocServices(DocFlavor[] f
458449
/*
459450
* add any directly registered services
460451
*/
461-
ArrayList<PrintService> registeredServices = null;
462-
try {
463-
@SuppressWarnings("removal")
464-
SecurityManager security = System.getSecurityManager();
465-
if (security != null) {
466-
security.checkPrintJobAccess();
467-
}
468-
registeredServices = getRegisteredServices();
469-
} catch (Exception e) {
470-
}
452+
ArrayList<PrintService> registeredServices = getRegisteredServices();
471453
if (registeredServices != null) {
472454
PrintService[] services =
473455
registeredServices.toArray(new PrintService[registeredServices.size()]);

‎src/java.desktop/share/classes/javax/print/ServiceUI.java

+1-4
Original file line numberDiff line numberDiff line change
@@ -203,10 +203,7 @@ public static PrintService printDialog(GraphicsConfiguration gc,
203203
flavor, attributes,
204204
owner);
205205
if (setOnTop) {
206-
try {
207-
dialog.setAlwaysOnTop(true);
208-
} catch (SecurityException e) {
209-
}
206+
dialog.setAlwaysOnTop(true);
210207
}
211208
Rectangle dlgBounds = dialog.getBounds();
212209

‎src/java.desktop/share/classes/sun/print/PSStreamPrintJob.java

+1-6
Original file line numberDiff line numberDiff line change
@@ -434,12 +434,7 @@ public void pageableJob(Pageable pageable,
434434
}
435435

436436
/* add the user name to the job */
437-
String userName = "";
438-
try {
439-
userName = System.getProperty("user.name");
440-
} catch (SecurityException se) {
441-
}
442-
437+
String userName = System.getProperty("user.name");
443438
if (userName == null || userName.isEmpty()) {
444439
RequestingUserName ruName =
445440
(RequestingUserName)reqSet.get(RequestingUserName.class);

‎src/java.desktop/share/classes/sun/print/PrintJob2D.java

+10-32
Original file line numberDiff line numberDiff line change
@@ -310,12 +310,6 @@ private void initPrintJob2D(Frame frame, String doctitle,
310310
JobAttributes jobAttributes,
311311
PageAttributes pageAttributes) {
312312

313-
@SuppressWarnings("removal")
314-
SecurityManager security = System.getSecurityManager();
315-
if (security != null) {
316-
security.checkPrintJobAccess();
317-
}
318-
319313
if (frame == null &&
320314
(jobAttributes == null ||
321315
jobAttributes.getDialog() == DialogType.NATIVE)) {
@@ -366,11 +360,6 @@ private void initPrintJob2D(Frame frame, String doctitle,
366360
} catch (IOException ioe) {
367361
throw new IllegalArgumentException("Cannot write to file:"+
368362
destStr);
369-
} catch (SecurityException se) {
370-
//There is already file read/write access so at this point
371-
// only delete access is denied. Just ignore it because in
372-
// most cases the file created in createNewFile gets overwritten
373-
// anyway.
374363
}
375364

376365
File pFile = f.getParentFile();
@@ -676,29 +665,18 @@ private void copyAttributes(PrintService printServ) {
676665
attributes.add(defaultDest);
677666
} else {
678667
URI uri = null;
679-
try {
680-
if (fileName != null) {
681-
if (fileName.isEmpty()) {
682-
fileName = ".";
683-
}
684-
} else {
685-
// defaultDest should not be null. The following code
686-
// is only added to safeguard against a possible
687-
// buggy implementation of a PrintService having a
688-
// null default Destination.
689-
fileName = "out.prn";
690-
}
691-
uri = (new File(fileName)).toURI();
692-
} catch (SecurityException se) {
693-
try {
694-
// '\\' file separator is illegal character in opaque
695-
// part and causes URISyntaxException, so we replace
696-
// it with '/'
697-
fileName = fileName.replace('\\', '/');
698-
uri = new URI("file:"+fileName);
699-
} catch (URISyntaxException e) {
668+
if (fileName != null) {
669+
if (fileName.isEmpty()) {
670+
fileName = ".";
700671
}
672+
} else {
673+
// defaultDest should not be null. The following code
674+
// is only added to safeguard against a possible
675+
// buggy implementation of a PrintService having a
676+
// null default Destination.
677+
fileName = "out.prn";
701678
}
679+
uri = (new File(fileName)).toURI();
702680
if (uri != null) {
703681
attributes.add(new Destination(uri));
704682
}

‎src/java.desktop/share/classes/sun/print/RasterPrinterJob.java

+3-29
Original file line numberDiff line numberDiff line change
@@ -816,10 +816,7 @@ public PageFormat pageDialog(final PrintRequestAttributeSet attributes)
816816
DocFlavor.SERVICE_FORMATTED.PAGEABLE,
817817
attributes, w);
818818
if (setOnTop) {
819-
try {
820-
pageDialog.setAlwaysOnTop(true);
821-
} catch (SecurityException e) {
822-
}
819+
pageDialog.setAlwaysOnTop(true);
823820
}
824821

825822
Rectangle dlgBounds = pageDialog.getBounds();
@@ -948,15 +945,6 @@ public boolean printDialog(final PrintRequestAttributeSet attributes)
948945

949946
}
950947

951-
/* A security check has already been performed in the
952-
* java.awt.print.printerJob.getPrinterJob method.
953-
* So by the time we get here, it is OK for the current thread
954-
* to print either to a file (from a Dialog we control!) or
955-
* to a chosen printer.
956-
*
957-
* We raise privilege when we put up the dialog, to avoid
958-
* the "warning applet window" banner.
959-
*/
960948
GraphicsConfiguration grCfg = null;
961949
Window w = KeyboardFocusManager.getCurrentKeyboardFocusManager().getActiveWindow();
962950
if (w != null) {
@@ -1311,11 +1299,7 @@ protected void setAttributes(PrintRequestAttributeSet attributes)
13111299
(!fidelity && userName != null)) {
13121300
userNameAttr = userName.getValue();
13131301
} else {
1314-
try {
1315-
userNameAttr = getUserName();
1316-
} catch (SecurityException e) {
1317-
userNameAttr = "";
1318-
}
1302+
userNameAttr = getUserName();
13191303
}
13201304

13211305
/* OpenBook is used internally only when app uses Printable.
@@ -1654,11 +1638,6 @@ protected void validateDestination(String dest) throws PrinterException {
16541638
} catch (IOException ioe) {
16551639
throw new PrinterException("Cannot write to file:"+
16561640
dest);
1657-
} catch (SecurityException se) {
1658-
//There is already file read/write access so at this point
1659-
// only delete access is denied. Just ignore it because in
1660-
// most cases the file created in createNewFile gets overwritten
1661-
// anyway.
16621641
}
16631642

16641643
File pFile = f.getParentFile();
@@ -1818,7 +1797,6 @@ protected int getCopiesInt() {
18181797

18191798
/**
18201799
* Get the name of the printing user.
1821-
* The caller must have security permission to read system properties.
18221800
*/
18231801
public String getUserName() {
18241802
return System.getProperty("user.name");
@@ -1831,11 +1809,7 @@ protected String getUserNameInt() {
18311809
if (userNameAttr != null) {
18321810
return userNameAttr;
18331811
} else {
1834-
try {
1835-
return getUserName();
1836-
} catch (SecurityException e) {
1837-
return "";
1838-
}
1812+
return getUserName();
18391813
}
18401814
}
18411815

‎src/java.desktop/share/classes/sun/print/ServiceDialog.java

+3-20
Original file line numberDiff line numberDiff line change
@@ -169,10 +169,7 @@ void initPrintDialog(int x, int y,
169169
* on top property
170170
*/
171171
if ((getOwner() == null) || (owner.getOwner() != getOwner())) {
172-
try {
173-
setAlwaysOnTop(true);
174-
} catch (SecurityException e) {
175-
}
172+
setAlwaysOnTop(true);
176173
}
177174
}
178175
Container c = getContentPane();
@@ -255,10 +252,7 @@ void initPageDialog(int x, int y,
255252
/* See comments in same block in initPrintDialog */
256253
DialogOwner owner = (DialogOwner)attributes.get(DialogOwner.class);
257254
if ((getOwner() == null) || (owner.getOwner() != getOwner())) {
258-
try {
259-
setAlwaysOnTop(true);
260-
} catch (SecurityException e) {
261-
}
255+
setAlwaysOnTop(true);
262256
}
263257
}
264258

@@ -2937,13 +2931,7 @@ public void setSelected(boolean selected) {
29372931
private static class ValidatingFileChooser extends JFileChooser {
29382932
public void approveSelection() {
29392933
File selected = getSelectedFile();
2940-
boolean exists;
2941-
2942-
try {
2943-
exists = selected.exists();
2944-
} catch (SecurityException e) {
2945-
exists = false;
2946-
}
2934+
boolean exists = selected.exists();
29472935

29482936
if (exists) {
29492937
int val;
@@ -2966,11 +2954,6 @@ public void approveSelection() {
29662954
getMsg("dialog.owtitle"),
29672955
JOptionPane.WARNING_MESSAGE);
29682956
return;
2969-
} catch (SecurityException se) {
2970-
//There is already file read/write access so at this point
2971-
// only delete access is denied. Just ignore it because in
2972-
// most cases the file created in createNewFile gets
2973-
// overwritten anyway.
29742957
}
29752958
File pFile = selected.getParentFile();
29762959
if ((selected.exists() &&

‎src/java.desktop/share/classes/sun/print/ServiceNotifier.java

+4-10
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,9 @@ class ServiceNotifier extends Thread {
5555
super(null, null, service.getName() + " notifier", 0, false);
5656
this.service = service;
5757
listeners = new Vector<>();
58-
try {
59-
setPriority(Thread.NORM_PRIORITY-1);
60-
setDaemon(true);
61-
start();
62-
} catch (SecurityException e) {
63-
}
58+
setPriority(Thread.NORM_PRIORITY-1);
59+
setDaemon(true);
60+
start();
6461
}
6562

6663
void addListener(PrintServiceAttributeListener listener) {
@@ -93,10 +90,7 @@ void stopNotifier() {
9390
* immediate notification of listeners.
9491
*/
9592
void wake() {
96-
try {
97-
interrupt();
98-
} catch (SecurityException e) {
99-
}
93+
interrupt();
10094
}
10195

10296
/* A heuristic is used to calculate sleep time.

‎src/java.desktop/unix/classes/sun/print/IPPPrintService.java

+3-32
Original file line numberDiff line numberDiff line change
@@ -511,11 +511,6 @@ private void initAttributes() {
511511

512512

513513
public DocPrintJob createPrintJob() {
514-
@SuppressWarnings("removal")
515-
SecurityManager security = System.getSecurityManager();
516-
if (security != null) {
517-
security.checkPrintJobAccess();
518-
}
519514
// REMIND: create IPPPrintJob
520515
return new UnixPrintJob(this);
521516
}
@@ -587,15 +582,7 @@ public DocPrintJob createPrintJob() {
587582
if (flavor == null ||
588583
flavor.equals(DocFlavor.SERVICE_FORMATTED.PAGEABLE) ||
589584
flavor.equals(DocFlavor.SERVICE_FORMATTED.PRINTABLE)) {
590-
try {
591585
return new Destination((new File("out.ps")).toURI());
592-
} catch (SecurityException se) {
593-
try {
594-
return new Destination(new URI("file:out.ps"));
595-
} catch (URISyntaxException e) {
596-
return null;
597-
}
598-
}
599586
}
600587
return null;
601588
} else if (category == Fidelity.class) {
@@ -797,11 +784,7 @@ public DocPrintJob createPrintJob() {
797784
return null;
798785
}
799786
} else if (category == RequestingUserName.class) {
800-
String userName = "";
801-
try {
802-
userName = System.getProperty("user.name", "");
803-
} catch (SecurityException se) {
804-
}
787+
String userName = System.getProperty("user.name", "");
805788
return new RequestingUserName(userName, null);
806789
} else if (category == Sides.class) {
807790
// The printer takes care of Sides so if short-edge
@@ -1574,15 +1557,7 @@ public boolean isAttributeValueSupported(Attribute attr,
15741557
} else if (category == Chromaticity.class) {
15751558
return Chromaticity.COLOR;
15761559
} else if (category == Destination.class) {
1577-
try {
1578-
return new Destination((new File("out.ps")).toURI());
1579-
} catch (SecurityException se) {
1580-
try {
1581-
return new Destination(new URI("file:out.ps"));
1582-
} catch (URISyntaxException e) {
1583-
return null;
1584-
}
1585-
}
1560+
return new Destination((new File("out.ps")).toURI());
15861561
} else if (category == Fidelity.class) {
15871562
return Fidelity.FIDELITY_FALSE;
15881563
} else if (category == Finishings.class) {
@@ -1674,11 +1649,7 @@ public boolean isAttributeValueSupported(Attribute attr,
16741649
return new PageRanges(1, Integer.MAX_VALUE);
16751650
}
16761651
} else if (category == RequestingUserName.class) {
1677-
String userName = "";
1678-
try {
1679-
userName = System.getProperty("user.name", "");
1680-
} catch (SecurityException se) {
1681-
}
1652+
String userName = System.getProperty("user.name", "");
16821653
return new RequestingUserName(userName, null);
16831654
} else if (category == SheetCollate.class) {
16841655
return SheetCollate.UNCOLLATED;

‎src/java.desktop/unix/classes/sun/print/PrintServiceLookupProvider.java

-22
Original file line numberDiff line numberDiff line change
@@ -210,12 +210,6 @@ public PrintServiceLookupProvider() {
210210
* lead people to assume its guaranteed.
211211
*/
212212
public synchronized PrintService[] getPrintServices() {
213-
@SuppressWarnings("removal")
214-
SecurityManager security = System.getSecurityManager();
215-
if (security != null) {
216-
security.checkPrintJobAccess();
217-
}
218-
219213
if (printServices == null || !pollServices) {
220214
refreshServices();
221215
}
@@ -549,11 +543,6 @@ private PrintService getServiceByName(PrinterName nameAttr) {
549543
*/
550544
public PrintService[] getPrintServices(DocFlavor flavor,
551545
AttributeSet attributes) {
552-
@SuppressWarnings("removal")
553-
SecurityManager security = System.getSecurityManager();
554-
if (security != null) {
555-
security.checkPrintJobAccess();
556-
}
557546
PrintRequestAttributeSet requestSet = null;
558547
PrintServiceAttributeSet serviceSet = null;
559548

@@ -613,22 +602,11 @@ public PrintService[] getPrintServices(DocFlavor flavor,
613602
public MultiDocPrintService[]
614603
getMultiDocPrintServices(DocFlavor[] flavors,
615604
AttributeSet attributes) {
616-
@SuppressWarnings("removal")
617-
SecurityManager security = System.getSecurityManager();
618-
if (security != null) {
619-
security.checkPrintJobAccess();
620-
}
621605
return new MultiDocPrintService[0];
622606
}
623607

624608

625609
public synchronized PrintService getDefaultPrintService() {
626-
@SuppressWarnings("removal")
627-
SecurityManager security = System.getSecurityManager();
628-
if (security != null) {
629-
security.checkPrintJobAccess();
630-
}
631-
632610
// clear defaultPrintService
633611
defaultPrintService = null;
634612
String psuri = null;

‎src/java.desktop/unix/classes/sun/print/UnixPrintJob.java

+1-17
Original file line numberDiff line numberDiff line change
@@ -707,12 +707,7 @@ public void pageableJob(Pageable pageable) throws PrintException {
707707
}
708708

709709
/* add the user name to the job */
710-
String userName = "";
711-
try {
712-
userName = System.getProperty("user.name");
713-
} catch (SecurityException se) {
714-
}
715-
710+
String userName = System.getProperty("user.name");
716711
if (userName == null || userName.isEmpty()) {
717712
RequestingUserName ruName =
718713
(RequestingUserName)reqSet.get(RequestingUserName.class);
@@ -791,17 +786,6 @@ private void getAttributeValues(DocFlavor flavor) throws PrintException {
791786
} catch (Exception e) {
792787
throw new PrintException(e);
793788
}
794-
// check write access
795-
@SuppressWarnings("removal")
796-
SecurityManager security = System.getSecurityManager();
797-
if (security != null) {
798-
try {
799-
security.checkWrite(mDestination);
800-
} catch (SecurityException se) {
801-
notifyEvent(PrintJobEvent.JOB_FAILED);
802-
throw new PrintException(se);
803-
}
804-
}
805789
}
806790
} else if (category == JobSheets.class) {
807791
if ((JobSheets)attr == JobSheets.NONE) {

‎src/java.desktop/unix/classes/sun/print/UnixPrintService.java

+3-32
Original file line numberDiff line numberDiff line change
@@ -416,11 +416,6 @@ private boolean isSupportedMedia(MediaSizeName msn) {
416416
}
417417

418418
public DocPrintJob createPrintJob() {
419-
@SuppressWarnings("removal")
420-
SecurityManager security = System.getSecurityManager();
421-
if (security != null) {
422-
security.checkPrintJobAccess();
423-
}
424419
return new UnixPrintJob(this);
425420
}
426421

@@ -627,15 +622,7 @@ public Class<?>[] getSupportedAttributeCategories() {
627622
} else if (category == Chromaticity.class) {
628623
return Chromaticity.COLOR;
629624
} else if (category == Destination.class) {
630-
try {
631-
return new Destination((new File("out.ps")).toURI());
632-
} catch (SecurityException se) {
633-
try {
634-
return new Destination(new URI("file:out.ps"));
635-
} catch (URISyntaxException e) {
636-
return null;
637-
}
638-
}
625+
return new Destination((new File("out.ps")).toURI());
639626
} else if (category == Fidelity.class) {
640627
return Fidelity.FIDELITY_FALSE;
641628
} else if (category == JobName.class) {
@@ -672,11 +659,7 @@ public Class<?>[] getSupportedAttributeCategories() {
672659
} else if (category == PageRanges.class) {
673660
return new PageRanges(1, Integer.MAX_VALUE);
674661
} else if (category == RequestingUserName.class) {
675-
String userName = "";
676-
try {
677-
userName = System.getProperty("user.name", "");
678-
} catch (SecurityException se) {
679-
}
662+
String userName = System.getProperty("user.name", "");
680663
return new RequestingUserName(userName, null);
681664
} else if (category == SheetCollate.class) {
682665
return SheetCollate.UNCOLLATED;
@@ -733,15 +716,7 @@ private boolean isAutoSense(DocFlavor flavor) {
733716
return null;
734717
}
735718
} else if (category == Destination.class) {
736-
try {
737719
return new Destination((new File("out.ps")).toURI());
738-
} catch (SecurityException se) {
739-
try {
740-
return new Destination(new URI("file:out.ps"));
741-
} catch (URISyntaxException e) {
742-
return null;
743-
}
744-
}
745720
} else if (category == JobName.class) {
746721
return new JobName("Java Printing", null);
747722
} else if (category == JobSheets.class) {
@@ -750,11 +725,7 @@ private boolean isAutoSense(DocFlavor flavor) {
750725
arr[1] = JobSheets.STANDARD;
751726
return arr;
752727
} else if (category == RequestingUserName.class) {
753-
String userName = "";
754-
try {
755-
userName = System.getProperty("user.name", "");
756-
} catch (SecurityException se) {
757-
}
728+
String userName = System.getProperty("user.name", "");
758729
return new RequestingUserName(userName, null);
759730
} else if (category == OrientationRequested.class) {
760731
if (flavor == null || isServiceFormattedFlavor(flavor)) {

‎src/java.desktop/windows/classes/sun/awt/windows/WPrinterJob.java

+1-10
Original file line numberDiff line numberDiff line change
@@ -1913,16 +1913,7 @@ private void setNativeAttributes(int flags, int fields, int values) {
19131913
Destination destPrn = (Destination)attributes.get(
19141914
Destination.class);
19151915
if (destPrn == null) {
1916-
try {
1917-
attributes.add(new Destination(
1918-
new File("./out.prn").toURI()));
1919-
} catch (SecurityException se) {
1920-
try {
1921-
attributes.add(new Destination(
1922-
new URI("file:out.prn")));
1923-
} catch (URISyntaxException e) {
1924-
}
1925-
}
1916+
attributes.add(new Destination(new File("./out.prn").toURI()));
19261917
}
19271918
} else {
19281919
attributes.remove(Destination.class);

‎src/java.desktop/windows/classes/sun/print/PrintServiceLookupProvider.java

-21
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,6 @@ public PrintServiceLookupProvider() {
106106
* lead people to assume its guaranteed.
107107
*/
108108
public synchronized PrintService[] getPrintServices() {
109-
@SuppressWarnings("removal")
110-
SecurityManager security = System.getSecurityManager();
111-
if (security != null) {
112-
security.checkPrintJobAccess();
113-
}
114109
if (printServices == null) {
115110
refreshServices();
116111
}
@@ -207,11 +202,6 @@ boolean matchingService(PrintService service,
207202
public PrintService[] getPrintServices(DocFlavor flavor,
208203
AttributeSet attributes) {
209204

210-
@SuppressWarnings("removal")
211-
SecurityManager security = System.getSecurityManager();
212-
if (security != null) {
213-
security.checkPrintJobAccess();
214-
}
215205
PrintRequestAttributeSet requestSet = null;
216206
PrintServiceAttributeSet serviceSet = null;
217207

@@ -273,22 +263,11 @@ public PrintService[] getPrintServices(DocFlavor flavor,
273263
public MultiDocPrintService[]
274264
getMultiDocPrintServices(DocFlavor[] flavors,
275265
AttributeSet attributes) {
276-
@SuppressWarnings("removal")
277-
SecurityManager security = System.getSecurityManager();
278-
if (security != null) {
279-
security.checkPrintJobAccess();
280-
}
281266
return new MultiDocPrintService[0];
282267
}
283268

284269

285270
public synchronized PrintService getDefaultPrintService() {
286-
@SuppressWarnings("removal")
287-
SecurityManager security = System.getSecurityManager();
288-
if (security != null) {
289-
security.checkPrintJobAccess();
290-
}
291-
292271

293272
// Windows does not have notification for a change in default
294273
// so we always get the latest.

‎src/java.desktop/windows/classes/sun/print/Win32PrintJob.java

+1-16
Original file line numberDiff line numberDiff line change
@@ -592,11 +592,7 @@ public void pageableJob(Pageable pageable) throws PrintException {
592592
}
593593

594594
/* add the user name to the job */
595-
String userName = "";
596-
try {
597-
userName = System.getProperty("user.name");
598-
} catch (SecurityException se) {
599-
}
595+
String userName = System.getProperty("user.name");
600596

601597
if (userName == null || userName.isEmpty()) {
602598
RequestingUserName ruName =
@@ -674,17 +670,6 @@ private void getAttributeValues(DocFlavor flavor) throws PrintException {
674670
} catch (Exception e) {
675671
throw new PrintException(e);
676672
}
677-
// check write access
678-
@SuppressWarnings("removal")
679-
SecurityManager security = System.getSecurityManager();
680-
if (security != null) {
681-
try {
682-
security.checkWrite(mDestination);
683-
} catch (SecurityException se) {
684-
notifyEvent(PrintJobEvent.JOB_FAILED);
685-
throw new PrintException(se);
686-
}
687-
}
688673
}
689674
} else if (category == JobName.class) {
690675
jobName = ((JobName)attr).getValue();

‎src/java.desktop/windows/classes/sun/print/Win32PrintService.java

+4-33
Original file line numberDiff line numberDiff line change
@@ -858,11 +858,6 @@ private boolean isSupportedResolution(PrinterResolution res) {
858858
}
859859

860860
public DocPrintJob createPrintJob() {
861-
@SuppressWarnings("removal")
862-
SecurityManager security = System.getSecurityManager();
863-
if (security != null) {
864-
security.checkPrintJobAccess();
865-
}
866861
return new Win32PrintJob(this);
867862
}
868863

@@ -1174,15 +1169,7 @@ public Class<?>[] getSupportedAttributeCategories() {
11741169
} else if (category == SunAlternateMedia.class) {
11751170
return null;
11761171
} else if (category == Destination.class) {
1177-
try {
1178-
return new Destination((new File("out.prn")).toURI());
1179-
} catch (SecurityException se) {
1180-
try {
1181-
return new Destination(new URI("file:out.prn"));
1182-
} catch (URISyntaxException e) {
1183-
return null;
1184-
}
1185-
}
1172+
return new Destination((new File("out.prn")).toURI());
11861173
} else if (category == Sides.class) {
11871174
switch(defSides) {
11881175
case DMDUP_VERTICAL :
@@ -1223,11 +1210,7 @@ public Class<?>[] getSupportedAttributeCategories() {
12231210
}
12241211
}
12251212
} else if (category == RequestingUserName.class) {
1226-
String userName = "";
1227-
try {
1228-
userName = System.getProperty("user.name", "");
1229-
} catch (SecurityException se) {
1230-
}
1213+
String userName = System.getProperty("user.name", "");
12311214
return new RequestingUserName(userName, null);
12321215
} else if (category == SheetCollate.class) {
12331216
if (defCollate == DMCOLLATE_TRUE) {
@@ -1302,11 +1285,7 @@ private boolean isAutoSense(DocFlavor flavor) {
13021285
if (category == JobName.class) {
13031286
return new JobName("Java Printing", null);
13041287
} else if (category == RequestingUserName.class) {
1305-
String userName = "";
1306-
try {
1307-
userName = System.getProperty("user.name", "");
1308-
} catch (SecurityException se) {
1309-
}
1288+
String userName = System.getProperty("user.name", "");
13101289
return new RequestingUserName(userName, null);
13111290
} else if (category == ColorSupported.class) {
13121291
int caps = getPrinterCapabilities();
@@ -1343,15 +1322,7 @@ private boolean isAutoSense(DocFlavor flavor) {
13431322
return null;
13441323
}
13451324
} else if (category == Destination.class) {
1346-
try {
1347-
return new Destination((new File("out.prn")).toURI());
1348-
} catch (SecurityException se) {
1349-
try {
1350-
return new Destination(new URI("file:out.prn"));
1351-
} catch (URISyntaxException e) {
1352-
return null;
1353-
}
1354-
}
1325+
return new Destination((new File("out.prn")).toURI());
13551326
} else if (category == OrientationRequested.class) {
13561327
if (flavor == null ||
13571328
flavor.equals(DocFlavor.SERVICE_FORMATTED.PAGEABLE) ||

1 commit comments

Comments
 (1)

openjdk-notifier[bot] commented on Dec 2, 2024

@openjdk-notifier[bot]
Please sign in to comment.