use of de.symeda.sormas.api.user.UserFacade in project SORMAS-Project by hzi-braunschweig.
the class SessionFilter method doFilter.
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
HttpSession session = ((HttpServletRequest) request).getSession();
final HttpServletResponse res = (HttpServletResponse) response;
res.addHeader("X-Content-Type-Options", "nosniff");
res.addHeader("X-Frame-Options", "SAMEORIGIN");
res.addHeader("Referrer-Policy", "same-origin");
ControllerProvider controllerProvider = Optional.of(session).map(s -> (ControllerProvider) s.getAttribute("controllerProvider")).orElseGet(() -> {
ControllerProvider cp = new ControllerProvider();
session.setAttribute("controllerProvider", cp);
return cp;
});
try {
sessionFilterBean.doFilter((req, resp) -> {
Language userLanguage = Optional.of(FacadeProvider.getUserFacade()).map(UserFacade::getCurrentUser).map(UserDto::getLanguage).orElse(null);
I18nProperties.setUserLanguage(userLanguage);
FacadeProvider.getI18nFacade().setUserLanguage(userLanguage);
try (Closeable bc = BaseControllerProvider.requestStart(controllerProvider)) {
chain.doFilter(req, response);
}
}, request, response);
} finally {
I18nProperties.removeUserLanguage();
FacadeProvider.getI18nFacade().removeUserLanguage();
}
}
use of de.symeda.sormas.api.user.UserFacade in project SORMAS-Project by hzi-braunschweig.
the class UserFacadeEjbTest method testGetByUserName.
@Test
public void testGetByUserName() {
final UserFacade userFacade = getUserFacade();
assertNull(userFacade.getByUserName("HansPeter"));
RDCF rdcf = creator.createRDCF();
UserDto user = creator.createUser(rdcf, "Hans", "Peter", SURVEILLANCE_OFFICER);
assertEquals(user, userFacade.getByUserName("HANSPETER"));
assertEquals(user, userFacade.getByUserName("hanspeter"));
assertEquals(user, userFacade.getByUserName("HansPeter"));
assertEquals(user, userFacade.getByUserName("hansPETER"));
}
use of de.symeda.sormas.api.user.UserFacade in project SORMAS-Project by hzi-braunschweig.
the class UserFacadeEjbTest method testLoginUnique.
@Test
public void testLoginUnique() {
final UserFacade userFacade = getUserFacade();
assertNull(userFacade.getByUserName("HansPeter"));
RDCF rdcf = creator.createRDCF();
creator.createUser(rdcf, "Hans", "Peter", SURVEILLANCE_OFFICER);
assertTrue(userFacade.isLoginUnique(String.valueOf(UUID.randomUUID()), "MarieLisa"));
assertFalse(userFacade.isLoginUnique(String.valueOf(UUID.randomUUID()), "HansPeter"));
assertFalse(userFacade.isLoginUnique(String.valueOf(UUID.randomUUID()), "hanspeter"));
}
use of de.symeda.sormas.api.user.UserFacade in project SORMAS-Project by hzi-braunschweig.
the class UserFacadeEjbTest method testFailOnSavingDuplicateUser.
@Test
public void testFailOnSavingDuplicateUser() {
final UserFacade userFacade = getUserFacade();
assertNull(userFacade.getByUserName("HansPeter"));
RDCF rdcf = creator.createRDCF();
creator.createUser(rdcf, "Hans", "Peter", SURVEILLANCE_OFFICER);
assertThrows("User name is not unique!", ValidationException.class, () -> creator.createUser(rdcf, "Hans", "Peter", SURVEILLANCE_OFFICER));
assertThrows("User name is not unique!", ValidationException.class, () -> creator.createUser(rdcf, "hans", "peter", SURVEILLANCE_OFFICER));
assertThrows("User name is not unique!", ValidationException.class, () -> creator.createUser(rdcf, "HANS", "PETER", SURVEILLANCE_OFFICER));
}
Aggregations