Advertisement
Guest User

Untitled

a guest
Jan 31st, 2017
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1. public static void tls(String tls){
  2. SSLContext context;
  3.  
  4. try {
  5. System.out.println(SSLContext.getDefault().getProtocol());
  6. context = SSLContext.getInstance(tls);
  7. context.init(null, null, null);
  8. System.out.println(SSLContext.getDefault().getProtocol());
  9. System.setProperty("https.protocols", tls);
  10. SSLContext.setDefault(context);
  11. System.out.println(SSLContext.getDefault().getProtocol());
  12. } catch (NoSuchAlgorithmException e) {
  13. e.printStackTrace();
  14. }
  15. }`
  16.  
  17. public static void login(){
  18. try {
  19.  
  20. System.out.println("login()"+SSLContext.getDefault().getProtocol());
  21. String username = "userName";
  22. String password = "pass";
  23. String authEndPoint = "https://login.salesforce.com/services/Soap/u/8.0/";
  24. SoapBindingStub binding = null;
  25. binding = (SoapBindingStub)new SforceServiceLocator().getSoap();
  26. binding._setProperty(SoapBindingStub.ENDPOINT_ADDRESS_PROPERTY, authEndPoint);
  27. LoginResult rs = null;
  28. rs = binding.login(username, password);
  29. GetUserInfoResult userInfo =rs.getUserInfo();
  30. binding._setProperty(SoapBindingStub.ENDPOINT_ADDRESS_PROPERTY, rs.getServerUrl());
  31. } catch (RemoteException e) {
  32. System.out.println(e.getMessage());
  33. } catch (Exception e) {
  34. e.printStackTrace();
  35. }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement