use of org.wso2.carbon.security.keystore.service.CertDataDetail in project carbon-identity-framework by wso2.
the class KeyStoreManagementServiceImpl method getPublicCertificate.
@Override
public Map<String, X509Certificate> getPublicCertificate(String tenantDomain) throws KeyStoreManagementException {
Map<String, X509Certificate> certData = new HashMap<>();
KeyStoreData keyStoreInfo = getKeystoreData(tenantDomain, getKeyStoreName(tenantDomain));
CertData key = keyStoreInfo.getKey();
certData.put(key.getAlias(), ((CertDataDetail) key).getCertificate());
return certData;
}
use of org.wso2.carbon.security.keystore.service.CertDataDetail in project carbon-identity-framework by wso2.
the class KeyStoreManagementServiceImpl method getKeyStoreCertificate.
@Override
public X509Certificate getKeyStoreCertificate(String tenantDomain, String alias) throws KeyStoreManagementException {
if (StringUtils.isEmpty(alias)) {
throw handleClientException(ERROR_CODE_EMPTY_ALIAS, null);
}
KeyStoreData keyStoreInfo = getKeystoreData(tenantDomain, getKeyStoreName(tenantDomain));
CertData key = keyStoreInfo.getKey();
if (key != null && StringUtils.equals(key.getAlias(), alias)) {
return ((CertDataDetail) key).getCertificate();
}
CertData[] certDataArray = keyStoreInfo.getCerts();
for (CertData certData : certDataArray) {
String aliasFromKeyStore = certData.getAlias();
if (StringUtils.equals(aliasFromKeyStore, alias)) {
return ((CertDataDetail) certData).getCertificate();
}
}
return null;
}
use of org.wso2.carbon.security.keystore.service.CertDataDetail in project carbon-identity-framework by wso2.
the class KeyStoreAdmin method fillCertData.
private CertData fillCertData(X509Certificate cert, String alise, Format formatter) throws CertificateEncodingException {
CertData certData = null;
if (includeCert) {
certData = new CertDataDetail();
} else {
certData = new CertData();
}
certData.setAlias(alise);
certData.setSubjectDN(cert.getSubjectDN().getName());
certData.setIssuerDN(cert.getIssuerDN().getName());
certData.setSerialNumber(cert.getSerialNumber());
certData.setVersion(cert.getVersion());
certData.setNotAfter(formatter.format(cert.getNotAfter()));
certData.setNotBefore(formatter.format(cert.getNotBefore()));
certData.setPublicKey(Base64.encode(cert.getPublicKey().getEncoded()));
if (includeCert) {
((CertDataDetail) certData).setCertificate(cert);
}
return certData;
}
Aggregations