use of org.apache.ranger.view.VXUserPermission in project ranger by apache.
the class XModuleDefService method populateViewBean.
@Override
public VXModuleDef populateViewBean(XXModuleDef xObj) {
VXModuleDef vModuleDef = super.populateViewBean(xObj);
Map<Long, XXUser> xXPortalUserIdXXUserMap = xUserService.getXXPortalUserIdXXUserMap();
Map<Long, XXGroup> xXGroupMap = xGroupService.getXXGroupIdXXGroupMap();
List<VXUserPermission> vXUserPermissionList = new ArrayList<VXUserPermission>();
List<VXGroupPermission> vXGroupPermissionList = new ArrayList<VXGroupPermission>();
List<XXUserPermission> xuserPermissionList = daoManager.getXXUserPermission().findByModuleId(xObj.getId(), false);
List<XXGroupPermission> xgroupPermissionList = daoManager.getXXGroupPermission().findByModuleId(xObj.getId(), false);
if (CollectionUtils.isEmpty(xXPortalUserIdXXUserMap)) {
for (XXUserPermission xUserPerm : xuserPermissionList) {
VXUserPermission vXUserPerm = xUserPermService.populateViewBean(xUserPerm);
vXUserPermissionList.add(vXUserPerm);
}
} else {
vXUserPermissionList = xUserPermService.getPopulatedVXUserPermissionList(xuserPermissionList, xXPortalUserIdXXUserMap, vModuleDef);
}
if (CollectionUtils.isEmpty(xXGroupMap)) {
for (XXGroupPermission xGrpPerm : xgroupPermissionList) {
VXGroupPermission vXGrpPerm = xGrpPermService.populateViewBean(xGrpPerm);
vXGroupPermissionList.add(vXGrpPerm);
}
} else {
vXGroupPermissionList = xGrpPermService.getPopulatedVXGroupPermissionList(xgroupPermissionList, xXGroupMap, vModuleDef);
}
vModuleDef.setUserPermList(vXUserPermissionList);
vModuleDef.setGroupPermList(vXGroupPermissionList);
return vModuleDef;
}
use of org.apache.ranger.view.VXUserPermission in project ranger by apache.
the class XUserPermissionService method getPopulatedVXUserPermissionList.
public List<VXUserPermission> getPopulatedVXUserPermissionList(List<XXUserPermission> xuserPermissionList, Map<Long, XXUser> xXPortalUserIdXXUserMap, VXModuleDef vModuleDef) {
List<VXUserPermission> vXUserPermissionList = new ArrayList<VXUserPermission>();
XXUser xXUser = null;
for (XXUserPermission xuserPermission : xuserPermissionList) {
if (xXPortalUserIdXXUserMap.containsKey(xuserPermission.getUserId())) {
xXUser = xXPortalUserIdXXUserMap.get(xuserPermission.getUserId());
VXUserPermission vXUserPerm = new VXUserPermission();
vXUserPerm.setId(xuserPermission.getId());
vXUserPerm.setUserId(xXUser.getId());
vXUserPerm.setModuleId(xuserPermission.getModuleId());
vXUserPerm.setIsAllowed(xuserPermission.getIsAllowed());
vXUserPerm.setCreateDate(xuserPermission.getCreateTime());
vXUserPerm.setUpdateDate(xuserPermission.getUpdateTime());
vXUserPerm.setModuleName(vModuleDef.getModule());
vXUserPerm.setLoginId(xXUser.getName());
vXUserPerm.setUserName(xXUser.getName());
vXUserPermissionList.add(vXUserPerm);
}
}
return vXUserPermissionList;
}
use of org.apache.ranger.view.VXUserPermission 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.view.VXUserPermission in project ranger by apache.
the class TestXUserREST method test82createXUserPermission.
@Test
public void test82createXUserPermission() {
VXUserPermission testvXUserPermission = createVXUserPermission();
Mockito.doNothing().when(xUserMgr).checkAdminAccess();
Mockito.when(xUserMgr.createXUserPermission(testvXUserPermission)).thenReturn(testvXUserPermission);
VXUserPermission retVXUserPermission = xUserRest.createXUserPermission(testvXUserPermission);
Mockito.verify(xUserMgr).createXUserPermission(testvXUserPermission);
Mockito.verify(xUserMgr).checkAdminAccess();
assertNotNull(retVXUserPermission);
assertEquals(retVXUserPermission.getId(), testvXUserPermission.getId());
assertEquals(retVXUserPermission.getUserName(), testvXUserPermission.getUserName());
}
use of org.apache.ranger.view.VXUserPermission in project ranger by apache.
the class TestXUserREST method test83getXUserPermission.
@Test
public void test83getXUserPermission() {
VXUserPermission testVXUserPermission = createVXUserPermission();
Mockito.when(xUserMgr.getXUserPermission(testVXUserPermission.getId())).thenReturn(testVXUserPermission);
VXUserPermission retVXUserPermission = xUserRest.getXUserPermission(testVXUserPermission.getId());
Mockito.verify(xUserMgr).getXUserPermission(id);
assertNotNull(retVXUserPermission);
assertEquals(retVXUserPermission.getId(), testVXUserPermission.getId());
assertEquals(retVXUserPermission.getUserName(), testVXUserPermission.getUserName());
}
Aggregations