/** * Maps any {@link Message} that has a null SimpMessageHeaderAccessor destination * header (i.e. CONNECT, CONNECT_ACK, HEARTBEAT, UNSUBSCRIBE, DISCONNECT, * DISCONNECT_ACK, OTHER) * * @return the Expression to associate */ public Constraint nullDestMatcher() { return matchers(SimpDestinationMessageMatcher.NULL_DESTINATION_MATCHER); }
/** * Maps any {@link Message} to a security expression. * * @return the Expression to associate */ public Constraint anyMessage() { return matchers(MessageMatcher.ANY_MESSAGE); }
/** * Maps a {@link List} of {@link SimpDestinationMessageMatcher} instances. * * @param typesToMatch the {@link SimpMessageType} instance to match on * @return the {@link Constraint} associated to the matchers. */ public Constraint simpTypeMatchers(SimpMessageType... typesToMatch) { MessageMatcher<?>[] typeMatchers = new MessageMatcher<?>[typesToMatch.length]; for (int i = 0; i < typesToMatch.length; i++) { SimpMessageType typeToMatch = typesToMatch[i]; typeMatchers[i] = new SimpMessageTypeMatcher(typeToMatch); } return matchers(typeMatchers); }
@Test public void matchersTrue() { when(matcher.matches(message)).thenReturn(true); messages.matchers(matcher).permitAll(); assertThat(getAttribute()).isEqualTo("permitAll"); }
@Test public void matchersFalse() { messages.matchers(matcher).permitAll(); assertThat(getAttribute()).isNull(); }
/** * Maps any {@link Message} to a security expression. * * @return the Expression to associate */ public Constraint anyMessage() { return matchers(MessageMatcher.ANY_MESSAGE); }
/** * Maps any {@link Message} that has a null SimpMessageHeaderAccessor destination * header (i.e. CONNECT, CONNECT_ACK, HEARTBEAT, UNSUBSCRIBE, DISCONNECT, * DISCONNECT_ACK, OTHER) * * @return the Expression to associate */ public Constraint nullDestMatcher() { return matchers(SimpDestinationMessageMatcher.NULL_DESTINATION_MATCHER); }
/** * Maps a {@link List} of {@link SimpDestinationMessageMatcher} instances. * * @param typesToMatch the {@link SimpMessageType} instance to match on * @return the {@link Constraint} associated to the matchers. */ public Constraint simpTypeMatchers(SimpMessageType... typesToMatch) { MessageMatcher<?>[] typeMatchers = new MessageMatcher<?>[typesToMatch.length]; for (int i = 0; i < typesToMatch.length; i++) { SimpMessageType typeToMatch = typesToMatch[i]; typeMatchers[i] = new SimpMessageTypeMatcher(typeToMatch); } return matchers(typeMatchers); }
/** * Maps any {@link Message} that has a null SimpMessageHeaderAccessor destination * header (i.e. CONNECT, CONNECT_ACK, HEARTBEAT, UNSUBSCRIBE, DISCONNECT, * DISCONNECT_ACK, OTHER) * * @return the Expression to associate */ public Constraint nullDestMatcher() { return matchers(SimpDestinationMessageMatcher.NULL_DESTINATION_MATCHER); }
/** * Maps any {@link Message} to a security expression. * * @return the Expression to associate */ public Constraint anyMessage() { return matchers(MessageMatcher.ANY_MESSAGE); }
/** * Maps a {@link List} of {@link SimpDestinationMessageMatcher} instances. * * @param typesToMatch the {@link SimpMessageType} instance to match on * @return the {@link Constraint} associated to the matchers. */ public Constraint simpTypeMatchers(SimpMessageType... typesToMatch) { MessageMatcher<?>[] typeMatchers = new MessageMatcher<?>[typesToMatch.length]; for (int i = 0; i < typesToMatch.length; i++) { SimpMessageType typeToMatch = typesToMatch[i]; typeMatchers[i] = new SimpMessageTypeMatcher(typeToMatch); } return matchers(typeMatchers); }