Fixing https://wso2.org/jira/browse/EMM-1448 which fixes issues while persisting certificates when PostgreSQL is used as the underlying certificate management repository database

revert-70aa11f8
prabathabey 8 years ago
parent 0125310440
commit ce2a801934

@ -67,10 +67,9 @@ public class GenericCertificateDAOImpl implements CertificateDAO {
serialNumber = String.valueOf(certificate.getCertificate().getSerialNumber()); serialNumber = String.valueOf(certificate.getCertificate().getSerialNumber());
} }
byte[] bytes = Serializer.serialize(certificate.getCertificate()); byte[] bytes = Serializer.serialize(certificate.getCertificate());
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(bytes);
stmt.setString(1, serialNumber); stmt.setString(1, serialNumber);
stmt.setObject(2, byteArrayInputStream); stmt.setBytes(2, bytes);
stmt.setInt(3, certificate.getTenantId()); stmt.setInt(3, certificate.getTenantId());
stmt.setString(4, username); stmt.setString(4, username);
stmt.addBatch(); stmt.addBatch();
@ -102,7 +101,7 @@ public class GenericCertificateDAOImpl implements CertificateDAO {
stmt.setInt(2, tenantId); stmt.setInt(2, tenantId);
resultSet = stmt.executeQuery(); resultSet = stmt.executeQuery();
while (resultSet.next()) { if (resultSet.next()) {
certificateResponse = new CertificateResponse(); certificateResponse = new CertificateResponse();
byte [] certificateBytes = resultSet.getBytes("CERTIFICATE"); byte [] certificateBytes = resultSet.getBytes("CERTIFICATE");
certificateResponse.setCertificate(certificateBytes); certificateResponse.setCertificate(certificateBytes);
@ -110,7 +109,6 @@ public class GenericCertificateDAOImpl implements CertificateDAO {
certificateResponse.setTenantId(resultSet.getInt("TENANT_ID")); certificateResponse.setTenantId(resultSet.getInt("TENANT_ID"));
certificateResponse.setUsername(resultSet.getString("USERNAME")); certificateResponse.setUsername(resultSet.getString("USERNAME"));
CertificateGenerator.extractCertificateDetails(certificateBytes, certificateResponse); CertificateGenerator.extractCertificateDetails(certificateBytes, certificateResponse);
break;
} }
} catch (SQLException e) { } catch (SQLException e) {
String errorMsg = String errorMsg =

Loading…
Cancel
Save