@Override
    public String getRealmFromToken(final SamlAssertionWrapper assertion) {
        val ki = assertion.getSignatureKeyInfo();
        val certs = ki.getCerts();
        val parsed = parseCNValue(certs[0].getSubjectX500Principal().getName());
        LOGGER.debug("Realm parsed from certificate CN of the SAML assertion: [{}]", parsed);
        if (StringUtils.equals(parsed, realm)) {
            return parsed;
        }
        LOGGER.warn("Retrieved realm from CN of SAML assertion certificate [{}] does not match the CAS realm [{}]. "
                + "Beware that realm mismatch does requires configuration to implement realm relationships or identity mapping",
            parsed, realm);
        return parsed;
    }
This is {@link SamlAssertionRealmCodec}.
Parse the realm from a SAML assertion.

@author Misagh Moayyed
@since 5.1.0
support/cas-server-support-ws-sts-api/src/main/java/org/apereo/cas/support/saml/SamlAssertionRealmCodec.java