use of org.eclipse.che.commons.subject.SubjectImpl in project che by eclipse.
the class WorkspaceManagerTest method setUp.
@BeforeMethod
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
workspaceManager = new WorkspaceManager(workspaceDao, runtimes, eventService, accountManager, false, false, snapshotDao, sharedPool);
when(accountManager.getByName(NAMESPACE)).thenReturn(new AccountImpl("accountId", NAMESPACE, "test"));
when(accountManager.getByName(NAMESPACE_2)).thenReturn(new AccountImpl("accountId2", NAMESPACE_2, "test"));
when(workspaceDao.create(any(WorkspaceImpl.class))).thenAnswer(invocation -> invocation.getArguments()[0]);
when(workspaceDao.update(any(WorkspaceImpl.class))).thenAnswer(invocation -> invocation.getArguments()[0]);
EnvironmentContext.setCurrent(new EnvironmentContext() {
@Override
public Subject getSubject() {
return new SubjectImpl(NAMESPACE, USER_ID, "token", false);
}
});
}
use of org.eclipse.che.commons.subject.SubjectImpl in project che by eclipse.
the class EnvironmentInitializationFilter method doFilter.
@Override
public final void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain) throws IOException, ServletException {
final HttpServletRequest httpRequest = (HttpServletRequest) request;
Subject subject = new SubjectImpl("che", "che", "dummy_token", false);
HttpSession session = httpRequest.getSession();
session.setAttribute("codenvy_user", subject);
final EnvironmentContext environmentContext = EnvironmentContext.getCurrent();
try {
environmentContext.setSubject(subject);
filterChain.doFilter(addUserInRequest(httpRequest, subject), response);
} finally {
EnvironmentContext.reset();
}
}
Aggregations