use non-deprecated authenticate methods (#5852)

Signed-off-by: Sally MacFarlane <macfarla.github@gmail.com>
pull/5860/head
Sally MacFarlane 1 year ago committed by GitHub
parent 5cce89545e
commit 71853e3e1c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 11
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/authentication/DefaultAuthenticationService.java

@ -33,6 +33,9 @@ import io.vertx.core.json.JsonObject;
import io.vertx.ext.auth.JWTOptions;
import io.vertx.ext.auth.User;
import io.vertx.ext.auth.authentication.AuthenticationProvider;
import io.vertx.ext.auth.authentication.Credentials;
import io.vertx.ext.auth.authentication.TokenCredentials;
import io.vertx.ext.auth.authentication.UsernamePasswordCredentials;
import io.vertx.ext.auth.jwt.JWTAuth;
import io.vertx.ext.auth.jwt.JWTAuthOptions;
import io.vertx.ext.web.RoutingContext;
@ -166,7 +169,7 @@ public class DefaultAuthenticationService implements AuthenticationService {
private void login(
final RoutingContext routingContext, final AuthenticationProvider credentialAuthProvider) {
final JsonObject requestBody = routingContext.getBodyAsJson();
final JsonObject requestBody = routingContext.body().asJsonObject();
if (requestBody == null) {
routingContext
@ -181,8 +184,10 @@ public class DefaultAuthenticationService implements AuthenticationService {
final JsonObject authParams = new JsonObject();
authParams.put(USERNAME, requestBody.getValue(USERNAME));
authParams.put("password", requestBody.getValue("password"));
final Credentials credentials = new UsernamePasswordCredentials(authParams);
credentialAuthProvider.authenticate(
authParams,
credentials,
r -> {
if (r.failed()) {
routingContext
@ -227,7 +232,7 @@ public class DefaultAuthenticationService implements AuthenticationService {
try {
getJwtAuthProvider()
.authenticate(
new JsonObject().put("token", token),
new TokenCredentials(new JsonObject().put("token", token)),
r -> {
if (r.succeeded()) {
final Optional<User> user = Optional.ofNullable(r.result());

Loading…
Cancel
Save