< prev index next >
src/jdk.net/linux/classes/jdk/net/LinuxSocketOptions.java
Print this page
@@ -23,13 +23,16 @@
* questions.
*/
package jdk.net;
import java.net.SocketException;
+import java.nio.file.attribute.UserPrincipal;
+import java.nio.file.attribute.GroupPrincipal;
import java.security.AccessController;
import java.security.PrivilegedAction;
import jdk.net.ExtendedSocketOptions.PlatformSocketOptions;
+import sun.nio.fs.UnixUserGroupUtil;
class LinuxSocketOptions extends PlatformSocketOptions {
public LinuxSocketOptions() {
}
@@ -52,10 +55,14 @@
@Override
boolean keepAliveOptionsSupported() {
return keepAliveOptionsSupported0();
}
+ boolean peerCredentialsSupported() {
+ return true;
+ }
+
@Override
void setTcpkeepAliveProbes(int fd, final int value) throws SocketException {
setTcpkeepAliveProbes0(fd, value);
}
@@ -92,18 +99,30 @@
@Override
int getIncomingNapiId(int fd) throws SocketException {
return getIncomingNapiId0(fd);
}
+
+ @Override
+ UnixDomainPrincipal getSoPeerCred(int fd) throws SocketException {
+ int[] result = new int[2];
+
+ getSoPeerCred0(fd, result);
+ UserPrincipal user = UnixUserGroupUtil.fromUid(result[0]);
+ GroupPrincipal group = UnixUserGroupUtil.fromGid(result[1]);
+ return new UnixDomainPrincipal(user, group);
+ }
+
private static native void setTcpkeepAliveProbes0(int fd, int value) throws SocketException;
private static native void setTcpKeepAliveTime0(int fd, int value) throws SocketException;
private static native void setTcpKeepAliveIntvl0(int fd, int value) throws SocketException;
private static native int getTcpkeepAliveProbes0(int fd) throws SocketException;
private static native int getTcpKeepAliveTime0(int fd) throws SocketException;
private static native int getTcpKeepAliveIntvl0(int fd) throws SocketException;
private static native void setQuickAck0(int fd, boolean on) throws SocketException;
private static native boolean getQuickAck0(int fd) throws SocketException;
+ private static native void getSoPeerCred0(int fd, int[] result) throws SocketException;
private static native boolean keepAliveOptionsSupported0();
private static native boolean quickAckSupported0();
private static native boolean incomingNapiIdSupported0();
private static native int getIncomingNapiId0(int fd) throws SocketException;
static {
< prev index next >