Package org.freedesktop.dbus.connections
Class SASL
- java.lang.Object
-
- org.freedesktop.dbus.connections.SASL
-
public class SASL extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSASL.Command(package private) static classSASL.SaslAuthStatestatic classSASL.SaslCommandstatic classSASL.SaslModestatic classSASL.SaslResult
-
Field Summary
Fields Modifier and Type Field Description static intAUTH_ANONstatic intAUTH_EXTERNALstatic intAUTH_NONEstatic intAUTH_SHAprivate static java.util.Set<java.nio.file.attribute.PosixFilePermission>BAD_FILE_PERMISSIONSprivate java.lang.Stringchallengeprivate static java.text.CollatorCOLprivate java.lang.Stringcookiestatic java.lang.StringCOOKIE_CONTEXTstatic intCOOKIE_TIMEOUTprivate static java.io.FileDBUS_KEYRINGS_DIRprivate static java.lang.StringDBUS_TEST_HOME_DIRstatic intEXPIRE_KEYS_TIMEOUT_SECONDSprivate booleanfileDescriptorSupportedwhether file descriptor passing is supported on the current connection.static intLOCK_TIMEOUTprivate org.slf4j.Loggerloggerprivate static intMAX_READ_BYTESstatic intMAX_TIME_TRAVEL_SECONDSstatic intNEW_KEY_TIMEOUT_SECONDSprivate SaslConfigsaslConfigprivate static java.lang.StringSYSPROP_USER_HOME
-
Constructor Summary
Constructors Constructor Description SASL()Deprecated, for removal: This API element is subject to removal in a future version.should not be used as SASL configuration is not providedSASL(SaslConfig _saslConfig)Create a new SASL auth handler.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidaddCookie(java.lang.String _context, java.lang.String _id, long _timestamp, java.lang.String _cookie)booleanauth(java.nio.channels.SocketChannel _sock, AbstractTransport _transport)Performs SASL auth on the given socketchannel.java.lang.String[]convertAuthTypes(int _types)(package private) SASL.SaslResultdoChallenge(int _auth, SASL.Command _c)(package private) SASL.SaslResultdoResponse(int _auth, java.lang.String _uid, java.lang.String _kernelUid, SASL.Command _c)private java.lang.StringfindCookie(java.lang.String _context, java.lang.String _id)private bytegetNibble(char _c)private longgetUserId()Tries to get the UID (user ID) of the current JVM process.private inthandleReject(int _available, java.lang.String _luid, java.nio.channels.SocketChannel _sock)Handle reject of authentication.booleanisFileDescriptorSupported()SASL.Commandreceive(java.nio.channels.SocketChannel _sock)voidsend(java.nio.channels.SocketChannel _sock, SASL.SaslCommand _command, java.lang.String... _data)private java.lang.StringstupidlyDecode(java.lang.String _data)private java.lang.StringstupidlyEncode(byte[] _data)private java.lang.StringstupidlyEncode(java.lang.String _data)Takes the string, encodes it as hex and then turns it into a string again.
-
-
-
Field Detail
-
AUTH_NONE
public static final int AUTH_NONE
- See Also:
- Constant Field Values
-
AUTH_EXTERNAL
public static final int AUTH_EXTERNAL
- See Also:
- Constant Field Values
-
AUTH_SHA
public static final int AUTH_SHA
- See Also:
- Constant Field Values
-
AUTH_ANON
public static final int AUTH_ANON
- See Also:
- Constant Field Values
-
LOCK_TIMEOUT
public static final int LOCK_TIMEOUT
- See Also:
- Constant Field Values
-
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
-
COOKIE_TIMEOUT
public static final int COOKIE_TIMEOUT
- See Also:
- Constant Field Values
-
COOKIE_CONTEXT
public static final java.lang.String COOKIE_CONTEXT
- See Also:
- Constant Field Values
-
MAX_READ_BYTES
private static final int MAX_READ_BYTES
- 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.
-
saslConfig
private final SaslConfig saslConfig
-
-
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 providedCreate 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
-
doChallenge
SASL.SaslResult doChallenge(int _auth, SASL.Command _c) throws java.io.IOException
- Throws:
java.io.IOException
-
doResponse
SASL.SaslResult doResponse(int _auth, java.lang.String _uid, java.lang.String _kernelUid, SASL.Command _c)
-
convertAuthTypes
public java.lang.String[] convertAuthTypes(int _types)
-
auth
public boolean auth(java.nio.channels.SocketChannel _sock, AbstractTransport _transport) throws java.io.IOExceptionPerforms 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.IOExceptionHandle 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
-
-