Authentication auth = null; try { auth = getSecurityManager().authenticationManager().authenticate(result); } catch (ProviderNotFoundException e) { LOGGER.log(Level.WARNING, "couldn't to authenticate user:" + us);
@Override public void initializeFromConfig(SecurityNamedServiceConfig config) throws IOException { super.initializeFromConfig(config); // not needed at the moment // RememberMeAuthenticationFilterConfig authConfig = // (RememberMeAuthenticationFilterConfig) config; GeoServerSecurityManager secMgr = getSecurityManager(); RememberMeAuthenticationFilter filter = new RememberMeAuthenticationFilter( secMgr.authenticationManager(), secMgr.getRememberMeService()); filter.afterPropertiesSet(); getNestedFilters().add(filter); }
@Override public void initializeFromConfig(SecurityNamedServiceConfig config) throws IOException { super.initializeFromConfig(config); try { digest = MessageDigest.getInstance("MD5"); } catch (NoSuchAlgorithmException e) { throw new IllegalStateException("No MD5 algorithm available!"); } aep = new BasicAuthenticationEntryPoint(); aep.setRealmName(GeoServerSecurityManager.REALM); try { aep.afterPropertiesSet(); } catch (Exception e) { throw new IOException(e); } BasicAuthenticationFilterConfig authConfig = (BasicAuthenticationFilterConfig) config; BasicAuthenticationFilter filter = new BasicAuthenticationFilter(getSecurityManager().authenticationManager(), aep); if (authConfig.isUseRememberMe()) { filter.setRememberMeServices(securityManager.getRememberMeService()); GeoServerWebAuthenticationDetailsSource s = new GeoServerWebAuthenticationDetailsSource(); filter.setAuthenticationDetailsSource(s); } filter.afterPropertiesSet(); getNestedFilters().add(filter); }
filter.setAuthenticationManager(getSecurityManager().authenticationManager());
filter.setAuthenticationManager(getSecurityManager().authenticationManager());
@Test public void testInactive() throws Exception { UsernamePasswordAuthenticationToken upAuth = new UsernamePasswordAuthenticationToken("foo", "bar"); try { getSecurityManager().authenticationManager().authenticate(upAuth); } catch (BadCredentialsException e) { } catch (ProviderNotFoundException e) { } }
@Test public void testActive() throws Exception { GeoServerSecurityManager secMgr = getSecurityManager(); UsernamePasswordAuthenticationProviderConfig config = new UsernamePasswordAuthenticationProviderConfig(); config.setName("custom"); config.setClassName(AuthProvider.class.getName()); secMgr.saveAuthenticationProvider(config); SecurityManagerConfig mgrConfig = secMgr.getSecurityConfig(); mgrConfig.getAuthProviderNames().add("custom"); mgrConfig.setConfigPasswordEncrypterName(getPlainTextPasswordEncoder().getName()); secMgr.saveSecurityConfig(mgrConfig); Authentication auth = new UsernamePasswordAuthenticationToken("foo", "bar"); auth = getSecurityManager().authenticationManager().authenticate(auth); assertTrue(auth.isAuthenticated()); }