mirror of
https://github.com/spring-projects/spring-security.git
synced 2025-07-02 00:32:15 +00:00
Release ByteBuf
Closes gh-9661
This commit is contained in:
parent
c8b6dc390d
commit
8ab7a27a20
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2019 the original author or authors.
|
* Copyright 2019-2021 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -67,17 +67,23 @@ public class AuthenticationPayloadExchangeConverter implements PayloadExchangeAu
|
|||||||
if (authenticationMetadata == null) {
|
if (authenticationMetadata == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
ByteBuf rawAuthentication = ByteBufAllocator.DEFAULT.buffer().writeBytes(authenticationMetadata);
|
ByteBuf rawAuthentication = ByteBufAllocator.DEFAULT.buffer();
|
||||||
if (!AuthMetadataFlyweight.isWellKnownAuthType(rawAuthentication)) {
|
try {
|
||||||
return null;
|
rawAuthentication.writeBytes(authenticationMetadata);
|
||||||
|
if (!AuthMetadataFlyweight.isWellKnownAuthType(rawAuthentication)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
WellKnownAuthType wellKnownAuthType = AuthMetadataFlyweight.decodeWellKnownAuthType(rawAuthentication);
|
||||||
|
if (WellKnownAuthType.SIMPLE.equals(wellKnownAuthType)) {
|
||||||
|
return simple(rawAuthentication);
|
||||||
|
} else if (WellKnownAuthType.BEARER.equals(wellKnownAuthType)) {
|
||||||
|
return bearer(rawAuthentication);
|
||||||
|
}
|
||||||
|
throw new IllegalArgumentException("Unknown Mime Type " + wellKnownAuthType);
|
||||||
}
|
}
|
||||||
WellKnownAuthType wellKnownAuthType = AuthMetadataFlyweight.decodeWellKnownAuthType(rawAuthentication);
|
finally {
|
||||||
if (WellKnownAuthType.SIMPLE.equals(wellKnownAuthType)) {
|
rawAuthentication.release();
|
||||||
return simple(rawAuthentication);
|
|
||||||
} else if (WellKnownAuthType.BEARER.equals(wellKnownAuthType)) {
|
|
||||||
return bearer(rawAuthentication);
|
|
||||||
}
|
}
|
||||||
throw new IllegalArgumentException("Unknown Mime Type " + wellKnownAuthType);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Authentication simple(ByteBuf rawAuthentication) {
|
private Authentication simple(ByteBuf rawAuthentication) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user