use of javax.naming.InvalidNameException in project qpid-broker-j by apache.
the class NonJavaKeyStoreImpl method getSubjectName.
@Override
public String getSubjectName() {
if (_certificate != null) {
try {
String dn = _certificate.getSubjectX500Principal().getName();
LdapName ldapDN = new LdapName(dn);
String name = dn;
for (Rdn rdn : ldapDN.getRdns()) {
if (rdn.getType().equalsIgnoreCase("CN")) {
name = String.valueOf(rdn.getValue());
break;
}
}
return name;
} catch (InvalidNameException e) {
LOGGER.error("Error getting subject name from certificate");
return null;
}
} else {
return null;
}
}
use of javax.naming.InvalidNameException in project jbosstools-openshift by jbosstools.
the class HumanReadableX509Certificate method getAllRDN.
private String getAllRDN(X500Principal principal) {
StringBuilder builder = new StringBuilder();
try {
LdapName ldapDN = new LdapName(principal.getName());
int i = 0;
for (Rdn rdn : ldapDN.getRdns()) {
String type = getTypeFullName(rdn.getType());
if (!StringUtils.isEmpty(type)) {
if (i++ > 0) {
builder.append(StringUtils.getLineSeparator());
}
builder.append(type).append(SEPARATOR_LABEL_VALUE).append(StringUtils.toStringOrNull(rdn.getValue()));
}
}
return builder.toString();
} catch (InvalidNameException e) {
return builder.toString();
}
}
use of javax.naming.InvalidNameException in project gerrit by GerritCodeReview.
the class LdapGroupBackend method cnFor.
private static String cnFor(String dn) {
try {
LdapName name = new LdapName(dn);
if (!name.isEmpty()) {
String cn = name.get(name.size() - 1);
int index = cn.indexOf('=');
if (index >= 0) {
cn = cn.substring(index + 1);
}
return cn;
}
} catch (InvalidNameException e) {
log.warn("Cannot parse LDAP dn for cn", e);
}
return dn;
}
use of javax.naming.InvalidNameException in project jdk8u_jdk by JetBrains.
the class ResolveResult method appendRemainingComponent.
/**
* Adds a single component to the end of remaining name.
*
* @param name The component to add. Can be null.
* @see #getRemainingName
* @see #appendRemainingName
*/
public void appendRemainingComponent(String name) {
if (name != null) {
CompositeName rname = new CompositeName();
try {
rname.add(name);
} catch (InvalidNameException e) {
// ignore; shouldn't happen for empty composite name
}
appendRemainingName(rname);
}
}
use of javax.naming.InvalidNameException in project Spark by igniterealtime.
the class MutualAuthenticationSettingsPanel method addCertificate.
private void addCertificate() {
fileChooser.setAcceptAllFileFilterUsed(false);
fileChooser.addChoosableFileFilter(certFilter);
fileChooser.setFileFilter(certFilter);
int retVal = fileChooser.showOpenDialog(this);
if (retVal == JFileChooser.APPROVE_OPTION) {
File file = fileChooser.getSelectedFile();
try {
idControll.addEntryToKeyStore(file);
} catch (CertificateException e) {
JOptionPane.showMessageDialog(null, Res.getString("dialog.cannot.upload.certificate.might.be.ill.formated"));
Log.error("Cannot upload certificate file", e);
} catch (InvalidKeySpecException | NoSuchAlgorithmException | KeyStoreException | InvalidNameException | IOException e) {
JOptionPane.showMessageDialog(null, Res.getString("dialog.cannot.upload.certificate"));
Log.error("Cannot upload certificate file", e);
}
}
}
Aggregations