mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 06:45:07 +02:00
8217997: Better socket support
Reviewed-by: alanb, ahgross, chegar, igerasim
This commit is contained in:
parent
67a0aa7960
commit
e4553cb2fa
4 changed files with 45 additions and 1 deletions
|
@ -25,6 +25,8 @@
|
|||
|
||||
package java.net;
|
||||
|
||||
import sun.security.util.SecurityConstants;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.IOException;
|
||||
|
@ -182,12 +184,28 @@ class Socket implements java.io.Closeable {
|
|||
*
|
||||
* @throws SocketException if there is an error in the underlying protocol,
|
||||
* such as a TCP error.
|
||||
*
|
||||
* @throws SecurityException if {@code impl} is non-null and a security manager is set
|
||||
* and its {@code checkPermission} method doesn't allow {@code NetPermission("setSocketImpl")}.
|
||||
*
|
||||
* @since 1.1
|
||||
*/
|
||||
protected Socket(SocketImpl impl) throws SocketException {
|
||||
checkPermission(impl);
|
||||
this.impl = impl;
|
||||
}
|
||||
|
||||
private static Void checkPermission(SocketImpl impl) {
|
||||
if (impl == null) {
|
||||
return null;
|
||||
}
|
||||
SecurityManager sm = System.getSecurityManager();
|
||||
if (sm != null) {
|
||||
sm.checkPermission(SecurityConstants.SET_SOCKETIMPL_PERMISSION);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a stream socket and connects it to the specified port
|
||||
* number on the named host.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue