docs: protected NameID encodeNameIdBasedOnNameFormat(final RequestAbstractType authnRequest,
                                                     final Object assertion,
                                                     final String nameFormat,
                                                     final SamlRegisteredService service,
                                                     final SamlRegisteredServiceServiceProviderMetadataFacade adaptor) {
          try {
              if (authnRequest instanceof AttributeQuery) {
                  val query = AttributeQuery.class.cast(authnRequest);
                  val nameID = query.getSubject().getNameID();
                  nameID.detach();
                  LOGGER.debug("Choosing NameID format [{}] with value [{}] for attribute query", nameID.getFormat(), nameID.getValue());
                  return nameID;
              }
  
              val attribute = prepareNameIdAttribute(assertion, nameFormat, adaptor);
              val encoder = prepareNameIdEncoder(authnRequest, nameFormat, attribute, service, adaptor);
              LOGGER.debug("Encoding NameID based on [{}]", nameFormat);
              var nameId = encoder.encode(attribute);
              LOGGER.debug("Final NameID encoded with format [{}] has value [{}]", nameId.getFormat(), nameId.getValue());
              return nameId;
          } catch (final Exception e) {
              LOGGER.error(e.getMessage(), e);
          }
          return null;
      }