Security: switch to IllegalArgumentException if request cannot be serialized
The commit switches the CreateTokenRequest and InvalidateTokenRequest to throw an IllegalArgumentException when the version the request is being serialized to does not support the request. This fixes test failures due to the use of the AssertingTransportInterceptor testing serialization with versions prior to 6.2. The IAE is an indication to the AssertingTranpsortInterceptor that the request does not support the version. Original commit: elastic/x-pack-elasticsearch@c73abf1bc0
This commit is contained in:
parent
ae1a90eba6
commit
a547049303
|
@ -142,7 +142,7 @@ public final class CreateTokenRequest extends ActionRequest {
|
||||||
out.writeOptionalString(refreshToken);
|
out.writeOptionalString(refreshToken);
|
||||||
} else {
|
} else {
|
||||||
if ("refresh_token".equals(grantType)) {
|
if ("refresh_token".equals(grantType)) {
|
||||||
throw new UnsupportedOperationException("a refresh request cannot be sent to an older version");
|
throw new IllegalArgumentException("a refresh request cannot be sent to an older version");
|
||||||
} else {
|
} else {
|
||||||
out.writeString(username);
|
out.writeString(username);
|
||||||
final byte[] passwordBytes = CharArrays.toUtf8Bytes(password.getChars());
|
final byte[] passwordBytes = CharArrays.toUtf8Bytes(password.getChars());
|
||||||
|
|
|
@ -74,7 +74,7 @@ public final class InvalidateTokenRequest extends ActionRequest {
|
||||||
if (out.getVersion().onOrAfter(Version.V_6_2_0)) {
|
if (out.getVersion().onOrAfter(Version.V_6_2_0)) {
|
||||||
out.writeVInt(tokenType.ordinal());
|
out.writeVInt(tokenType.ordinal());
|
||||||
} else if (tokenType == Type.REFRESH_TOKEN) {
|
} else if (tokenType == Type.REFRESH_TOKEN) {
|
||||||
throw new UnsupportedOperationException("refresh token invalidation cannot be serialized with version [" + out.getVersion() +
|
throw new IllegalArgumentException("refresh token invalidation cannot be serialized with version [" + out.getVersion() +
|
||||||
"]");
|
"]");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue