logger.debug("Updating principal "+updatedPrincipal.getName()+" of type "+updatedPrincipal.getType().getName()+" ...");
}
SecurityAttributes principalAttrs = updatedPrincipal.getSecurityAttributes();
for (Map.Entry<String, Attribute> entityAttrEntry : mappedEntityAttrs.entrySet())
{
SecurityAttribute principalAttr = principalAttrs.getAttribute(entityAttrEntry.getKey());
Attribute entityAttr = entityAttrEntry.getValue();
if (principalAttr != null)
{
if (entityAttr.getDefinition().isMultiValue())
{
// TODO : multi-valued Principal attrs are not yet
// supported
}
else
{
if (!StringUtils.equals(principalAttr.getStringValue(), entityAttr.getValue()))
{
attrsToBeUpdated.add(entityAttr);
}
}
}
else
{
attrsToBeUpdated.add(entityAttr);
}
}
}
SecurityAttributes principalAttrs = updatedPrincipal.getSecurityAttributes();
Map<String, SecurityAttributeType> securityAttrTypes = principalAttrs.getSecurityAttributeTypes().getAttributeTypeMap();
// Step 1. update principal's attributes
for (Attribute addedEntityAttr : attrsToBeUpdated)
{
if (!addedEntityAttr.getDefinition().isMultiValue())
{
SecurityAttribute principalAttr = null;
try
{
SecurityAttributeType securityAttrType = securityAttrTypes.get(addedEntityAttr.getMappedName());
if (securityAttrType != null)
{
principalAttr = principalAttrs.getAttribute(addedEntityAttr.getMappedName(), true);
}
if (principalAttr != null)
principalAttr.setStringValue(addedEntityAttr.getValue());
if (logger.isDebugEnabled()){
logger.debug("Marked attribute "+principalAttr.getName()+" as updated for principal "+updatedPrincipal.getName()+". New value: "+principalAttr.getStringValue());
}
}
catch (SecurityException e)
{
if (logger.isErrorEnabled())