@@ -163,29 +163,29 @@ public static OAuthClient getOAuthClientById(Start start, String clientId, AppId
163163
164164 public static void createOrUpdateOAuthSession (Start start , AppIdentifier appIdentifier , @ NotNull String gid , @ NotNull String clientId ,
165165 String externalRefreshToken , String internalRefreshToken , String sessionHandle ,
166- List < String > jtis , long exp )
166+ String jti , long exp )
167167 throws SQLException , StorageQueryException {
168168 String sessionTable = Config .getConfig (start ).getOAuthSessionsTable ();
169169 String QUERY = "INSERT INTO " + sessionTable +
170170 " (gid, client_id, app_id, external_refresh_token, internal_refresh_token, session_handle, jti, exp) VALUES (?, ?, ?, ?, ?, ?, ?, ?) " +
171171 "ON CONFLICT (gid) DO UPDATE SET external_refresh_token = ?, internal_refresh_token = ?, " +
172- "session_handle = ? , jti = CONCAT(" +sessionTable +".jti, ',' , ?), exp = ?" ;
172+ "session_handle = ? , jti = CONCAT(" +sessionTable +".jti, ?), exp = ?" ;
173173 update (start , QUERY , pst -> {
174- String jtiDbValue = jtis == null ? null : String . join ( "," , jtis ) ;
174+ String jtiToInsert = jti + "," ;
175175
176176 pst .setString (1 , gid );
177177 pst .setString (2 , clientId );
178178 pst .setString (3 , appIdentifier .getAppId ());
179179 pst .setString (4 , externalRefreshToken );
180180 pst .setString (5 , internalRefreshToken );
181181 pst .setString (6 , sessionHandle );
182- pst .setString (7 , jtiDbValue );
182+ pst .setString (7 , jtiToInsert ); //the starting list element also has to have a "," at the end as the remove removes "jti + ,"
183183 pst .setLong (8 , exp );
184184
185185 pst .setString (9 , externalRefreshToken );
186186 pst .setString (10 , internalRefreshToken );
187187 pst .setString (11 , sessionHandle );
188- pst .setString (12 , jtiDbValue );
188+ pst .setString (12 , jtiToInsert );
189189 pst .setLong (13 , exp );
190190 });
191191 }
@@ -283,7 +283,7 @@ public static boolean deleteJTIFromOAuthSession(Start start, AppIdentifier appId
283283 + " SET jti = REPLACE(jti, ?, '')" // deletion means replacing the jti with empty char
284284 + " WHERE app_id = ? and gid = ?" ;
285285 int numberOfRows = update (start , DELETE , pst -> {
286- pst .setString (1 , jti );
286+ pst .setString (1 , jti + "," ); //removing with the "," to not leave behind trash
287287 pst .setString (2 , appIdentifier .getAppId ());
288288 pst .setString (3 , gid );
289289 });
0 commit comments