Class SQLCoreProvider
java.lang.Object
pro.gravit.launchserver.auth.core.AuthCoreProvider
pro.gravit.launchserver.auth.core.AbstractSQLCoreProvider
pro.gravit.launchserver.auth.core.SQLCoreProvider
- All Implemented Interfaces:
AutoCloseable, AuthSupport, AuthSupportExtendedCheckServer, AuthSupportHardware, AuthSupportSudo, Reconfigurable
public class SQLCoreProvider
extends AbstractSQLCoreProvider
implements AuthSupportHardware, AuthSupportExtendedCheckServer
SQL-backed auth provider with hardware-ID tracking and optional TOTP support.
Required configuration fields (in addition to base class)
hardwareIdColumn– FK column in the user table pointing to the hwids table
Optional configuration fields
AbstractSQLCoreProvider.totpSecretColumn– when set, the TOTP secret is read from this column and stored onAbstractSQLCoreProvider.SQLUser.totpSecret. Whennullthe column is completely absent from every SELECT query and ResultSet mapping.tableHWID– defaults to"hwids"tableHWIDLog– defaults to"hwidLog"criticalCompareLevel– fuzzy-match threshold, defaults to1.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic classImmutable hardware record (except mutablepublicKeyandbanned).classSession with lazy-loaded hardware info.Nested classes/interfaces inherited from class AbstractSQLCoreProvider
AbstractSQLCoreProvider.ColumnFeature<U,T> Modifier and TypeClassDescriptionstatic final classDescribes a single optional column in the user table.Nested classes/interfaces inherited from class AuthCoreProvider
AuthCoreProvider.OAuthAccessTokenExpired, AuthCoreProvider.PasswordVerifyReportModifier and TypeClassDescriptionstatic classstatic classNested classes/interfaces inherited from interface AuthSupportHardware
AuthSupportHardware.HardwareInfoCompareResult -
Field Summary
FieldsModifier and TypeFieldDescriptiondoubleMinimum similarity level for a hardware record to be considered a match ingetHardwareInfoByData(HardwareReportRequest.HardwareInfo).Column in the user table that holds the hardware-ID foreign key (required).Hikari connection-pool config (required).Hardware-info table name.Hardware-change audit-log table name.Fields inherited from class AbstractSQLCoreProvider
accessTokenColumn, codeGenerator, customQueryByLoginSQL, customQueryByUsernameSQL, customQueryByUUIDSQL, customQueryPermissionsByUUIDSQL, customQueryRolesByUserUUID, customUpdateAuthSQL, customUpdateServerIdSQL, expireSeconds, logger, passwordColumn, passwordVerifier, permissionsPermissionColumn, permissionsTable, permissionsUUIDColumn, rolesNameColumn, rolesTable, rolesUUIDColumn, serverIDColumn, table, timeProvider, totpSecretColumn, usernameColumn, uuidColumn, verifierModifier and TypeFieldDescriptionprotected final dev.samstevens.totp.code.CodeGeneratorlongSession / access-token lifetime in seconds (default: 1 hour).protected final org.apache.logging.log4j.Loggerprotected final dev.samstevens.totp.time.TimeProviderOptional TOTP secret column in the user table.protected final dev.samstevens.totp.code.CodeVerifierFields inherited from class AuthCoreProvider
pair, providers, serverModifier and TypeFieldDescriptionprotected AuthProviderPairstatic final pro.gravit.utils.ProviderMap<AuthCoreProvider> protected LaunchServer -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddPublicKeyToHardwareInfo(UserHardware hardware, byte[] publicKey) voidbanHardware(UserHardware hardware) protected voidBuilds all transient SQL strings.voidclose()voidconnectUserAndHardware(UserSession userSession, UserHardware hardware) protected SQLCoreProvider.SQLUserReads all required columns plushardwareIdColumn, then lets the base class apply every registered optional column (includingAbstractSQLCoreProvider.totpSecretColumnwhen enabled) via theAbstractSQLCoreProvider.ColumnFeatureregistry.createHardwareInfo(pro.gravit.launcher.base.request.secure.HardwareReportRequest.HardwareInfo info, byte[] publicKey) protected SQLCoreProvider.SQLUserSessionextendedCheckServer(Client client, String username, String serverID) getHardwareInfoByData(pro.gravit.launcher.base.request.secure.HardwareReportRequest.HardwareInfo info) getHardwareInfoByPublicKey(byte[] publicKey) getUsersByHardwareInfo(UserHardware hardware) voidinit(LaunchServer server, AuthProviderPair pair) protected StringhardwareIdColumnis a required column for this provider, so it is appended here rather than through the optional registry.voidunbanHardware(UserHardware hardware) Methods inherited from class AbstractSQLCoreProvider
applyOptionalColumns, authorize, checkServer, constructUser, executeSingleUpdate, getDetails, getUserByLogin, getUserByUsername, getUserByUUID, getUserSessionByOAuthAccessToken, isPermissionsEnabled, isRolesEnabled, joinServer, loadPermissions, refreshAccessToken, registerColumnFeature, registerOptionalColumns, safeQueryUser, sudo, updateAuth, updateServerID, verifyTotpCodeModifier and TypeMethodDescriptionprotected final voidApplies all registered optional columns touserfrom the current row ofset.authorize(String login, AuthResponse.AuthContext context, pro.gravit.launcher.base.request.auth.AuthRequest.AuthPasswordInterface password, boolean minecraftAccess) checkServer(Client client, String username, String serverID) protected AbstractSQLCoreProvider.SQLUserconstructUser(ResultSet set) Advancessetby one row and delegates toAbstractSQLCoreProvider.constructUserFromRow(ResultSet), or returnsnullif the result set is empty.protected intexecuteSingleUpdate(String sql, String p1, String p2) Runs a two-parameter UPDATE and returns the affected-row count.List<pro.gravit.launcher.base.events.request.GetAvailabilityAuthRequestEvent.AuthAvailabilityDetails> getDetails(Client client) getUserByLogin(String login) getUserByUsername(String username) getUserByUUID(UUID uuid) getUserSessionByOAuthAccessToken(String accessToken) booleanbooleanbooleanpro.gravit.launcher.base.ClientPermissionsloadPermissions(String uuid) refreshAccessToken(String refreshToken, AuthResponse.AuthContext context) protected final voidregisterColumnFeature(AbstractSQLCoreProvider.ColumnFeature<?, ?> feature) Registers one optional column.protected voidOverride to declare optional user-table columns.protected final AbstractSQLCoreProvider.SQLUsersafeQueryUser(String sql, String param) Executes a single-parameter SELECT and maps the result to aAbstractSQLCoreProvider.SQLUser(with permissions).protected voidupdateAuth(User user, String accessToken) protected booleanupdateServerID(User user, String serverID) protected voidverifyTotpCode(AbstractSQLCoreProvider.SQLUser user, String totpCode) Methods inherited from class AuthCoreProvider
authorize, getCommands, isSupport, registerProviders, verifyAuthModifier and TypeMethodDescriptionauthorize(User user, AuthResponse.AuthContext context, pro.gravit.launcher.base.request.auth.AuthRequest.AuthPasswordInterface password, boolean minecraftAccess) Gets a list of commands available for this object.<T> Tstatic voidvoidverifyAuth(AuthResponse.AuthContext context) Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface AuthSupportHardware
compareHardwareInfo, normalizeHardwareInfoModifier and TypeMethodDescriptioncompareHardwareInfo(pro.gravit.launcher.base.request.secure.HardwareReportRequest.HardwareInfo first, pro.gravit.launcher.base.request.secure.HardwareReportRequest.HardwareInfo second) default voidnormalizeHardwareInfo(pro.gravit.launcher.base.request.secure.HardwareReportRequest.HardwareInfo hardwareInfo) Methods inherited from interface Reconfigurable
defaultCommandsMapModifier and TypeMethodDescription
-
Field Details
-
holder
Hikari connection-pool config (required). -
hardwareIdColumn
Column in the user table that holds the hardware-ID foreign key (required). This is a required column for this provider — it is always included in SELECT queries viamakeUserCols(), not via the optional registry. -
tableHWID
Hardware-info table name. -
tableHWIDLog
Hardware-change audit-log table name. -
criticalCompareLevel
public double criticalCompareLevelMinimum similarity level for a hardware record to be considered a match ingetHardwareInfoByData(HardwareReportRequest.HardwareInfo). -
customFindHardwareByPublicKey
-
customFindHardwareByData
-
customFindHardwareById
-
customCreateHardware
-
customCreateHWIDLog
-
customUpdateHardwarePublicKey
-
customUsersByHwidId
-
-
Constructor Details
-
SQLCoreProvider
public SQLCoreProvider()
-
-
Method Details
-
getSQLConfig
- Specified by:
getSQLConfigin classAbstractSQLCoreProvider
-
init
- Overrides:
initin classAbstractSQLCoreProvider
-
makeUserCols
hardwareIdColumnis a required column for this provider, so it is appended here rather than through the optional registry. Optional columns (e.g.AbstractSQLCoreProvider.totpSecretColumn) are appended byAbstractSQLCoreProviderautomatically after the required set.- Overrides:
makeUserColsin classAbstractSQLCoreProvider
-
buildPreparedQueries
protected void buildPreparedQueries()Description copied from class:AbstractSQLCoreProviderBuilds all transient SQL strings. Called once perAbstractSQLCoreProvider.init(LaunchServer, AuthProviderPair)after the optional-column registry is finalised.Subclasses that need additional SQL should override this and call
super.buildPreparedQueries()first.- Overrides:
buildPreparedQueriesin classAbstractSQLCoreProvider
-
constructUserFromRow
Reads all required columns plushardwareIdColumn, then lets the base class apply every registered optional column (includingAbstractSQLCoreProvider.totpSecretColumnwhen enabled) via theAbstractSQLCoreProvider.ColumnFeatureregistry.- Overrides:
constructUserFromRowin classAbstractSQLCoreProvider- Throws:
SQLException
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Overrides:
closein classAbstractSQLCoreProvider
-
getHardwareInfoByPublicKey
- Specified by:
getHardwareInfoByPublicKeyin interfaceAuthSupportHardware
-
getHardwareInfoByData
public UserHardware getHardwareInfoByData(pro.gravit.launcher.base.request.secure.HardwareReportRequest.HardwareInfo info) - Specified by:
getHardwareInfoByDatain interfaceAuthSupportHardware
-
getHardwareInfoById
- Specified by:
getHardwareInfoByIdin interfaceAuthSupportHardware
-
createHardwareInfo
public UserHardware createHardwareInfo(pro.gravit.launcher.base.request.secure.HardwareReportRequest.HardwareInfo info, byte[] publicKey) - Specified by:
createHardwareInfoin interfaceAuthSupportHardware
-
connectUserAndHardware
- Specified by:
connectUserAndHardwarein interfaceAuthSupportHardware
-
addPublicKeyToHardwareInfo
- Specified by:
addPublicKeyToHardwareInfoin interfaceAuthSupportHardware
-
getUsersByHardwareInfo
- Specified by:
getUsersByHardwareInfoin interfaceAuthSupportHardware
-
banHardware
- Specified by:
banHardwarein interfaceAuthSupportHardware
-
unbanHardware
- Specified by:
unbanHardwarein interfaceAuthSupportHardware
-
extendedCheckServer
- Specified by:
extendedCheckServerin interfaceAuthSupportExtendedCheckServer
-
createSession
- Overrides:
createSessionin classAbstractSQLCoreProvider
-