Skip to main content

Hi,



we are using java1.8 version and trying to get the Token using Java SDK , but we got the below exception.







above blog suggeste all the jar’s added.



Sample Code:


Path configPath = Paths.get(“config.json”);


try (BufferedReader reader = Files.newBufferedReader(configPath, Charset.forName(“UTF-8”))) {


BoxConfig boxConfig = BoxConfig.readFrom(reader);


BoxDeveloperEditionAPIConnection client = BoxDeveloperEditionAPIConnection.getAppEnterpriseConnection(boxConfig);



//Not able to get this token


System.out.println(client.getAccessToken());



}catch(Exception e){


System.out.println(“Error =”+e.getMessage());


}



This below exception, we are getting recently.



Exception in thread “main” com.box.sdk.BoxAPIException: Error parsing PKCS private key for Box Developer Edition.


at com.box.sdk.BoxDeveloperEditionAPIConnection.decryptPrivateKey(BoxDeveloperEditionAPIConnection.java:568)



Caused by: org.bouncycastle.pkcs.PKCSException: unable to read encrypted data: javax.crypto.BadPaddingException: pad block corrupted



Caused by: java.io.IOException: javax.crypto.BadPaddingException: pad block corrupted


at javax.crypto.CipherInputStream.getMoreData(CipherInputStream.java:128)


at javax.crypto.CipherInputStream.read(CipherInputStream.java:246)


at org.bouncycastle.util.io.Streams.pipeAll(Unknown Source)



Regards,


Srinivas.

Hi Srini, welcome to the forum.



Let me see if I can get the Java SDK folks to help with this question.



Cheers


Hi,


the way to resolve this issue is described in README.md: GitHub - box/box-java-sdk: The Box SDK for Java.


Best,


Lukasz


Hi Lukasz,



Thank you for the details , i will check it and implement it.



Regards,


Srinivas.


Hi Lsocha,



we had implemetned the changes suggested in this git link" GitHub - box/box-java-sdk: The Box SDK for Java. .



still we are gettting the same exception.


we came to know to fix this issue, we need to generate Custom decryption and configure it ?





FIPS 140-2 Compliance



How can we implement it Custom description for the box provided config.json file data?


How to know, what encoding format used to encript private key?


is there any example available to write Custom Decryption mentod for this Interface" IPrivateKeyDecryptor"


do we need to follow any Standards to implment Custom Description ?


Reply