src/solaris/classes/sun/print/CUPSPrinter.java
Print this page
*** 244,256 ****
URL url = new URL("http", getServer(), getPort(), "");
final HttpURLConnection urlConnection =
IPPPrintService.getIPPConnection(url);
if (urlConnection != null) {
! OutputStream os = (OutputStream)java.security.AccessController.
! doPrivileged(new java.security.PrivilegedAction() {
! public Object run() {
try {
return urlConnection.getOutputStream();
} catch (Exception e) {
IPPPrintService.debug_println(debugPrefix+e);
}
--- 244,256 ----
URL url = new URL("http", getServer(), getPort(), "");
final HttpURLConnection urlConnection =
IPPPrintService.getIPPConnection(url);
if (urlConnection != null) {
! OutputStream os = java.security.AccessController.
! doPrivileged(new java.security.PrivilegedAction<OutputStream>() {
! public OutputStream run() {
try {
return urlConnection.getOutputStream();
} catch (Exception e) {
IPPPrintService.debug_println(debugPrefix+e);
}
*** 272,285 ****
if (IPPPrintService.writeIPPRequest(os,
IPPPrintService.OP_CUPS_GET_DEFAULT,
attCl)) {
! HashMap defaultMap = null;
String[] printerInfo = new String[2];
InputStream is = urlConnection.getInputStream();
! HashMap[] responseMap = IPPPrintService.readIPPResponse(
is);
is.close();
if (responseMap != null && responseMap.length > 0) {
defaultMap = responseMap[0];
--- 272,285 ----
if (IPPPrintService.writeIPPRequest(os,
IPPPrintService.OP_CUPS_GET_DEFAULT,
attCl)) {
! HashMap<String, AttributeClass> defaultMap = null;
String[] printerInfo = new String[2];
InputStream is = urlConnection.getInputStream();
! HashMap<String, AttributeClass>[] responseMap = IPPPrintService.readIPPResponse(
is);
is.close();
if (responseMap != null && responseMap.length > 0) {
defaultMap = responseMap[0];
*** 307,323 ****
return null;
}
}
! AttributeClass attribClass = (AttributeClass)
! defaultMap.get("printer-name");
if (attribClass != null) {
printerInfo[0] = attribClass.getStringValue();
! attribClass = (AttributeClass)
! defaultMap.get("printer-uri-supported");
IPPPrintService.debug_println(debugPrefix+
"printer-uri-supported="+attribClass);
if (attribClass != null) {
printerInfo[1] = attribClass.getStringValue();
} else {
--- 307,321 ----
return null;
}
}
! AttributeClass attribClass = defaultMap.get("printer-name");
if (attribClass != null) {
printerInfo[0] = attribClass.getStringValue();
! attribClass = defaultMap.get("printer-uri-supported");
IPPPrintService.debug_println(debugPrefix+
"printer-uri-supported="+attribClass);
if (attribClass != null) {
printerInfo[1] = attribClass.getStringValue();
} else {
*** 346,358 ****
final HttpURLConnection urlConnection =
IPPPrintService.getIPPConnection(url);
if (urlConnection != null) {
! OutputStream os = (OutputStream)java.security.AccessController.
! doPrivileged(new java.security.PrivilegedAction() {
! public Object run() {
try {
return urlConnection.getOutputStream();
} catch (Exception e) {
}
return null;
--- 344,356 ----
final HttpURLConnection urlConnection =
IPPPrintService.getIPPConnection(url);
if (urlConnection != null) {
! OutputStream os = java.security.AccessController.
! doPrivileged(new java.security.PrivilegedAction<OutputStream>() {
! public OutputStream run() {
try {
return urlConnection.getOutputStream();
} catch (Exception e) {
}
return null;
*** 373,404 ****
if (IPPPrintService.writeIPPRequest(os,
IPPPrintService.OP_CUPS_GET_PRINTERS, attCl)) {
InputStream is = urlConnection.getInputStream();
! HashMap[] responseMap =
IPPPrintService.readIPPResponse(is);
is.close();
os.close();
urlConnection.disconnect();
if (responseMap == null || responseMap.length == 0) {
return null;
}
! ArrayList printerNames = new ArrayList();
for (int i=0; i< responseMap.length; i++) {
! AttributeClass attribClass = (AttributeClass)
responseMap[i].get("printer-uri-supported");
if (attribClass != null) {
String nameStr = attribClass.getStringValue();
printerNames.add(nameStr);
}
}
! return (String[])printerNames.toArray(new String[] {});
} else {
os.close();
urlConnection.disconnect();
}
}
--- 371,402 ----
if (IPPPrintService.writeIPPRequest(os,
IPPPrintService.OP_CUPS_GET_PRINTERS, attCl)) {
InputStream is = urlConnection.getInputStream();
! HashMap<String, AttributeClass>[] responseMap =
IPPPrintService.readIPPResponse(is);
is.close();
os.close();
urlConnection.disconnect();
if (responseMap == null || responseMap.length == 0) {
return null;
}
! ArrayList<String> printerNames = new ArrayList<>();
for (int i=0; i< responseMap.length; i++) {
! AttributeClass attribClass =
responseMap[i].get("printer-uri-supported");
if (attribClass != null) {
String nameStr = attribClass.getStringValue();
printerNames.add(nameStr);
}
}
! return printerNames.toArray(new String[] {});
} else {
os.close();
urlConnection.disconnect();
}
}