RTC - How to decrypt enumeration literals that are encrypted in the database?
Database: SQL Server 2008
RTC Version: 4.0.1
Query to get specified encrypted field:
USE RTC
SELECT
I.ITEM_VALUE
FROM
REPOSITORY.ITEM_STATES AS I
Thanks,
Accepted answer
Comments
Thanks for the response. So these enum literals ARE stored in this field/column ( REPOSITORY.ITEM_STATES.ITEM_VALUE)? And the value of the field is a gzipped blob that contains XML that specifies what enum has been chosen?
I was able to get part of the XML extracted by putting the binary data into a hex editor, saving it as a .gz file and extracting the data from there. Unfortunately, it only appears to be part of the XML, though. I guess from here it would be a different question but I'll ask anyways. Should ITEM_VALUE contain the entirety of the XML or is it merely one part of something larger?
@ben from my knowledge it is XML.
Ralph is quite correct in suggesting not to touch the DB directly especially any updates.
But if you want to really read from the column you could try something like below.
ResultSet rs = null;
PreparedStatement ps = null;
InputStream inputStream = null, rawStream = null;
ByteArrayOutputStream out = null;
try {
ps = conn.prepareStatement(query);
rs = ps.executeQuery();
int start =0;
boolean hasNext = rs.next();
while (hasNext ) {
rawStream = rs.getBinaryStream(column);
inputStream = new GZIPInputStream(rawStream, 8192);
out = new ByteArrayOutputStream(2048);
byte[] bytes = new byte[1024];
int size = -1;
while ((size = inputStream.read(bytes)) > 0) {
out.write(bytes, 0, size);
}
fw.flush();
start++;
hasNext = rs.next();
out.close();
inputStream.close();
rawStream.close();
}
One other answer
Comments
Thanks for the warning, but we have quite a few reports that pull directly from the database and they work perfectly for our use. We've even updated from v3 to v4 and the queries/reports still worked fine. I guess we got lucky. We may try the API route if we do, indeed, start running into issues though. So far it's been fine.