message: Correct getAccount() method to work both for OIDC and JWT
diff: package io.github.jhipster.registry.web.rest;
  -import com.codahale.metrics.annotation.Timed;
  -import io.github.jhipster.registry.web.rest.vm.UserVM;
  +import java.util.stream.Collectors;
  +import javax.servlet.http.HttpServletRequest;
  +
  import org.slf4j.Logger;
  import org.slf4j.LoggerFactory;
  import org.springframework.http.HttpStatus;
  @@ -9,13 +10,12 @@ import org.springframework.http.ResponseEntity;
  import org.springframework.security.core.Authentication;
  import org.springframework.security.core.GrantedAuthority;
  import org.springframework.security.core.context.SecurityContextHolder;
  +import org.springframework.web.bind.annotation.*;
  import org.springframework.security.core.userdetails.User;
  -import org.springframework.web.bind.annotation.GetMapping;
  -import org.springframework.web.bind.annotation.RequestMapping;
  -import org.springframework.web.bind.annotation.RestController;
  -import javax.servlet.http.HttpServletRequest;
  -import java.util.stream.Collectors;
  +import com.codahale.metrics.annotation.Timed;
  +
  +import io.github.jhipster.registry.web.rest.vm.UserVM;
  /**
  * REST controller for managing the current user's account.
  @@ -50,7 +50,19 @@ public class AccountResource {
  public ResponseEntity<UserVM> getAccount() {
  Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
  try {
  - UserVM userVM = new UserVM((String) authentication.getPrincipal(),
  + String login;
  + if (authentication.getPrincipal() instanceof User) {
  + log.debug(("The username `{}` has been found using JWT"));
  + User user = (User) authentication.getPrincipal();
  + login = user.getUsername();
  + } else if (authentication.getPrincipal() instanceof String) {
  + log.debug(("The username `{}` has been found using OpenID Connect"));
  + login = (String) authentication.getPrincipal();
  + } else {
  + log.debug("The username could not be found");
  + return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
  + }
  + UserVM userVM = new UserVM(login,
  authentication.getAuthorities().stream()
  .map(GrantedAuthority::getAuthority).collect(Collectors.toSet()));
  return new ResponseEntity<>(userVM, HttpStatus.OK);
  