protected String deobfuscate(String value) { try { return value == null ? null : Obfuscator.decode(value); } catch (NumberFormatException nfe) {//detect unobfuscated properties from before patch //Assuming that this was in incorrect state from BZ840512 //logging that we found an unobfuscated value and if it's not part of patch/upgrade contact administrator LOG.error("Failed to deobfuscate property value: [" + value + "]. If this is not part of a patch/upgrade " + "then you should contact System Administrator to have the property details reset."); //Returning plain value to prevent Content Source load failure. On save should be correctly obfuscated return value; } catch (Exception e) { LOG.error("Failed to deobfuscate property value: [" + value + "]", e); throw new IllegalArgumentException("Failed to deobfuscate property value: [" + value + "]", e); } }
@Override public void execute(DatabaseType type, Connection connection) throws SQLException { String sql = "SELECT id, string_value FROM rhq_config_property WHERE dtype = 'obfuscated'"; List<Object[]> results = type.executeSelectSql(connection, sql); for(Object[] row : results) { String value = (String) row[1]; //try to decode the value try { Obfuscator.decode(value); } catch (Exception e) { int id = ((Number) row[0]).intValue(); type.executeSql(connection, "UPDATE rhq_config_property SET string_value = NULL WHERE id = " + id); } } } }
String bindPW = options.get("BindPW"); try { bindPW = Obfuscator.decode(bindPW); } catch (Exception e) { LOG.debug("Failed to decode bindPW, binding using undecoded value [" + bindPW + "]", e);
private void deobfuscateAgentInstall(AgentInstall ai) { try { String pw = ai.getSshPassword(); if (pw != null && pw.length() > 0) { ai.setSshPassword(Obfuscator.decode(pw)); } } catch (Exception e) { ai.setSshPassword(""); LOG.debug("Failed to deobfuscate password for agent [" + ai.getAgentName() + "]. Will be emptied."); } }
String bindPW = (String) options.get("BindPW"); try { bindPW = Obfuscator.decode(bindPW); } catch (Exception e) { log.debug("Failed to decode bindPW, validating using undecoded value [" + bindPW + "]", e);