docs: protected Principal authenticateAndGetPrincipal(final UsernamePasswordCredential credential) throws GeneralSecurityException {
          val lc = getLoginContext(credential);
          try {
              lc.login();
              val principals = lc.getSubject().getPrincipals();
              LOGGER.debug("JAAS principals extracted from subject are [{}}", principals);
              if (principals != null && !principals.isEmpty()) {
                  val secPrincipal = principals.iterator().next();
                  LOGGER.debug("JAAS principal detected from subject login context is [{}}", secPrincipal.getName());
                  return this.principalFactory.createPrincipal(secPrincipal.getName());
              }
          } finally {
              if (lc != null) {
                  lc.logout();
              }
          }
          return null;
      }