Class SASL


  • public class SASL
    extends java.lang.Object
    • Field Detail

      • NEW_KEY_TIMEOUT_SECONDS

        public static final int NEW_KEY_TIMEOUT_SECONDS
        See Also:
        Constant Field Values
      • EXPIRE_KEYS_TIMEOUT_SECONDS

        public static final int EXPIRE_KEYS_TIMEOUT_SECONDS
        See Also:
        Constant Field Values
      • MAX_TIME_TRAVEL_SECONDS

        public static final int MAX_TIME_TRAVEL_SECONDS
        See Also:
        Constant Field Values
      • COL

        private static final java.text.Collator COL
      • SYSPROP_USER_HOME

        private static final java.lang.String SYSPROP_USER_HOME
      • DBUS_TEST_HOME_DIR

        private static final java.lang.String DBUS_TEST_HOME_DIR
      • DBUS_KEYRINGS_DIR

        private static final java.io.File DBUS_KEYRINGS_DIR
      • BAD_FILE_PERMISSIONS

        private static final java.util.Set<java.nio.file.attribute.PosixFilePermission> BAD_FILE_PERMISSIONS
      • challenge

        private java.lang.String challenge
      • cookie

        private java.lang.String cookie
      • logger

        private final org.slf4j.Logger logger
      • fileDescriptorSupported

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

      • 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:
        _hasFileDescriptorSupport - true to support file descriptor passing (usually only works with UNIX_SOCKET).
        _saslConfig - SASL configuration
    • Method Detail

      • findCookie

        private java.lang.String findCookie​(java.lang.String _context,
                                            java.lang.String _id)
                                     throws java.io.IOException
        Throws:
        java.io.IOException
      • addCookie

        private void addCookie​(java.lang.String _context,
                               java.lang.String _id,
                               long _timestamp,
                               java.lang.String _cookie)
                        throws java.io.IOException
        Throws:
        java.io.IOException
      • stupidlyEncode

        private java.lang.String stupidlyEncode​(java.lang.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 java.lang.String stupidlyEncode​(byte[] _data)
      • getNibble

        private byte getNibble​(char _c)
      • stupidlyDecode

        private java.lang.String stupidlyDecode​(java.lang.String _data)
      • receive

        public SASL.Command receive​(java.nio.channels.SocketChannel _sock)
                             throws java.io.IOException
        Throws:
        java.io.IOException
      • send

        public void send​(java.nio.channels.SocketChannel _sock,
                         SASL.SaslCommand _command,
                         java.lang.String... _data)
                  throws java.io.IOException
        Throws:
        java.io.IOException
      • convertAuthTypes

        public java.lang.String[] convertAuthTypes​(int _types)
      • auth

        public boolean auth​(java.nio.channels.SocketChannel _sock,
                            AbstractTransport _transport)
                     throws java.io.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:
        _config - sasl configuration parameters
        _sock - socket channel
        _transport - transport
        Returns:
        true if the auth was successful and false if it failed.
        Throws:
        java.io.IOException - on failure
      • isFileDescriptorSupported

        public boolean isFileDescriptorSupported()
      • handleReject

        private int handleReject​(int _available,
                                 java.lang.String _luid,
                                 java.nio.channels.SocketChannel _sock)
                          throws java.io.IOException
        Handle reject of authentication.
        Parameters:
        _available -
        _luid -
        _sock - socketchannel
        Returns:
        current state or -1 if failed
        Throws:
        java.io.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