if (attr == null)
{
if (!syncAll)
{
// if principal has attr: remove it
SecurityAttribute principalAttr = principalAttrs.getAttribute(attrDef.getMappedName());
if (principalAttr != null)
{
feedbackLogger.debug("Removing attribute {} for principal {}", principalAttr.getName(), principal.getName());
principalAttrs.removeAttribute(principalAttr.getName());
updated = true;
}
}
}
else if (syncAll)
{
SecurityAttribute principalAttr = principalAttrs.getAttribute(attrDef.getMappedName(), true);
if (feedbackLogger.isDebugEnabled())
{
feedbackLogger.debug("Adding attribute {} for principal {}. Value: {}",
new String[] {principalAttr.getName(), principal.getName(), attr.getValue()});
}
principalAttr.setStringValue(attr.getValue());
updated = true;
}
else
{
SecurityAttribute principalAttr = principalAttrs.getAttribute(attrDef.getMappedName(), true);
if (!StringUtils.equals(principalAttr.getStringValue(), attr.getValue()))
{
if (feedbackLogger.isDebugEnabled())
{
feedbackLogger.debug("Attribute attribute {} for principal {}. Old value: {}, new value: {}",
new String[] {principalAttr.getName(), principal.getName(), (principalAttr.getStringValue()), attr.getValue()});
}
principalAttr.setStringValue(attr.getValue());
updated = true;
}
}
}
}