本文整理汇总了Java中org.apache.shiro.web.filter.mgt.FilterChainManager类的典型用法代码示例。如果您正苦于以下问题:Java FilterChainManager类的具体用法?Java FilterChainManager怎么用?Java FilterChainManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FilterChainManager类属于org.apache.shiro.web.filter.mgt包,在下文中一共展示了FilterChainManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createInstance
import org.apache.shiro.web.filter.mgt.FilterChainManager; //导入依赖的package包/类
@Override
protected AbstractShiroFilter createInstance() throws Exception {
SecurityManager securityManager = getSecurityManager();
if (securityManager == null){
throw new BeanInitializationException("SecurityManager property must be set.");
}
if (!(securityManager instanceof WebSecurityManager)){
throw new BeanInitializationException("The security manager does not implement the WebSecurityManager interface.");
}
PathMatchingFilterChainResolver chainResolver = new PathMatchingFilterChainResolver();
FilterChainManager chainManager = createFilterChainManager();
chainResolver.setFilterChainManager(chainManager);
return new MySpringShiroFilter((WebSecurityManager)securityManager, chainResolver);
}
示例2: configure
import org.apache.shiro.web.filter.mgt.FilterChainManager; //导入依赖的package包/类
@Override
protected void configure() {
super.configure();
bind(ResourceConfig.class).toProvider(ResourceConfigProvider.class).in(Singleton.class);
bind(ServletContainer.class).to(DefaultServletContainer.class);
contribute(FilterChainConfigurator.class, new FilterChainConfigurator() {
@Override
public void configure(FilterChainManager filterChainManager) {
filterChainManager.createChain("/rest/**", "noSessionCreation, authcBasic");
}
});
contribute(JerseyConfigurator.class, new JerseyConfigurator() {
@Override
public void configure(ResourceConfig resourceConfig) {
resourceConfig.packages(RestModule.class.getPackage().getName());
}
});
}
示例3: DefaultFilterChainResolver
import org.apache.shiro.web.filter.mgt.FilterChainManager; //导入依赖的package包/类
@Inject
public DefaultFilterChainResolver(
Set<FilterChainConfigurator> filterChainConfigurators,
BasicAuthenticationFilter basicAuthenticationFilter) {
super();
FilterChainManager filterChainManager = getFilterChainManager();
filterChainManager.addFilter("authcBasic", basicAuthenticationFilter);
for (FilterChainConfigurator configurator: filterChainConfigurators) {
configurator.configure(filterChainManager);
}
filterChainManager.createChain("/**", "authcBasic");
}
示例4: createChains
import org.apache.shiro.web.filter.mgt.FilterChainManager; //导入依赖的package包/类
protected void createChains(Map<String, String> urls, FilterChainManager manager) {
if (CollectionUtils.isEmpty(urls)) {
if (log.isDebugEnabled()) {
log.debug("No urls to process.");
}
return;
}
if (log.isTraceEnabled()) {
log.trace("Before url processing.");
}
for (Map.Entry<String, String> entry : urls.entrySet()) {
String path = entry.getKey();
String value = entry.getValue();
manager.createChain(path, value);
}
}
示例5: configureShiroWeb
import org.apache.shiro.web.filter.mgt.FilterChainManager; //导入依赖的package包/类
@Override
protected void configureShiroWeb() {
bindRealm().to(EmptyRealm.class); // not used in practice, just here to keep Shiro module happy
bindSingleton(SessionFactory.class, NexusSessionFactory.class);
bindSingleton(SessionStorageEvaluator.class, NexusSessionStorageEvaluator.class);
bindSingleton(SubjectDAO.class, NexusSubjectDAO.class);
// configure our preferred security components
bindSingleton(SessionDAO.class, NexusSessionDAO.class);
bindSingleton(Authenticator.class, FirstSuccessfulModularRealmAuthenticator.class);
bindSingleton(Authorizer.class, ExceptionCatchingModularRealmAuthorizer.class);
bindSingleton(FilterChainManager.class, DynamicFilterChainManager.class);
// path matching resolver has several constructors so we need to point Guice to the appropriate one
bind(FilterChainResolver.class).toConstructor(ctor(PathMatchingFilterChainResolver.class)).asEagerSingleton();
// bindings used by external modules
expose(FilterChainResolver.class);
expose(FilterChainManager.class);
}
示例6: getFilterChainResolver
import org.apache.shiro.web.filter.mgt.FilterChainManager; //导入依赖的package包/类
/**
* @return the default filter chain resolver for this application
*/
@Produces
public FilterChainResolver getFilterChainResolver() {
if (this.filterChainResolver == null) {
final FilterChainManager chainManager = new DefaultFilterChainManager();
chainManager.addFilter("anon", new AnonymousFilter());
chainManager.addFilter("authc", this.configureFormAuthentication());
chainManager.addFilter("perms", new PermissionsAuthorizationFilter());
final PathMatchingFilterChainResolver resolver
= new PathMatchingFilterChainResolver();
chainManager.createChain("/secured/**", "authc");
chainManager.createChain("/index.xhtml", "anon");
resolver.setFilterChainManager(chainManager);
this.filterChainResolver = resolver;
}
return this.filterChainResolver;
}
示例7: getChain
import org.apache.shiro.web.filter.mgt.FilterChainManager; //导入依赖的package包/类
public FilterChain getChain(ServletRequest request, ServletResponse response, FilterChain originalChain) {
FilterChainManager filterChainManager = getFilterChainManager();
if (!filterChainManager.hasChains()) {
return null;
}
String requestURI = getPathWithinApplication(request);
List<String> chainNames = new ArrayList<String>();
//the 'chain names' in this implementation are actually path patterns defined by the user. We just use them
//as the chain name for the FilterChainManager's requirements
for (String pathPattern : filterChainManager.getChainNames()) {
// If the path does match, then pass on to the subclass implementation for specific checks:
if (pathMatches(pathPattern, requestURI)) {
chainNames.add(pathPattern);
}
}
if(chainNames.size() == 0) {
return null;
}
return customDefaultFilterChainManager.proxy(originalChain, chainNames);
}
开发者ID:yudar1024,项目名称:spring4-springmvc4-mybatis3-activiti,代码行数:26,代码来源:CustomPathMatchingFilterChainResolver.java
示例8: init
import org.apache.shiro.web.filter.mgt.FilterChainManager; //导入依赖的package包/类
@Override
public void init() throws Exception {
super.init();
String shiroConfigFile = GojaConfig.getAppSecurityConfig();
final File configFolderFile = GojaConfig.getConfigFolderFile();
shiroConfig = configFolderFile == null ? PropKit.use(shiroConfigFile).getProperties()
: PropKit.use(FileUtils.getFile(configFolderFile, shiroConfigFile)).getProperties();
WebSecurityManager webSecurityManager = initSecurityManager();
FilterChainManager manager = createFilterChainManager();
//Expose the constructed FilterChainManager by first wrapping it in a
// FilterChainResolver implementation. The AbstractShiroFilter implementations
// do not know about FilterChainManagers - only resolvers:
PathMatchingFilterChainResolver chainResolver = new PathMatchingFilterChainResolver();
chainResolver.setFilterChainManager(manager);
setSecurityManager(webSecurityManager);
setFilterChainResolver(chainResolver);
}
示例9: createFilterChainManager
import org.apache.shiro.web.filter.mgt.FilterChainManager; //导入依赖的package包/类
protected FilterChainManager createFilterChainManager() {
final DefaultFilterChainManager manager = new DefaultFilterChainManager();
Map<String, Filter> defaultFilters = manager.getFilters();
//apply global settings if necessary:
for (Filter filter : defaultFilters.values()) {
applyGlobalPropertiesIfNecessary(filter);
}
if (shiroConfig != null && !shiroConfig.isEmpty()) {
for (Object urlKey : shiroConfig.keySet()) {
String url = String.valueOf(urlKey);
if (org.apache.commons.lang3.StringUtils.equals("login.url", url)
|| org.apache.commons.lang3.StringUtils.equals("success.url", url)
|| org.apache.commons.lang3.StringUtils.equals("unauthorized.url", url)
|| org.apache.commons.lang3.StringUtils.equals("session.expired", url)
) {
continue;
}
// { "authc", "roles[admin,user]", "perms[file:edit]" }
manager.createChain(url, MoreObjects.firstNonNull(shiroConfig.getProperty(url), "anon"));
}
}
return manager;
}
示例10: FDWebEnvironment
import org.apache.shiro.web.filter.mgt.FilterChainManager; //导入依赖的package包/类
public FDWebEnvironment() {
BasicHttpAuthenticationFilter authc = new CorsBasicHttpAuthenticationFilter();
LogoutFilter logout = new LogoutFilter();
logout.setRedirectUrl("http://www.freedomotic.com/");
FilterChainManager fcMan = new DefaultFilterChainManager();
fcMan.addFilter("authc", authc);
fcMan.addFilter("logout", logout);
fcMan.createChain("/auth/logout", "logout");
fcMan.createChain("/v3/**", "authc");
PathMatchingFilterChainResolver resolver = new PathMatchingFilterChainResolver();
resolver.setFilterChainManager(fcMan);
setFilterChainResolver(resolver);
setWebSecurityManager(RestAPIv3.defaultWebSecurityManager);
}
示例11: getChain
import org.apache.shiro.web.filter.mgt.FilterChainManager; //导入依赖的package包/类
@Override
public FilterChain getChain(ServletRequest request, ServletResponse response, FilterChain originalChain) {
FilterChainManager filterChainManager = getFilterChainManager();
if (!filterChainManager.hasChains()) {
return null;
}
String requestURI = getPathWithinApplication(request);
List<String> chainNames = new ArrayList<String>();
for (String pathPattern : filterChainManager.getChainNames()) {
//校验满足所有规则的URL
// if (pathMatches(pathPattern, requestURI)) {
// chainNames.add(pathPattern);
// }
//校验第一个满足规则的URL
if (pathMatches(pathPattern, requestURI)) {
log.debug("Matched path pattern [" + pathPattern + "] for requestURI [" + requestURI + "]. " +
"Utilizing corresponding filter chain...");
return filterChainManager.proxy(originalChain, pathPattern);
}
}
if(chainNames.size() == 0) {
return null;
}
return customDefaultFilterChainManager.proxy(originalChain, chainNames);
}
示例12: getFilterChainResolver
import org.apache.shiro.web.filter.mgt.FilterChainManager; //导入依赖的package包/类
@Produces
public FilterChainResolver getFilterChainResolver() {
FilterChainResolver filterChainResolver = null;
if (filterChainResolver == null) {
FormAuthenticationFilter authc = new FormAuthenticationFilter();
AnonymousFilter anon = new AnonymousFilter();
UserFilter user = new UserFilter();
authc.setLoginUrl(WebPages.LOGIN_URL);
user.setLoginUrl(WebPages.LOGIN_URL);
FilterChainManager fcMan = new DefaultFilterChainManager();
fcMan.addFilter("authc", authc);
fcMan.addFilter("anon", anon);
fcMan.addFilter("user", user);
fcMan.createChain("/index.html", "anon");
fcMan.createChain("/css/**", "anon");
fcMan.createChain("/api/**", "anon");
fcMan.createChain(WebPages.LOGIN_URL, "authc");
fcMan.createChain("/**", "user");
PathMatchingFilterChainResolver resolver = new PathMatchingFilterChainResolver();
resolver.setFilterChainManager(fcMan);
filterChainResolver = resolver;
}
return filterChainResolver;
}
示例13: createInstance
import org.apache.shiro.web.filter.mgt.FilterChainManager; //导入依赖的package包/类
protected FilterChainResolver createInstance(Ini ini) {
FilterChainResolver filterChainResolver = createDefaultInstance();
if (filterChainResolver instanceof PathMatchingFilterChainResolver) {
PathMatchingFilterChainResolver resolver = (PathMatchingFilterChainResolver) filterChainResolver;
FilterChainManager manager = resolver.getFilterChainManager();
buildChains(manager, ini);
}
return filterChainResolver;
}
示例14: buildChains
import org.apache.shiro.web.filter.mgt.FilterChainManager; //导入依赖的package包/类
protected void buildChains(FilterChainManager manager, Ini ini) {
//filters section:
Ini.Section section = ini.getSection(FILTERS);
if (!CollectionUtils.isEmpty(section)) {
String msg = "The [{}] section has been deprecated and will be removed in a future release! Please " +
"move all object configuration (filters and all other objects) to the [{}] section.";
log.warn(msg, FILTERS, IniSecurityManagerFactory.MAIN_SECTION_NAME);
}
Map<String, Object> defaults = new LinkedHashMap<String, Object>();
Map<String, Filter> defaultFilters = manager.getFilters();
//now let's see if there are any object defaults in addition to the filters
//these can be used to configure the filters:
//create a Map of objects to use as the defaults:
if (!CollectionUtils.isEmpty(defaultFilters)) {
defaults.putAll(defaultFilters);
}
//User-provided objects must come _after_ the default filters - to allow the user-provided
//ones to override the default filters if necessary.
if (!CollectionUtils.isEmpty(this.defaultBeans)) {
defaults.putAll(this.defaultBeans);
}
Map<String, Filter> filters = getFilters(section, defaults);
//add the filters to the manager:
registerFilters(filters, manager);
//urls section:
section = ini.getSection(URLS);
createChains(section, manager);
}
示例15: registerFilters
import org.apache.shiro.web.filter.mgt.FilterChainManager; //导入依赖的package包/类
protected void registerFilters(Map<String, Filter> filters, FilterChainManager manager) {
if (!CollectionUtils.isEmpty(filters)) {
boolean init = getFilterConfig() != null; //only call filter.init if there is a FilterConfig available
for (Map.Entry<String, Filter> entry : filters.entrySet()) {
String name = entry.getKey();
Filter filter = entry.getValue();
manager.addFilter(name, filter, init);
}
}
}