From b717333707d1c98b17ff210611effdba41addc03 Mon Sep 17 00:00:00 2001 From: Rob Winch Date: Tue, 16 Sep 2014 14:31:06 -0500 Subject: [PATCH] Polish messaging generics and imports --- .../expression/DefaultMessageSecurityExpressionHandler.java | 3 ++- ...ExpressionBasedMessageSecurityMetadataSourceFactory.java | 3 +-- .../access/expression/MessageExpressionConfigAttribute.java | 1 + .../messaging/access/expression/MessageExpressionVoter.java | 2 +- .../access/expression/MessageSecurityExpressionRoot.java | 2 +- .../intercept/DefaultMessageSecurityMetadataSource.java | 1 + .../security/messaging/util/matcher/MessageMatcher.java | 4 ++-- .../access/intercept/ChannelSecurityInterceptorTests.java | 4 ++-- .../DefaultMessageSecurityMetadataSourceTests.java | 6 +++--- .../context/SecurityContextChannelInterceptorTests.java | 2 +- 10 files changed, 15 insertions(+), 13 deletions(-) diff --git a/messaging/src/main/java/org/springframework/security/messaging/access/expression/DefaultMessageSecurityExpressionHandler.java b/messaging/src/main/java/org/springframework/security/messaging/access/expression/DefaultMessageSecurityExpressionHandler.java index b48fe6eb79..b6c2818592 100644 --- a/messaging/src/main/java/org/springframework/security/messaging/access/expression/DefaultMessageSecurityExpressionHandler.java +++ b/messaging/src/main/java/org/springframework/security/messaging/access/expression/DefaultMessageSecurityExpressionHandler.java @@ -24,8 +24,9 @@ import org.springframework.security.core.Authentication; /** * The default implementation of {@link SecurityExpressionHandler} which uses a {@link MessageSecurityExpressionRoot}. * - * @since 4.0 + * @param the type for the body of the Message * + * @since 4.0 * @author Rob Winch */ public class DefaultMessageSecurityExpressionHandler extends AbstractSecurityExpressionHandler> { diff --git a/messaging/src/main/java/org/springframework/security/messaging/access/expression/ExpressionBasedMessageSecurityMetadataSourceFactory.java b/messaging/src/main/java/org/springframework/security/messaging/access/expression/ExpressionBasedMessageSecurityMetadataSourceFactory.java index 2b0047b097..964b6d6c9e 100644 --- a/messaging/src/main/java/org/springframework/security/messaging/access/expression/ExpressionBasedMessageSecurityMetadataSourceFactory.java +++ b/messaging/src/main/java/org/springframework/security/messaging/access/expression/ExpressionBasedMessageSecurityMetadataSourceFactory.java @@ -20,7 +20,6 @@ import org.springframework.security.access.ConfigAttribute; import org.springframework.security.messaging.access.intercept.DefaultMessageSecurityMetadataSource; import org.springframework.security.messaging.access.intercept.MessageSecurityMetadataSource; import org.springframework.security.messaging.util.matcher.MessageMatcher; -import org.springframework.security.messaging.util.matcher.SimpDestinationMessageMatcher; import java.util.Arrays; import java.util.Collection; @@ -66,7 +65,7 @@ public final class ExpressionBasedMessageSecurityMetadataSourceFactory { * @return the {@link MessageSecurityMetadataSource} to use. Cannot be null. */ public static MessageSecurityMetadataSource createExpressionMessageMetadataSource(LinkedHashMap,String> matcherToExpression) { - DefaultMessageSecurityExpressionHandler handler = new DefaultMessageSecurityExpressionHandler(); + DefaultMessageSecurityExpressionHandler handler = new DefaultMessageSecurityExpressionHandler(); LinkedHashMap, Collection> matcherToAttrs = new LinkedHashMap, Collection>(); diff --git a/messaging/src/main/java/org/springframework/security/messaging/access/expression/MessageExpressionConfigAttribute.java b/messaging/src/main/java/org/springframework/security/messaging/access/expression/MessageExpressionConfigAttribute.java index b80dc50107..9c355c35f6 100644 --- a/messaging/src/main/java/org/springframework/security/messaging/access/expression/MessageExpressionConfigAttribute.java +++ b/messaging/src/main/java/org/springframework/security/messaging/access/expression/MessageExpressionConfigAttribute.java @@ -26,6 +26,7 @@ import org.springframework.util.Assert; * @since 4.0 * @author Rob Winch */ +@SuppressWarnings("serial") class MessageExpressionConfigAttribute implements ConfigAttribute { private final Expression authorizeExpression; diff --git a/messaging/src/main/java/org/springframework/security/messaging/access/expression/MessageExpressionVoter.java b/messaging/src/main/java/org/springframework/security/messaging/access/expression/MessageExpressionVoter.java index 3079e1f2fb..b9a0022e89 100644 --- a/messaging/src/main/java/org/springframework/security/messaging/access/expression/MessageExpressionVoter.java +++ b/messaging/src/main/java/org/springframework/security/messaging/access/expression/MessageExpressionVoter.java @@ -35,7 +35,7 @@ import java.util.Collection; * @author Rob Winch */ public class MessageExpressionVoter implements AccessDecisionVoter> { - private SecurityExpressionHandler> expressionHandler = new DefaultMessageSecurityExpressionHandler(); + private SecurityExpressionHandler> expressionHandler = new DefaultMessageSecurityExpressionHandler(); public int vote(Authentication authentication, Message message, Collection attributes) { assert authentication != null; diff --git a/messaging/src/main/java/org/springframework/security/messaging/access/expression/MessageSecurityExpressionRoot.java b/messaging/src/main/java/org/springframework/security/messaging/access/expression/MessageSecurityExpressionRoot.java index ba9a15ec80..af6da074ef 100644 --- a/messaging/src/main/java/org/springframework/security/messaging/access/expression/MessageSecurityExpressionRoot.java +++ b/messaging/src/main/java/org/springframework/security/messaging/access/expression/MessageSecurityExpressionRoot.java @@ -27,7 +27,7 @@ import org.springframework.security.core.Authentication; */ final class MessageSecurityExpressionRoot extends SecurityExpressionRoot { - public MessageSecurityExpressionRoot(Authentication authentication, Message message) { + public MessageSecurityExpressionRoot(Authentication authentication, Message message) { super(authentication); } } diff --git a/messaging/src/main/java/org/springframework/security/messaging/access/intercept/DefaultMessageSecurityMetadataSource.java b/messaging/src/main/java/org/springframework/security/messaging/access/intercept/DefaultMessageSecurityMetadataSource.java index 60066ff475..02f857b21c 100644 --- a/messaging/src/main/java/org/springframework/security/messaging/access/intercept/DefaultMessageSecurityMetadataSource.java +++ b/messaging/src/main/java/org/springframework/security/messaging/access/intercept/DefaultMessageSecurityMetadataSource.java @@ -44,6 +44,7 @@ public final class DefaultMessageSecurityMetadataSource implements MessageSecuri this.messageMap = messageMap; } + @SuppressWarnings({ "rawtypes", "unchecked" }) public Collection getAttributes(Object object) throws IllegalArgumentException { final Message message = (Message) object; for (Map.Entry, Collection> entry : messageMap.entrySet()) { diff --git a/messaging/src/main/java/org/springframework/security/messaging/util/matcher/MessageMatcher.java b/messaging/src/main/java/org/springframework/security/messaging/util/matcher/MessageMatcher.java index 8a70934fb6..2fd1d92e24 100644 --- a/messaging/src/main/java/org/springframework/security/messaging/util/matcher/MessageMatcher.java +++ b/messaging/src/main/java/org/springframework/security/messaging/util/matcher/MessageMatcher.java @@ -33,9 +33,9 @@ public interface MessageMatcher { boolean matches(Message message); /** - * Matches every {@link Message} + * Matches every {@link Message} */ - MessageMatcher ANY_MESSAGE = new MessageMatcher() { + MessageMatcher ANY_MESSAGE = new MessageMatcher() { public boolean matches(Message message) { return true; } diff --git a/messaging/src/test/java/org/springframework/security/messaging/access/intercept/ChannelSecurityInterceptorTests.java b/messaging/src/test/java/org/springframework/security/messaging/access/intercept/ChannelSecurityInterceptorTests.java index a8a1927289..e8107f16fa 100644 --- a/messaging/src/test/java/org/springframework/security/messaging/access/intercept/ChannelSecurityInterceptorTests.java +++ b/messaging/src/test/java/org/springframework/security/messaging/access/intercept/ChannelSecurityInterceptorTests.java @@ -27,13 +27,11 @@ import org.springframework.security.access.AccessDecisionManager; import org.springframework.security.access.AccessDeniedException; import org.springframework.security.access.ConfigAttribute; import org.springframework.security.access.SecurityConfig; -import org.springframework.security.access.intercept.InterceptorStatusToken; import org.springframework.security.access.intercept.RunAsManager; import org.springframework.security.authentication.TestingAuthenticationToken; import org.springframework.security.core.Authentication; import org.springframework.security.core.context.SecurityContextHolder; -import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.List; @@ -119,6 +117,7 @@ public class ChannelSecurityInterceptorTests { } + @SuppressWarnings("unchecked") @Test public void preSendPostSendRunAs() throws Exception { when(source.getAttributes(message)).thenReturn(attrs); @@ -138,6 +137,7 @@ public class ChannelSecurityInterceptorTests { interceptor.afterSendCompletion(message, channel, true, null); } + @SuppressWarnings("unchecked") @Test public void preSendFinallySendRunAs() throws Exception { when(source.getAttributes(message)).thenReturn(attrs); diff --git a/messaging/src/test/java/org/springframework/security/messaging/access/intercept/DefaultMessageSecurityMetadataSourceTests.java b/messaging/src/test/java/org/springframework/security/messaging/access/intercept/DefaultMessageSecurityMetadataSourceTests.java index 3ce85fca12..425e4a01fd 100644 --- a/messaging/src/test/java/org/springframework/security/messaging/access/intercept/DefaultMessageSecurityMetadataSourceTests.java +++ b/messaging/src/test/java/org/springframework/security/messaging/access/intercept/DefaultMessageSecurityMetadataSourceTests.java @@ -36,11 +36,11 @@ import static org.powermock.api.mockito.PowerMockito.when; @RunWith(MockitoJUnitRunner.class) public class DefaultMessageSecurityMetadataSourceTests { @Mock - MessageMatcher matcher1; + MessageMatcher matcher1; @Mock - MessageMatcher matcher2; + MessageMatcher matcher2; @Mock - Message message; + Message message; @Mock Authentication authentication; diff --git a/messaging/src/test/java/org/springframework/security/messaging/context/SecurityContextChannelInterceptorTests.java b/messaging/src/test/java/org/springframework/security/messaging/context/SecurityContextChannelInterceptorTests.java index 60c3ab9ccf..2a1c5d3f7a 100644 --- a/messaging/src/test/java/org/springframework/security/messaging/context/SecurityContextChannelInterceptorTests.java +++ b/messaging/src/test/java/org/springframework/security/messaging/context/SecurityContextChannelInterceptorTests.java @@ -29,7 +29,7 @@ public class SecurityContextChannelInterceptorTests { @Mock Principal principal; - MessageBuilder messageBuilder; + MessageBuilder messageBuilder; Authentication authentication;