Decryption error in IDeal module

3
I upgraded my project from Mx 5.12 to Mx 7.6.0. I had some troubles with XML to domain mappings, but they have seen solved. I also experienced some problems in XMLMessageSign with BouncyCastle that has been solved as well. So far I can start a transaction and do a successful payment with IDeal, but when the deeplink (IDEAL.DeepLinkMicro) is triggered to decode the InputString I receive the error "De transactie is niet gevonden. Uw wordt terug geleid naar de webshop."   com.mendix.core.CoreException: com.mendix.core.CoreRuntimeException: com.mendix.systemwideinterfaces.MendixRuntimeException: com.mendix.core.CoreException: Er is een fout ontstaan in het systeem at com.mendix.basis.component.InternalCore.execute(InternalCore.java:581) Caused by: com.mendix.core.CoreRuntimeException: com.mendix.systemwideinterfaces.MendixRuntimeException: com.mendix.core.CoreException: Er is een fout ontstaan in het systeem at com.mendix.basis.actionmanagement.ActionManager.executeSync(ActionManager.java:195) Caused by: com.mendix.systemwideinterfaces.MendixRuntimeException: com.mendix.core.CoreException: Er is een fout ontstaan in het systeem at com.mendix.util.classloading.Runner.doRunUsingClassLoaderOf(Runner.java:37) Caused by: com.mendix.core.CoreException: Er is een fout ontstaan in het systeem at ideal.actions.InputText_Decode.DecryptText(InputText_Decode.java:148) Caused by: javax.crypto.BadPaddingException: Decryption error at sun.security.rsa.RSAPadding.unpadV15(RSAPadding.java:380) at sun.security.rsa.RSAPadding.unpad(RSAPadding.java:291) at com.sun.crypto.provider.RSACipher.doFinal(RSACipher.java:356) at com.sun.crypto.provider.RSACipher.engineDoFinal(RSACipher.java:389) at javax.crypto.Cipher.doFinal(Cipher.java:2165) at ideal.actions.InputText_Decode.DecryptText(InputText_Decode.java:144) at ideal.actions.InputText_Decode.executeAction(InputText_Decode.java:63) at ideal.actions.InputText_Decode.executeAction(InputText_Decode.java:26) at com.mendix.systemwideinterfaces.core.UserAction.execute(UserAction.java:50) at com.mendix.basis.actionmanagement.CoreActionHandlerImpl.doCall(CoreActionHandlerImpl.scala:76) at com.mendix.basis.actionmanagement.CoreActionHandlerImpl.call(CoreActionHandlerImpl.scala:55) at com.mendix.core.actionmanagement.CoreAction.call(CoreAction.java:51) at com.mendix.basis.actionmanagement.ActionManager$1.execute(ActionManager.java:186) at com.mendix.util.classloading.Runner.doRunUsingClassLoaderOf(Runner.java:33) at com.mendix.basis.actionmanagement.ActionManager.executeSync(ActionManager.java:191) at com.mendix.basis.component.InternalCore.execute(InternalCore.java:577) at com.mendix.modules.microflowengine.actions.actioncall.JavaAction.execute(JavaAction.scala:60) at com.mendix.modules.microflowengine.microflow.impl.MicroflowObject.execute(MicroflowObject.java:47) at com.mendix.modules.microflowengine.microflow.impl.MicroflowImpl.executeAfterBreakingIfNecessary(MicroflowImpl.java:200) at com.mendix.modules.microflowengine.microflow.impl.MicroflowImpl.executeAction(MicroflowImpl.java:157) at com.mendix.systemwideinterfaces.core.UserAction.execute(UserAction.java:50) at com.mendix.basis.actionmanagement.CoreActionHandlerImpl.doCall(CoreActionHandlerImpl.scala:76) at com.mendix.basis.actionmanagement.CoreActionHandlerImpl.call(CoreActionHandlerImpl.scala:55) at com.mendix.core.actionmanagement.CoreAction.call(CoreAction.java:51) at com.mendix.basis.actionmanagement.ActionManager$1.execute(ActionManager.java:186) at com.mendix.util.classloading.Runner.doRunUsingClassLoaderOf(Runner.java:33) at com.mendix.basis.actionmanagement.ActionManager.executeSync(ActionManager.java:191) at com.mendix.basis.component.InternalCore.execute(InternalCore.java:546) at com.mendix.basis.component.InternalCore.execute(InternalCore.java:561) at com.mendix.core.Core.execute(Core.java:214) at deeplink.actions.ExecuteDeeplink.executeAction(ExecuteDeeplink.java:99) at deeplink.actions.ExecuteDeeplink.executeAction(ExecuteDeeplink.java:31) at com.mendix.systemwideinterfaces.core.UserAction.execute(UserAction.java:50) at com.mendix.basis.actionmanagement.CoreActionHandlerImpl.doCall(CoreActionHandlerImpl.scala:76) at com.mendix.basis.actionmanagement.CoreActionHandlerImpl.call(CoreActionHandlerImpl.scala:55) at com.mendix.core.actionmanagement.CoreAction.call(CoreAction.java:51) at com.mendix.basis.actionmanagement.ActionManager$1.execute(ActionManager.java:186) at com.mendix.util.classloading.Runner.doRunUsingClassLoaderOf(Runner.java:33) at com.mendix.basis.actionmanagement.ActionManager.executeSync(ActionManager.java:191) at com.mendix.basis.component.InternalCore.execute(InternalCore.java:577) at com.mendix.modules.microflowengine.actions.actioncall.JavaAction.execute(JavaAction.scala:60) at com.mendix.modules.microflowengine.microflow.impl.MicroflowObject.execute(MicroflowObject.java:47) at com.mendix.modules.microflowengine.microflow.impl.MicroflowImpl.executeAfterBreakingIfNecessary(MicroflowImpl.java:200) at com.mendix.modules.microflowengine.microflow.impl.MicroflowImpl.executeAction(MicroflowImpl.java:157) at com.mendix.systemwideinterfaces.core.UserAction.execute(UserAction.java:50) at com.mendix.basis.actionmanagement.CoreActionHandlerImpl.doCall(CoreActionHandlerImpl.scala:76) at com.mendix.basis.actionmanagement.CoreActionHandlerImpl.call(CoreActionHandlerImpl.scala:55) at com.mendix.core.actionmanagement.CoreAction.call(CoreAction.java:51) at com.mendix.basis.actionmanagement.ActionManager$1.execute(ActionManager.java:186) at com.mendix.util.classloading.Runner.doRunUsingClassLoaderOf(Runner.java:33) at com.mendix.basis.actionmanagement.ActionManager.executeSync(ActionManager.java:191) at com.mendix.basis.component.InternalCore.executeSync(InternalCore.java:655) at com.mendix.modules.microflowengine.actions.SubMicroflowAction.execute(SubMicroflowAction.scala:43) at com.mendix.modules.microflowengine.microflow.impl.MicroflowObject.execute(MicroflowObject.java:47) at com.mendix.modules.microflowengine.microflow.impl.MicroflowImpl.executeAfterBreakingIfNecessary(MicroflowImpl.java:200) at com.mendix.modules.microflowengine.microflow.impl.MicroflowImpl.executeAction(MicroflowImpl.java:157) at com.mendix.systemwideinterfaces.core.UserAction.execute(UserAction.java:50) at com.mendix.basis.actionmanagement.CoreActionHandlerImpl.doCall(CoreActionHandlerImpl.scala:76) at com.mendix.basis.actionmanagement.CoreActionHandlerImpl.call(CoreActionHandlerImpl.scala:55) at com.mendix.core.actionmanagement.CoreAction.call(CoreAction.java:51) at com.mendix.basis.actionmanagement.ActionManager$1.execute(ActionManager.java:186) at com.mendix.util.classloading.Runner.doRunUsingClassLoaderOf(Runner.java:33) at com.mendix.basis.actionmanagement.ActionManager.executeSync(ActionManager.java:191) at com.mendix.basis.component.InternalCore.execute(InternalCore.java:577) at com.mendix.webui.actions.microflow.GoHome$.go(ShowHomePageAction.scala:40) at com.mendix.webui.actions.client.GetSessionDataAction.execute(GetSessionDataAction.scala:106) at com.mendix.webui.requesthandling.ClientRequestHandler$$anonfun$handleRequest$1.apply$mcV$sp(ClientRequestHandler.scala:315) at com.mendix.webui.requesthandling.ClientRequestHandler$$anonfun$handleRequest$1.apply(ClientRequestHandler.scala:300) at com.mendix.webui.requesthandling.ClientRequestHandler$$anonfun$handleRequest$1.apply(ClientRequestHandler.scala:300) at com.mendix.basis.actionmanagement.IMonitoredAction$$anon$1.execute(IMonitoredAction.scala:47) at com.mendix.util.classloading.Runner.doRunUsingClassLoaderOf(Runner.java:33) at com.mendix.basis.actionmanagement.IMonitoredAction$class.monitor(IMonitoredAction.scala:49) at com.mendix.webui.requesthandling.ClientRequestHandler$ClientMonitoredAction.monitor(ClientRequestHandler.scala:418) at com.mendix.webui.requesthandling.ClientRequestHandler.handleRequest(ClientRequestHandler.scala:300) at com.mendix.webui.requesthandling.ClientRequestHandler.handleActionWithSessionRequired(ClientRequestHandler.scala:238) at com.mendix.webui.requesthandling.ClientRequestHandler.handleAction(ClientRequestHandler.scala:200) at com.mendix.webui.requesthandling.ClientRequestHandler.liftedTree1$1(ClientRequestHandler.scala:104) at com.mendix.webui.requesthandling.ClientRequestHandler.processRequest(ClientRequestHandler.scala:96) at com.mendix.externalinterface.connector.RequestHandler.doProcessRequest(RequestHandler.java:40) at com.mendix.external.connector.MxRuntimeConnector$1.execute(MxRuntimeConnector.java:70) at com.mendix.external.connector.MxRuntimeConnector$1.execute(MxRuntimeConnector.java:67) at com.mendix.util.classloading.Runner.doRunUsingClassLoaderOf(Runner.java:33) at com.mendix.external.connector.MxRuntimeConnector.processRequest(MxRuntimeConnector.java:73) at com.mendix.basis.impl.MxRuntimeImpl.processRequest(MxRuntimeImpl.java:876) at com.mendix.m2ee.appcontainer.server.handler.RuntimeHandler.handle(RuntimeHandler.java:41) at org.eclipse.jetty.server.handler.HandlerList.handle(HandlerList.java:52) at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116) at org.eclipse.jetty.server.Server.handle(Server.java:368) at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:489) at org.eclipse.jetty.server.AbstractHttpConnection.content(AbstractHttpConnection.java:953) at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.content(AbstractHttpConnection.java:1014) at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:861) at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:240) at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82) at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:628) at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:52) at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608) at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543) at java.lang.Thread.run(Thread.java:748)  
asked
1 answers
3

Hi

in InputText_Decode.java

please replace the:

import org.apache.commons.codec.binary.Base64;
to:
import java.util.Base64;

 

then change

        // Decrypt the Text
        try
        {
            // Decode the base64
            byte[] baseDecode = Base64.decodeBase64(parseStripes(InputText).getBytes());
            // Initialize a cipher to decrypt the text.
            Cipher cipher = Cipher.getInstance(certificate.getPublicKey().getAlgorithm());
            cipher.init(Cipher.DECRYPT_MODE, certificate);
            // Decrypt and return text.
            return new String(cipher.doFinal(baseDecode));
        } catch (Exception ex)

 

to;

// Decrypt the Text
        try
        {
            // Decode the base64
            //byte[] baseDecode = Base64.decodeBase64(parseStripes(InputText).getBytes());
        	//Updated the Base64 encoding from apache to java. (due to java 1.8)
            byte[] baseDecode = Base64.getDecoder().decode(parseStripes(URLEncoder.encode(InputText)));
            // Initialize a cipher to decrypt the text.
            Cipher cipher = Cipher.getInstance(certificate.getPublicKey().getAlgorithm());
            cipher.init(Cipher.DECRYPT_MODE, certificate);
            // Decrypt and return text.
            return new String(cipher.doFinal(baseDecode));
        } catch (Exception ex)

 

This will fix the issue. (Thanks to my colleague Diego who helped me with this)

answered