/** * Extracts the Certificate Principal Common Name (CN). */ public static String getCommonName(Principal certPrincipal) { if (certPrincipal == null || certPrincipal.getName() == null || certPrincipal.getName().isEmpty()) { return null; } String attr = getAttributeFromDN(certPrincipal.getName(), "CN"); if (attr == null) { Utils.logWarning("DN %s doesn't contain attribute 'CN'", certPrincipal.getName()); attr = certPrincipal.getName(); } return attr; }