From 0663fbacd7b9dc4813a415351727d056635b6fad Mon Sep 17 00:00:00 2001 From: djmil Date: Thu, 31 Aug 2023 12:03:18 +0200 Subject: [PATCH] SpringBoot: rename HoldingIdentityNameResolver --- .../main/java/djmil/cordacheckers/ApiController.java | 4 ++-- .../main/java/djmil/cordacheckers/ApiUserDetails.java | 10 +++++----- .../djmil/cordacheckers/ApiUserDetailsService.java | 8 ++++---- ...shManager.java => HoldingIdentityNameResolver.java} | 4 ++-- 4 files changed, 13 insertions(+), 13 deletions(-) rename backend/src/main/java/djmil/cordacheckers/{ShortHashManager.java => HoldingIdentityNameResolver.java} (93%) diff --git a/backend/src/main/java/djmil/cordacheckers/ApiController.java b/backend/src/main/java/djmil/cordacheckers/ApiController.java index 44bc849..2a67e7f 100644 --- a/backend/src/main/java/djmil/cordacheckers/ApiController.java +++ b/backend/src/main/java/djmil/cordacheckers/ApiController.java @@ -31,11 +31,11 @@ public class ApiController { * * @return a Json list of active games */ - @GetMapping("/api/activegames") + @GetMapping("/api/gameproposals") public ResponseEntity dashboard(@AuthenticationPrincipal ApiUserDetails user) { System.out.println("List of active games for " + "user: " + user.getUsername() - + " with shortIdentityHash: " + user.getShortHash()); + + " with shortIdentityHash: " + user.getHoldingIdentityShortHash()); return ResponseEntity.ok("{ \"ActiveGames\" : [\"id_game1\", \"id_game2\"] }" ); } diff --git a/backend/src/main/java/djmil/cordacheckers/ApiUserDetails.java b/backend/src/main/java/djmil/cordacheckers/ApiUserDetails.java index 752f708..6a6034c 100644 --- a/backend/src/main/java/djmil/cordacheckers/ApiUserDetails.java +++ b/backend/src/main/java/djmil/cordacheckers/ApiUserDetails.java @@ -4,16 +4,16 @@ import org.springframework.security.core.userdetails.User; import org.springframework.security.core.userdetails.UserDetails; public class ApiUserDetails extends User { - private final String shortHash; + private final String holdingIdentityShortHash; - public ApiUserDetails(UserDetails user, String shortHash) { + public ApiUserDetails(UserDetails user, String holdingIdentityShortHash) { super(user.getUsername(), user.getPassword(), user.isEnabled(), user.isAccountNonExpired(), user.isCredentialsNonExpired(), user.isAccountNonLocked(), user.getAuthorities()); - this.shortHash = shortHash; + this.holdingIdentityShortHash = holdingIdentityShortHash; } - public String getShortHash() { - return this.shortHash; + public String getHoldingIdentityShortHash() { + return this.holdingIdentityShortHash; } } \ No newline at end of file diff --git a/backend/src/main/java/djmil/cordacheckers/ApiUserDetailsService.java b/backend/src/main/java/djmil/cordacheckers/ApiUserDetailsService.java index af264b3..f333d6e 100644 --- a/backend/src/main/java/djmil/cordacheckers/ApiUserDetailsService.java +++ b/backend/src/main/java/djmil/cordacheckers/ApiUserDetailsService.java @@ -11,18 +11,18 @@ import org.springframework.stereotype.Service; public class ApiUserDetailsService implements UserDetailsService { private final PasswordEncoder encoder; - private final ShortHashManager shortHashManager; + private final HoldingIdentityNameResolver holdingIdentityNameResolver; public ApiUserDetailsService( PasswordEncoder encoder, - ShortHashManager shortHashManager) { + HoldingIdentityNameResolver holdingIdentityNameResolver) { this.encoder = encoder; - this.shortHashManager = shortHashManager; + this.holdingIdentityNameResolver = holdingIdentityNameResolver; } @Override public ApiUserDetails loadUserByUsername(String username) throws UsernameNotFoundException { - String shortHash = shortHashManager.getShortHashBy(username); + String shortHash = holdingIdentityNameResolver.getShortHashBy(username); if (shortHash == null) { throw new UsernameNotFoundException("ShortHash for user '" +username+ "' not found"); diff --git a/backend/src/main/java/djmil/cordacheckers/ShortHashManager.java b/backend/src/main/java/djmil/cordacheckers/HoldingIdentityNameResolver.java similarity index 93% rename from backend/src/main/java/djmil/cordacheckers/ShortHashManager.java rename to backend/src/main/java/djmil/cordacheckers/HoldingIdentityNameResolver.java index 962f83f..0cc2843 100644 --- a/backend/src/main/java/djmil/cordacheckers/ShortHashManager.java +++ b/backend/src/main/java/djmil/cordacheckers/HoldingIdentityNameResolver.java @@ -13,12 +13,12 @@ import djmil.cordacheckers.cordaclient.CordaClient; import djmil.cordacheckers.cordaclient.pojo.virtualNodes; @Service -public class ShortHashManager { +public class HoldingIdentityNameResolver { static final Locale locale = Locale.getDefault(); Map cnName2shortHash; - ShortHashManager(CordaClient client) { + HoldingIdentityNameResolver(CordaClient client) { this.cnName2shortHash = setCnName2shortHash(client); }