JOSEException for javacallout policy for Apigee Edge

Hi,

We are trying to implement the JWT token validation of our own with java callout policy. We have developed our java code in the similar lines with apigee recommendation, but still not able to get any success.

We are getting the below error. We compare out project with apigee project "jwt_signed" present in github, both of them same version of nimbus jars etc. can anyone help us, what is issue about --

{ "fault": { "faultstring": "com/nimbusds/jose/JOSEException", "detail": { "errorcode": "Internal Server Error" } } }

Also wants to know how to diagnose the issue of java callout in apigee edge.

0 1 121
1 REPLY 1

Hi

Hmm, that's an unusual circumstance. How frustrating.

First, are you sure you have to write new code? The existing jwt_signed callout ought to work for you out of the box if you just want to verify a JWT. Is there a reason you feel that you need to write new code to accomplish your goal?

ok, second

It sounds to me that your new Java code is throwing an exception. If you examine the code in the jwt_signed callout from github, you'll see that the execute method has its entire body wrapped in a try...catch clause. Then, in the catch, there is some handling of the error, to aid in diagnostics such as in this case. Specifically, the code puts the stacktrace into a context variable. The code looks like this:

        try {
           // your logic goes here....
        }
        catch (Exception e) {
            // unhandled exceptions
            if (debug) { e.printStackTrace(); /* to MP system.log */ }
            String error = e.toString();
            msgCtxt.setVariable(varName("error"), error);
            int ch = error.indexOf(':');
            if (ch >= 0) {
                msgCtxt.setVariable(varName("reason"), error.substring(ch+2));
            }
            else {
                msgCtxt.setVariable(varName("reason"), error);
            }
            msgCtxt.setVariable(varName("isValid"), "false");
            msgCtxt.setVariable(varName("stacktrace"), ExceptionUtils.getStackTrace(e));
            return ExecutionResult.ABORT;
        }

Are you doing something similar in your code? If not, you should, then check the stacktrace and you will be able to determine exactly where the JOSEException is occurring. This is the first step to diagnosis.