use of org.apache.ranger.security.context.RangerSecurityContext in project ranger by apache.
the class TestUserMgr method setup.
public void setup() {
RangerSecurityContext context = new RangerSecurityContext();
context.setUserSession(new UserSessionBase());
RangerContextHolder.setSecurityContext(context);
UserSessionBase currentUserSession = ContextUtil.getCurrentUserSession();
currentUserSession.setUserAdmin(true);
}
use of org.apache.ranger.security.context.RangerSecurityContext in project ranger by apache.
the class TestXUserMgr method setup.
public void setup() {
RangerSecurityContext context = new RangerSecurityContext();
context.setUserSession(new UserSessionBase());
RangerContextHolder.setSecurityContext(context);
UserSessionBase currentUserSession = ContextUtil.getCurrentUserSession();
currentUserSession.setUserAdmin(true);
XXPortalUser gjUser = new XXPortalUser();
gjUser.setLoginId("test");
gjUser.setId(1L);
currentUserSession.setXXPortalUser(gjUser);
}
use of org.apache.ranger.security.context.RangerSecurityContext in project ranger by apache.
the class TestPublicAPIsv2 method setup.
@Before
public void setup() throws Exception {
RangerSecurityContext context = new RangerSecurityContext();
context.setUserSession(new UserSessionBase());
RangerContextHolder.setSecurityContext(context);
UserSessionBase currentUserSession = ContextUtil.getCurrentUserSession();
currentUserSession.setUserAdmin(true);
}
use of org.apache.ranger.security.context.RangerSecurityContext in project ranger by apache.
the class TestServiceREST method setup.
public void setup() {
RangerSecurityContext context = new RangerSecurityContext();
context.setUserSession(new UserSessionBase());
RangerContextHolder.setSecurityContext(context);
UserSessionBase currentUserSession = ContextUtil.getCurrentUserSession();
currentUserSession.setUserAdmin(true);
}
use of org.apache.ranger.security.context.RangerSecurityContext in project ranger by apache.
the class JPABeanCallbacks method onPrePersist.
@PrePersist
void onPrePersist(Object o) {
try {
if (o != null && o instanceof XXDBBase) {
XXDBBase entity = (XXDBBase) o;
entity.setUpdateTime(DateUtil.getUTCDate());
RangerSecurityContext context = RangerContextHolder.getSecurityContext();
if (context != null) {
UserSessionBase userSession = context.getUserSession();
if (userSession != null) {
entity.setAddedByUserId(userSession.getUserId());
entity.setUpdatedByUserId(userSession.getUserId());
}
} else {
if (logger.isDebugEnabled()) {
logger.debug("Security context not found for this request. obj=" + o, new Throwable());
}
}
}
} catch (Throwable t) {
logger.error(t);
}
}
Aggregations