mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 06:45:07 +02:00
8344078: Remove security manager dependency in java.nio
Reviewed-by: alanb, rriggs
This commit is contained in:
parent
2649406323
commit
922b12f30c
67 changed files with 285 additions and 1480 deletions
|
@ -202,11 +202,7 @@ class ServerSocketChannelImpl
|
|||
public SocketAddress getLocalAddress() throws IOException {
|
||||
synchronized (stateLock) {
|
||||
ensureOpen();
|
||||
if (isUnixSocket()) {
|
||||
return UnixDomainSockets.getRevealedLocalAddress(localAddress);
|
||||
} else {
|
||||
return Net.getRevealedLocalAddress(localAddress);
|
||||
}
|
||||
return localAddress;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -305,7 +301,6 @@ class ServerSocketChannelImpl
|
|||
}
|
||||
|
||||
private SocketAddress unixBind(SocketAddress local, int backlog) throws IOException {
|
||||
UnixDomainSockets.checkPermission();
|
||||
if (local == null) {
|
||||
// Attempt up to 10 times to find an unused name in temp directory.
|
||||
// If local address supplied then bind called only once
|
||||
|
@ -336,10 +331,6 @@ class ServerSocketChannelImpl
|
|||
} else {
|
||||
isa = Net.checkAddress(local, family);
|
||||
}
|
||||
@SuppressWarnings("removal")
|
||||
SecurityManager sm = System.getSecurityManager();
|
||||
if (sm != null)
|
||||
sm.checkListen(isa.getPort());
|
||||
NetHooks.beforeTcpBind(fd, isa.getAddress(), isa.getPort());
|
||||
Net.bind(family, fd, isa.getAddress(), isa.getPort());
|
||||
Net.listen(fd, backlog < 1 ? 50 : backlog);
|
||||
|
@ -423,7 +414,6 @@ class ServerSocketChannelImpl
|
|||
throws IOException
|
||||
{
|
||||
if (isUnixSocket()) {
|
||||
UnixDomainSockets.checkPermission();
|
||||
String[] pa = new String[1];
|
||||
int n = UnixDomainSockets.accept(fd, newfd, pa);
|
||||
if (n > 0)
|
||||
|
@ -495,16 +485,6 @@ class ServerSocketChannelImpl
|
|||
try {
|
||||
// newly accepted socket is initially in blocking mode
|
||||
IOUtil.configureBlocking(newfd, true);
|
||||
|
||||
// check permitted to accept connections from the remote address
|
||||
if (isNetSocket()) {
|
||||
@SuppressWarnings("removal")
|
||||
SecurityManager sm = System.getSecurityManager();
|
||||
if (sm != null) {
|
||||
InetSocketAddress isa = (InetSocketAddress) sa;
|
||||
sm.checkAccept(isa.getAddress().getHostAddress(), isa.getPort());
|
||||
}
|
||||
}
|
||||
return new SocketChannelImpl(provider(), family, newfd, sa);
|
||||
} catch (Exception e) {
|
||||
nd.close(newfd);
|
||||
|
@ -749,9 +729,7 @@ class ServerSocketChannelImpl
|
|||
if (addr == null) {
|
||||
sb.append("unbound");
|
||||
} else if (isUnixSocket()) {
|
||||
sb.append(UnixDomainSockets.getRevealedLocalAddressAsString(addr));
|
||||
} else {
|
||||
sb.append(Net.getRevealedLocalAddressAsString(addr));
|
||||
sb.append(addr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue