use of org.apache.ranger.entity.XXPortalUserRole in project ranger by apache.
the class UserMgr method createUser.
public XXPortalUser createUser(XXPortalUser user, int userStatus, Collection<String> userRoleList) {
user.setStatus(userStatus);
String saltEncodedpasswd = encrypt(user.getLoginId(), user.getPassword());
user.setPassword(saltEncodedpasswd);
user = daoManager.getXXPortalUser().create(user);
// Create the UserRole for this user
List<XXPortalUserRole> gjUserRoleList = new ArrayList<XXPortalUserRole>();
if (userRoleList != null) {
for (String userRole : userRoleList) {
XXPortalUserRole gjUserRole = addUserRole(user.getId(), userRole);
if (gjUserRole != null) {
gjUserRoleList.add(gjUserRole);
}
}
}
return user;
}
use of org.apache.ranger.entity.XXPortalUserRole in project ranger by apache.
the class UserMgr method gjUserToUserProfile.
private void gjUserToUserProfile(XXPortalUser user, VXPortalUser userProfile) {
UserSessionBase sess = ContextUtil.getCurrentUserSession();
if (sess == null) {
return;
}
// Admin
if (sess.isUserAdmin() || sess.isKeyAdmin() || sess.getXXPortalUser().getId().equals(user.getId())) {
userProfile.setLoginId(user.getLoginId());
userProfile.setStatus(user.getStatus());
userProfile.setUserRoleList(new ArrayList<String>());
String emailAddress = user.getEmailAddress();
if (emailAddress != null && stringUtil.validateEmail(emailAddress)) {
userProfile.setEmailAddress(user.getEmailAddress());
}
userProfile.setUserSource(sess.getAuthProvider());
List<XXPortalUserRole> gjUserRoleList = daoManager.getXXPortalUserRole().findByParentId(user.getId());
for (XXPortalUserRole gjUserRole : gjUserRoleList) {
userProfile.getUserRoleList().add(gjUserRole.getUserRole());
}
userProfile.setId(user.getId());
List<XXUserPermission> xUserPermissions = daoManager.getXXUserPermission().findByUserPermissionIdAndIsAllowed(userProfile.getId());
List<XXGroupPermission> xxGroupPermissions = daoManager.getXXGroupPermission().findbyVXPortalUserId(userProfile.getId());
List<VXGroupPermission> groupPermissions = new ArrayList<VXGroupPermission>();
List<VXUserPermission> vxUserPermissions = new ArrayList<VXUserPermission>();
for (XXGroupPermission xxGroupPermission : xxGroupPermissions) {
VXGroupPermission groupPermission = xGroupPermissionService.populateViewBean(xxGroupPermission);
groupPermission.setModuleName(daoManager.getXXModuleDef().findByModuleId(groupPermission.getModuleId()).getModule());
groupPermissions.add(groupPermission);
}
for (XXUserPermission xUserPermission : xUserPermissions) {
VXUserPermission vXUserPermission = xUserPermissionService.populateViewBean(xUserPermission);
vXUserPermission.setModuleName(daoManager.getXXModuleDef().findByModuleId(vXUserPermission.getModuleId()).getModule());
vxUserPermissions.add(vXUserPermission);
}
userProfile.setGroupPermissions(groupPermissions);
userProfile.setUserPermList(vxUserPermissions);
userProfile.setFirstName(user.getFirstName());
userProfile.setLastName(user.getLastName());
userProfile.setPublicScreenName(user.getPublicScreenName());
}
}
use of org.apache.ranger.entity.XXPortalUserRole in project ranger by apache.
the class UserMgr method getRolesForUser.
@Transactional(readOnly = true, propagation = Propagation.REQUIRED)
public Collection<String> getRolesForUser(XXPortalUser user) {
Collection<String> roleList = new ArrayList<String>();
Collection<XXPortalUserRole> roleCollection = daoManager.getXXPortalUserRole().findByUserId(user.getId());
for (XXPortalUserRole role : roleCollection) {
roleList.add(role.getUserRole());
}
return roleList;
}
use of org.apache.ranger.entity.XXPortalUserRole in project ranger by apache.
the class UserMgr method getRolesByLoginId.
public Collection<String> getRolesByLoginId(String loginId) {
if (loginId == null || loginId.trim().isEmpty()) {
return DEFAULT_ROLE_LIST;
}
XXPortalUser xXPortalUser = daoManager.getXXPortalUser().findByLoginId(loginId);
if (xXPortalUser == null) {
return DEFAULT_ROLE_LIST;
}
Collection<XXPortalUserRole> xXPortalUserRoles = daoManager.getXXPortalUserRole().findByUserId(xXPortalUser.getId());
if (xXPortalUserRoles == null) {
return DEFAULT_ROLE_LIST;
}
Collection<String> roleList = new ArrayList<String>();
for (XXPortalUserRole role : xXPortalUserRoles) {
if (role != null && VALID_ROLE_LIST.contains(role.getUserRole())) {
if (!roleList.contains(role.getUserRole())) {
roleList.add(role.getUserRole());
}
}
}
if (roleList == null || roleList.size() == 0) {
return DEFAULT_ROLE_LIST;
}
return roleList;
}
use of org.apache.ranger.entity.XXPortalUserRole in project ranger by apache.
the class UserService method mapEntityToViewBean.
@Override
protected VXPortalUser mapEntityToViewBean(VXPortalUser userProfile, XXPortalUser user) {
userProfile.setId(user.getId());
userProfile.setLoginId(user.getLoginId());
userProfile.setFirstName(user.getFirstName());
userProfile.setLastName(user.getLastName());
userProfile.setPublicScreenName(user.getPublicScreenName());
userProfile.setStatus(user.getStatus());
userProfile.setUserRoleList(new ArrayList<String>());
String emailAddress = user.getEmailAddress();
if (emailAddress != null && stringUtil.validateEmail(emailAddress)) {
userProfile.setEmailAddress(user.getEmailAddress());
}
UserSessionBase sess = ContextUtil.getCurrentUserSession();
if (sess != null) {
userProfile.setUserSource(sess.getAuthProvider());
}
List<XXPortalUserRole> gjUserRoleList = daoManager.getXXPortalUserRole().findByParentId(user.getId());
for (XXPortalUserRole gjUserRole : gjUserRoleList) {
userProfile.getUserRoleList().add(gjUserRole.getUserRole());
}
return userProfile;
}
Aggregations