soteria icon indicating copy to clipboard operation
soteria copied to clipboard

java.lang.NullPointerException in HttpServletRequestDelegator.getParameter(HttpServletRequestDelegator.java:160)

Open pdbs opened this issue 3 years ago • 1 comments

On an OIDC Callback i.e.

http://localhost:8080/MyApplication/index.html?code=0.AXMAlS8XEZqje0-SJMahHR5cJCFY7Ad5WTJDkKCbZUg-0LdzAH8....

the following line (160) in HttpServletRequestDelegator.java

    String[] values = requestData.getParameters().get(name);

throws a java.lang.NullPointerException when accessing a request parameter which is not in the GET request sent bei OIDC server, i.e.

request.getParameter("action")

Could this be fixed?

pdbs avatar Sep 28 '22 09:09 pdbs

By using an explicit callback servlet which does not use request.getParameter(... and redirects to the main application URL, there is no NPE anymore:

response.sendRedirect(request.getHeader("x-forwarded-proto") + "://" + request.getHeader("x-forwarded-host") + request.getContextPath());

Servlet is behind a reverse proxy, that's why the X-headers are used.

But maybe HttpServletRequestDelegator.getParameter should return null (just like in ServletRequest) when parameter name is not found.

pdbs avatar Nov 14 '22 18:11 pdbs