|
28 | 28 | import java.util.Locale; |
29 | 29 | import java.util.Map; |
30 | 30 | import java.util.TreeMap; |
| 31 | +import java.util.function.Predicate; |
31 | 32 | import java.util.logging.Level; |
32 | 33 | import java.util.logging.Logger; |
33 | 34 |
|
@@ -219,7 +220,7 @@ protected boolean processStack(Nameable entity, |
219 | 220 | PluginDecisionPredicate pluginPredicate, |
220 | 221 | PluginSkippingPredicate skippingPredicate) { |
221 | 222 |
|
222 | | - Boolean overallDecision = null; |
| 223 | + boolean overallDecision = true; |
223 | 224 | boolean optionalFailure = false; |
224 | 225 |
|
225 | 226 | if (getStack().isEmpty()) { |
@@ -253,14 +254,9 @@ protected boolean processStack(Nameable entity, |
253 | 254 | break; |
254 | 255 | } else if (!entityDecision && authEntity.isOptional()) { |
255 | 256 | optionalFailure = true; |
256 | | - } else if (entityDecision && authEntity.isSufficient()) { |
| 257 | + } else if (overallDecision && entityDecision && authEntity.isSufficient()) { |
257 | 258 | // sufficient immediately returns the success |
258 | | - if ((overallDecision == null) || overallDecision) { |
259 | | - overallDecision = true; |
260 | | - break; |
261 | | - } |
262 | | - } else if (overallDecision == null && entityDecision) { |
263 | | - overallDecision = true; |
| 259 | + break; |
264 | 260 | } |
265 | 261 | } catch (AuthorizationException ex) { |
266 | 262 | // Propagate up so that proper HTTP error can be given. |
@@ -292,14 +288,12 @@ protected boolean processStack(Nameable entity, |
292 | 288 | } |
293 | 289 | } |
294 | 290 |
|
295 | | - if (overallDecision == null && optionalFailure) { |
| 291 | + if (optionalFailure && |
| 292 | + getStack().stream().filter(AuthorizationEntity::isOptional).count() == 1 && |
| 293 | + getStack().stream().filter(Predicate.not(AuthorizationEntity::isOptional)).findAny().isEmpty()) { |
296 | 294 | return false; |
297 | 295 | } |
298 | 296 |
|
299 | | - if (overallDecision == null) { |
300 | | - return true; |
301 | | - } |
302 | | - |
303 | 297 | return overallDecision; |
304 | 298 | } |
305 | 299 |
|
|
0 commit comments