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
|
||||
*/
|
||||
@GetMapping("/api/activegames")
|
||||
@GetMapping("/api/gameproposals")
|
||||
public ResponseEntity<String> 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\"] }" );
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
@ -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");
|
||||
|
@ -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<String, String> cnName2shortHash;
|
||||
|
||||
ShortHashManager(CordaClient client) {
|
||||
HoldingIdentityNameResolver(CordaClient client) {
|
||||
this.cnName2shortHash = setCnName2shortHash(client);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user