Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please if possible do not use the word "Workaround" in a parameter name or method.

Original file line number Diff line number Diff line change
Expand Up @@ -872,4 +872,23 @@ public String getMessage(String key, Object... args) {
return getMessage(key);
}
}

private boolean ignorePasswordWorkaround = false;

/**
* If set to true then the password processed in updateOp. It will simply be ignored.
* If set to false then the password will be processed as usual.
*/
@ConfigurationProperty(order = 25,
displayMessageKey = "IGNORE_PASSWORD_WORKAROUND_DISPLAY",
helpMessageKey = "IGNORE_PASSWORD_WORKAROUND_HELP")
public boolean getIgnorePasswordWorkaround() {
return ignorePasswordWorkaround;
}

public void setIgnorePasswordWorkaround(boolean ignorePasswordWorkaround) {
this.ignorePasswordWorkaround = ignorePasswordWorkaround;
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -395,18 +395,26 @@ public Uid update(ObjectClass oclass, Uid uid, Set<Attribute> attrs, OperationOp
for (Attribute attribute : attrs) {
// All attributes needs to be updated except the UID
if (!attribute.is(Uid.NAME)) {
final String attributeName = attribute.getName();
final String columnName = getColumnName(attributeName);
Object value = AttributeUtil.getSingleValue(attribute);
// Handle the empty string values
if (isToBeEmpty(columnName, value)) {
log.info("Append empty attribute {0} for required columnName {1}", attributeName, columnName);
value = DatabaseTableConstants.EMPTY_STR;
if (config.getIgnorePasswordWorkaround() && attribute.is(OperationalAttributeInfos.PASSWORD.getName())) {
if(attrs.size() == 1) {
return ret;
} else {
break;
}
} else {
final String attributeName = attribute.getName();
final String columnName = getColumnName(attributeName);
Object value = AttributeUtil.getSingleValue(attribute);
// Handle the empty string values
if (isToBeEmpty(columnName, value)) {
log.info("Append empty attribute {0} for required columnName {1}", attributeName, columnName);
value = DatabaseTableConstants.EMPTY_STR;
}
final SQLColumnTypeInfo sqlColumnTypeInfo = getColumnTypeInfo(columnName);
final SQLParam param = new SQLParam(quoteName(columnName), value, sqlColumnTypeInfo.getTypeCode(), sqlColumnTypeInfo.getTypeName());
updateSet.addBind(param);
log.ok("Appended to update statement the attribute {0} for columnName {1} and sql type code {2}", attributeName, columnName, sqlColumnTypeInfo.getTypeCode());
}
final SQLColumnTypeInfo sqlColumnTypeInfo = getColumnTypeInfo(columnName);
final SQLParam param = new SQLParam(quoteName(columnName), value, sqlColumnTypeInfo.getTypeCode(), sqlColumnTypeInfo.getTypeName());
updateSet.addBind(param);
log.ok("Appended to update statement the attribute {0} for columnName {1} and sql type code {2}", attributeName, columnName, sqlColumnTypeInfo.getTypeCode());
}
}
log.info("Update account {0}", accountName);
Expand Down Expand Up @@ -1031,8 +1039,13 @@ private Set<AttributeInfo> buildAttributeInfoSet(ResultSet rset) throws SQLExcep
log.ok("Name of the parameter being evaluated : {0}", name);

final AttributeInfoBuilder attrBld = new AttributeInfoBuilder();
final int columnType = meta.getColumnType(i);
final String columnTypeName = meta.getColumnTypeName(i);
Integer columnType = meta.getColumnType(i);
String columnTypeName = meta.getColumnTypeName(i);

if(meta.getColumnType(i) == 5) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Type interpretation is handled in a separate project, the DB table connector has a dependency on. Please do not use this code snipped in this place and rather port this part of the contribution to the "https://github.com/Evolveum/connector-legacy-libs/tree/master/dbcommon" repository. You can use parts of the commit "Evolveum/connector-legacy-libs@6a80de7" as a reference fo the modifications needed for this.

columnType = 4;
columnTypeName = "int";
}

columnSQLTypes.put(name, new SQLColumnTypeInfo(columnTypeName, columnType));
if (name.equalsIgnoreCase(config.getKeyColumn())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,5 @@ SQL_STATE_INVALID_ATTRIBUTE_VALUE_DISPLAY=Invalid Attribute Value SQL state code
SQL_STATE_INVALID_ATTRIBUTE_VALUE_HELP=Collection of values representing SQL state codes which can be interpreted to create an Invalid Attribute Value exception.
SQL_STATE_CONFIGURATION_EXCEPTION_DISPLAY=Configuration Exception SQL state codes
SQL_STATE_CONFIGURATION_EXCEPTION_HELP=Collection of values representing SQL state codes which can be interpreted to create an Configuration exception.
IGNORE_PASSWORD_WORKAROUND_DISPLAY=Ignore Password Workaround
IGNORE_PASSWORD_WORKAROUND_HELP=If set to true then the password processed in updateOp. It will simply be ignored. If set to false then the password will be processed as usual.