SpringBoot: rename HoldingIdentityNameResolver
This commit is contained in:
parent
c4048c20b6
commit
0663fbacd7
@ -31,11 +31,11 @@ public class ApiController {
|
|||||||
*
|
*
|
||||||
* @return a Json list of active games
|
* @return a Json list of active games
|
||||||
*/
|
*/
|
||||||
@GetMapping("/api/activegames")
|
@GetMapping("/api/gameproposals")
|
||||||
public ResponseEntity<String> dashboard(@AuthenticationPrincipal ApiUserDetails user) {
|
public ResponseEntity<String> dashboard(@AuthenticationPrincipal ApiUserDetails user) {
|
||||||
System.out.println("List of active games for "
|
System.out.println("List of active games for "
|
||||||
+ "user: " + user.getUsername()
|
+ "user: " + user.getUsername()
|
||||||
+ " with shortIdentityHash: " + user.getShortHash());
|
+ " with shortIdentityHash: " + user.getHoldingIdentityShortHash());
|
||||||
|
|
||||||
return ResponseEntity.ok("{ \"ActiveGames\" : [\"id_game1\", \"id_game2\"] }" );
|
return ResponseEntity.ok("{ \"ActiveGames\" : [\"id_game1\", \"id_game2\"] }" );
|
||||||
}
|
}
|
||||||
|
@ -4,16 +4,16 @@ import org.springframework.security.core.userdetails.User;
|
|||||||
import org.springframework.security.core.userdetails.UserDetails;
|
import org.springframework.security.core.userdetails.UserDetails;
|
||||||
|
|
||||||
public class ApiUserDetails extends User {
|
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());
|
super(user.getUsername(), user.getPassword(), user.isEnabled(), user.isAccountNonExpired(), user.isCredentialsNonExpired(), user.isAccountNonLocked(), user.getAuthorities());
|
||||||
|
|
||||||
this.shortHash = shortHash;
|
this.holdingIdentityShortHash = holdingIdentityShortHash;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getShortHash() {
|
public String getHoldingIdentityShortHash() {
|
||||||
return this.shortHash;
|
return this.holdingIdentityShortHash;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -11,18 +11,18 @@ import org.springframework.stereotype.Service;
|
|||||||
public class ApiUserDetailsService implements UserDetailsService {
|
public class ApiUserDetailsService implements UserDetailsService {
|
||||||
|
|
||||||
private final PasswordEncoder encoder;
|
private final PasswordEncoder encoder;
|
||||||
private final ShortHashManager shortHashManager;
|
private final HoldingIdentityNameResolver holdingIdentityNameResolver;
|
||||||
|
|
||||||
public ApiUserDetailsService(
|
public ApiUserDetailsService(
|
||||||
PasswordEncoder encoder,
|
PasswordEncoder encoder,
|
||||||
ShortHashManager shortHashManager) {
|
HoldingIdentityNameResolver holdingIdentityNameResolver) {
|
||||||
this.encoder = encoder;
|
this.encoder = encoder;
|
||||||
this.shortHashManager = shortHashManager;
|
this.holdingIdentityNameResolver = holdingIdentityNameResolver;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ApiUserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
|
public ApiUserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
|
||||||
String shortHash = shortHashManager.getShortHashBy(username);
|
String shortHash = holdingIdentityNameResolver.getShortHashBy(username);
|
||||||
if (shortHash == null) {
|
if (shortHash == null) {
|
||||||
throw new UsernameNotFoundException("ShortHash for user '"
|
throw new UsernameNotFoundException("ShortHash for user '"
|
||||||
+username+ "' not found");
|
+username+ "' not found");
|
||||||
|
@ -13,12 +13,12 @@ import djmil.cordacheckers.cordaclient.CordaClient;
|
|||||||
import djmil.cordacheckers.cordaclient.pojo.virtualNodes;
|
import djmil.cordacheckers.cordaclient.pojo.virtualNodes;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class ShortHashManager {
|
public class HoldingIdentityNameResolver {
|
||||||
static final Locale locale = Locale.getDefault();
|
static final Locale locale = Locale.getDefault();
|
||||||
|
|
||||||
Map<String, String> cnName2shortHash;
|
Map<String, String> cnName2shortHash;
|
||||||
|
|
||||||
ShortHashManager(CordaClient client) {
|
HoldingIdentityNameResolver(CordaClient client) {
|
||||||
this.cnName2shortHash = setCnName2shortHash(client);
|
this.cnName2shortHash = setCnName2shortHash(client);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user