|
|
|
@ -120,6 +120,22 @@ public class CertificateGenerator {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static String getOrganizationalUnit(X509Certificate requestCertificate) {
|
|
|
|
|
String distinguishedName = requestCertificate.getSubjectDN().getName();
|
|
|
|
|
if (distinguishedName != null && !distinguishedName.isEmpty()) {
|
|
|
|
|
String[] dnSplits = distinguishedName.split(",");
|
|
|
|
|
for (String dnSplit : dnSplits) {
|
|
|
|
|
if (dnSplit.contains("O=")) {
|
|
|
|
|
String[] cnSplits = dnSplit.split("=");
|
|
|
|
|
if (cnSplits[1] != null) {
|
|
|
|
|
return cnSplits[1];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void extractCertificateDetails(byte[] certificateBytes, CertificateResponse certificateResponse)
|
|
|
|
|
throws CertificateManagementDAOException {
|
|
|
|
|
try {
|
|
|
|
@ -845,8 +861,15 @@ public class CertificateGenerator {
|
|
|
|
|
}
|
|
|
|
|
String subjectDn = joiner.toString();
|
|
|
|
|
X500Name issuerName = new X500Name(subjectDn);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String commonName = certificationRequest.getSubject().getRDNs(BCStyle.CN)[0].getFirst()
|
|
|
|
|
.getValue().toString();
|
|
|
|
|
.getValue().toString();
|
|
|
|
|
// CSR sent from a Windows device will have an '!' followed by the device ID in the CN
|
|
|
|
|
if (commonName.contains("!")) {
|
|
|
|
|
commonName = commonName.split("!")[1];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
|
|
|
|
|
X500Name subjectName = new X500Name("O=" + commonName + " ,CN=" +
|
|
|
|
|
serialNumber + ", OU=tenant_" + tenantId);
|
|
|
|
|