Class UnixCredentialsMessage

All Implemented Interfaces:
Proxy

@Generated("org.javagi.JavaGI") public class UnixCredentialsMessage extends SocketControlMessage

This SocketControlMessage contains a Credentials instance. It may be sent using Socket.sendMessage(SocketAddress, OutputVector[], SocketControlMessage[], int, Cancellable) and received using Socket.receiveMessage(Out, InputVector[], Out, Out, Cancellable) over UNIX sockets (ie: sockets in the G_SOCKET_FAMILY_UNIX family).

For an easier way to send and receive credentials over stream-oriented UNIX sockets, see UnixConnection.sendCredentials(Cancellable) and UnixConnection.receiveCredentials(Cancellable). To receive credentials of a foreign process connected to a socket, use Socket.getCredentials().

Since GLib 2.72, GUnixCredentialMessage is available on all platforms. It requires underlying system support (such as Windows 10 with AF_UNIX) at run time.

Before GLib 2.72, <gio/gunixcredentialsmessage.h> belonged to the UNIX-specific GIO interfaces, thus you had to use the gio-unix-2.0.pc pkg-config file when using it. This is no longer necessary since GLib 2.72.

Since:
2.26
  • Constructor Details

    • UnixCredentialsMessage

      public UnixCredentialsMessage(MemorySegment address)
      Create a UnixCredentialsMessage instance for the provided memory address.
      Parameters:
      address - the memory address of the native object
    • UnixCredentialsMessage

      public UnixCredentialsMessage()
      Create a new UnixCredentialsMessage.
  • Method Details

    • getType

      public static @Nullable Type getType()
      Get the GType of the UnixCredentialsMessage class.
      Returns:
      the GType
    • getMemoryLayout

      public static MemoryLayout getMemoryLayout()
      The memory layout of the native struct.
      Returns:
      the memory layout
    • asParent

      protected UnixCredentialsMessage asParent()
      Return this instance as if it were its parent type. Comparable to the Java super keyword, but ensures the parent typeclass is also used in native code.
      Overrides:
      asParent in class SocketControlMessage
      Returns:
      the instance as if it were its parent type
    • withCredentials

      public static SocketControlMessage withCredentials(Credentials credentials)
      Creates a new GUnixCredentialsMessage holding credentials.
      Parameters:
      credentials - A GCredentials object.
      Returns:
      a new GUnixCredentialsMessage
      Since:
      2.26
    • isSupported

      public static boolean isSupported()
      Checks if passing GCredentials on a GSocket is supported on this platform.
      Returns:
      true if supported, false otherwise
      Since:
      2.26
    • getCredentials

      public Credentials getCredentials()
      Gets the credentials stored in message.
      Returns:
      A GCredentials instance. Do not free, it is owned by message.
      Since:
      2.26
    • builder

      A UnixCredentialsMessage.Builder object constructs a UnixCredentialsMessage with the specified properties. Use the various set...() methods to set properties, and finish construction with UnixCredentialsMessage.Builder.build().
      Returns:
      the builder object