@Override
    public String getPrincipalIdFrom(final JoinPoint auditTarget, final Authentication authentication,
                                     final Object returnValue, final Exception exception) {
        val response = (Response) returnValue;
        if (!response.getAssertions().isEmpty()) {
            val assertion = response.getAssertions().getFirst();
            val subject = assertion.getSubject();
            if (subject != null && subject.getNameID() != null) {
                return subject.getNameID().getValue();
            }
        }
        return super.getPrincipalIdFrom(auditTarget, authentication, returnValue, exception);
    }
This is {@link SamlResponseAuditPrincipalIdProvider}.

@author Misagh Moayyed
@since 5.3.0
support/cas-server-support-saml-idp-web/src/main/java/org/apereo/cas/support/saml/web/idp/audit/SamlResponseAuditPrincipalIdProvider.java