Reports drill link encryption parameters

|
Run Dry parameter template comes with its own parameters will be unified into a pool parameters to pass parameters to pass parameters pool ID through url, and not directly exposed directly to the parameters in the address bar. But in the report hyperlinks, we are usually good on the fight url to write a report drill, then drill the url will find all the show is on the outside, how to deal with it this url safe?

Java itself with this encode and decode functions, and hyperlink url Run Dry and can write an expression, so it can be implemented by a custom function.

Achieved First class two custom function MyEncode () and MyDecode ()

Most of these two classes with the same code are normal flow of acquisition parameters - extracted expression - the calculation expression - determines whether the empty types:

// determine the number of parameters

      if(this.paramList.size()< 1) {

           MessageManager mm = EngineMessage.get();

           throw****newReportError(“encrypt:”

                  + mm.getMessage(“function.missingParam”));

       }

       // Get the first argument, the default is an expression, the expression need to be calculated, the result is a function of the parameter values

       Expression param1 = (Expression)this.paramList.get(0);

      IF (the param1 == null ) {// determines whether the parameter is null

           MessageManager mm = EngineMessage.get();

           throw****newReportError(“encrypt:”

                  + mm.getMessage(“function.invalidParam”));

       }

       // calculate the first parameter value

       Object result1 = Variant2.getValue(param1.calculate(ctx, isInput),

              false, isInput);

       // The first parameter is determined whether the value is null

      if(result1 ==null) {

           return****null;

       }

      if(!(result1instanceofString)) {

           MessageManager mm = EngineMessage.get();

           throw****newReportError(“encrypt:”

                  + mm.getMessage(“function.paramTypeError”));

       }

In MyEncode class, we need to figure out parameter values ​​to encrypt:

BASE64Encoder base64 =newBASE64Encoder();

String value = base64.encode(result1.toString().getBytes());

In DeEncode class parameters necessary to decrypt the encrypted process:

BASE64Decoder base64 =newBASE64Decoder();

String value =null;

try{

    value =newString(base64.decodeBuffer(result1.toString()));

}catch(IOException e) {

    e.printStackTrace ();

}

Then customize function register, modify customFunctions.properties:

decode=0,com.runqian.MyDecode

encode=0,com.runqian.MyEncode

Finally, we design a report with drill-down capabilities through custom functions for encryption and decryption process parameters, as follows:

Hyperlinks to increase expression in cell A2:

“reportJsp/showReport.jsp?raq=demo.raq&arg=”+encode(A2)

Page we can see the need to pass parameters have been encrypted before.

       http://localhost:6001/demo/reportJsp/showReport.jsp?raq=demo.raq&arg=MTA1MzE=

Arg parameter is then increased in the drill table, add dynamic parameter decode (arg) as the filter conditions.

For example, a picture

This can be done url of encryption parameters.

This same method can also be used for a plurality of transmission parameters makes up the multi-arg be encrypted together encode the necessary parameters, and then to decode decrypted by the dynamic parameter, the parameter string is split into individual parameters.

|

Picture 1.png (29.58 KB, Downloads: 0)

Parameter value processing

Published 48 original articles · won praise 13 · views 20000 +

Guess you like

Origin blog.csdn.net/zozoxxma/article/details/103660063