Skip to content

Commit 35a614b

Browse files
committed
Update to Use New DelegateAuthenticationEntryPoint Constructor
1 parent 978181e commit 35a614b

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

web/src/main/java/org/springframework/security/web/access/DelegatingMissingAuthorityAccessDeniedHandler.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package org.springframework.security.web.access;
1818

1919
import java.io.IOException;
20+
import java.util.ArrayList;
2021
import java.util.Collection;
2122
import java.util.LinkedHashMap;
2223
import java.util.List;
@@ -40,6 +41,7 @@
4041
import org.springframework.security.web.util.ThrowableAnalyzer;
4142
import org.springframework.security.web.util.matcher.AnyRequestMatcher;
4243
import org.springframework.security.web.util.matcher.RequestMatcher;
44+
import org.springframework.security.web.util.matcher.RequestMatcherEntry;
4345

4446
public final class DelegatingMissingAuthorityAccessDeniedHandler implements AccessDeniedHandler {
4547

@@ -114,7 +116,7 @@ public static Builder builder() {
114116

115117
public static final class Builder {
116118

117-
private final Map<String, Map<RequestMatcher, AuthenticationEntryPoint>> entryPointByRequestMatcherByAuthority = new LinkedHashMap<>();
119+
private final Map<String, List<RequestMatcherEntry<AuthenticationEntryPoint>>> entryPointByRequestMatcherByAuthority = new LinkedHashMap<>();
118120

119121
private Builder() {
120122

@@ -123,9 +125,9 @@ private Builder() {
123125
Builder entryPointFor(RequestMatcher requestMatcher, AuthenticationEntryPoint entryPoint,
124126
String... authorities) {
125127
for (String authority : authorities) {
126-
Map<RequestMatcher, AuthenticationEntryPoint> requestMatcherByAuthority = this.entryPointByRequestMatcherByAuthority
127-
.computeIfAbsent(authority, (k) -> new LinkedHashMap<>());
128-
requestMatcherByAuthority.put(requestMatcher, entryPoint);
128+
List<RequestMatcherEntry<AuthenticationEntryPoint>> entryPointByRequestMatcher = this.entryPointByRequestMatcherByAuthority
129+
.computeIfAbsent(authority, (k) -> new ArrayList<>());
130+
entryPointByRequestMatcher.add(new RequestMatcherEntry<>(requestMatcher, entryPoint));
129131
}
130132
return this;
131133
}
@@ -137,16 +139,15 @@ public EntryPoint authorities(String... authorities) {
137139
public DelegatingMissingAuthorityAccessDeniedHandler build() {
138140
Map<String, AuthenticationEntryPoint> entryPointByAuthority = new LinkedHashMap<>();
139141
for (String authority : this.entryPointByRequestMatcherByAuthority.keySet()) {
140-
Map<RequestMatcher, AuthenticationEntryPoint> entryPointByRequestMatcher = this.entryPointByRequestMatcherByAuthority
142+
List<RequestMatcherEntry<AuthenticationEntryPoint>> entryPointByRequestMatcher = this.entryPointByRequestMatcherByAuthority
141143
.get(authority);
142-
AuthenticationEntryPoint defaultEntryPoint = entryPointByRequestMatcher.values().iterator().next();
144+
AuthenticationEntryPoint defaultEntryPoint = entryPointByRequestMatcher.iterator().next().getEntry();
143145
if (entryPointByRequestMatcher.size() == 1) {
144146
entryPointByAuthority.put(authority, defaultEntryPoint);
145147
}
146148
else {
147149
DelegatingAuthenticationEntryPoint entryPoint = new DelegatingAuthenticationEntryPoint(
148-
new LinkedHashMap<>(entryPointByRequestMatcher));
149-
entryPoint.setDefaultEntryPoint(defaultEntryPoint);
150+
defaultEntryPoint, entryPointByRequestMatcher);
150151
entryPointByAuthority.put(authority, entryPoint);
151152
}
152153
}

0 commit comments

Comments
 (0)