- changed status to open
HTTPRequest.parse(URL httprequest)
I use Apache Wicket 7 and this sdk (latest version) to create oaut2 auth endpoint, example code as below
HttpServletRequest request = (HttpServletRequest) getRequest().getContainerRequest(); URI uri = new URI(AuthUtils.getFullURL(request)); final HTTPRequest httprequest = new HTTPRequest(Method.GET, uri.toURL());
and I got full url as below southernlight.common.AuthUtils - FULL URL : http://192.168.56.103/oauth2/azp?response_type=code&client_id=myid&redirect_uri=http%3A%2F%2F192.168.56.103%2Fclient%2Foauthreturn&scope=myscope&state=SzIeJwyhotHCYdzyPAgTSh56hUIOEn4yh-SwCvgbTE4]
when i trid to parse this url AuthorizationRequest authrequest = AuthorizationRequest.parse(httprequest);
exception raised Caused by: com.nimbusds.oauth2.sdk.ParseException: Missing URI query string at com.nimbusds.oauth2.sdk.AuthorizationRequest.parse(AuthorizationRequest.java:814) ~[oauth2-oidc-sdk-4.16.1.jar:4.16.1]
But, When I using AuthorizationRequest authrequest = AuthorizationRequest.parse(new URI(AuthUtils.getFullURL(request)));
It works fine.
And I checked the source of AutthorizationRequest, then found this method
808 public static AuthorizationRequest parse(final HTTPRequest httpRequest)
809 throws ParseException {
810
811 String query = httpRequest.getQuery();
812
813 if (query == null)
814 throw new ParseException("Missing URI query string");
815
816 try {
817 return parse(URIUtils.getBaseURI(httpRequest.getURL().toURI()), query);
818
819 } catch (URISyntaxException e) {
820
821 throw new ParseException(e.getMessage(), e);
822 }
823 }
824}
and trace the httpRequest.getQuery();
250 public String getQuery() {
251
252 return query;
253 }
as query = null so raise that exception.
May you check that, thanks.
Comments (4)
-
-
Please use the following:
HTTPRequest httpRequest = ServletUtils.createHTTPRequest(httpServletRequest);
This will parse the query string from the servlet request correctly.
-
reporter Great, it works. Thanks a lot.
-
- changed status to resolved
Yay! Happy coding :)
- Log in to comment
Thanks for reporting this, we'll try to replicate.