diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java index 54c5950c2..0cfdfd2b3 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java @@ -210,8 +210,9 @@ ServerPortPlaceHolder getRoutingInfo() { } // 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 @@ -4663,6 +4664,20 @@ public void setNetworkTimeout(Executor executor, } checkClosed(); + + // check for setNetworkTimeout 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);