|
|
@ -323,19 +323,25 @@ public class CertificateGenerator {
|
|
|
|
CertificateResponse lookUpCertificate = null;
|
|
|
|
CertificateResponse lookUpCertificate = null;
|
|
|
|
KeyStoreReader keyStoreReader = new KeyStoreReader();
|
|
|
|
KeyStoreReader keyStoreReader = new KeyStoreReader();
|
|
|
|
if (distinguishedName != null && !distinguishedName.isEmpty()) {
|
|
|
|
if (distinguishedName != null && !distinguishedName.isEmpty()) {
|
|
|
|
LdapName ldapName;
|
|
|
|
if (distinguishedName.contains("/CN=")) {
|
|
|
|
try {
|
|
|
|
String[] dnSplits = distinguishedName.split("/CN=");
|
|
|
|
ldapName = new LdapName(distinguishedName);
|
|
|
|
String commonNameExtracted = dnSplits[dnSplits.length - 1];
|
|
|
|
} catch (InvalidNameException e) {
|
|
|
|
lookUpCertificate = keyStoreReader.getCertificateBySerial(commonNameExtracted);
|
|
|
|
throw new KeystoreException(
|
|
|
|
} else {
|
|
|
|
"Invalid name exception while trying to create a LDAP name using the distinguished name ", e);
|
|
|
|
LdapName ldapName;
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
for (Rdn relativeDistinuguishedNames : ldapName.getRdns()) {
|
|
|
|
ldapName = new LdapName(distinguishedName);
|
|
|
|
if (relativeDistinuguishedNames.getType().equalsIgnoreCase("CN")) {
|
|
|
|
} catch (InvalidNameException e) {
|
|
|
|
System.err.println("CN is: " + relativeDistinuguishedNames.getValue());
|
|
|
|
throw new KeystoreException(
|
|
|
|
lookUpCertificate = keyStoreReader
|
|
|
|
"Invalid name exception while trying to create a LDAP name using the distinguished name ",
|
|
|
|
.getCertificateBySerial(String.valueOf(relativeDistinuguishedNames.getValue()));
|
|
|
|
e);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (Rdn relativeDistinguishedNames : ldapName.getRdns()) {
|
|
|
|
|
|
|
|
if (relativeDistinguishedNames.getType().equalsIgnoreCase("CN")) {
|
|
|
|
|
|
|
|
lookUpCertificate = keyStoreReader
|
|
|
|
|
|
|
|
.getCertificateBySerial(String.valueOf(relativeDistinguishedNames.getValue()));
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|