Search code examples
yodlee

Yodlee REST api addSiteAccount1 exception IncompleteArgumentException


I have code to addSiteAccount1 for a cobUser, user, siteId, userName, password.

This code adds the site account correctly for me in the dev environment ie I get a valid response and can continue (note this is for DAG Bank).

However in the staging environment the addSiteAccount returns me an exception (note this is for siteId 15798).

exceptionType: com.yodlee.core.IncompleteArgumentException referenceCode: _xxxxxxx message: 'Decryption failure for FieldInfo:FieldInfoSingle:


Solution

  • Yodlee has implemented PKI to enhance current security measures further. It seems like your staging environment is enabled with PKI feature. Once this is enabled Yodlee is expecting you to send credentials in encrypted form. This means before calling addSiteAccount1 API and others APIs like putMFARequest and updateCredentials you need to encrypt the value of username/password and MFA information and then send it instead of sending it as a plaintext like you are doing right now. Or else you can ask Yodlee support team to disable PKI feature in your staging environment.

    To get public key for your environment you can call getPublicKeyDetails API Sub- URL: jsonsdk/DataEncryptionService/getPublicKeyDetails

    You have to pass cobSessionToken as a parameter and this is a HTTP POST call.

    EDIT-1(Added code in Java for encrypting values) Here is the code in Java about how to encrypt, just for reference:-

    public static String encrypt(String plainText) throws Exception
    {
    
        Security.addProvider(new BouncyCastleProvider());
        String pub = "-----BEGIN PUBLIC KEY-----"+
                "\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAtUS7ZJpnbcu8B+mfGrr0Gz6A23lS893mEFNnuR+frbtWDsoIHTfN4yhfbslkzsAMp3ENvM6Ic/0nHEvftrZxFXSrN7n3xZ+mdzOV/u8rqZoB7MEu6mZvdg3zfj7dGglq/fqlYxzHLlxDHjeCrY0dSD0ZAX1zCm3IZ0ufbMBqTrsSaHAuDlIXaQlJXmz3/Y+YfynJZXth/ats1gTBQhMIU9lWutMa4iKkeehn+P9ja4pC9NUlB9W4pojF2Qs+pY4kgTb9+SP8WjnhoSAmJMQGbYwY3HOZyfuOqAmdjoh9Y0LEZ3tq5NGD0b+T7L+P/FuIzvjYZYq6g/FaWaPcVrVLpwIDAQAB"+
                "\n-----END PUBLIC KEY-----";
        System.out.println(pub);
        String strt= pub;
        StringReader fileReader= new StringReader(strt); 
        PEMReader pemReader= new PEMReader(fileReader);
        PublicKey pk= (PublicKey)pemReader.readObject();
    
        Cipher c = Cipher.getInstance(RSA_ECB_PKCS5);
        PublicKey publicKey = pk;
        c.init(Cipher.ENCRYPT_MODE, transformKey(publicKey,     
        "RSA", new BouncyCastleProvider()));
        byte[] encValue= new byte[0];
        try {
            encValue = c.doFinal(plainText.getBytes());
        } catch (IllegalBlockSizeException e) {
            e.printStackTrace();
        } catch (BadPaddingException e) {
            e.printStackTrace();
        }
        String encrypted = DatatypeConverter.printHexBinary(encValue);  
        System.out.println("Encrypted value: "+encrypted);
        return encrypted;
    }