Skip to content

Commit e8094b8

Browse files
philwebbrwinch
authored andcommitted
Polish spring-security-rsocket main code
Manually polish `spring-security-rsocket` following the formatting and checkstyle fixes. Issue gh-8945
1 parent 16819be commit e8094b8

File tree

7 files changed

+19
-16
lines changed

7 files changed

+19
-16
lines changed

rsocket/src/main/java/org/springframework/security/rsocket/authentication/AnonymousPayloadInterceptor.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@
3939
*/
4040
public class AnonymousPayloadInterceptor implements PayloadInterceptor, Ordered {
4141

42-
private String key;
42+
private final String key;
4343

44-
private Object principal;
44+
private final Object principal;
4545

46-
private List<GrantedAuthority> authorities;
46+
private final List<GrantedAuthority> authorities;
4747

4848
private int order;
4949

rsocket/src/main/java/org/springframework/security/rsocket/authentication/AuthenticationPayloadExchangeConverter.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public class AuthenticationPayloadExchangeConverter implements PayloadExchangeAu
5656
private static final MimeType AUTHENTICATION_MIME_TYPE = MimeTypeUtils
5757
.parseMimeType(WellKnownMimeType.MESSAGE_RSOCKET_AUTHENTICATION.getString());
5858

59-
private MetadataExtractor metadataExtractor = createDefaultExtractor();
59+
private final MetadataExtractor metadataExtractor = createDefaultExtractor();
6060

6161
@Override
6262
public Mono<Authentication> convert(PayloadExchange exchange) {
@@ -79,7 +79,7 @@ private Authentication authentication(Map<String, Object> metadata) {
7979
if (WellKnownAuthType.SIMPLE.equals(wellKnownAuthType)) {
8080
return simple(rawAuthentication);
8181
}
82-
else if (WellKnownAuthType.BEARER.equals(wellKnownAuthType)) {
82+
if (WellKnownAuthType.BEARER.equals(wellKnownAuthType)) {
8383
return bearer(rawAuthentication);
8484
}
8585
throw new IllegalArgumentException("Unknown Mime Type " + wellKnownAuthType);

rsocket/src/main/java/org/springframework/security/rsocket/authorization/PayloadExchangeMatcherReactiveAuthorizationManager.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import org.springframework.security.rsocket.api.PayloadExchange;
2929
import org.springframework.security.rsocket.util.matcher.PayloadExchangeAuthorizationContext;
3030
import org.springframework.security.rsocket.util.matcher.PayloadExchangeMatcher;
31+
import org.springframework.security.rsocket.util.matcher.PayloadExchangeMatcher.MatchResult;
3132
import org.springframework.security.rsocket.util.matcher.PayloadExchangeMatcherEntry;
3233
import org.springframework.util.Assert;
3334

@@ -53,7 +54,7 @@ private PayloadExchangeMatcherReactiveAuthorizationManager(
5354
public Mono<AuthorizationDecision> check(Mono<Authentication> authentication, PayloadExchange exchange) {
5455
return Flux.fromIterable(this.mappings)
5556
.concatMap((mapping) -> mapping.getMatcher().matches(exchange)
56-
.filter(PayloadExchangeMatcher.MatchResult::isMatch).map((r) -> r.getVariables())
57+
.filter(PayloadExchangeMatcher.MatchResult::isMatch).map(MatchResult::getVariables)
5758
.flatMap((variables) -> mapping.getEntry().check(authentication,
5859
new PayloadExchangeAuthorizationContext(exchange, variables))))
5960
.next().switchIfEmpty(Mono.fromCallable(() -> new AuthorizationDecision(false)));

rsocket/src/main/java/org/springframework/security/rsocket/core/PayloadSocketAcceptor.java

-2
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,8 @@ class PayloadSocketAcceptor implements SocketAcceptor {
6666
public Mono<RSocket> accept(ConnectionSetupPayload setup, RSocket sendingSocket) {
6767
MimeType dataMimeType = parseMimeType(setup.dataMimeType(), this.defaultDataMimeType);
6868
Assert.notNull(dataMimeType, "No `dataMimeType` in ConnectionSetupPayload and no default value");
69-
7069
MimeType metadataMimeType = parseMimeType(setup.metadataMimeType(), this.defaultMetadataMimeType);
7170
Assert.notNull(metadataMimeType, "No `metadataMimeType` in ConnectionSetupPayload and no default value");
72-
7371
// FIXME do we want to make the sendingSocket available in the PayloadExchange
7472
return intercept(setup, dataMimeType, metadataMimeType)
7573
.flatMap(

rsocket/src/main/java/org/springframework/security/rsocket/metadata/BasicAuthenticationDecoder.java

-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ public Flux<UsernamePasswordMetadata> decode(Publisher<DataBuffer> input, Resolv
4848
return Flux.from(input).map(DataBuffer::asByteBuffer).map((byteBuffer) -> {
4949
byte[] sizeBytes = new byte[4];
5050
byteBuffer.get(sizeBytes);
51-
5251
int usernameSize = 4;
5352
byte[] usernameBytes = new byte[usernameSize];
5453
byteBuffer.get(usernameBytes);

rsocket/src/main/java/org/springframework/security/rsocket/util/matcher/PayloadExchangeMatchers.java

+10-4
Original file line numberDiff line numberDiff line change
@@ -24,37 +24,43 @@
2424
/**
2525
* @author Rob Winch
2626
*/
27-
public abstract class PayloadExchangeMatchers {
27+
public final class PayloadExchangeMatchers {
28+
29+
private PayloadExchangeMatchers() {
30+
}
2831

2932
public static PayloadExchangeMatcher setup() {
3033
return new PayloadExchangeMatcher() {
34+
3135
@Override
3236
public Mono<MatchResult> matches(PayloadExchange exchange) {
3337
return PayloadExchangeType.SETUP.equals(exchange.getType()) ? MatchResult.match()
3438
: MatchResult.notMatch();
3539
}
40+
3641
};
3742
}
3843

3944
public static PayloadExchangeMatcher anyRequest() {
4045
return new PayloadExchangeMatcher() {
46+
4147
@Override
4248
public Mono<MatchResult> matches(PayloadExchange exchange) {
4349
return exchange.getType().isRequest() ? MatchResult.match() : MatchResult.notMatch();
4450
}
51+
4552
};
4653
}
4754

4855
public static PayloadExchangeMatcher anyExchange() {
4956
return new PayloadExchangeMatcher() {
57+
5058
@Override
5159
public Mono<MatchResult> matches(PayloadExchange exchange) {
5260
return MatchResult.match();
5361
}
54-
};
55-
}
5662

57-
private PayloadExchangeMatchers() {
63+
};
5864
}
5965

6066
}

rsocket/src/main/java/org/springframework/security/rsocket/util/matcher/RoutePayloadExchangeMatcher.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,9 @@
2626
import org.springframework.util.Assert;
2727
import org.springframework.util.RouteMatcher;
2828

29+
// FIXME: Pay attention to the package this goes into. It requires spring-messaging for the MetadataExtractor.
30+
2931
/**
30-
* FIXME: Pay attention to the package this goes into. It requires spring-messaging for
31-
* the MetadataExtractor.
32-
*
3332
* @author Rob Winch
3433
* @since 5.2
3534
*/

0 commit comments

Comments
 (0)