setNetworkTimeout checks for SQLPermission before proceeding
@@ -210,9 +210,10 @@ public class SQLServerConnection implements ISQLServerConnection {
}
// Permission targets
- // currently only callAbort is implemented
private static final String callAbortPerm = "callAbort";
+ private static final String SET_NETWORK_TIMEOUT_PERM = "setNetworkTimeout";
+
private boolean sendStringParametersAsUnicode = SQLServerDriverBooleanProperty.SEND_STRING_PARAMETERS_AS_UNICODE.getDefaultValue(); // see
// connection
// properties
@@ -4664,6 +4665,20 @@ public class SQLServerConnection implements ISQLServerConnection {
checkClosed();
+ // check for callAbort permission
+ SecurityManager secMgr = System.getSecurityManager();
+ if (secMgr != null) {
+ try {
+ SQLPermission perm = new SQLPermission(SET_NETWORK_TIMEOUT_PERM);
+ secMgr.checkPermission(perm);
+ }
+ catch (SecurityException ex) {
+ MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_permissionDenied"));
+ Object[] msgArgs = {SET_NETWORK_TIMEOUT_PERM};
+ SQLServerException.makeFromDriverError(this, this, form.format(msgArgs), null, true);
+ }
+ }
+
try {
tdsChannel.setNetworkTimeout(timeout);
}
