|
|
@ -29,6 +29,7 @@ import io.entgra.device.mgt.core.certificate.mgt.core.util.CertificateManagement
|
|
|
|
import io.entgra.device.mgt.core.certificate.mgt.core.util.CommonUtil;
|
|
|
|
import io.entgra.device.mgt.core.certificate.mgt.core.util.CommonUtil;
|
|
|
|
import io.entgra.device.mgt.core.certificate.mgt.core.util.Serializer;
|
|
|
|
import io.entgra.device.mgt.core.certificate.mgt.core.util.Serializer;
|
|
|
|
import org.apache.commons.codec.binary.Base64;
|
|
|
|
import org.apache.commons.codec.binary.Base64;
|
|
|
|
|
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
|
import org.apache.commons.logging.Log;
|
|
|
|
import org.apache.commons.logging.Log;
|
|
|
|
import org.apache.commons.logging.LogFactory;
|
|
|
|
import org.apache.commons.logging.LogFactory;
|
|
|
|
import org.bouncycastle.asn1.ASN1Encodable;
|
|
|
|
import org.bouncycastle.asn1.ASN1Encodable;
|
|
|
@ -429,20 +430,35 @@ public class CertificateGenerator {
|
|
|
|
generateCertificate(byteArrayInputStream);
|
|
|
|
generateCertificate(byteArrayInputStream);
|
|
|
|
|
|
|
|
|
|
|
|
if (reqCert != null && reqCert.getSerialNumber() != null) {
|
|
|
|
if (reqCert != null && reqCert.getSerialNumber() != null) {
|
|
|
|
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
log.debug("looking up certificate for serial: " + reqCert.getSerialNumber().toString());
|
|
|
|
log.debug("looking up certificate for serial: " + reqCert.getSerialNumber().toString());
|
|
|
|
CertificateResponse lookUpCertificate = keyStoreReader.getCertificateBySerial(
|
|
|
|
}
|
|
|
|
|
|
|
|
String orgUnit = CommonUtil.getSubjectDnAttribute(reqCert,
|
|
|
|
|
|
|
|
CertificateManagementConstants.ORG_UNIT_ATTRIBUTE);
|
|
|
|
|
|
|
|
CertificateResponse lookUpCertificate;
|
|
|
|
|
|
|
|
if (StringUtils.isNotEmpty(orgUnit)) {
|
|
|
|
|
|
|
|
int tenantId = Integer.parseInt(orgUnit.split(("_"))[1]);
|
|
|
|
|
|
|
|
lookUpCertificate = keyStoreReader.getCertificateBySerial(reqCert.getSerialNumber().toString(),
|
|
|
|
|
|
|
|
tenantId);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
lookUpCertificate = keyStoreReader.getCertificateBySerial(
|
|
|
|
reqCert.getSerialNumber().toString());
|
|
|
|
reqCert.getSerialNumber().toString());
|
|
|
|
|
|
|
|
}
|
|
|
|
if (lookUpCertificate != null && lookUpCertificate.getCertificate() != null) {
|
|
|
|
if (lookUpCertificate != null && lookUpCertificate.getCertificate() != null) {
|
|
|
|
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
log.debug("certificate found for serial: " + reqCert.getSerialNumber()
|
|
|
|
log.debug("certificate found for serial: " + reqCert.getSerialNumber()
|
|
|
|
.toString());
|
|
|
|
.toString());
|
|
|
|
|
|
|
|
}
|
|
|
|
Certificate certificate = (Certificate) Serializer.deserialize(lookUpCertificate.getCertificate());
|
|
|
|
Certificate certificate = (Certificate) Serializer.deserialize(lookUpCertificate.getCertificate());
|
|
|
|
if (certificate instanceof X509Certificate) {
|
|
|
|
if (certificate instanceof X509Certificate) {
|
|
|
|
return (X509Certificate) certificate;
|
|
|
|
return (X509Certificate) certificate;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
log.debug("certificate not found for serial: " + reqCert.getSerialNumber()
|
|
|
|
log.debug("certificate not found for serial: " + reqCert.getSerialNumber()
|
|
|
|
.toString());
|
|
|
|
.toString());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -464,7 +480,6 @@ public class CertificateGenerator {
|
|
|
|
log.error(errorMsg);
|
|
|
|
log.error(errorMsg);
|
|
|
|
throw new KeystoreException(errorMsg, e);
|
|
|
|
throw new KeystoreException(errorMsg, e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|