List of usage examples for org.apache.shiro.web.filter.mgt DefaultFilter authc
DefaultFilter authc
To view the source code for org.apache.shiro.web.filter.mgt DefaultFilter authc.
Click Source Link
From source file:com.stormpath.shiro.servlet.env.StormpathShiroIniEnvironment.java
License:Apache License
private void addDefaultsToIni(Ini ini) { // TODO: this is not ideal, we need to make shiro a bit more flexible // and this is tightly coupled with the following method Ini.Section configSection = getConfigSection(ini); // lazy associate the client with the realm, so changes can be made if needed. if (!configSection.containsKey(DEFAULTS_STORMPATH_REALM_PROPERTY + ".client")) { configSection.put(DEFAULTS_STORMPATH_REALM_PROPERTY + ".client", "$" + DEFAULTS_STORMPATH_CLIENT_PROPERTY); }//from www .j a v a 2s. co m // global properties 'shiro.*' are not loaded from the defaults, we must set it in the ini. if (!configSection.containsKey("shiro.loginUrl")) { configSection.put("shiro.loginUrl", "/login"); } // protect the world if the URL section is missing Ini.Section urls = ini.getSection(IniFilterChainResolverFactory.URLS); Ini.Section filters = ini.getSection(IniFilterChainResolverFactory.FILTERS); // deprecated behavior if (CollectionUtils.isEmpty(urls) && CollectionUtils.isEmpty(filters)) { ini.setSectionProperty(IniFilterChainResolverFactory.URLS, "/**", DefaultFilter.authc.name()); } }
From source file:com.stormpath.shiro.spring.boot.autoconfigure.StormpathShiroWebAutoConfiguration.java
License:Apache License
@Bean @ConditionalOnMissingBean//from ww w . j a v a 2 s. c o m public ShiroFilterChainDefinition shiroFilterChainDefinition() { DefaultShiroFilterChainDefinition filterChainDefinition = new DefaultShiroFilterChainDefinition(); filterChainDefinition.addPathDefinition("/assets/**", DefaultFilter.anon.name()); filterChainDefinition.addPathDefinition("/**", DefaultFilter.authc.name()); return filterChainDefinition; }
From source file:com.stormpath.shiro.spring.boot.examples.WebApp.java
License:Apache License
@Bean public ShiroFilterChainDefinition shiroFilterChainDefinition() { DefaultShiroFilterChainDefinition filterChainDefinition = new DefaultShiroFilterChainDefinition(); filterChainDefinition.addPathDefinition("/assets/**", DefaultFilter.anon.name()); // static web resources filterChainDefinition.addPathDefinition("/", DefaultFilter.anon.name()); // the welcome page allows guest or logged in users filterChainDefinition.addPathDefinition("/account-info", DefaultFilter.authc.name()); // the account-info page requires a user return filterChainDefinition; }
From source file:org.panifex.itest.security.shiro.container.SecurityFilterTest.java
License:Open Source License
@Test public void filteredGetFromServletTest() throws Exception { ServiceRegistration<SecFilterMapping> filterPathRegistration = null; ServiceRegistration<Servlet> servletRegistration = null; try {/*from w ww. j a v a 2s .c o m*/ // register filter path filterPathRegistration = registerFilterPath("/zk/*", DefaultFilter.authc); // register login servlet servletRegistration = registerServlet("loginServlet", WebApplicationConstants.DEFAULT_LOGIN_URL, new OkServlet()); testGet(URL + "/zk/", HttpServletResponse.SC_OK); } finally { if (filterPathRegistration != null) { filterPathRegistration.unregister(); } if (servletRegistration != null) { servletRegistration.unregister(); } } }
From source file:org.panifex.itest.security.shiro.container.SecurityFilterTest.java
License:Open Source License
@Test public void testSetValidLoginUrl() throws Exception { ServiceRegistration<SecFilterMapping> filterPathRegistration = null; ServiceRegistration<Servlet> servletRegistration = null; try {// w ww. j ava2 s . c o m String newLoginUrl = "/new"; registerNewLoginUrl(newLoginUrl); // register filter path filterPathRegistration = registerFilterPath("/zk/*", DefaultFilter.authc); // register login servlet servletRegistration = registerServlet("loginServlet", newLoginUrl, new OkServlet()); testGet(URL + "/zk/", HttpServletResponse.SC_OK); } finally { if (servletRegistration != null) { servletRegistration.unregister(); } if (filterPathRegistration != null) { filterPathRegistration.unregister(); } } }
From source file:org.panifex.itest.security.shiro.container.SecurityFilterTest.java
License:Open Source License
private void testLoginWithSpecifiedParams(String usernameParam, String passwordParam, String rememberMeParam) throws Exception { String username = "username1"; String password = "userPass1"; ServiceRegistration<SecFilterMapping> filterPathRegistration = null; ServiceRegistration<AuthenticationService> authcServiceRegistration = null; try {//from w ww . j a v a 2 s. c om // register properties setWebApplicationProperty(WebApplicationConstants.PROPERTY_USERNAME_PARAM, usernameParam, WebApplicationConstants.DEFAULT_USERNAME_PARAM); setWebApplicationProperty(WebApplicationConstants.PROPERTY_PASSWORD_PARAM, passwordParam, WebApplicationConstants.DEFAULT_PASSWORD_PARAM); setWebApplicationProperty(WebApplicationConstants.PROPERTY_REMEMBER_ME_PARAM, rememberMeParam, WebApplicationConstants.DEFAULT_REMEMBER_ME_PARAM); // register filter path filterPathRegistration = registerFilterPath("/*", DefaultFilter.authc); // register security service SimpleAuthenticationService simpleAuthcService = new SimpleAuthenticationService(); simpleAuthcService.addAccount(username, password); authcServiceRegistration = registerService(AuthenticationService.class, simpleAuthcService, null); Thread.sleep(1_000L); Map<String, String> params = new HashMap<>(); params.put(usernameParam, username); params.put(passwordParam, password); testPost(URL + WebApplicationConstants.DEFAULT_LOGIN_URL, HttpServletResponse.SC_FOUND, null, params); } finally { if (filterPathRegistration != null) { filterPathRegistration.unregister(); } if (authcServiceRegistration != null) { authcServiceRegistration.unregister(); } } }
From source file:org.panifex.security.shiro.SecurityFilterImpl.java
License:Open Source License
/** * Returns the active {@link AccessControlFilter}. The superclass for any filter that * controls access to a resource and may redirect the user to the login page if they * are not authenticated.//from ww w . j a va 2 s. com * * @return the active {@link AccessControlFilter} */ protected AccessControlFilter getAccessControlFilter() { return (AccessControlFilter) getFilter(DefaultFilter.authc.toString()); }
From source file:org.panifex.security.shiro.SecurityFilterImpl.java
License:Open Source License
/** * Returns the active {@link AuthenticationFilter}. The base class for all Filters * that require the current user to be authenticated. This class encapsulates * the logic of checking whether a user is already authenticated in the system * while subclasses are required to perform specific logic for unauthenticated * requests./*from www. j a v a2 s .com*/ * * @return the active {@link AuthenticationFilter} */ protected AuthenticationFilter getAuthenticationFilter() { return (AuthenticationFilter) getFilter(DefaultFilter.authc.toString()); }
From source file:org.panifex.security.shiro.SecurityFilterImpl.java
License:Open Source License
/** * Returns the active {@link FormAuthenticationFilter}. It requires the requesting * user to be authenticated for the request to continue, and if they are not, * forces the user to login via by redirecting them to the loginUrl you configure. * * @return the active {@link FormAuthenticationFilter} *//*from www .jav a 2 s . c om*/ protected FormAuthenticationFilter getFormAuthenticationFilter() { return (FormAuthenticationFilter) getFilter(DefaultFilter.authc.toString()); }
From source file:org.panifex.security.shiro.SecurityFilterImplTest.java
License:Open Source License
private void expectGettingFilterWithName(Filter filter, String filterName) { // expect getting filterChainManager FilterChainManager filterChainManagerMock = createMock(FilterChainManager.class); expect(filterChainResolverMock.getFilterChainManager()).andReturn(filterChainManagerMock); // expect getting form authentication filters Map<String, Filter> filters = new HashMap<>(); filters.put(DefaultFilter.authc.toString(), filter); expect(filterChainManagerMock.getFilters()).andReturn(filters); }