class X509CommonNameUserMapper extends X509AbstractMapper {

    public String mapCertificateToMainframeUserId(X509Certificate certificate) {
        if (isClientAuthCertificate(certificate)) {
            String dn = certificate.getSubjectX500Principal().getName();
            LdapName ldapDN = getLdapName(dn);
            for (Rdn rdn : ldapDN.getRdns()) {
                if ("cn".equalsIgnoreCase(rdn.getType())) {
                    return String.valueOf(rdn.getValue());
                }
            }
        }
        return null;
    }

}