Browse Source

Fix SNAPSHOT builds

- Stop using deprecated RSocket APIs
- Update SNAPSHOT build to use Boot SNAPSHOT
pull/8962/head
Rob Winch 5 years ago
parent
commit
94cf4d1de7
  1. 2
      Jenkinsfile
  2. 14
      rsocket/src/main/java/org/springframework/security/rsocket/authentication/AuthenticationPayloadExchangeConverter.java
  3. 5
      rsocket/src/main/java/org/springframework/security/rsocket/core/PayloadInterceptorRSocket.java
  4. 4
      rsocket/src/main/java/org/springframework/security/rsocket/metadata/BearerTokenAuthenticationEncoder.java
  5. 4
      rsocket/src/main/java/org/springframework/security/rsocket/metadata/SimpleAuthenticationEncoder.java
  6. 4
      rsocket/src/test/java/org/springframework/security/rsocket/authentication/AuthenticationPayloadInterceptorTests.java

2
Jenkinsfile vendored

@ -89,7 +89,7 @@ try { @@ -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) {

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

@ -19,8 +19,8 @@ package org.springframework.security.rsocket.authentication; @@ -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 @@ -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 @@ -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);
}

5
rsocket/src/main/java/org/springframework/security/rsocket/core/PayloadInterceptorRSocket.java

@ -18,7 +18,6 @@ package org.springframework.security.rsocket.core; @@ -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; @@ -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;

4
rsocket/src/main/java/org/springframework/security/rsocket/metadata/BearerTokenAuthenticationEncoder.java

@ -18,7 +18,7 @@ package org.springframework.security.rsocket.metadata; @@ -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 @@ -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);
}

4
rsocket/src/main/java/org/springframework/security/rsocket/metadata/SimpleAuthenticationEncoder.java

@ -18,7 +18,7 @@ package org.springframework.security.rsocket.metadata; @@ -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 @@ -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);
}

4
rsocket/src/test/java/org/springframework/security/rsocket/authentication/AuthenticationPayloadInterceptorTests.java

@ -19,7 +19,7 @@ package org.springframework.security.rsocket.authentication; @@ -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 { @@ -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(),

Loading…
Cancel
Save