Class SASL

java.lang.Object
org.freedesktop.dbus.connections.SASL

public class SASL extends Object
  • Field Details

    • AUTH_NONE

      public static final int AUTH_NONE
      See Also:
    • AUTH_EXTERNAL

      public static final int AUTH_EXTERNAL
      See Also:
    • AUTH_SHA

      public static final int AUTH_SHA
      See Also:
    • AUTH_ANON

      public static final int AUTH_ANON
      See Also:
    • LOCK_TIMEOUT

      public static final int LOCK_TIMEOUT
      See Also:
    • NEW_KEY_TIMEOUT_SECONDS

      public static final int NEW_KEY_TIMEOUT_SECONDS
      See Also:
    • EXPIRE_KEYS_TIMEOUT_SECONDS

      public static final int EXPIRE_KEYS_TIMEOUT_SECONDS
      See Also:
    • MAX_TIME_TRAVEL_SECONDS

      public static final int MAX_TIME_TRAVEL_SECONDS
      See Also:
    • MAX_READ_BYTES

      private static final int MAX_READ_BYTES
      See Also:
    • COL

      private static final Collator COL
    • SYSPROP_USER_HOME

      private static final String SYSPROP_USER_HOME
    • DBUS_TEST_HOME_DIR

      private static final String DBUS_TEST_HOME_DIR
    • DBUS_KEYRINGS_DIR

      private static final File DBUS_KEYRINGS_DIR
    • BAD_FILE_PERMISSIONS

      private static final Set<PosixFilePermission> BAD_FILE_PERMISSIONS
    • challenge

      private String challenge
    • logger

      private final org.slf4j.Logger logger
    • fileDescriptorSupported

      private boolean fileDescriptorSupported
      whether file descriptor passing is supported on the current connection.
    • saslConfig

      private final SaslConfig saslConfig
  • Constructor Details

    • SASL

      @Deprecated(since="4.2.2 - 2023-02-03", forRemoval=true) public SASL()
      Deprecated, for removal: This API element is subject to removal in a future version.
      should not be used as SASL configuration is not provided
      Create a new SASL auth handler. Defaults to disable file descriptor passing.
    • SASL

      public SASL(SaslConfig _saslConfig)
      Create a new SASL auth handler.
      Parameters:
      _saslConfig - SASL configuration
      _hasFileDescriptorSupport - true to support file descriptor passing (usually only works with UNIX_SOCKET).
  • Method Details

    • findCookie

      private String findCookie(String _context, String _id) throws IOException
      Throws:
      IOException
    • addCookie

      private void addCookie(String _context, String _id, long _timestamp, String _cookie) throws IOException
      Throws:
      IOException
    • stupidlyEncode

      private String stupidlyEncode(String _data)
      Takes the string, encodes it as hex and then turns it into a string again. No, I don't know why either.
    • stupidlyEncode

      private String stupidlyEncode(byte[] _data)
    • getNibble

      private byte getNibble(char _c)
    • stupidlyDecode

      private String stupidlyDecode(String _data)
    • receive

      public SASL.Command receive(SocketChannel _sock) throws IOException
      Throws:
      IOException
    • send

      public void send(SocketChannel _sock, SASL.SaslCommand _command, String... _data) throws IOException
      Throws:
      IOException
    • doChallenge

      SASL.SaslResult doChallenge(int _auth, SASL.Command _c) throws IOException
      Throws:
      IOException
    • doResponse

      SASL.SaslResult doResponse(int _auth, String _uid, String _kernelUid, SASL.Command _c)
    • convertAuthTypes

      public String[] convertAuthTypes(int _types)
    • auth

      public boolean auth(SocketChannel _sock, AbstractTransport _transport) throws IOException
      Performs SASL auth on the given socketchannel. Mode selects whether to run as a SASL server or client. Types is a bitmask of the available auth types.
      Parameters:
      _sock - socket channel
      _transport - transport
      _config - sasl configuration parameters
      Returns:
      true if the auth was successful and false if it failed.
      Throws:
      IOException - on failure
    • isFileDescriptorSupported

      public boolean isFileDescriptorSupported()
    • handleReject

      private int handleReject(int _available, String _luid, SocketChannel _sock) throws IOException
      Handle reject of authentication.
      Parameters:
      _available -
      _luid -
      _sock - socketchannel
      Returns:
      current state or -1 if failed
      Throws:
      IOException - when sending fails
    • getUserId

      private long getUserId()
      Tries to get the UID (user ID) of the current JVM process. Will always return 0 on windows.
      Returns:
      long