code: private AuthnRequest createAuthRequest(SamlIdentityProviderConfig idp, String defaultHostname) {
          requireNonNull(idp, "idp");
  
          final AuthnRequest authnRequest = build(AuthnRequest.DEFAULT_ELEMENT_NAME);
  
          final Issuer issuer = build(Issuer.DEFAULT_ELEMENT_NAME);
          issuer.setValue(myEntityId);
          authnRequest.setIssuer(issuer);
  
          authnRequest.setIssueInstant(DateTime.now());
          authnRequest.setDestination(idp.ssoEndpoint().toUriString());
          authnRequest.setID(requestIdManager.newId());
  
          // The ProtocolBinding attribute is mutually exclusive with the AssertionConsumerServiceIndex attribute
          // and is typically accompanied by the AssertionConsumerServiceURL attribute.
          final SamlPortConfig portConfig = portConfigHolder.config().get();
          final SamlEndpoint acsEndpoint = idp.acsEndpoint()
                                              .orElse(sp.defaultAcsConfig().endpoint());
          authnRequest.setAssertionConsumerServiceURL(acsEndpoint.toUriString(portConfig.scheme().uriText(),
                                                                              defaultHostname,
                                                                              portConfig.port()));
          authnRequest.setProtocolBinding(acsEndpoint.bindingProtocol().urn());
  
          final SamlNameIdPolicy policy = idp.nameIdPolicy();
          final NameIDPolicy nameIdPolicy = build(NameIDPolicy.DEFAULT_ELEMENT_NAME);
          nameIdPolicy.setFormat(policy.format().urn());
          nameIdPolicy.setAllowCreate(policy.isCreatable());
          authnRequest.setNameIDPolicy(nameIdPolicy);
  
          final AuthnContextClassRef passwordAuthnCtxRef = build(AuthnContextClassRef.DEFAULT_ELEMENT_NAME);
          passwordAuthnCtxRef.setAuthnContextClassRef(AuthnContext.PASSWORD_AUTHN_CTX);
  
          final RequestedAuthnContext requestedAuthnContext = build(RequestedAuthnContext.DEFAULT_ELEMENT_NAME);
          requestedAuthnContext.setComparison(AuthnContextComparisonTypeEnumeration.EXACT);
          requestedAuthnContext.getAuthnContextClassRefs().add(passwordAuthnCtxRef);
  
          authnRequest.setRequestedAuthnContext(requestedAuthnContext);
  
          return authnRequest;
      }
docs: Returns an {@link AuthnRequest} which is mapped to the specified identity provider.