private Subject buildSubject(final SamlProfileBuilderContext context) throws Exception {
        val validFromDate = ZonedDateTime.now(ZoneOffset.UTC);
        LOGGER.trace("Locating the assertion consumer service url for binding [{}]", context.getBinding());
        val acs = SamlIdPUtils.determineEndpointForRequest(Pair.of(context.getSamlRequest(), context.getMessageContext()),
            context.getAdaptor(), context.getBinding());
        val location = StringUtils.isBlank(acs.getResponseLocation()) ? acs.getLocation() : acs.getResponseLocation();
        val subjectNameId = getNameIdForService(context);

        val registeredService = context.getRegisteredService();
        val subjectConfNameId = registeredService.isSkipGeneratingSubjectConfirmationNameId()
            ? null
            : getNameIdForService(context);

        val notOnOrAfterDateTime = validFromDate.plusSeconds(registeredService.getSkewAllowance() != 0
            ? registeredService.getSkewAllowance()
            : Beans.newDuration(casProperties.getAuthn().getSamlIdp().getResponse().getSkewAllowance()).toSeconds());
        val notOnOrAfter = registeredService.isSkipGeneratingSubjectConfirmationNotOnOrAfter()
            ? null
            : notOnOrAfterDateTime;
        LOGGER.trace("Subject confirmation notOnOrAfter for service [{}] is [{}]", registeredService.getServiceId(), notOnOrAfter);

        val finalSubjectNameId = encryptNameIdIfNecessary(subjectNameId, context);
        val finalSubjectConfigNameId = encryptNameIdIfNecessary(subjectConfNameId, context);

        val entityId = casProperties.getAuthn().getSamlIdp().getCore().getEntityId();
        val subjectConfirmation = newSubjectConfirmation(
            registeredService.isSkipGeneratingSubjectConfirmationRecipient() ? null : location,
            notOnOrAfter,
            getInResponseTo(context.getSamlRequest(), entityId, registeredService.isSkipGeneratingSubjectConfirmationInResponseTo()),
            registeredService.isSkipGeneratingSubjectConfirmationNotBefore() ? null : ZonedDateTime.now(ZoneOffset.UTC),
            registeredService.isSkipGeneratingSubjectConfirmationAddress() ? null : InetAddressUtils.getByName(location));
        
        val subject = newSubject(finalSubjectNameId, finalSubjectConfigNameId, subjectConfirmation);
        LOGGER.debug("Created SAML subject [{}]", subject);
        return subject;
    }
This is {@link SamlProfileSamlSubjectBuilder}.

@author Misagh Moayyed
@since 5.0.0
support/cas-server-support-saml-idp-web/src/main/java/org/apereo/cas/support/saml/web/idp/profile/builders/subject/SamlProfileSamlSubjectBuilder.java