function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
dmorsedmorse 

Session Id

Hi,

My application should allow to SFDC user to be connected directly. So I need to check if it is a valid SFDC user. I do not want test and know his login and password. Test the SFDC session id of the user seem to be a good test. If the user has a session valid, he is connected, so he can access to my application.

But, I met a SSL exception when I tried to run the code Invalid connection from web intergation link. Cannot verify sessionId is correct: ; nested exception is:
 javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: No trusted certificate found

After searching in the sforce community, I found this solution :  upgrade to the latest JRE solved the problem. I have uninstalled my previous java version and reinstalled the latest J2SDK.
And now, I am using the J2RE, Standard Edition <build 1.4.2_05-b04> but I already have the error.
 
Remark: Previously I have succeeded to run the pre-compiled sample in the Java Getting Started Package (sforce 4.0)
 1. Login Only
 2. Create Account
 3. Create Contact
 4. Create Task
 5. Run Query
 6. Run Retrieve
 ...
 
Hope I have been clearer. Appreciate your help.
 
Thanks,
Laurent
 
Note : This is the code :
 
VerifySessionId(String sfdcSessionId) {
 
//Initialize the binding stub
SoapBindingStub binding = null;
try
{
 binding = (SoapBindingStub)new SforceServiceLocator().getSoap();
}
catch(Exception e)
{
 System.out.println(e.getMessage());
}
 
//Create a new session header object and add the session id
_SessionHeader sh = new _SessionHeader();
sh.setSessionId(sfdcSessionId);
//Set the session header for subsequent call authentication
binding.setHeader("SforceService", "SessionHeader", sh);
 
//Now try to actually do something with the API
try
{
 //Retrieve the current system timestamp from the sforce Web service
 GetServerTimestampResult now = binding.getServerTimestamp();
 if(now == null)
  System.out.println("Cannot determine sforce server timestamp. User may be invalid");
 else
  System.out.println("Valid sessionId connection from web integration link at "+now.getTimestamp().getTime  ());
}
catch(Exception e)
{
 System.out.println("Invalid connection from web intergation link. Cannot verify sessionId is correct:  "+e.getMessage());
}
}
Venk_ModelMetriVenk_ModelMetri

You are using Web Integration Link. So, are you using an applet embedded in a SControl? If so, you need to sign the applet.

DevAngelDevAngel

Hi laurent,

So, one issue is that you are using the default endpoint for the getServerTimestamp call.  You should be using the url returned from the login call.  I know, you are not doing a login call so how do you get that url?  I guess the answer is from the same "place" that you are getting the session id.

Second, the quickstart has an mistake in the set header part of the login.  The "SforceService" uri, although I believe it works for SessionHeader, is incorrect.  For header additions use the following snippet:

binding.setHeader(new SforceServiceLocator().getServiceName().getNamespaceURI(), "SessionHeader", sh);

Now, to your SSL issue.  Most developers have more than one JDK on their machines.  The JDK being used by the compiled version is probably different from the one in your development environment.  Make sure that you have installed the updated certificates in all JDKs on your system.

Cheers

dmorsedmorse
Thanks you DevAngel, Venk_ModelMetri.