if (userPwdsSB == null || userPwdsSB.size() == 0) {
logger.error("UserName [" + userId + "] not found!!");
return null;
}
SpagoBIUserProfile profile = new SpagoBIUserProfile();
profile.setUniqueIdentifier(userId);
profile.setUserId(userId);
// get user name
String userName = userId;
// get roles of the user
List rolesSB = configSingleton.getFilteredSourceBeanAttributeAsList(
"AUTHORIZATIONS.RELATIONS.BEHAVIOURS.BEHAVIOUR", "userID", userName);
List roles = new ArrayList();
Iterator iterRolesSB = rolesSB.iterator();
while (iterRolesSB.hasNext()) {
SourceBean roleSB = (SourceBean) iterRolesSB.next();
String rolename = (String) roleSB.getAttribute("roleName");
roles.add(rolename);
}
// start load profile attributes
HashMap userAttributes = new HashMap();
List userSB = configSingleton.getFilteredSourceBeanAttributeAsList("AUTHORIZATIONS.ENTITIES.USERS.USER",
"userID", userName);
if (userSB.size() == 0) {
logger.warn("User " + userName + " not found on configuration!!!");
} else if (userSB.size() > 1)
logger.warn("There are more user with userID=" + userName);
else {
SourceBean userTmp = (SourceBean) userSB.get(0);
XmlSecurityInfoProviderImpl xmlSecInfo = new XmlSecurityInfoProviderImpl();
List attributesList = xmlSecInfo.getAllProfileAttributesNames();
if (attributesList != null) {
Iterator iterAttributesList = attributesList.iterator();
while (iterAttributesList.hasNext()) {
// Attribute to lookup
String attributeName = (String) iterAttributesList.next();
String attributeValue = (String) userTmp.getAttribute(attributeName);
if (attributeValue != null) {
logger.debug("Add attribute. " + attributeName + "=" + attributeName + " to the user"
+ userName);
userAttributes.put(attributeName, attributeValue);
}
}
}
}
logger.debug("Attributes load into SpagoBI profile: " + userAttributes);
// end load profile attributes
String[] roleStr = new String[roles.size()];
for (int i = 0; i < roles.size(); i++) {
roleStr[i] = (String) roles.get(i);
}
profile.setRoles(roleStr);
profile.setAttributes(userAttributes);
//profile.setFunctions(readFunctionality(profile.getRoles()));
logger.debug("OUT");
return profile;
}