|
42 | 42 | import org.springframework.beans.factory.xml.BeanDefinitionParser; |
43 | 43 | import org.springframework.beans.factory.xml.ParserContext; |
44 | 44 | import org.springframework.core.OrderComparator; |
45 | | -import org.springframework.core.Ordered; |
46 | 45 | import org.springframework.security.authentication.AuthenticationManager; |
47 | 46 | import org.springframework.security.authentication.DefaultAuthenticationEventPublisher; |
48 | 47 | import org.springframework.security.authentication.ProviderManager; |
@@ -399,97 +398,70 @@ static void registerFilterChainProxyIfNecessary(ParserContext pc, Object source) |
399 | 398 | registry.registerBeanDefinition(requestRejectedPostProcessorName, requestRejectedBean); |
400 | 399 | } |
401 | 400 |
|
402 | | -} |
403 | | - |
404 | | -class RequestRejectedHandlerPostProcessor implements BeanDefinitionRegistryPostProcessor { |
| 401 | + static class RequestRejectedHandlerPostProcessor implements BeanDefinitionRegistryPostProcessor { |
405 | 402 |
|
406 | | - private final String beanName; |
| 403 | + private final String beanName; |
407 | 404 |
|
408 | | - private final String targetBeanName; |
| 405 | + private final String targetBeanName; |
409 | 406 |
|
410 | | - private final String targetPropertyName; |
| 407 | + private final String targetPropertyName; |
411 | 408 |
|
412 | | - RequestRejectedHandlerPostProcessor(String beanName, String targetBeanName, String targetPropertyName) { |
413 | | - this.beanName = beanName; |
414 | | - this.targetBeanName = targetBeanName; |
415 | | - this.targetPropertyName = targetPropertyName; |
416 | | - } |
417 | | - |
418 | | - @Override |
419 | | - public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) throws BeansException { |
420 | | - if (registry.containsBeanDefinition(this.beanName)) { |
421 | | - BeanDefinition beanDefinition = registry.getBeanDefinition(this.targetBeanName); |
422 | | - beanDefinition.getPropertyValues().add(this.targetPropertyName, new RuntimeBeanReference(this.beanName)); |
| 409 | + RequestRejectedHandlerPostProcessor(String beanName, String targetBeanName, String targetPropertyName) { |
| 410 | + this.beanName = beanName; |
| 411 | + this.targetBeanName = targetBeanName; |
| 412 | + this.targetPropertyName = targetPropertyName; |
423 | 413 | } |
424 | | - } |
425 | | - |
426 | | - @Override |
427 | | - public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { |
428 | | - |
429 | | - } |
430 | 414 |
|
431 | | -} |
432 | | - |
433 | | -class OrderDecorator implements Ordered { |
434 | | - |
435 | | - final BeanMetadataElement bean; |
436 | | - |
437 | | - final int order; |
438 | | - |
439 | | - OrderDecorator(BeanMetadataElement bean, SecurityFilters filterOrder) { |
440 | | - this.bean = bean; |
441 | | - this.order = filterOrder.getOrder(); |
442 | | - } |
| 415 | + @Override |
| 416 | + public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) throws BeansException { |
| 417 | + if (registry.containsBeanDefinition(this.beanName)) { |
| 418 | + BeanDefinition beanDefinition = registry.getBeanDefinition(this.targetBeanName); |
| 419 | + beanDefinition.getPropertyValues().add(this.targetPropertyName, |
| 420 | + new RuntimeBeanReference(this.beanName)); |
| 421 | + } |
| 422 | + } |
443 | 423 |
|
444 | | - OrderDecorator(BeanMetadataElement bean, int order) { |
445 | | - this.bean = bean; |
446 | | - this.order = order; |
447 | | - } |
| 424 | + @Override |
| 425 | + public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { |
448 | 426 |
|
449 | | - @Override |
450 | | - public int getOrder() { |
451 | | - return this.order; |
452 | | - } |
| 427 | + } |
453 | 428 |
|
454 | | - @Override |
455 | | - public String toString() { |
456 | | - return this.bean + ", order = " + this.order; |
457 | 429 | } |
458 | 430 |
|
459 | | -} |
| 431 | + /** |
| 432 | + * Custom {@link MethodInvokingFactoryBean} that is specifically used for looking up |
| 433 | + * the child {@link ProviderManager} value for |
| 434 | + * {@link ProviderManager#setEraseCredentialsAfterAuthentication(boolean)} given the |
| 435 | + * parent {@link AuthenticationManager}. This is necessary because the parent |
| 436 | + * {@link AuthenticationManager} might not be a {@link ProviderManager}. |
| 437 | + * |
| 438 | + * @author Rob Winch |
| 439 | + */ |
| 440 | + static final class ClearCredentialsMethodInvokingFactoryBean extends MethodInvokingFactoryBean { |
460 | 441 |
|
461 | | -/** |
462 | | - * Custom {@link MethodInvokingFactoryBean} that is specifically used for looking up the |
463 | | - * child {@link ProviderManager} value for |
464 | | - * {@link ProviderManager#setEraseCredentialsAfterAuthentication(boolean)} given the |
465 | | - * parent {@link AuthenticationManager}. This is necessary because the parent |
466 | | - * {@link AuthenticationManager} might not be a {@link ProviderManager}. |
467 | | - * |
468 | | - * @author Rob Winch |
469 | | - */ |
470 | | -final class ClearCredentialsMethodInvokingFactoryBean extends MethodInvokingFactoryBean { |
| 442 | + @Override |
| 443 | + public void afterPropertiesSet() throws Exception { |
| 444 | + boolean isTargetProviderManager = getTargetObject() instanceof ProviderManager; |
| 445 | + if (!isTargetProviderManager) { |
| 446 | + setTargetObject(this); |
| 447 | + } |
| 448 | + super.afterPropertiesSet(); |
| 449 | + } |
471 | 450 |
|
472 | | - @Override |
473 | | - public void afterPropertiesSet() throws Exception { |
474 | | - boolean isTargetProviderManager = getTargetObject() instanceof ProviderManager; |
475 | | - if (!isTargetProviderManager) { |
476 | | - setTargetObject(this); |
| 451 | + /** |
| 452 | + * The default value if the target object is not a ProviderManager is false. We |
| 453 | + * use false because this feature is associated with {@link ProviderManager} not |
| 454 | + * {@link AuthenticationManager}. If the user wants to leverage |
| 455 | + * {@link ProviderManager#setEraseCredentialsAfterAuthentication(boolean)} their |
| 456 | + * original {@link AuthenticationManager} must be a {@link ProviderManager} (we |
| 457 | + * should not magically add this functionality to their implementation since we |
| 458 | + * cannot determine if it should be on or off). |
| 459 | + * @return |
| 460 | + */ |
| 461 | + public boolean isEraseCredentialsAfterAuthentication() { |
| 462 | + return false; |
477 | 463 | } |
478 | | - super.afterPropertiesSet(); |
479 | | - } |
480 | 464 |
|
481 | | - /** |
482 | | - * The default value if the target object is not a ProviderManager is false. We use |
483 | | - * false because this feature is associated with {@link ProviderManager} not |
484 | | - * {@link AuthenticationManager}. If the user wants to leverage |
485 | | - * {@link ProviderManager#setEraseCredentialsAfterAuthentication(boolean)} their |
486 | | - * original {@link AuthenticationManager} must be a {@link ProviderManager} (we should |
487 | | - * not magically add this functionality to their implementation since we cannot |
488 | | - * determine if it should be on or off). |
489 | | - * @return |
490 | | - */ |
491 | | - public boolean isEraseCredentialsAfterAuthentication() { |
492 | | - return false; |
493 | 465 | } |
494 | 466 |
|
495 | 467 | } |
0 commit comments