@Override public void doFilter( ServletRequest inRequest, ServletResponse inResponse, FilterChain inFilterChain) throws IOException, ServletException { HttpServletRequest servletRequest = (HttpServletRequest) inRequest; String remoteUser = servletRequest.getRemoteUser(); boolean userIsActivated = false; if (!StringUtils.isEmpty(remoteUser)) { User user = (User) inRequest.getAttribute("user"); if (user != null && user.isActive()) { userIsActivated = true; } } inRequest.setAttribute("userIsActivated", userIsActivated); inFilterChain.doFilter(inRequest, inResponse); }
public static AuthenticationMethod userToAuthenticationMethod(User user) { AuthenticationMethod authMethod; if (user instanceof LocalUser) { authMethod = AuthenticationMethod.LOCAL; } else if (user instanceof LdapUser) { authMethod = AuthenticationMethod.LDAP; } else if (user instanceof OAuthUser) { authMethod = AuthenticationMethod.OAUTH; } else { throw new AssertionError("Unspected userRequest type: " + user.getClass().getName()); } return authMethod; }