acciduck / jscep

Automatically exported from code.google.com/p/jscep
MIT License
0 stars 0 forks source link

getBytes in SCEPServlet doesn't work. #16

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
java.lang.NullPointerException
        at org.jscep.server.ScepServlet.getSignedData(ScepServlet.java:209)

According to the Java API you can either call the getInputStream OR one of the 
methods that return parameters but not both. Once you call one of the 
getParameter methods, the servlet parses the input stream to get the 
parameters. Once parsed, it's no longer available to the getInputStream method. 

You first use the getParameter method to get the OP_PARAM so when it tries to 
call the method GetBytes on the InputStream it returns null and thus you get 
the NPE.

What version of the product are you using? On what operating system?
This is happening to me on GlassFish 2.1.1, but AFAIK it shouldn't work on any 
container.

Original issue reported on code.google.com by hir...@gmail.com on 9 Jul 2010 at 5:41

GoogleCodeExporter commented 8 years ago

Original comment by davidgrant41 on 2 Nov 2010 at 4:51

GoogleCodeExporter commented 8 years ago
Since the parameters we're interested  in are in the query string, I guess we 
can read the body into a byte array, and then make the call to retrieve the 
operation parameter.

Original comment by davidgrant41 on 2 Nov 2010 at 5:01

GoogleCodeExporter commented 8 years ago
Hiro,

I have committed some changes to get this working, alongside lots of other 
changes which should hopefully make working with the server-side component a 
bit more intuitive, and have added a few tests to make sure everything is 
working properly.

Can you try building from the trunk to see how you get on?

Original comment by davidgrant41 on 3 Nov 2010 at 2:00

GoogleCodeExporter commented 8 years ago
Hi David, sorry but I don't have any of that testing code on hand. I'm using 
EJBCA as my SCEP server now and haven't had any problems with the client.

Good luck

Original comment by hir...@gmail.com on 9 Nov 2010 at 7:19

GoogleCodeExporter commented 8 years ago
I had problem with Jetty 7. Workaround:

        final String operation;
        final String message;

        final String queryString = req.getQueryString();
        if (queryString != null) {
            final Map<String, String> params = new HashMap<String, String>();
            for (final String param : queryString.split("&")) {
                final String[] pair = param.split("=");
                final String key = URLDecoder.decode(pair[0], "UTF-8");
                final String value = pair.length == 1 ? "" : URLDecoder.decode(pair[1], "UTF-8");
                params.put(key, value);
            }
            operation = params.get("operation");
            message = params.get("message");
        } else {
            operation = req.getParameter("operation");
            message = req.getParameter("message");
        }

Original comment by m.zd...@gmail.com on 9 Nov 2010 at 7:40

GoogleCodeExporter commented 8 years ago
In response to comment 5, have you tried the servlet from the latest release?  
When using test-jetty-servlet v7, I no longer get a NPE when handling a POST 
request with the recent fixes.

Original comment by *dgr...@ubq.thrupoint.net on 9 Nov 2010 at 11:21

GoogleCodeExporter commented 8 years ago

Original comment by da...@grant.org.uk on 13 Jul 2011 at 6:37

GoogleCodeExporter commented 8 years ago

Original comment by da...@grant.org.uk on 13 Jul 2011 at 6:42

GoogleCodeExporter commented 8 years ago

Original comment by da...@grant.org.uk on 21 Aug 2012 at 12:06