public String getUsername() { if (this.userName == null) { Properties prop = new Properties(); this.userName = getCertificatePrincipal().getName(); try { prop.load(new StringReader(userName.replaceAll(",", "\n"))); } catch (IOException e) { e.printStackTrace(); } userName = prop.getProperty("CN"); } return this.userName; }
public String getUsername() { if (this.userName == null) { this.userName = getCertificatePrincipal().getName(); if (subjectRegex == null) { try { LdapName ldapName = new LdapName(this.userName); this.userName = ldapName.getRdn(ldapName.size() - 1).getValue().toString(); } catch (Exception e) { throw new IdentityManagementException("Could not extract CN from X509.", e); } } else { Matcher matcher = Pattern.compile(this.subjectRegex).matcher(this.userName); if (matcher.find()) if (matcher.groupCount() != 1) { throw new IdentityManagementException("Single group expected from expression."); } this.userName = matcher.group(1); } } return this.userName; }
public String getUsername() { if (this.userName == null) { this.userName = getCertificatePrincipal().getName(); if (subjectRegex == null) { try { LdapName ldapName = new LdapName(this.userName); this.userName = ldapName.getRdn(ldapName.size() - 1).getValue().toString(); } catch (Exception e) { throw new IdentityManagementException("Could not extract CN from X509.", e); } } else { Matcher matcher = Pattern.compile(this.subjectRegex).matcher(this.userName); if (matcher.find()) if (matcher.groupCount() != 1) { throw new IdentityManagementException("Single group expected from expression."); } this.userName = matcher.group(1); } } return this.userName; }