use of org.apache.ranger.entity.XXDBBase in project ranger by apache.
the class TestRangerBizUtil method testGetMObject_NOVXDataObject.
@Test
public void testGetMObject_NOVXDataObject() {
XXDBBase xXDBaseChk = rangerBizUtil.getMObject(null);
Assert.assertNull(xXDBaseChk);
}
use of org.apache.ranger.entity.XXDBBase in project ranger by apache.
the class TestRangerBizUtil method testGetMObject.
@SuppressWarnings({ "unchecked", "rawtypes" })
@Test
public void testGetMObject() {
BaseDao baseDao = Mockito.mock(BaseDao.class);
Mockito.when(daoManager.getDaoForClassType(RangerCommonEnums.CLASS_TYPE_USER_PROFILE)).thenReturn(baseDao);
Mockito.when(baseDao.getById(id)).thenReturn(new XXAsset());
XXDBBase mObjChk = rangerBizUtil.getMObject(RangerCommonEnums.CLASS_TYPE_USER_PROFILE, id);
Assert.assertNotNull(mObjChk);
}
use of org.apache.ranger.entity.XXDBBase in project ranger by apache.
the class RangerBizUtil method getClassType.
public int getClassType(Class<?> klass) {
String className = klass.getName();
// See if this mapping is already in the database
Integer classType = classTypeMappings.get(className);
if (classType == null) {
// Instantiate the class and call the getClassType method
if (XXDBBase.class.isAssignableFrom(klass)) {
try {
XXDBBase gjObj = (XXDBBase) klass.newInstance();
classType = gjObj.getMyClassType();
classTypeMappings.put(className, classType);
} catch (Throwable ex) {
logger.error("Error instantiating object for class " + className, ex);
}
}
}
if (classType == null) {
return RangerCommonEnums.CLASS_TYPE_NONE;
} else {
return classType;
}
}
use of org.apache.ranger.entity.XXDBBase in project ranger by apache.
the class RangerDomainObjectSecurityHandler method hasAccess.
public boolean hasAccess(Class<? extends XXDBBase> targetClass, Serializable targetId, Permission.permissionType permission) {
try {
Class<? extends XXDBBase> gjClazz = targetClass.asSubclass(XXDBBase.class);
XXDBBase base = getDaoManager().getEntityManager().find(gjClazz, targetId);
return hasAccess(base, permission);
} catch (Exception e) {
logger.error("Excepion targetType:" + targetClass + " targetId:" + targetId, e);
}
return false;
}
use of org.apache.ranger.entity.XXDBBase in project ranger by apache.
the class TestRangerBizUtil method testGetMObject_VXDataObject.
@SuppressWarnings({ "rawtypes", "unchecked" })
@Test
public void testGetMObject_VXDataObject() {
VXAsset vXDataObject = new VXAsset();
vXDataObject.setId(id);
BaseDao baseDao = Mockito.mock(BaseDao.class);
Mockito.when(daoManager.getDaoForClassType(vXDataObject.getMyClassType())).thenReturn(baseDao);
Mockito.when(baseDao.getById(vXDataObject.getId())).thenReturn(new XXAsset());
XXDBBase xXDBaseChk = rangerBizUtil.getMObject(vXDataObject);
Assert.assertNotNull(xXDBaseChk);
}
Aggregations