static Credentials getCredentials(int fd) { Ucred c = new Ucred(); int error = Native.getsockopt(fd, SocketLevel.SOL_SOCKET, SocketOption.SO_PEERCRED, c); if (error != 0) { throw new UnsupportedOperationException(Native.getLastErrorString()); } return new Credentials(c); } }