Wednesday, January 20, 2016

Integrate WebSphere Commerce and Pinterest

Why integrate IBM WebSphere Commerce and Pinterest

IBM WebSphere Commerce
IBM WebSphere Commerce (WC) provides an e-commerce platform that delivers seamless and consistent omni-channel shopping experiences, including mobile, social, and in-store shopping experiences. WebSphere Commerce engages your customers with immersive brand experiences through contextually relevant content, marketing. and promotions while extending your brand across customer touch points.

Pinterest
Pinterest has introduced Buyable Pins to their mobile application.  When a pinned item in the Pinterest app shows a blue price, you will also see a blue Buy It button, indicating that the item can be purchased from the retailer, directly via the Pinterest app – no need to pause your pinning activities to bounce out to the retailer’s web site! 

Business Value
Your marketing team recognizes the power of social media, and knows that many of the people browsing Pinterest have the intention of shopping for the items they see and love.   If you are using WC as your eCommerce platform, you can use this asset to accelerate the integration of Pinterest Buyable Pins with your own WC environment.



Monday, January 18, 2016

jQuery Selector

jQuery Selector

#No     Syntax                              Description
---------------------------------------------------------------------------------------
1.      $(this)                             Current HTML element
2.      $(".intro")                         All elements with class="intro"
3.      $("#intro")                         The first element with id="intro"
4.      $("p")                              All <p> elements
5.      $("p.intro")                        All <p> elements with class="intro"
6.      $("p#intro")                        All <p> elements with id="intro"
7.      $("p#intro:first-child")            The first <p> element with id="intro"
8.      $("ul li:first-child")              The first <li> element of each <ul>
9.      $("ul li:last-child")               The last <li> element of each <ul>
10.     $("ul li:nth-child(4)")             The fourth <li> element of each <ul>
11.     $("div#intro .head")                All elements with class="head" and id="intro" of DIV
12.     $("[href*='User']")                 All elements with href contains "User"
13.     $("[href^='User']")                 All elements with href start with "User"
14.     $("[href$='.html']")                All elements with an href attribute
                                            that ends with ".html"
15.     $("[href*='User'] div")             AND condition for Getting all element
                                            which have href contains "User" and inner element div
16.     $("[href*='User'],div")             OR condition for Getting all element
                                            which have href contains "User" or div element
17.     $("[href!='UserInfo.html']")        NOT condition for Getting all element  
                                            which have href not equle to "UserInfo.html"
18.     $("div > input#User")               Getting all element which have a parent element is
                                            DIV and next element is INPUT have a id User
19.     $("div").find("input#User")         Getting all element of parent element is
                                            DIV and child element is INPUT have a id User
20.     $("div").not(".UserInfo, #UserId")  Getting all div element which not have a

                                            class USERINFO or id is USERID

Thursday, January 14, 2016

Duplicate Emails issue in IBM WCS


Getting Duplicate Emails

Configuring your store to avoid sending multiple marketing e-mails to the same e-mail address

Procedure

1.       Open the WebSphere Commerce configuration file.

2.       Locate the section of the file that starts with the <Instance element.

3.       Within the <Instance element, add the attribute filterDuplicateEmails="true", as shown in the following example:

<Instance BootstrapMulti="wcs.bootstrap_multi_en_US.xml,"

               . . . . . . . . .

              InstanceName="demo"

              filterDuplicateEmails="true"

              InstanceType="local"

              . . . . . . . . . . .

              WCSInstallDir="D:\WebSphere\CommerceServer70"

              WorkspacePath="" />

4.       Save and close the file.

5.       Propagate the changes to the WebSphere Commerce configuration file.

Enhancing security in IBm WCS

Enhancing security in IBm WCS
1.       Protecting against Cross-site Scripting (XSS) Attacks
What a Cross Site Scripting vulnerability?
Cross-site Scripting allows an attacker to alter the behavior of your site in many ways, such as inserting HTML, running JavaScript or displaying images.
How it occur :
Lets take below line of code :
<li class=”current”>${searchTerm}</li>
 
 
If someone were to modify this to something malicious, similar to the following:
It will produce unwanted result.
To control it :
<li class=”current”><wcf:out value=”${searchTerm}”/></li>
This code By converting to HTML Entities, the browser will display the text as entered instead of running it as though it was a script (HTML, JavaScript, ect.).
Using the above example, the input was encoded into HTML entities similar to the following:
</div><img src=http://<servername>/<someimage>.jpg><div>
Although the XSiteScriptingProtection is enabled in wc-server.xml for the Store by default, it didn't stop this particular case. The OOTB prohibitedChar rules are defined to stop script tags.  Adding all possible HTML tags could impact both performance and store functionality.
 
2.       Enabling WhiteList data validation
When enabled, WhiteList data validation ensures that when a URL command or view is run, the parameter values conform to a specified regular expression. For example, you can configure it so that the storeId must be an integer. When a WhiteList violation is detected, the request is changed to the ProhibCharEncodingErrorView view. WhiteList data validation is disabled by default.
 
Procedure
1.       Open the WebSphere Commerce configuration file.
2.       Search for the following element outside of the <Module> element:
<XSiteScriptingProtection display="false" enabled="true" name="Cross Site Scripting Protection">
3.       Insert the following sample WhiteList configuration before the preceding element, and modify it to suit your business needs:
<WhiteListProtection enabled="true" name="WhiteListProtection" display="false">
   <param name="storeId" regex="[-]?[0-9]*"/>
   <param name="langId" regex="[-]?[0-9]*"/>
   <param name="catalogId" regex="[-]?[0-9]*"/>
   <param name="categoryId" regex="[-]?[0-9]*"/>
   <param name="productId" regex="[-]?[0-9]*"/>
   <param name="parent_category_rn" regex="[-]?[0-9]*"/>
   <param name="physicalStoreId" regex="[-]?[0-9]*"/>
   <param name="geoNodeId" regex="[-]?[0-9]*"/> 
</WhiteListProtection>
<XSiteScriptingProtection display="false" enabled="true" name="Cross Site Scripting Protection">
Where:
WhiteListProtection.enabled
Global flag to enable or disable WhiteList data validation. Valid values are true or false.
WhiteListProtection.param.name
The name of the parameter to be validated.
WhiteListProtection.param.regex
The regular expression that defines the allowed values. The regular expression syntax is based on the standard that is used by Java.
For the regular expression syntax, see the Sun Class Pattern Java API documentation.
WhiteListProtection.param.maxLength
The maximum number of characters allowed.
4.       In each web module that requires WhiteList data validation, search for the corresponding Module element. For example, the Stores web module element:
<Module contextPath="/webapp/wcs/stores" fileServletEnabled="false" name="Stores"
   urlMappingPath="/servlet" webAlias="/wcsstore">
   <InitParameters adapters="XML/HTTP, BrowserAdapter" contextSetName="Store" handleDoubleClick="true"/>
   <URLRedirectFilter enable="true"/>
</Module>
5.       Insert a WhiteListProtection element to enable this feature for that web module:
<WhiteListProtection enable="true"/>
For instance, to enable WhiteList data validation in the Stores web module, the WhiteListProtection element is added in the following snippet in bold:
 
<Module contextPath="/webapp/wcs/stores" fileServletEnabled="false" name="Stores"
   urlMappingPath="/servlet" webAlias="/wcsstore">
   <InitParameters adapters="XML/HTTP, BrowserAdapter" contextSetName="Store" handleDoubleClick="true"/>
   <URLRedirectFilter enable="true"/>
   <WhiteListProtection enable="true"/>
</Module>
Note: If the WhiteListProtection element is not specified for a web module, the default WhiteListProtection value is false (WhiteList data validation disabled).
6.       Start your WebSphere Commerce instance if it is not already started.

Tuesday, January 12, 2016

Encrypting data using EncryptionFactory in IBM WCS


Encrypting data using EncryptionFactory in IBM WCS
The following are the encryption providers that you can use for encrypting / decrypting data:
ActiveProvider: This provider is responsible for encrypting and decrypting sensitive data to be stored in the database, for example credit card numbers. The encryption key is the merchant key.
SessionProvider: This provider is responsible for encrypting and decrypting external facing data such as values in a cookie. The encryption key is the session key.
To retrieve a particular encryption provider, call this method:
EncryptionFactory.getInstance().getProvider("name of provider")
To encrypt data that uses an encryption provider, call the encrypt() method. For example, to encrypt data to be stored in the database, use the ActiveProvider (merchant key):

com.ibm.commerce.foundation.common.util.encryption.EncryptionFactory.getInstance()

.getProvider("com.ibm.commerce.server.ECConstants.EC_ENCRYPTION_ACTIVEPROVIDER")

.encrypt("myDataToEncrypt");
 
Similarly, to decrypt data that uses an encryption provider, call the decrypt() method. For example, to decrypt data from the database, use the ActiveProvider (merchant key):

com.ibm.commerce.foundation.common.util.encryption.EncryptionFactory.getInstance()

.getProvicer("com.ibm.commerce.server.ECConstants.EC_ENCRYPTION_ACTIVEPROVIDER")

.decrpypt("myEncryptedData");

Immediately send password reset notification e-mails

Configure WebSphere Commerce to immediately send password reset notification e-mails
When a user resets their password, by default the request is queued in the MSGSTORE table and the temporary password is not e-mailed to the customer until the SendTransactedMsg scheduled job is run.
To modify the behavior of the reset password notification logic, select one of the following solutions:
1. Increase the frequency of the SendTransactedMsg scheduled job, which sends out the temporary password notification e-mail. This might not be ideal as you might still experience some delay based on the frequency of the scheduled job.
You can modify the scheduled job's frequency by updating the Schedule interval value in the WebSphere Commerce Administration Console. 

2. Recommended: Leverage the sendImmediate () method within SendPasswordNotificationCmdImpl.performExecute() as SendPasswordNotificationCmdImpl makes use of the sendTransacted() method, which stores the reset password notification in the MSGSTORE table. For more information on the default behavior of SendPasswordNotificationCmdImpl, 

       SendMsgCmd sendMsgCmd = (SendMsgCmd)CommandFactory.createCommand(
                                "com.ibm.commerce.messaging.commands.SendMsgCmd", getStoreId());
                    sendMsgCmd.setMsgType("PasswordNotify");
                    sendMsgCmd.setStoreID(getStoreId());
                    TypedProperty tp = new TypedProperty();
                    tp.put("resetPasswordUrl", passwordNotifyMsg);
                    tp.put("LANGUAGE_ID", getCommandContext().getLanguageId());
                    sendMsgCmd.compose("NDFPasswordNotify", getCommandContext(), tp);
                    sendMsgCmd.sendImmediate();
                    sendMsgCmd.setCommandContext(getCommandContext());
                    sendMsgCmd.execute();


If you want the password reset notification e-mails to be sent to customers immediately after the request is made, you must extend and replace SendPasswordNotificationCmdImpl.performExecute() to use sendImmediate() rather than sendTransacted(). This sends the message directly to the customer instead of queuing it in the MSGSTORE table and waiting for the SendTransactedMsg job to run.

public void sendImmediate()
This method sends the message immediately to recipients. The caller is blocked until the message has been sent.

public void sendTransacted()

This method stores the message in the MSGSTORE database table. At a predetermined time, the WebSphere Commerce scheduler invokes a job that sends all messages stored in batch mode. Using this method ensures that a send occurs only after the caller has committed or terminated successfully. This method should be used if blocking a call using the sendImmediate() method cannot be tolerated.

Configure the X-Frame-Options header settings

                    Configure the X-Frame-Options header settings
Configure the X-Frame-Options header settings to help you protect your site against Clickjacking. Clickjacking is a technique that tricks a web user into clicking a malicious site, thinking that it is your site. This malicious site can then reveal confidential information or take control of the user's computer.


Procedure
Include the X-Frame-Options header with a response. The Feature Pack 8 Aurora store has the X-Frame-Options header enabled in Stores.war/Aurora/Common/EnvironmentSetup.jspf. You can include this X-Frame-Options header by using one of the following options:

•             Use the IBM HTTP Server (IHS)
Enabling the header with IHS is the more popular technique and this technique ensures that the header is included with all responses. To include the X-Frame-Options header, use a command that is similar to the following command, which appends the X-Frame-Options header SAMEORIGIN to responses:
      Header always append X-Frame-Options SAMEORIGIN
         •             Use the WebSphere Commerce application.
            1.            Go to the following directory:
                            Store_archivedir/Aurora/common
            2.            Open the EnvironmentSetup.jspf for editing and add the following line of code:
                           response.setHeader("X-Frame-Options","SAMEORIGIN");

            3.            Save and close the file.