Example usage for org.apache.shiro.web.filter.authz AuthorizationFilter setUnauthorizedUrl

List of usage examples for org.apache.shiro.web.filter.authz AuthorizationFilter setUnauthorizedUrl

Introduction

In this page you can find the example usage for org.apache.shiro.web.filter.authz AuthorizationFilter setUnauthorizedUrl.

Prototype

public void setUnauthorizedUrl(String unauthorizedUrl) 

Source Link

Document

Sets the URL to which users should be redirected if they are denied access to an underlying path or resource.

Usage

From source file:com.centfor.frame.shiro.FrameShiroFilterFactoryBean.java

License:Apache License

private void applyUnauthorizedUrlIfNecessary(Filter filter) {
    String unauthorizedUrl = getUnauthorizedUrl();
    if (StringUtils.hasText(unauthorizedUrl) && (filter instanceof AuthorizationFilter)) {
        AuthorizationFilter authzFilter = (AuthorizationFilter) filter;
        //only apply the unauthorizedUrl if they haven't explicitly configured one already:
        String existingUnauthorizedUrl = authzFilter.getUnauthorizedUrl();
        if (existingUnauthorizedUrl == null) {
            authzFilter.setUnauthorizedUrl(unauthorizedUrl);
        }//from w  ww.  ja va 2s .c  o m
    }
}