2
0

messaging.adoc 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. == Messaging Migrations
  2. [[use-path-pattern]]
  3. == Use PathPatternMessageMatcher by Default
  4. In Spring Security 7, `SimpDestMessageMatcher` is no longer supported and will use `PathPatternMessageMatcher` by default.
  5. To check how prepared you are for this change, you can publish this bean:
  6. [tabs]
  7. ======
  8. Java::
  9. +
  10. [source,java,role="primary"]
  11. ----
  12. @Bean
  13. PathPatternMessageMatcherBuilderFactoryBean messageMatcherBuilder() {
  14. return new PathPatternMessageMatcherBuilderFactoryBean();
  15. }
  16. ----
  17. Kotlin::
  18. +
  19. [source,kotlin,role="secondary"]
  20. ----
  21. @Bean
  22. fun messageMatcherBuilder(): PathPatternMessageMatcherBuilderFactoryBean {
  23. return PathPatternMessageMatcherBuilderFactoryBean()
  24. }
  25. ----
  26. Xml::
  27. +
  28. [source,xml,role="secondary"]
  29. ----
  30. <b:bean class="org.springframework.security.config.web.messaging.PathPatternMessageMatcherBuilderFactoryBean"/>
  31. ----
  32. ======
  33. This will tell the Spring Security DSL to use `PathPatternMessageMatcher` for all message matchers that it constructs.
  34. Use of `PathMatcher` is no longer supported in 7.
  35. If you are using `PathMatcher` to change the path separator or to change case sensitivity for message matching, you can configure the `PathPatternParser` to do this instead like so:
  36. [tabs]
  37. ======
  38. Java::
  39. +
  40. [source,java,role="primary"]
  41. ----
  42. @Bean
  43. PathPatternMessageMatcherBuilderFactoryBean messageMatcherBuilder() {
  44. PathPatternParser pathPatternParser = new PathPatternParser();
  45. pathPatternParser.setCaseSensitive(false);
  46. // use . as path separator
  47. pathPatternParser.setPathOptions(PathContainer.Options.MESSAGE_ROUTE);
  48. return new PathPatternMessageMatcherBuilderFactoryBean(pathPatternParser);
  49. }
  50. ----
  51. Kotlin::
  52. +
  53. [source,kotlin,role="secondary"]
  54. ----
  55. @Bean
  56. fun messageMatcherBuilder(): PathPatternMessageMatcherBuilderFactoryBean {
  57. val pathPatternParser = PathPatternParser()
  58. pathPatternParser.setCaseSensitive(false)
  59. // use . as path separator
  60. pathPatternParser.setPathOptions(PathContainer.Options.MESSAGE_ROUTE)
  61. return PathPatternMessageMatcherBuilderFactoryBean(pathPatternParser)
  62. }
  63. ----
  64. Xml::
  65. +
  66. [source,xml,role="secondary"]
  67. ----
  68. <b:bean class="org.springframework.web.util.pattern.PathPatternParser">
  69. <b:property name="caseSensitive" value="false"/>
  70. <!-- use . as path separator -->
  71. <b:property name="pathOptions" value="#{T(org.springframework.http.server.PathContainer.Options).MESSAGE_ROUTE"/>
  72. </b:bean>
  73. <b:bean class="org.springframework.security.config.web.messaging.PathPatternMessageMatcherBuilderFactoryBean"/>
  74. ----
  75. ======