Class MessageSecurityMetadataSourceRegistry
- java.lang.Object
-
- org.springframework.security.config.annotation.web.messaging.MessageSecurityMetadataSourceRegistry
-
public class MessageSecurityMetadataSourceRegistry extends java.lang.ObjectAllows mapping security constraints usingMessageMatcherto the security expressions.- Since:
- 4.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classMessageSecurityMetadataSourceRegistry.ConstraintRepresents the security constraint to be applied to theMessageMatcherinstances.
-
Constructor Summary
Constructors Constructor Description MessageSecurityMetadataSourceRegistry()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description MessageSecurityMetadataSourceRegistry.ConstraintanyMessage()Maps anyMessageto a security expression.protected booleancontainsMapping()Allows determining if a mapping was added.protected org.springframework.security.messaging.access.intercept.MessageSecurityMetadataSourcecreateMetadataSource()Allows subclasses to create creating aMessageSecurityMetadataSource.MessageSecurityMetadataSourceRegistryexpressionHandler(org.springframework.security.access.expression.SecurityExpressionHandler<org.springframework.messaging.Message<java.lang.Object>> expressionHandler)TheSecurityExpressionHandlerto be used.protected booleanisSimpDestPathMatcherConfigured()Determines if thesimpDestPathMatcher(PathMatcher)has been explicitly set.MessageSecurityMetadataSourceRegistry.Constraintmatchers(org.springframework.security.messaging.util.matcher.MessageMatcher<?>... matchers)Maps aListofMessageMatcherinstances to a security expression.MessageSecurityMetadataSourceRegistry.ConstraintnullDestMatcher()Maps anyMessagethat has a null SimpMessageHeaderAccessor destination header (i.e.MessageSecurityMetadataSourceRegistry.ConstraintsimpDestMatchers(java.lang.String... patterns)Maps aListofSimpDestinationMessageMatcherinstances without regard to theSimpMessageType.MessageSecurityMetadataSourceRegistrysimpDestPathMatcher(org.springframework.util.PathMatcher pathMatcher)ThePathMatcherto be used with thesimpDestMatchers(String...).MessageSecurityMetadataSourceRegistry.ConstraintsimpMessageDestMatchers(java.lang.String... patterns)Maps aListofSimpDestinationMessageMatcherinstances that match onSimpMessageType.MESSAGE.MessageSecurityMetadataSourceRegistry.ConstraintsimpSubscribeDestMatchers(java.lang.String... patterns)Maps aListofSimpDestinationMessageMatcherinstances that match onSimpMessageType.SUBSCRIBE.MessageSecurityMetadataSourceRegistry.ConstraintsimpTypeMatchers(org.springframework.messaging.simp.SimpMessageType... typesToMatch)Maps aListofSimpDestinationMessageMatcherinstances.
-
-
-
Method Detail
-
anyMessage
public MessageSecurityMetadataSourceRegistry.Constraint anyMessage()
Maps anyMessageto a security expression.- Returns:
- the Expression to associate
-
nullDestMatcher
public MessageSecurityMetadataSourceRegistry.Constraint nullDestMatcher()
Maps anyMessagethat has a null SimpMessageHeaderAccessor destination header (i.e. CONNECT, CONNECT_ACK, HEARTBEAT, UNSUBSCRIBE, DISCONNECT, DISCONNECT_ACK, OTHER)- Returns:
- the Expression to associate
-
simpTypeMatchers
public MessageSecurityMetadataSourceRegistry.Constraint simpTypeMatchers(org.springframework.messaging.simp.SimpMessageType... typesToMatch)
Maps aListofSimpDestinationMessageMatcherinstances.- Parameters:
typesToMatch- theSimpMessageTypeinstance to match on- Returns:
- the
MessageSecurityMetadataSourceRegistry.Constraintassociated to the matchers.
-
simpDestMatchers
public MessageSecurityMetadataSourceRegistry.Constraint simpDestMatchers(java.lang.String... patterns)
Maps aListofSimpDestinationMessageMatcherinstances without regard to theSimpMessageType. If no destination is found on the Message, then the Matcher returns false.- Parameters:
patterns- the patterns to createSimpDestinationMessageMatcherfrom. UsessimpDestPathMatcher(PathMatcher).- Returns:
- the
MessageSecurityMetadataSourceRegistry.Constraintthat is associated to theMessageMatcher - See Also:
simpDestPathMatcher(PathMatcher)
-
simpMessageDestMatchers
public MessageSecurityMetadataSourceRegistry.Constraint simpMessageDestMatchers(java.lang.String... patterns)
Maps aListofSimpDestinationMessageMatcherinstances that match onSimpMessageType.MESSAGE. If no destination is found on the Message, then the Matcher returns false.- Parameters:
patterns- the patterns to createSimpDestinationMessageMatcherfrom. UsessimpDestPathMatcher(PathMatcher).- Returns:
- the
MessageSecurityMetadataSourceRegistry.Constraintthat is associated to theMessageMatcher - See Also:
simpDestPathMatcher(PathMatcher)
-
simpSubscribeDestMatchers
public MessageSecurityMetadataSourceRegistry.Constraint simpSubscribeDestMatchers(java.lang.String... patterns)
Maps aListofSimpDestinationMessageMatcherinstances that match onSimpMessageType.SUBSCRIBE. If no destination is found on the Message, then the Matcher returns false.- Parameters:
patterns- the patterns to createSimpDestinationMessageMatcherfrom. UsessimpDestPathMatcher(PathMatcher).- Returns:
- the
MessageSecurityMetadataSourceRegistry.Constraintthat is associated to theMessageMatcher - See Also:
simpDestPathMatcher(PathMatcher)
-
simpDestPathMatcher
public MessageSecurityMetadataSourceRegistry simpDestPathMatcher(org.springframework.util.PathMatcher pathMatcher)
ThePathMatcherto be used with thesimpDestMatchers(String...). The default is to use the default constructor ofAntPathMatcher.- Parameters:
pathMatcher- thePathMatcherto use. Cannot be null.- Returns:
- the
MessageSecurityMetadataSourceRegistryfor further customization.
-
isSimpDestPathMatcherConfigured
protected boolean isSimpDestPathMatcherConfigured()
Determines if thesimpDestPathMatcher(PathMatcher)has been explicitly set.- Returns:
- true if
simpDestPathMatcher(PathMatcher)has been explicitly set, else false.
-
matchers
public MessageSecurityMetadataSourceRegistry.Constraint matchers(org.springframework.security.messaging.util.matcher.MessageMatcher<?>... matchers)
Maps aListofMessageMatcherinstances to a security expression.- Parameters:
matchers- theMessageMatcherinstances to map.- Returns:
- The
MessageSecurityMetadataSourceRegistry.Constraintthat is associated to theMessageMatcherinstances
-
expressionHandler
public MessageSecurityMetadataSourceRegistry expressionHandler(org.springframework.security.access.expression.SecurityExpressionHandler<org.springframework.messaging.Message<java.lang.Object>> expressionHandler)
TheSecurityExpressionHandlerto be used. The default is to useDefaultMessageSecurityExpressionHandler.- Parameters:
expressionHandler- theSecurityExpressionHandlerto use. Cannot be null.- Returns:
- the
MessageSecurityMetadataSourceRegistryfor further customization.
-
createMetadataSource
protected org.springframework.security.messaging.access.intercept.MessageSecurityMetadataSource createMetadataSource()
Allows subclasses to create creating aMessageSecurityMetadataSource.This is not exposed so as not to confuse users of the API, which should never invoke this method.
- Returns:
- the
MessageSecurityMetadataSourceto use
-
containsMapping
protected boolean containsMapping()
Allows determining if a mapping was added.This is not exposed so as not to confuse users of the API, which should never need to invoke this method.
- Returns:
- true if a mapping was added, else false
-
-