@@ -62,6 +62,7 @@ public class MyHttpAuthCoreProvider extends AuthCoreProvider implements AuthSupp
6262 public String banHardwareUrl ;
6363 public String unbanHardwareUrl ;
6464 private transient HttpRequester requester ;
65+
6566 @ Override
6667 public User getUserByUsername (String username ) {
6768 try {
@@ -223,7 +224,6 @@ public List<GetAvailabilityAuthRequestEvent.AuthAvailabilityDetails> getDetails(
223224
224225 @ Override
225226 public void close () {
226-
227227 }
228228
229229 @ Override
@@ -280,7 +280,12 @@ public MyHttpUserHardware getHardwareInfoById(String id) {
280280 public void connectUserAndHardware (UserSession userSession , UserHardware hardware ) {
281281 HttpHelper .HttpOptional <MyHttpSimpleResponse , HttpRequester .SimpleError > response = null ;
282282 try {
283- response = requester .send (requester .post (connectUserAndHardwareUrl , new UserHardwareRequest ((MyHttpUserHardware ) hardware , (MyHttpUserSession ) userSession ), bearerToken ), MyHttpSimpleResponse .class );
283+ String sessionid = userSession .getID ();
284+ logger .debug ("Connecting user {} to hardware {}" , sessionid , hardware .getId ());
285+ response = requester .send (
286+ requester .post (connectUserAndHardwareUrl , new UserHardwareRequest ((MyHttpUserHardware ) hardware , sessionid ), bearerToken ),
287+ MyHttpSimpleResponse .class
288+ );
284289 } catch (Throwable e ) {
285290 logger .error ("connectUserAndHardware" , e );
286291 }
@@ -359,11 +364,11 @@ public void unbanHardware(UserHardware hardware) {
359364 }
360365
361366 if (response != null && response .isSuccessful ()) {
362- logger .debug ("Successfully banned hardware with id {}" , hardware .getId ());
367+ logger .debug ("Successfully unbanned hardware with id {}" , hardware .getId ());
363368 return ;
364369 }
365370
366- logger .debug ("Something went wrong while bannind hardware with id {}" , hardware .getId ());
371+ logger .debug ("Something went wrong while unbanning hardware with id {}" , hardware .getId ());
367372 }
368373
369374 public record JoinServerRequest (String username , UUID uuid , String accessToken , String serverId ) {}
@@ -394,24 +399,21 @@ public record HardwareInfoRequest(HardwareInfo info, byte[] publicKey, String id
394399 }
395400 }
396401
397- public record UserHardwareRequest (MyHttpUserHardware hardware , MyHttpUserSession userSession , byte [] publicKey ) {
398- UserHardwareRequest (MyHttpUserHardware hardware ) {
399- this (hardware , null , null );
402+ public record UserHardwareRequest (MyHttpUserHardware hardware , MyHttpUserSession userSession , byte [] publicKey , String sessionID ) {
403+ public UserHardwareRequest (MyHttpUserHardware hardware ) {
404+ this (hardware , null , null , null );
400405 }
401406
402- UserHardwareRequest (MyHttpUserHardware hardware , byte [] publicKey ) {
403- this (hardware , null , publicKey );
407+ public UserHardwareRequest (MyHttpUserHardware hardware , byte [] publicKey ) {
408+ this (hardware , null , publicKey , null );
404409 }
405410
406- UserHardwareRequest (MyHttpUserHardware hardware , MyHttpUserSession userSession ) {
407- this (hardware , userSession , null );
411+ public UserHardwareRequest (MyHttpUserHardware hardware , String sessionID ) {
412+ this (hardware , null , null , sessionID );
408413 }
409414 }
410415
411-
412-
413416 public record MyHttpUserSession (String id , String accessToken , String refreshToken , int expire , MyHttpUser user , String hardwareId , UserHardware userHardware ) implements UserSession , UserSessionSupportHardware {
414-
415417 @ Override
416418 public String getID () {
417419 return id ;
@@ -433,7 +435,7 @@ public long getExpireIn() {
433435 }
434436
435437 public AuthManager .AuthReport toAuthReport () {
436- return new AuthManager .AuthReport (accessToken , accessToken , refreshToken , expire *1000L /* seconds to milliseconds */ , this );
438+ return new AuthManager .AuthReport (accessToken , accessToken , refreshToken , expire *1000L , this );
437439 }
438440
439441 @ Override
@@ -448,7 +450,6 @@ public UserHardware getHardware() {
448450 }
449451
450452 public record MyHttpUser (String username , UUID uuid , List <String > permissions , List <String > roles , Map <String , JsonTextureProvider .JsonTexture > assets , boolean banned , UserHardware userHardware ) implements User , UserSupportTextures {
451-
452453 @ Override
453454 public String getUsername () {
454455 return username ;
@@ -494,7 +495,6 @@ public Map<String, Texture> getUserAssets() {
494495 }
495496
496497 public record MyHttpUserHardware (HardwareInfo hardwareInfo , byte [] publicKey , String id , boolean banned ) implements UserHardware {
497-
498498 @ Override
499499 public HardwareInfo getHardwareInfo () {
500500 return hardwareInfo ;
@@ -516,8 +516,7 @@ public boolean isBanned() {
516516 }
517517 }
518518
519- public record MyHttpSimpleResponse (String message ) {
520- }
519+ public record MyHttpSimpleResponse (String message ) {}
521520
522521 @ Override
523522 public UserHardware getHardwareInfoByData (HardwareInfo info ) {
@@ -534,9 +533,8 @@ public UserHardware getHardwareInfoByData(HardwareInfo info) {
534533 return userHardware ;
535534 }
536535
537- // HTTP 204 meaning NO CONTENT, that usually means no data found, but request processed successfully
538536 if (response != null && response .statusCode () == 204 ) {
539- logger .debug ("UserHardware not found by publicKey " );
537+ logger .debug ("UserHardware not found by hardware info " );
540538 return null ;
541539 }
542540
@@ -560,8 +558,6 @@ public UserHardware createHardwareInfo(HardwareInfo info, byte[] publicKey) {
560558 }
561559
562560 logger .debug ("Something went wrong while creating UserHardware" );
563-
564- // shouldn't actually happen
565561 throw new SecurityException ("Please contact administrator" );
566562 }
567- }
563+ }
0 commit comments