• Bechir Oueslati
  • NEWBIE
  • 5 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies
I was working on a trigger that change all contacts owners once their parent account owner is changed. Before deploying it in production, I realized that this is already the actual behavior. Was it added in the recent Spring 16 release?

Note: An idea was posted on this purpose https://success.salesforce.com/ideaView?id=08730000000XrJFAA0 and I think that it hasn't added to the roadmap.
Hi All,

I have created conneted app in one of our SFDC sandbox and tring to get the token but ended up with below error.
Please suggest.

Follewd the below link :
https://help.salesforce.com/HTViewHelpDoc?id=remoteaccess_oauth_jwt_flow.htm#create_token


Error : java.security.InvalidKeyException: No installed provider supports this key: (null)
    at java.security.Signature$Delegate.chooseProvider(Unknown Source)
    at java.security.Signature$Delegate.engineInitSign(Unknown Source)
    at java.security.Signature.initSign(Unknown Source)
    at JWTExample.main(JWTExample.java:45)


JAVA Class  code :
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.codec.binary.BaseNCodec;
import java.io.*;
import java.security.*;
import java.text.MessageFormat;  

public class JWTExample {

  public static void main(String[] args) {

    String header = "{\"alg\":\"RS256\"}";
    String claimTemplate = "'{'\"iss\": \"{0}\", \"sub\": \"{1}\", \"aud\": \"{2}\", \"exp\": \"{3}\"'}'";

    try {
      StringBuffer token = new StringBuffer();

      //Encode the JWT Header and add it to our string to sign
      token.append(Base64.encodeBase64URLSafeString(header.getBytes("UTF-8")));

      //Separate with a period
      token.append(".");

      //Create the JWT Claims Object
      String[] claimArray = new String[4];
      claimArray[0] = "client_id";
      claimArray[1] = "username";
      claimArray[2] = "https://test.salesforce.com";
      claimArray[3] = Long.toString( ( System.currentTimeMillis()/1000 ) + 300);
      MessageFormat claims;
      claims = new MessageFormat(claimTemplate);
      String payload = claims.format(claimArray);

      //Add the encoded claims object
      token.append(Base64.encodeBase64URLSafeString(payload.getBytes("UTF-8")));

      //Load the private key from a keystore
      KeyStore keystore = KeyStore.getInstance("JKS");
      keystore.load(new FileInputStream("C:/Users/gm/Downloads/Backup/00DQ000000GKQwv.jks"), "password1".toCharArray());
      PrivateKey privateKey = (PrivateKey) keystore.getKey("00DQ000000GKQwv.jks", "password1".toCharArray());

      //Sign the JWT Header + "." + JWT Claims Object
      //Signature signature = Signature.getInstance("SHA256withRSA");
      Signature signature = Signature.getInstance("SHA256withRSA");
      
      signature.initSign(privateKey);
      signature.update(token.toString().getBytes("UTF-8"));
      String signedPayload = Base64.encodeBase64URLSafeString(signature.sign());

      //Separate with a period
      token.append(".");

      //Add the encoded signature
      token.append(signedPayload);

      System.out.println(token.toString());

    } catch (Exception e) {
        e.printStackTrace();
    }
  }
}


Thanks,
GM
  • May 06, 2016
  • Like
  • 0