List of usage examples for com.vaadin.server VaadinServletService getCurrentResponse
public static VaadinServletResponse getCurrentResponse()
From source file:de.symeda.sormas.ui.login.LoginHelper.java
License:Open Source License
public static boolean login(String username, String password) throws UserRightsException { if (username == null || username.isEmpty()) return false; BeanManager bm = CDI.current().getBeanManager(); @SuppressWarnings("unchecked") Bean<SecurityContext> securityContextBean = (Bean<SecurityContext>) bm.getBeans(SecurityContext.class) .iterator().next();//from w ww .j av a 2 s .co m CreationalContext<SecurityContext> ctx = bm.createCreationalContext(securityContextBean); SecurityContext securityContext = (SecurityContext) bm.getReference(securityContextBean, SecurityContext.class, ctx); AuthenticationParameters authentication = new AuthenticationParameters(); authentication.credential(new UsernamePasswordCredential(username, password)); authentication.newAuthentication(true); authentication.setRememberMe(true); AuthenticationStatus status = securityContext.authenticate(VaadinServletService.getCurrentServletRequest(), VaadinServletService.getCurrentResponse().getHttpServletResponse(), authentication); if (status == AuthenticationStatus.SUCCESS) return true; return false; }