use of org.apache.shiro.web.filter.AccessControlFilter in project shiro by apache.
the class ShiroFilterFactoryBean method applyLoginUrlIfNecessary.
private void applyLoginUrlIfNecessary(Filter filter) {
String loginUrl = getLoginUrl();
if (StringUtils.hasText(loginUrl) && (filter instanceof AccessControlFilter)) {
AccessControlFilter acFilter = (AccessControlFilter) filter;
// only apply the login url if they haven't explicitly configured one already:
String existingLoginUrl = acFilter.getLoginUrl();
if (AccessControlFilter.DEFAULT_LOGIN_URL.equals(existingLoginUrl)) {
acFilter.setLoginUrl(loginUrl);
}
}
}
use of org.apache.shiro.web.filter.AccessControlFilter in project nutzboot by nutzam.
the class NbResourceBasedWebEnvironment method configure.
protected void configure() {
this.objects.clear();
WebSecurityManager securityManager = createWebSecurityManager();
setWebSecurityManager(securityManager);
String loginUrl = conf.get(ShiroEnvStarter.PROP_URL_LOGIN, "/user/login");
String unauthorizedUrl = conf.get(ShiroEnvStarter.PROP_URL_UNAUTH, "/user/login");
String logoutUrl = conf.get(ShiroEnvStarter.PROP_URL_LOGOUT_REDIRECT, "/");
for (Map.Entry<String, Filter> en : DefaultFilter.createInstanceMap(null).entrySet()) {
Filter filter = en.getValue();
if (filter instanceof LogoutFilter) {
((LogoutFilter) filter).setRedirectUrl(logoutUrl);
} else if (filter instanceof AuthenticatingFilter) {
((AuthenticatingFilter) filter).setLoginUrl(loginUrl);
} else if (filter instanceof AccessControlFilter) {
((AccessControlFilter) filter).setLoginUrl(unauthorizedUrl);
}
objects.put(en.getKey(), en.getValue());
}
for (String objectName : Strings.splitIgnoreBlank(conf.get("shiro.objects", ""))) {
objects.put(objectName, ioc.get(null, objectName));
}
FilterChainResolver resolver = createFilterChainResolver();
if (resolver != null) {
setFilterChainResolver(resolver);
}
NutShiro.DefaultLoginURL = loginUrl;
NutShiro.DefaultNoAuthURL = unauthorizedUrl;
}
Aggregations