Showing posts with label Integration. Show all posts
Showing posts with label Integration. Show all posts

Friday, 22 March 2013

Webservices integration, using certificates to increase security (SSL).

What are SSL Certificates and how to use them? How to use SSL certificates to communicate to external secure webservices?
Types of certificates:
There are two types of certificates. In a two-way SSL connection, both certificates must exist:
  • Server certificate
  • Client Certificate
Server Certificate:
  • This certifies the web server
  • Customer has to pay for this certificate to their certification agency.
  • We do not care about this certificate on setup, just on execution.
  • This certificate must reside on their server.
  • File extension is usually .cer
  • Certificate must be signed by an approved CA (Certificate Authority), you can find a list of current CAs here: http://wiki.developerforce.com/index.php/Outbound_Messaging_SSL_CA_Certificates
Client Certificate:
  • This certifies the client.
  • This certificate can be self-signed or signed by a trusted CA for improved security (optional, not required).
  • There are two ways in which this client certificate can be created:
    • Created in their web server.
    • Created in your Salesforce ORG
The Client Certificate only has information on the receiving web server (the Salesforce server does not matter); therefore the same Client Certificate can be used regardless if the call is made from the production ORG or from the sandbox, as long as the destination server is the same.
Importing and using the client certificates
Client Certificate created in customer's web server (Legacy):
  • The keystore has to be built and the certificate is exported in PKCS12 format.
  • When this certificate is generated, a password is also created.
  • This certificate is embedded in the Apex code. Since it is just ASCII letters (Base64), it goes on a String variable.


This sample was taken from Apex Code Developer's Guide (Invoking Callouts Using Apex > Using Certificates > Using Certificates with SOAP Services):
docSample.DocSamplePort stub = new docSample.DocSamplePort();
stub.clientCert_x = 'MIIGlgIBAzCCBlAGCSqGSIb3DQEHAaCCBkEEggY9MIIGOTCCAe4GCSqGSIb3DQEHAaCCAd8EggHb'+
'MIIB1zCCAdMGCyqGSIb3DQEMCgECoIIBgjCCAX4wKAYKKoZIhvcNAQwBAzAaBBSaUMlXnxjzpfdu'+
'6YFwZgJFMklDWFyvCnQeuZpN2E+Rb4rf9MkJ6FsmPDA9MCEwCQYFKw4DAhoFAAQU4ZKBfaXcN45w'+
'9hYm215CcA4n4d0EFJL8jr68wwKwFsVckbjyBz/zYHO6AgIEAA==';
stub.clientCertPasswd_x = 'passwd'; // <<< Password for the keystore
String output = stub.InvokeWebservice();
  • The clientCert_x is the keystore certificate in PKCS12 format
  • The clientCertPasswd_x is the password used for the web server's keystore (when the certificate was added).
    • This Server must be certified using a 3rd Party Signed Certificate
    • The certificate being added to the keystore is the Keystore certificate.
  • The keystore owner must give the developer the certificate and the password.
    • We can't help if they don't want to share the password... The whole concept of using PKCS12 is to give access to the trusted parties.
    • They don't need to share the password of their server certificate, just the private key of the certificate
    • They should not have problems sharing the password of a self signed PKCS12 certificate
Client Certificate created in your Salesforce ORG (preferred way):
  • The certificate is generated in Salesforce (Setup > Administration Setup > Security Controls > Certificate and Key Management)
  • The certificate must them be installed on the web server’s keystore.
  • A link to this certificate is embedded in the Apex code.
Sample code:
docSample.DocSamplePort stub = new docSample.DocSamplePort();
stub.clientCertName_x = 'Certificate Name'; // <<< Salesforce’s certificate name
String output = stub.InvokeWebservice();
Who can sign Server Certificates?
When performing callouts from Salesforce over HTTPS, it is required that the remote server have an SSL certificate signed by a root certification authority (CA) trusted by the default keystore in Sun's JDK 6 and approved by Salesforce. A complete list is found here: http://wiki.developerforce.com/index.php/Outbound_Messaging_SSL_CA_Certificates.

For security purposes, Salesforce will not add any additional certificates to the trusted list. If the server certificate is not signed directly by a root CA, the server must also return any intermediate certificates to complete the trust chain to the root CA. The server or certificate vendor can assist with instructions to install local and intermediate certificates.
What certificate to use?
Basically, Both ;-)
  • Server Certificate must be used to certify the destination for your SOAP calls (web server).
  • Client Certificate is used in the handshake, at the start of the SOAP call.
  • You could have the Client Certificates signed by a CA, but this is not required.
How it works?
When SFDC makes a call to a secured server, it first tries to see if the server has a Server Certificate. If it does, then it sends the Client Certificate (and possibly a password, see samples above). If this Client Certificate is accepted by the web server, then the communication is valid and the data is sent ack and forth between SFDC and the web server.
Other information
openssl s_client -showcerts -connect <host>:<port>

Friday, 15 March 2013


Twilio integration with salesforce

Following are the steps to integrate twilio with salesforce: -
1      First of all we have to create an account on twilio website. Twilio website provides two type of account .
a.) Free account:-   In this type account you can call to any number around the world, but the number  from which you call should be registered with twilio.
b.) Paid account:-  In this type account you can purchase new number, can port your number with twilio and can send sms also. With this account you can also use many other premium facilities like you can create client app and can use interactive deshboard etc.
But for now we will create only free account as follow:-
a.) Open  https://www.twilio.com/try-twilio and create an account
b.) Verify Your number by request a call or sms and then enter code which you get from call
c.)   Now the twilio will give you a chance to select a number.
That’s it we have created our account.
2         Now install apache-ant-1.8.2-bin fromhttp://apache.techartifact.com/mirror//ant/binaries/apache-ant-1.9.0-bin.zip
3      Extract this zip folder.
4      Make sure you have a Java environment installed.
5      create two variable ANT_HOME and JAVA_HOME
ANT_HOME =  D:\apache-ant-1.8.2-bin\apache-ant-1.8.2 (if your ant folder is in D- drive)         JAVA_HOME  = C:\Program Files\Java\jdk1.6.0_25 (give path of jdk)
PATH %SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\ProgramFiles\Java\jdk1.6.0_25\jre\bin;D:\apache-ant-1.8.2-bin\apache-ant-1.8.2\bin;
(if path variable is alreadyavailable then append this also other wise create new Path variable)
6       from the ANT_HOME(for ex. D:\apache-ant-1.8.2-bin\apache-ant-1.8.2  ) directory run ant -f fetch.xml -Ddest=system in command prompt to get the library dependencies of most of the Ant tasks that require them. If you don’t do this, many of the dependent Ant tasks will not be available.
7      Now open your salesforce org and nevigate Set up>-App Setup>Develop > Tool> force.comMigrationTool download this and extract it in a folder and copy ant-salesforce.jar  file from it and paste in your ANT_HOME/lib folder (ex.  E:\apache-ant-1.8.4-bin\apache-ant-1.8.4\lib).
8      Now  download twilio liabreary for salesforce from
9      Unzip it and edit the Build.property file which you will found in install folder of twilio library folder as follow
a)   sf.username = your id of org
b)   sf.password = your password+token(may be required)
10   now open command prompt at install folder and run ant deployTwilio .This will install twilio liabrary in your org.
How To Add dialler side component to your Home Page
11   Now we are going to add a side narrow component like below
12   Above component can be Imageused to dial any no as well as it also receive call and notify user about incomming call.
13   To create this component we will create a Visualforce page which you can download from link below:-
14   We will also create a controller for this page which you can download from this link
15   Now we have a ready to dial page by which you can dial any number.
16   Now we will add this component to our home page.
To do this go to setup|customize|Home|Home Page Component click new button to create a new component.
17   Now select click next button and give a name to your component and select  HTML Areacheckbox.
18   Now select Narrow (Left) Column  checkbox and in editor select show HTML checkbox
19   Now paste following code in this area

Here we just calling our created page in a iframe  so be sure your page name is correct.
20   Now click your Home page tabe and voilla!!!! Your page have a dialler component by which you can call and receive calls.
How To add Dial and Sms buttons to your contacts page
21   Now we are going to add call and sms buttons at your contact page like below
Image
22   Now create a apex class whose purpose is to provide capability code for our call button scrip. You can get this apex class code from following Link
23   To do this go to setup|customize|contacts|Button and Links.
24   Now click on New Button .
25   Now Enter Call in label and name field and select Detail Page  radio button and  for Behavior select Execute JavaScript  and for content source select onclick JavaScript.
26   Now Download  script code from following link and paste it in script editor of call button.
27   Save it and go to your contact page and select any one of your contact and woooo!!!! You have a call button over there by which you can call to this contact.
28   Now its turn to create SMS button for this contact. To do this first follow the steps for call button you followed earlier.
29   You can download script for this code from following link
30   Now copy this code and paste it in script editor of newly created sms button.
31   And That’s it we have done creating new call and Sms buttons.

Monday, 4 March 2013



INTEGRATION IN SALESFORCE


Integration:

A typical enterprise uses many applications, many or most of which are not designed to work with one another out of the box. Integrating separate but related apps helps organizations achieve greater levels of operational consistency, efficiency, and quality.
Each application can have data, business logic, presentation, and security layers, all of which are possible targets for integration. This page is an overall launch point for exploring the various integration options related to Force.com and other Salesforce platform technologies.
Security Integration
Integrate authentication mechanisms across applications to improve the user experience and minimize user administration.
Coming Soon
User Interface Integration
Combine the UIs of two or more apps to create composite apps with little or no rework on the UI of each individual app.
Business Logic Integration
Business logic often spans multiple application systems. Extending related business logic from one app to another helps to implement complete end to end business processes.
Data Integration
Integrating applications at the data layer is a common scenario. For example, multiple apps written in different programming languages can all use an open API and manage related data in one shared database.

Force.Com Canvas ( User Interface Integration):


Enhance your user experience, expand your Salesforce footprint, and unlock the power of your developers with the new Force.com Canvas feature, now available to all new Developer Edition Orgs. Force.com Canvas features include:
Language Independence
You develop it and we display it. With Force.com Canvas you can develop in the language of your choice and easily surface the app inside of Salesforce.
JavaScript SDK
Lightweight and easy-to-use JavaScript libraries allow your app to authenticate and communicate without having to deal with cross-domain network issues. This provides your users with a single command center to drive all their apps.
Simplified Authentication
Force.com Canvas allows you to authenticate by using OAuth 2.0 or a signed request. This means that your app can connect to Salesforce at a data layer while remaining seamless for users.
App Registration and Management
Developers: Create your app and allow your customers to install it with a single click. Administrators: Easily install apps from developers and quickly manage who in your org can use the app.

The Force.com Canvas SDK is an open-source suite of JavaScript libraries and provides simple methods that use existing Salesforce APIs (SOAP API, REST API, Chatter REST API) so you can build a seamless end-user experience inside of salesforce.com.
With the Force.com Canvas SDK, you can now integrate your Web app with the trusted salesforce.com platform: Your language, your  code

Business Logic Integration:

Business logic often spans multiple application systems. Extending related business logic from one system to another helps to implement complete end to end business processes.


Force.com (and Database.com) supports the extension of business logic that originates from outside the platform (inbound logic integration) and from within the platform itself (outbound logic integration). Follow the links to the right or below for more information about inbound and outbound logic integrations.
  • Apex Web Services (Inbound)
  • Email Services (Inbound and Outbound)
  • Apex Callouts (Outbound)
  • Outbound Messaging


Data Integration:

In general, there are several different ways to integrate separate but related application systems at the data layer. For example, any number of apps can access a single shared database and efficiently manage data in real time. In contrast, when each app must maintain its own database, or when you want to import or export large amounts of data, mechanizing the transfer of data among pertinent systems helps preserve the consistency and quality of data across the entire organization.
The following sections briefly introduce various data integration options related to Salesforce platforms.

Open APIs:

At the core level, all Salesforce platforms have open APIs (based on industry-standards such as REST and SOAP) that you can use to integrate Salesforce endpoints (Force.com, Database.com, etc.) with external endpoints such as apps or enterprise integration hubs.
Here's a guide to the various general- and special-purpose APIs for Salesforce platforms.
General purpose data integration APIs support applications that need to work with the core data managed by Force.com and Database.com.
  • Data integrations via SOAP with the SOAP API
  • Data integrations via REST with the REST API
  • Data streaming with the Streaming API
Special purpose data integration APIs support applications that need to work with peripheral data models in Force.com and Database.com, or data managed by other Salesforce platforms such as Radian6, Do.com, and Desk.com.
  • Social integration with the Chatter REST API
  • Listen and engage on social media with the Radian6 API
  • Work better with the Do API
  • Support customers with the Desk API

Bulk Data Transfer API:

The Bulk API provides programmatic access that lets you quickly load data into your Salesforce organization. It is a RESTful API that is optimal for loading or deleting large sets of data. You can use it to query, insert, update, upsert, or delete a large number of records asynchronously by submitting batches that Salesforce processes in the background.

Language - Specific Resources and Toolkits:

When working with specific programming languages, several toolkits are available that abstract the core SOAP and REST APIs to support native development approaches and simplify integrations.
  • Salesforce Mobile SDK (Android and iOS)
  • JavaScript
  • Java
  • Ruby
  • PHP

Integration Primers:

For a broad overview of integration before heading down one of the above paths, you might want explore the following resources:
  • Integration Patterns and Practices
  • Integrating with the Force.com Platform

Integration Patterns and Practices:

You Can download it from here Integration Patterns and Practices

Integrating with the Force.com Platform:

You Can get more information about this here Integrating with the force.com Platform

    Links