Skip to content

Commit

Permalink
第十九章
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangkaitao committed Mar 1, 2014
1 parent 165b589 commit 9b6e53b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class UrlFilterDaoImpl implements UrlFilterDao {
private JdbcTemplate jdbcTemplate;

public UrlFilter createUrlFilter(final UrlFilter urlFilter) {
final String sql = "insert into sys_url_filter(name, url, roles, permissions) values(?,?,?,?,?)";
final String sql = "insert into sys_url_filter(name, url, roles, permissions) values(?,?,?,?)";

GeneratedKeyHolder keyHolder = new GeneratedKeyHolder();
jdbcTemplate.update(new PreparedStatementCreator() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
*/
public class UrlFilter implements Serializable {
private Long id;
private String name;
private String url;
private String roles;
private String permissions;
private String name; //url名称/描述
private String url; //地址
private String roles; //所需要的角色,可省略
private String permissions; //所需要的权限,可省略

public Long getId() {
return id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class CustomDefaultFilterChainManager extends DefaultFilterChainManager {
public CustomDefaultFilterChainManager() {
setFilters(new LinkedHashMap<String, Filter>());
setFilterChains(new LinkedHashMap<String, NamedFilterList>());
addDefaultFilters(true);
addDefaultFilters(false);
}

public Map<String, String> getFilterChainDefinitionMap() {
Expand All @@ -47,7 +47,9 @@ public void setFilterChainDefinitionMap(Map<String, String> filterChainDefinitio
}

public void setCustomFilters(Map<String, Filter> customFilters) {
getFilters().putAll(customFilters);
for(Map.Entry<String, Filter> entry : customFilters.entrySet()) {
addFilter(entry.getKey(), entry.getValue(), false);
}
}


Expand Down Expand Up @@ -90,12 +92,6 @@ public void setUnauthorizedUrl(String unauthorizedUrl) {

@PostConstruct
public void init() {
Map<String, Filter> defaultFilters = getFilters();
//apply global settings if necessary:
for (Filter filter : defaultFilters.values()) {
applyGlobalPropertiesIfNecessary(filter);
}

//Apply the acquired and/or configured filters:
Map<String, Filter> filters = getFilters();
if (!CollectionUtils.isEmpty(filters)) {
Expand All @@ -106,9 +102,6 @@ public void init() {
if (filter instanceof Nameable) {
((Nameable) filter).setName(name);
}
//'init' argument is false, since Spring-configured filters should be initialized
//in Spring (i.e. 'init-method=blah') or implement InitializingBean:
addFilter(name, filter, false);
}
}

Expand Down

0 comments on commit 9b6e53b

Please sign in to comment.