From a64212346d7d3182305cf3ae1089676ab7ac899f Mon Sep 17 00:00:00 2001 From: Roman Strobl Date: Wed, 20 Feb 2019 17:41:51 +0100 Subject: [PATCH] Backport fix of #65: Validation fails because of missing enclosing method --- .../app/dataadapter/controller/AuthenticationController.java | 5 ++--- .../dataadapter/controller/SMSAuthorizationController.java | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/powerauth-data-adapter/src/main/java/io/getlime/security/powerauth/app/dataadapter/controller/AuthenticationController.java b/powerauth-data-adapter/src/main/java/io/getlime/security/powerauth/app/dataadapter/controller/AuthenticationController.java index 0cc74641..701e76fd 100644 --- a/powerauth-data-adapter/src/main/java/io/getlime/security/powerauth/app/dataadapter/controller/AuthenticationController.java +++ b/powerauth-data-adapter/src/main/java/io/getlime/security/powerauth/app/dataadapter/controller/AuthenticationController.java @@ -38,7 +38,6 @@ import org.springframework.web.bind.annotation.*; import javax.validation.Valid; -import java.lang.invoke.MethodHandles; /** * Controller class which handles user authentication. @@ -87,8 +86,8 @@ private void initBinder(WebDataBinder binder) { @RequestMapping(value = "/authenticate", method = RequestMethod.POST) public @ResponseBody ObjectResponse authenticate(@Valid @RequestBody ObjectRequest request, BindingResult result) throws MethodArgumentNotValidException, DataAdapterRemoteException, AuthenticationFailedException { if (result.hasErrors()) { - // Call of getEnclosingMethod() on class found using MethodHandles.lookup() returns a reference to current method - MethodParameter methodParam = new MethodParameter(MethodHandles.lookup().lookupClass().getEnclosingMethod(),0); + // Call of getEnclosingMethod() on new object returns a reference to current method + MethodParameter methodParam = new MethodParameter(new Object(){}.getClass().getEnclosingMethod(), 0); logger.warn("The authenticate request failed due to validation errors"); throw new MethodArgumentNotValidException(methodParam, result); } diff --git a/powerauth-data-adapter/src/main/java/io/getlime/security/powerauth/app/dataadapter/controller/SMSAuthorizationController.java b/powerauth-data-adapter/src/main/java/io/getlime/security/powerauth/app/dataadapter/controller/SMSAuthorizationController.java index b2c4d660..3cf1b3f7 100644 --- a/powerauth-data-adapter/src/main/java/io/getlime/security/powerauth/app/dataadapter/controller/SMSAuthorizationController.java +++ b/powerauth-data-adapter/src/main/java/io/getlime/security/powerauth/app/dataadapter/controller/SMSAuthorizationController.java @@ -39,7 +39,6 @@ import org.springframework.web.bind.annotation.*; import javax.validation.Valid; -import java.lang.invoke.MethodHandles; /** * Controller class which handles SMS OTP authorization. @@ -92,8 +91,8 @@ private void initBinder(WebDataBinder binder) { @RequestMapping(value = "create", method = RequestMethod.POST) public @ResponseBody ObjectResponse createAuthorizationSMS(@Valid @RequestBody ObjectRequest request, BindingResult result) throws MethodArgumentNotValidException, DataAdapterRemoteException, SMSAuthorizationFailedException, InvalidOperationContextException { if (result.hasErrors()) { - // Call of getEnclosingMethod() on class found using MethodHandles.lookup() returns a reference to current method - MethodParameter methodParam = new MethodParameter(MethodHandles.lookup().lookupClass().getEnclosingMethod(),0); + // Call of getEnclosingMethod() on new object returns a reference to current method + MethodParameter methodParam = new MethodParameter(new Object(){}.getClass().getEnclosingMethod(), 0); logger.warn("The createAuthorizationSMS request failed due to validation errors"); throw new MethodArgumentNotValidException(methodParam, result); }