Fix SNAPSHOT builds

- Stop using deprecated RSocket APIs
- Update SNAPSHOT build to use Boot SNAPSHOT
This commit is contained in:
Rob Winch 2020-08-10 11:35:15 -05:00
parent 12a8795c3d
commit 94cf4d1de7
6 changed files with 16 additions and 17 deletions

2
Jenkinsfile vendored
View File

@ -89,7 +89,7 @@ try {
"GRADLE_ENTERPRISE_CACHE_USERNAME=${GRADLE_ENTERPRISE_CACHE_USERNAME}",
"GRADLE_ENTERPRISE_CACHE_PASSWORD=${GRADLE_ENTERPRISE_CACHE_PASSWORD}",
"GRADLE_ENTERPRISE_ACCESS_KEY=${GRADLE_ENTERPRISE_ACCESS_KEY}"]) {
sh "./gradlew test -PforceMavenRepositories=snapshot -PspringVersion='5.+' -PreactorVersion=20+ -PspringDataVersion=Lovelace-BUILD-SNAPSHOT -PrsocketVersion=1.1.0-SNAPSHOT -PlocksDisabled --stacktrace"
sh "./gradlew test -PforceMavenRepositories=snapshot -PspringVersion='5.+' -PreactorVersion='20+' -PspringDataVersion='Lovelace-BUILD-SNAPSHOT' -PrsocketVersion=1.1.0-SNAPSHOT -PspringBootVersion=2.4.0-SNAPSHOT -PlocksDisabled --stacktrace"
}
}
} catch(Exception e) {

View File

@ -19,8 +19,8 @@ package org.springframework.security.rsocket.authentication;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufAllocator;
import io.rsocket.metadata.WellKnownMimeType;
import io.rsocket.metadata.security.AuthMetadataFlyweight;
import io.rsocket.metadata.security.WellKnownAuthType;
import io.rsocket.metadata.AuthMetadataCodec;
import io.rsocket.metadata.WellKnownAuthType;
import org.springframework.core.codec.ByteArrayDecoder;
import org.springframework.messaging.rsocket.DefaultMetadataExtractor;
import org.springframework.messaging.rsocket.MetadataExtractor;
@ -68,10 +68,10 @@ public class AuthenticationPayloadExchangeConverter implements PayloadExchangeAu
return null;
}
ByteBuf rawAuthentication = ByteBufAllocator.DEFAULT.buffer().writeBytes(authenticationMetadata);
if (!AuthMetadataFlyweight.isWellKnownAuthType(rawAuthentication)) {
if (!AuthMetadataCodec.isWellKnownAuthType(rawAuthentication)) {
return null;
}
WellKnownAuthType wellKnownAuthType = AuthMetadataFlyweight.decodeWellKnownAuthType(rawAuthentication);
WellKnownAuthType wellKnownAuthType = AuthMetadataCodec.readWellKnownAuthType(rawAuthentication);
if (WellKnownAuthType.SIMPLE.equals(wellKnownAuthType)) {
return simple(rawAuthentication);
} else if (WellKnownAuthType.BEARER.equals(wellKnownAuthType)) {
@ -81,15 +81,15 @@ public class AuthenticationPayloadExchangeConverter implements PayloadExchangeAu
}
private Authentication simple(ByteBuf rawAuthentication) {
ByteBuf rawUsername = AuthMetadataFlyweight.decodeUsername(rawAuthentication);
ByteBuf rawUsername = AuthMetadataCodec.readUsername(rawAuthentication);
String username = rawUsername.toString(StandardCharsets.UTF_8);
ByteBuf rawPassword = AuthMetadataFlyweight.decodePassword(rawAuthentication);
ByteBuf rawPassword = AuthMetadataCodec.readPassword(rawAuthentication);
String password = rawPassword.toString(StandardCharsets.UTF_8);
return new UsernamePasswordAuthenticationToken(username, password);
}
private Authentication bearer(ByteBuf rawAuthentication) {
char[] rawToken = AuthMetadataFlyweight.decodeBearerTokenAsCharArray(rawAuthentication);
char[] rawToken = AuthMetadataCodec.readBearerTokenAsCharArray(rawAuthentication);
String token = new String(rawToken);
return new BearerTokenAuthenticationToken(token);
}

View File

@ -18,7 +18,6 @@ package org.springframework.security.rsocket.core;
import io.rsocket.Payload;
import io.rsocket.RSocket;
import io.rsocket.ResponderRSocket;
import io.rsocket.util.RSocketProxy;
import org.reactivestreams.Publisher;
import org.springframework.security.rsocket.api.PayloadExchangeType;
@ -31,11 +30,11 @@ import reactor.util.context.Context;
import java.util.List;
/**
* Combines the {@link PayloadInterceptor} with a {@link ResponderRSocket}
* Combines the {@link PayloadInterceptor} with an {@link RSocketProxy}
* @author Rob Winch
* @since 5.2
*/
class PayloadInterceptorRSocket extends RSocketProxy implements ResponderRSocket {
class PayloadInterceptorRSocket extends RSocketProxy {
private final List<PayloadInterceptor> interceptors;
private final MimeType metadataMimeType;

View File

@ -18,7 +18,7 @@ package org.springframework.security.rsocket.metadata;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufAllocator;
import io.rsocket.metadata.security.AuthMetadataFlyweight;
import io.rsocket.metadata.AuthMetadataCodec;
import org.reactivestreams.Publisher;
import org.springframework.core.ResolvableType;
import org.springframework.core.codec.AbstractEncoder;
@ -64,7 +64,7 @@ public class BearerTokenAuthenticationEncoder extends
String token = credentials.getToken();
NettyDataBufferFactory factory = nettyFactory(bufferFactory);
ByteBufAllocator allocator = factory.getByteBufAllocator();
ByteBuf simpleAuthentication = AuthMetadataFlyweight
ByteBuf simpleAuthentication = AuthMetadataCodec
.encodeBearerMetadata(allocator, token.toCharArray());
return factory.wrap(simpleAuthentication);
}

View File

@ -18,7 +18,7 @@ package org.springframework.security.rsocket.metadata;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufAllocator;
import io.rsocket.metadata.security.AuthMetadataFlyweight;
import io.rsocket.metadata.AuthMetadataCodec;
import org.reactivestreams.Publisher;
import org.springframework.core.ResolvableType;
import org.springframework.core.codec.AbstractEncoder;
@ -67,7 +67,7 @@ public class SimpleAuthenticationEncoder extends
String password = credentials.getPassword();
NettyDataBufferFactory factory = nettyFactory(bufferFactory);
ByteBufAllocator allocator = factory.getByteBufAllocator();
ByteBuf simpleAuthentication = AuthMetadataFlyweight
ByteBuf simpleAuthentication = AuthMetadataCodec
.encodeSimpleMetadata(allocator, username.toCharArray(), password.toCharArray());
return factory.wrap(simpleAuthentication);
}

View File

@ -19,7 +19,7 @@ package org.springframework.security.rsocket.authentication;
import io.netty.buffer.ByteBufAllocator;
import io.netty.buffer.CompositeByteBuf;
import io.rsocket.Payload;
import io.rsocket.metadata.CompositeMetadataFlyweight;
import io.rsocket.metadata.CompositeMetadataCodec;
import io.rsocket.metadata.WellKnownMimeType;
import io.rsocket.util.DefaultPayload;
import org.junit.Test;
@ -132,7 +132,7 @@ public class AuthenticationPayloadInterceptorTests {
ByteBufAllocator allocator = ByteBufAllocator.DEFAULT;
CompositeByteBuf metadata = allocator.compositeBuffer();
CompositeMetadataFlyweight.encodeAndAddMetadata(
CompositeMetadataCodec.encodeAndAddMetadata(
metadata, allocator, mimeType.toString(), NettyDataBufferFactory.toByteBuf(dataBuffer));
return DefaultPayload.create(allocator.buffer(),