tag:blogger.com,1999:blog-590770945578922024-03-12T17:40:09.374-07:00Evanthika Amarasiri's BlogEvanthikahttp://www.blogger.com/profile/02913709559298376105noreply@blogger.comBlogger73125tag:blogger.com,1999:blog-59077094557892.post-51316598061178207292019-04-07T22:49:00.002-07:002019-04-07T22:49:24.071-07:00How to verify whether a property value is null or notAssume you have a scenario where want to do something based on the fact whether a property value is null or not.<br />
<br />
Using the Filter mediator, this is possible. See below for the configuration.<br />
<br />
<filter regex="^\d+$" xpath="get-property('memberId')"><br />
<then>//Do something</then><br />
<br />
<br />
<else>//Do something else</else><br />
<br />
<br />
</filter>Evanthikahttp://www.blogger.com/profile/02913709559298376105noreply@blogger.com0tag:blogger.com,1999:blog-59077094557892.post-7812018370132596302018-01-10T00:07:00.001-08:002018-01-10T00:07:59.815-08:00Why don't I see "Request Body" in the "Raw tab" of SOAP UIWhen sending requests in SOAP UI, I was not able to see the <b>Request Body</b> in the <b>Raw tab</b>.<br />
<br />
The reason for was this was a setting in SOAP UI.<br />
<br />
To enable this, all you have to do is, go to <b>Preferences</b> and then go to<b> Editor Settings</b> and check <i><b>Validate Requests</b></i> and <b><i>Validate Responses</i></b> check boxes.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjJcHrl5Ti2RdfxwETLdNSC7ebRQ2BLrbokECKV-o3w3mVyWFUkv-Z1OaybP_HAvo7-2N3Lp5quHuWG_EekyOSvX0pY3NW0G-qt4QQ5zYWXJ58bgdIGgrWEM0EI7nzKWRSES8mv0Aq6/s1600/Screen+Shot+2018-01-10+at+1.35.10+PM.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="1018" data-original-width="1600" height="253" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjJcHrl5Ti2RdfxwETLdNSC7ebRQ2BLrbokECKV-o3w3mVyWFUkv-Z1OaybP_HAvo7-2N3Lp5quHuWG_EekyOSvX0pY3NW0G-qt4QQ5zYWXJ58bgdIGgrWEM0EI7nzKWRSES8mv0Aq6/s400/Screen+Shot+2018-01-10+at+1.35.10+PM.png" width="400" /></a></div>
<br />Evanthikahttp://www.blogger.com/profile/02913709559298376105noreply@blogger.com0tag:blogger.com,1999:blog-59077094557892.post-83792071319181270382017-11-06T21:16:00.002-08:002017-11-06T21:18:21.712-08:00How to resolve "Could not generate DH keypair" issue faced with WSO2 productsWhen working with WSO2 products, sometimes, you might see the below exception when trying out security scenarios with JDK 1.7.<br />
<br />
<span style="border: 2px solid rgb(180, 180, 180); display: block; padding: 5px;">
TID: [0] [AS] [2017-11-07 05:02:26,655] ERROR {org.apache.tomcat.util.net.NioEndpoint$SocketProcessor} - {org.apache.tomcat.util.net.NioEndpoint$SocketProcessor}<br />java.lang.RuntimeException: Could not generate DH keypair<br /> at sun.security.ssl.Handshaker.checkThrown(Handshaker.java:1345)<br /> at sun.security.ssl.SSLEngineImpl.checkTaskThrown(SSLEngineImpl.java:519)<br /> at sun.security.ssl.SSLEngineImpl.readNetRecord(SSLEngineImpl.java:796)<br /> at sun.security.ssl.SSLEngineImpl.unwrap(SSLEngineImpl.java:764)<br /> at javax.net.ssl.SSLEngine.unwrap(SSLEngine.java:624)<br /> at org.apache.tomcat.util.net.SecureNioChannel.handshakeUnwrap(SecureNioChannel.java:335)<br /> at org.apache.tomcat.util.net.SecureNioChannel.handshake(SecureNioChannel.java:193)<br /> at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1642)<br /> at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)<br /> at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)<br /> at java.lang.Thread.run(Thread.java:745)<br />Caused by: java.lang.RuntimeException: Could not generate DH keypair<br /> at sun.security.ssl.ECDHCrypt.<init>(ECDHCrypt.java:68)<br /> at sun.security.ssl.ServerHandshaker.setupEphemeralECDHKeys(ServerHandshaker.java:1215)<br /> at sun.security.ssl.ServerHandshaker.trySetCipherSuite(ServerHandshaker.java:1069)<br /> at sun.security.ssl.ServerHandshaker.chooseCipherSuite(ServerHandshaker.java:896)<br /> at sun.security.ssl.ServerHandshaker.clientHello(ServerHandshaker.java:629)<br /> at sun.security.ssl.ServerHandshaker.processMessage(ServerHandshaker.java:167)<br /> at sun.security.ssl.Handshaker.processLoop(Handshaker.java:913)<br /> at sun.security.ssl.Handshaker$1.run(Handshaker.java:853)<br /> at sun.security.ssl.Handshaker$1.run(Handshaker.java:851)<br /> at java.security.AccessController.doPrivileged(Native Method)<br /> at sun.security.ssl.Handshaker$DelegatedTask.run(Handshaker.java:1285)<br /> at org.apache.tomcat.util.net.SecureNioChannel.tasks(SecureNioChannel.java:285)<br /> at org.apache.tomcat.util.net.SecureNioChannel.handshakeUnwrap(SecureNioChannel.java:343)<br /> ... 5 more<br />Caused by: java.security.InvalidAlgorithmParameterException: unknown curve name: 1.2.840.10045.3.1.7<br /> at org.bouncycastle.jce.provider.JDKKeyPairGenerator$EC.initialize(Unknown Source)<br /> at sun.security.ssl.ECDHCrypt.<init>(ECDHCrypt.java:63)<br /> ... 17 more<init><init> </init></init></init></init></span> <br />
The reason for this is missing JCE policy files in the JDK. So in order to do this, you need to download the relevant JCE policy files from [2] and patch the JDK.<br />
<br />
[1] - https://stackoverflow.com/questions/6851461/java-why-does-ssl-handshake-give-could-not-generate-dh-keypair-exception?answertab=votes#tab-top<br />
[2] - http://www.oracle.com/technetwork/java/javase/downloads/jce-7-download-432124.html<br />
Evanthikahttp://www.blogger.com/profile/02913709559298376105noreply@blogger.com0tag:blogger.com,1999:blog-59077094557892.post-55740215880050936652017-09-27T06:48:00.000-07:002017-09-27T06:53:01.506-07:00Transfering PDF files via the VFS transport with WSO2 ESBThis post will explain how one can transfer PDF files through VFS transport within WSO2 ESB.<br />
<br />
In this example, I will be providing the configuration which is tested on <a href="https://docs.wso2.com/display/ESB481/WSO2+Enterprise+Service+Bus+Documentation">WSO2 ESB 4.8.1</a>.<br />
<br />
<br />
In order for you to get the scenario to work, first you will need to enable the VFS sender and listener through the following configuration in the axis2.xml. The below lines will be commented out by default and all you need to do to enable the VFS transport is uncomment the following two entries.<br />
<br />
<span style="border: 2px solid rgb(180, 180, 180); display: block; padding: 5px;"><transportReceiver name="vfs" class="org.apache.synapse.transport.vfs.VFSTransportListener"/><br /><br /><transportSender name="vfs" class="org.apache.synapse.transport.vfs.VFSTransportSender"/></span><br />
<br />
Next, to enable PDF file transferring within ESB, you will have to enable the message relay feature. For this, we need to add the appropriate message builder and formatter to the axis2.xml file.<br />
<br />
<span style="border: 2px solid rgb(180, 180, 180); display: block; padding: 5px;"><messageFormatters><br /><br /> <messageFormatter contentType="application/pdf" class="org.wso2.carbon.relay.ExpandingMessageFormatter"/><br /> :<br /> :<br /></messageFormatters><br />
<br />
<messageBuilders><br />
<messageBuilder contentType="application/pdf" class="org.wso2.carbon.relay.BinaryRelayBuilder"/><br />
:<br />
:<br />
</messageBuilders></span><br />
<br />
<br />
Once the above changes have been done, create a Proxy Service as shown below.<br />
<br />
<span style="border: 2px solid rgb(180, 180, 180); display: block; padding: 5px;"> <proxy name="PdfProxy" transports="vfs" startOnLoad="true"><br /> <target><br /> <inSequence><br /> <log level="custom"><br /> <property name="status=" value="PDF file transferred"/><br /> </log><br /> <drop/><br /> </inSequence><br /> </target><br /> <parameter name="transport.vfs.ActionAfterProcess">MOVE</parameter><br /> <parameter name="transport.PollInterval">15</parameter><br /> <parameter name="transport.vfs.MoveAfterProcess">file:///Users/evanthika/Downloads/vfs/out</parameter><br /> <parameter name="transport.vfs.FileURI">file:///Users/evanthika/Downloads/vfs/in</parameter><br /> <parameter name="transport.vfs.MoveAfterFailure">file:///Users/evanthika/Downloads/vfs/failure</parameter><br /> <parameter name="transport.vfs.FileNamePattern">.*\.pdf</parameter><br /> <parameter name="transport.vfs.ContentType">application/pdf</parameter><br /> <parameter name="transport.vfs.ActionAfterFailure">MOVE</parameter><br /> </proxy></span><br />
<br />
Now drop the relevant PDF file to the location mentioned in the <b>transport.vfs.FileURI</b><br />
parameter. After the time specified in the <b>transport.PollInterval</b> parameter, the relevant PDF file will be read and moved to the folder specified as the <b>transport.vfs.MoveAfterProcess</b> parameter value. <br />
<br />Evanthikahttp://www.blogger.com/profile/02913709559298376105noreply@blogger.com0tag:blogger.com,1999:blog-59077094557892.post-16830109011141621122017-09-02T20:57:00.000-07:002017-09-02T21:00:04.179-07:00How to accept requests from different URLs that has different query parameters through ESB APIsProducts used - WSO2 ESB 4.8.1<br />
WSO2 DSS 3.5.0<br />
<br />
<br />
Assume that we have a back-end service which reads a database and returns employee information depending on particular parameters that are being passed. Let's say that we are using the following Data Services Server which is hosted in <a href="http://wso2.com/products/data-services-server/">WSO2 DSS</a> product.<br />
<br />
<span style="border: 2px solid rgb(180, 180, 180); display: block; padding: 5px;">
<data name="GetEmployees" transports="http https local"><br /> <config enableOData="false" id="mysql"><br /> <property name="driverClassName">com.mysql.jdbc.Driver</property><br /> <property name="url">jdbc:mysql://localhost:3306/employee</property><br /> <property name="username">root</property><br /> <property name="password">root</property><br /> </config><br /> <query id="query1" useConfig="mysql"><br /> <sql>select * from employees where id=? and lastname=?</sql><br /> <result element="employees" rowName="employee"><br /> <element column="id" name="id" xsdType="string"/><br /> <element column="lastname" name="lastname" xsdType="string"/><br /> <element column="firstname" name="firstname" xsdType="string"/><br /> </result><br /> <param name="id" sqlType="STRING"/><br /> <param name="lastname" sqlType="STRING"/><br /> </query><br /> <query id="query2" useConfig="mysql"><br /> <sql>select * from employees</sql><br /> <result element="employees" rowName="employee"><br /> <element column="id" name="id" xsdType="string"/><br /> <element column="lastname" name="lastname" xsdType="string"/><br /> <element column="firstname" name="firstname" xsdType="string"/><br /> </result><br /> </query><br /> <query id="query3" useConfig="mysql"><br /> <sql>select * from employees where id=?</sql><br /> <result element="employees" rowName="employee"><br /> <element column="id" name="id" xsdType="string"/><br /> <element column="lastname" name="lastname" xsdType="string"/><br /> <element column="firstname" name="firstname" xsdType="string"/><br /> </result><br /> <param name="param0" sqlType="STRING"/><br /> </query><br /> <operation name="getemployee"><br /> <call-query href="query1"><br /> <with-param name="id" query-param="id"/><br /> <with-param name="lastname" query-param="lastname"/><br /> </call-query><br /> </operation><br /> <operation name="getemployeeid"><br /> <call-query href="query3"><br /> <with-param name="param0" query-param="param0"/><br /> </call-query><br /> </operation><br /> <operation name="getAllEmployees"><br /> <call-query href="query2"/><br /> </operation><br /></data><br />
</span>
<br />
<br />
Lets assume that the client expects to send the requests in the following format.<br />
<br />
<i>To get all the employee details of the database</i> - http://localhost:8280/newsample/employee/get/employees<br />
<br />
<i>To get employee details which matches a particular id</i> - http://localhost:8280/newsample/employee/get/employees?id={id_number}<br />
<br />
<i>To get details of a particular employee which matches a particular id and the lastname</i> - http://localhost:8280/newsample/employee/get/employees?id=1&lastname=Amarasiri<br />
<br />
To support this, we can create an API in <a href="http://wso2.com/products/enterprise-service-bus/">WSO2 ESB</a> with the following configuration.<br />
<br />
<span style="border: 2px solid rgb(180, 180, 180); display: block; padding: 5px;">
<api name="EmployeeDetApi" context="/newsample"><br /> <resource methods="GET"<br /> uri-template="/employee/get/employees?id={id}&lastname={lastname}"><br /> <inSequence><br /> <payloadFactory media-type="xml"><br /> <format><br /> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"<br /> xmlns:dat="http://ws.wso2.org/dataservice"><br /> <soapenv:Header/><br /> <soapenv:Body><br /> <dat:getemployee><br /> <dat:id>$1</dat:id><br /> <dat:lastname>$2</dat:lastname><br /> </dat:getemployee><br /> </soapenv:Body><br /> </soapenv:Envelope><br /> </format><br /> <args><br /> <arg evaluator="xml" expression="$url:id"/><br /> <arg evaluator="xml" expression="$url:lastname"/><br /> </args><br /> </payloadFactory><br /> <property name="SOAPAction"<br /> value="urn:getemployee"<br /> scope="transport"<br /> type="STRING"/><br /> <property name="ContentType" value="text/xml" scope="axis2" type="STRING"/><br /> <log><br /> <property name="incoming_message"<br /> value="*******GET EMPLOYEE DETAILS - id ,lastname *******"/><br /> </log><br /> <send><br /> <endpoint key="AddressEpr"/><br /> </send><br /> </inSequence><br /> </resource><br /> <resource methods="GET" uri-template="/employee/get/employees?id={param0}"><br /> <inSequence><br /> <payloadFactory media-type="xml"><br /> <format><br /> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"<br /> xmlns:dat="http://ws.wso2.org/dataservice"><br /> <soapenv:Header/><br /> <soapenv:Body><br /> <dat:getemployeeid><br /> <dat:param0>$1</dat:param0><br /> </dat:getemployeeid><br /> </soapenv:Body><br /> </soapenv:Envelope><br /> </format><br /> <args><br /> <arg evaluator="xml" expression="$url:id"/><br /> </args><br /> </payloadFactory><br /> <property name="SOAPAction"<br /> value="urn:getemployeeid"<br /> scope="transport"<br /> type="STRING"/><br /> <property name="ContentType" value="text/xml" scope="axis2" type="STRING"/><br /> <log><br /> <property name="incoming_message"<br /> value="*******GET EMPLOYEE DETAILS - id *******"/><br /> </log><br /> <send><br /> <endpoint key="AddressEpr"/><br /> </send><br /> </inSequence><br /> </resource><br /> <resource methods="GET" uri-template="/employee/get/employees"><br /> <inSequence><br /> <payloadFactory media-type="xml"><br /> <format><br /> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"<br /> xmlns:dat="http://ws.wso2.org/dataservice"><br /> <soapenv:Header/><br /> <soapenv:Body><br /> <dat:getAllEmployees/><br /> </soapenv:Body><br /> </soapenv:Envelope><br /> </format><br /> <args/><br /> </payloadFactory><br /> <property name="SOAPAction"<br /> value="urn:getemployeedetails"<br /> scope="transport"<br /> type="STRING"/><br /> <property name="ContentType" value="text/xml" scope="axis2" type="STRING"/><br /> <log><br /> <property name="incoming_message"<br /> value="*******GET EMPLOYEE DETAILS - All employees details *******”/><br /> </log><br /> <send><br /> <endpoint key="AddressEpr"/><br /> </send><br /> </inSequence><br /> </resource><br /> </api>
</span>Evanthikahttp://www.blogger.com/profile/02913709559298376105noreply@blogger.com0tag:blogger.com,1999:blog-59077094557892.post-28534371417610028632017-07-26T11:13:00.004-07:002017-07-27T00:56:01.646-07:00Analysing data with Data Analytics ServerWhen we talk about WSO2 DAS there are a few important things we need to give focus to. They are, Event receivers, Event Streams, Event Stream definitions and Event Stores.<br />
<br />
<i><b>Events</b></i>, are units of data, that are received by WSO2 DAS using <i><b>Event Receivers.</b></i> Through these Event Receivers WSO2 DAS receives events from different transports in JSON, XML, WSO2 Event formats, etc. formats. There are many different Event receivers available in WSO2 DAS, such as HTTP Event Receivers, SOAP Event Receivers, WSO2Event Event Receivers, etc.<br />
<br />
<i><b>Event Streams</b></i> are known to be a sequence of events of a particular type. The “type” in this context can be defined as an event stream definition.<br />
<br />
An <i><b>Event Stream definition</b></i> is sort of a schema which describes in which format the events that comes into WSO2 DAS server should be in. Each Event Stream Definition would have a name, a version and most importantly the type of the data that it expects to be sent in to WSO2 DAS as Events.<br />
<br />
Once an event is received by the Event Receiver, it would be checked against the Event Stream definition and be persisted to an <i><b>Event Store</b></i>. This is happening through the Data Analytics Layer (DAL) where the events will be stored in the Event store (can be a relational database) as a BLOB which is in human <i>unreadable</i> format. Then these events will be analyzed and processed and the processed information will then again be store in a Process Store (This too can be a relational database) in a BLOB format. <br />
These analyzed data will be decrypted by DAL and presented in a human readable format through the <i><b>Data Explorer</b></i> of WSO2 DAS.<br />
<br />
When it comes to IS Analytics, whatever the analyzed data that are in the Process Store will be presented through the Analytics Dashboard which is available in WSO2 DAS after the data being decrypted from DAL.<br />
<br />
However, the API Manager Analytics are visible from the Store/Publisher portals that are shipped with the API Manager product. However, the API manager related events that are stored in the Process store cannot be read directly from the API Manager dashboards as they are in a encrypted format. Only a DAL can decrypt this information into a human readable format. Because of this, we have introduced a way which is using a method called carbonJDBC where the DAL converts these information that are in the process store and store them in an external relational database. This database is then pointed to, from the API Manager dashboards and you will see API Manager analytics accordingly.Evanthikahttp://www.blogger.com/profile/02913709559298376105noreply@blogger.com0tag:blogger.com,1999:blog-59077094557892.post-84104330981785039412017-06-13T05:23:00.004-07:002017-06-13T05:35:25.294-07:00How to resolve "Un-recognized attribute 'targetFramework'. Note that attribute names are case-sensitive." in IISWhile trying to configure a SOAP service in IIS, I came across various issues where I had to do many things to resolve them. One of them is the following issue.<br />
<br />
<span style="border: 2px solid rgb(180, 180, 180); display: block; padding: 5px;">
Server Error in '/' Application.<br />Configuration Error<br />Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.<br /><br />Parser Error Message: Un-recognized attribute 'targetFramework'. Note that attribute names are case-sensitive.<br /><br />Source Error:<br /><br />Line 3: <br />Line 4: <system .web=""><br />Line 5: <compilation debug="true" targetframework="4.0"><br />Line 6: </compilation></system><br />Line 7: <system .servicemodel=""><br /><br />Source File: C:\RestService\RestService2\RestService\web.config Line: 5<br /><br />Version Information: Microsoft .NET Framework Version:2.0.50727.5420; ASP.NET Version:2.0.50727.5459 </system><br />
</span><br />
To resolve this issue, what you need to do is, check whether you have installed ASP.NET 4 on your Windows instance.<br />
If it is installed, open up a command window, go to the location where .NET 4 is available,<br />
<br />
C:\Users\Administrator>cd C:\Windows\Microsoft.NET\Framework\v4.0.30319<br />
<br />
Then run the following command<br />
<br />
<span style="border: 2px solid rgb(180, 180, 180); display: block; padding: 5px;">
aspnet_regiis -i
</span><br />
<br />
<span style="border: 2px solid rgb(180, 180, 180); display: block; padding: 5px;">
E.g.:- C:\Windows\Microsoft.NET\Framework\v4.0.30319>aspnet_regiis -i </span>
<br />
<br />
Once this is done, open your IIS (type inetmgr in run) and change your Application pool setting to .Net4 (Go to Application Pools -> click on your project -> Right click and select 'Basic Settings')<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhzjBS-fSsF16hvCq7lIs8j60xbnZ9JGURMvBf7nro7yNciW7Uxpomn4YwkuVb8AAD41xlEPAQZfgzQAqD9zqVXdjQEvwouTPgdveLPAnVgbIQS2O8d5pOxJ3UPOvpnEr7ad0IVB9gG/s1600/Screen+Shot+2017-06-13+at+6.04.21+PM.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="278" data-original-width="308" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhzjBS-fSsF16hvCq7lIs8j60xbnZ9JGURMvBf7nro7yNciW7Uxpomn4YwkuVb8AAD41xlEPAQZfgzQAqD9zqVXdjQEvwouTPgdveLPAnVgbIQS2O8d5pOxJ3UPOvpnEr7ad0IVB9gG/s1600/Screen+Shot+2017-06-13+at+6.04.21+PM.png" /></a></div>
<br />
<br />
<br />
<br />Evanthikahttp://www.blogger.com/profile/02913709559298376105noreply@blogger.com0tag:blogger.com,1999:blog-59077094557892.post-79277682214820922402017-06-11T23:05:00.000-07:002017-06-11T23:06:48.113-07:00Where do we have the public GIT repos for XACML and XACML Mediation Feature?If you want to do changes to the
<b>XACML</b> and <b>XACML mediation features</b> and use it within your product, you can get the code from the below locations.<br />
<br />
<b>XACML</b><br />
<b><i></i></b>
<span style="border: 2px solid rgb(180, 180, 180); display: block; padding: 5px;">
https://github.com/wso2/carbon-identity-framework/tree/master/features/xacml
</span>
<b> </b><br />
<br />
<b>XACML Mediation Feature<i></i></b>
<span style="border: 2px solid rgb(180, 180, 180); display: block; padding: 5px;">
https://github.com/wso2/carbon-mediation/tree/master/components/mediators/entitlement/org.wso2.carbon.identity.entitlement.mediator
</span>Evanthikahttp://www.blogger.com/profile/02913709559298376105noreply@blogger.com0tag:blogger.com,1999:blog-59077094557892.post-88970672409845149922017-06-05T22:52:00.000-07:002017-06-05T22:52:50.571-07:00Some important grep commandsWhile working on day to day work, there are many important grep commands that comes in handy. Below are some of these commands.<br />
<br />
<ul>
<li>How to find the number of occurrences of a particular text in a file.</li>
</ul>
<br />
<div style="text-align: justify;">
<span style="border: 2px solid rgb(180, 180, 180); display: block; padding: 5px;">
grep -o "text to be searchd" nohup.out | wc -l
</span></div>
This blog is yet to be developed and I will add one by one when I come across them.
Evanthikahttp://www.blogger.com/profile/02913709559298376105noreply@blogger.com0tag:blogger.com,1999:blog-59077094557892.post-69414231292017932002017-06-04T09:18:00.001-07:002017-06-04T09:30:41.100-07:00How does thread switching happen in WSO2 ESB (Switching between ServerWorker & IO reactor threads)One of the most important things we need to understand when working with <a href="https://docs.wso2.com/display/ESB500/WSO2+Enterprise+Service+Bus+Documentation">WSO2 ESB</a> is it's threading model. There are two types of threads that does the main functionality within the ESB.<br />
<br />
a) SynapseWorker threads<br />
b) IO Reactor Threads<br />
<br />
Out of these two threads, the SynapseWorker threads handles whatever the operations related to message mediation. On the other hand, the IO reactor threads are available for event handling such as receiving message headers, receiving message body, etc.<br />
<br />
Inside the Synapse engine, the message would go through many classes where transformations that are required are done to the incoming message. The classes involved in this flow are explained in a previous <a href="http://evanthika.blogspot.com/2017/05/mediation-flow-inside-esb-wso2-esb-is.html">post</a> which I have written.<br />
<br />
Once the message mediation is done, it is passed onto the Axis2Engine where it's receive() method is called. Inside this method, the type of the receiver is read from the context. In this example, since we are sending the message to a Proxy service, the receiver would be set to <i>ProxyServiceMessageReceiver</i>. So the message context would be passed on to the receive method of the <i>ProxyServiceMessageReceiver</i> class.<br />
This is the point where the incoming message is passed onto the Synapse Engine.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjwQI8PXVvtoSs0FiXEuXxvmbtD7ai4gp0ug5QkmghrBldV1H6XXF8s9q6v7cB3cQl3JhSNcylRgaHyXq6WF4zY-gGTED-q6eXIHZekFmo5exP345j44-K1dbZPGY0iN_Uq6_ISVa8R/s1600/axis2_engine.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="233" data-original-width="1600" height="91" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjwQI8PXVvtoSs0FiXEuXxvmbtD7ai4gp0ug5QkmghrBldV1H6XXF8s9q6v7cB3cQl3JhSNcylRgaHyXq6WF4zY-gGTED-q6eXIHZekFmo5exP345j44-K1dbZPGY0iN_Uq6_ISVa8R/s640/axis2_engine.png" width="640" /></a></div>
<br />
<br />
After the mediation flow completes for the incoming message inside the mediation engine, it would be handed over to the <i>PassThroughHttpSender</i> where the outbound HTTP requests can be sent.<br />
<br />
The <i>PassThroughHttpSender</i> implements the <i>TransportSender</i> interface. The initialisation of the <i>PassThroughHttpSender</i> happens at the server startup and an instance of the <i>NHttpClientEventHandler</i> is created by the name <i>TargetHandler</i>.<br />
<br />
In addition to this, when the <i>PassThroughHttpSender</i> is initialised, it creates an instance of the <i>DefaultConnectingIOReactor</i> as well.<br />
Along with this an instance of the <i>DeliveryAgent</i> is also formed which allows storing of messages for later delivery.<br />
If a connection is available to send the message it would send the message right away and if not, it would put the message to a message queue to be delivered to the backend whenever a connection is available. This implementation is available inside the <b>submit()</b> method of the <i>DeliveryAgent</i> class.<br />
<br />
When the message comes in the <i>PassThroughHttpSender</i> it hits it's<b> invoke()</b> method. After removing unwanted headers sent through the request, it would then check the messageContext for the endpoint value sent in the request message.<br />
If an endpoint is passed in from the request, the <b>submit() </b>method of the <i>DeliveryAgent</i> class is called. If no endpoint is sent, it would call the <b>submitResponse() </b>method.<br />
<br />
In this scenario, since we have specified an endpoint value, I would explain the flow which continues from the <b>submit()</b> method of the <i>DeliveryAgent</i> class.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhQavG5IHG2s_KLLmCz18J1EqXOSKgN2MFZB6bRIDHmhwxovtmAhK-BHfPVyJVfpPwhJPW1jCAE8GxC33poGhbwtUxIyYZndDY7A3pEJulGmgyf9RQl4WEjnHQYln03tZW6ZppHuk1Q/s1600/call_deliveryagent_submit.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="757" data-original-width="1600" height="300" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhQavG5IHG2s_KLLmCz18J1EqXOSKgN2MFZB6bRIDHmhwxovtmAhK-BHfPVyJVfpPwhJPW1jCAE8GxC33poGhbwtUxIyYZndDY7A3pEJulGmgyf9RQl4WEjnHQYln03tZW6ZppHuk1Q/s640/call_deliveryagent_submit.png" width="640" /></a></div>
<br />
<br />
Inside the <b>submit() </b>method, it would add the incoming message to a queue as shown below.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiipwasRodC-nLKUBubK8uOumorLrqyD5GLAkKLkyLe39rPqFOH28SOCLD_S3-3H8Ep1jnbWO9Y0lALlRQCzAIOIL4txMebPXjKvvsrHOU9l_GbYa8ZHYT1UrqBP7NgbH7NsDoNBkIA/s1600/add_to_queue.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="716" data-original-width="1600" height="284" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiipwasRodC-nLKUBubK8uOumorLrqyD5GLAkKLkyLe39rPqFOH28SOCLD_S3-3H8Ep1jnbWO9Y0lALlRQCzAIOIL4txMebPXjKvvsrHOU9l_GbYa8ZHYT1UrqBP7NgbH7NsDoNBkIA/s640/add_to_queue.png" width="640" /></a></div>
<br />
<br />
Once the message is added to the queue, it would call the <b>getConnection()</b> method of the <i>TargetConnections</i> class. This would return a connection if already available or won't return anything and will notify the delivery agent when a connection is available.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhUvgjwzG6U8LkvR8b2EjbWLI086RdiMCKAXI7sjyRgUIGH3oA0qrii-rNBwHVupda07KdahBAAJfbD0nUy3aHK9czVg1fYOw7GgIXN3nBCklXhSKnU_4MHnlwx5AXHmdO3BeAPiTJY/s1600/return_connection.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="453" data-original-width="1600" height="180" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhUvgjwzG6U8LkvR8b2EjbWLI086RdiMCKAXI7sjyRgUIGH3oA0qrii-rNBwHVupda07KdahBAAJfbD0nUy3aHK9czVg1fYOw7GgIXN3nBCklXhSKnU_4MHnlwx5AXHmdO3BeAPiTJY/s640/return_connection.png" width="640" /></a></div>
<br />
<br />
In a scenario where a connection is available, the <b>connected() </b>method of the <i>TargetHandler</i> is called and also a new TargetContext is created and the Protocol state is set to <b><i>REQUEST_READY</i></b>. which means that the connection is at the initial stage and is ready to receive a request.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgFh00CfjJbkA3qPXUQkyH7bdSDNMKoHxwFHZj-PYeaHVjt2AAyOYfun7SlB0DOAU1R9uoRR2zZBA-_NRZIHtFcMhSlWsCPoOwKu-QoMTUTAobbMWibxuGpqYHAw3yCdwWMPniG6Oq3/s1600/target_handler_connected.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="401" data-original-width="1600" height="160" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgFh00CfjJbkA3qPXUQkyH7bdSDNMKoHxwFHZj-PYeaHVjt2AAyOYfun7SlB0DOAU1R9uoRR2zZBA-_NRZIHtFcMhSlWsCPoOwKu-QoMTUTAobbMWibxuGpqYHAw3yCdwWMPniG6Oq3/s640/target_handler_connected.png" width="640" /></a></div>
<br />
Next the <b>connected() </b>method of the <i>DeliveryAgent</i> class is invoked where it would check the queue for any messages and pass onto the <b>tryNextMessage()</b> method.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEihBW0PoRtNZpQ4Lhh15zV0uY0-AnzcgTEmPEz6WDiwM0zTSuEPSbAjB7N2dvdDGdWEJ4SjqG8R4pCwKqAw6A-RvPu5cRVUAJ4CDDsyjPYByaT7wEmzTvZFac_jYaCctqY_cDhWr80j/s1600/delivery_agent_connected.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="421" data-original-width="1600" height="168" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEihBW0PoRtNZpQ4Lhh15zV0uY0-AnzcgTEmPEz6WDiwM0zTSuEPSbAjB7N2dvdDGdWEJ4SjqG8R4pCwKqAw6A-RvPu5cRVUAJ4CDDsyjPYByaT7wEmzTvZFac_jYaCctqY_cDhWr80j/s640/delivery_agent_connected.png" width="640" /></a></div>
<br />
<br />
Inside this method, the TargetConext will be updated with the status <b><i>REQUEST_READY</i></b>. At the same time, the TargetContext will be set with the messageContext and then the message will be sent to the <b>submitRequest() </b>method.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhV5R4cvQcgVCffEfqGJC3R_IJzsqeuxNtNK8bWnQV4KQIHJFkuDMBQyqluR5aB1cHH1avdrCa6DHpNd9_dCGywhXrvbrRDgdtpejPQ5gkJ4sZfI5VD8NsKxF6PEkmPHAzbgln7azUY/s1600/tryNextMessage.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="232" data-original-width="1600" height="92" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhV5R4cvQcgVCffEfqGJC3R_IJzsqeuxNtNK8bWnQV4KQIHJFkuDMBQyqluR5aB1cHH1avdrCa6DHpNd9_dCGywhXrvbrRDgdtpejPQ5gkJ4sZfI5VD8NsKxF6PEkmPHAzbgln7azUY/s640/tryNextMessage.png" width="640" /></a></div>
<br />
<br />
When the <b>submitRequest()</b> method is called, it would create a TargetRequest and attach it to the TargetContext.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi7z6REmCSYthPi3bmBimnD_xweqqDTQboAFkwLzIOVW32fhNOODGssdZQzWmJwXWpRvQGbhwybNiyoMKgG3MQS3rAJ_37tbVVk9KGQYZ9ZAduaQGDo9f80wO3Ga9zLklRcLVCOKOvH/s1600/delivery_agent_submitRequest.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="656" data-original-width="1600" height="262" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi7z6REmCSYthPi3bmBimnD_xweqqDTQboAFkwLzIOVW32fhNOODGssdZQzWmJwXWpRvQGbhwybNiyoMKgG3MQS3rAJ_37tbVVk9KGQYZ9ZAduaQGDo9f80wO3Ga9zLklRcLVCOKOvH/s640/delivery_agent_submitRequest.png" width="640" /></a></div>
<br />
Next is the invocation of the<b> requestReady() </b>method of the TargetHandler class where the HTTP headers are written to the TargetRequest.<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjfKHe6bWYfn1rOLMtmGR7bUCge_n7mTFQ1QeoUu92bBmbQdEEJdkZVDrspSrI0ZD0ql2OVW9sDg9C5JXLH8ttstU_FUatNTi3OKmJuFf7wxxC8cr_jhbk1FBJVVuL7mub9rXDpm558/s1600/get_target_request.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="230" data-original-width="1600" height="92" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjfKHe6bWYfn1rOLMtmGR7bUCge_n7mTFQ1QeoUu92bBmbQdEEJdkZVDrspSrI0ZD0ql2OVW9sDg9C5JXLH8ttstU_FUatNTi3OKmJuFf7wxxC8cr_jhbk1FBJVVuL7mub9rXDpm558/s640/get_target_request.png" width="640" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhcHSij61Sq7zAzV6TBaFAYkmaeLCpUw7EK_vKkwGNrMDL8YsbLK_-ML9qo2SyrUVt1ZBgcFQB2QUrtZOjQmKL_ZVH98E6ddSl-ilUz8yiX3ZtTSOviqtkey9LHWXdeQkRmm5F5lO_P/s1600/set_headers_for_request.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="431" data-original-width="1600" height="172" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhcHSij61Sq7zAzV6TBaFAYkmaeLCpUw7EK_vKkwGNrMDL8YsbLK_-ML9qo2SyrUVt1ZBgcFQB2QUrtZOjQmKL_ZVH98E6ddSl-ilUz8yiX3ZtTSOviqtkey9LHWXdeQkRmm5F5lO_P/s640/set_headers_for_request.png" width="640" /></a></div>
<br />
<br />
Then the <b>outputReady() </b>of the <i>TargetHandler</i> is called; where the <b>write()</b> method of the TargetRequest is hit.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjY6GyPpGIlhZ8bdfBjoq4yybXQeEliFzOXznoPG_4byxhLWp3m4GQWf14SReju-0d6UBFvVYiYbdEn-U6NbaofSAoFlvNLYJoPlYETXBUKNgFEh9sNEctcc5CYKuu3p_rF4pLKY7Z8/s1600/targetHandler_outputReady.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="484" data-original-width="1600" height="192" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjY6GyPpGIlhZ8bdfBjoq4yybXQeEliFzOXznoPG_4byxhLWp3m4GQWf14SReju-0d6UBFvVYiYbdEn-U6NbaofSAoFlvNLYJoPlYETXBUKNgFEh9sNEctcc5CYKuu3p_rF4pLKY7Z8/s640/targetHandler_outputReady.png" width="640" /></a></div>
<br />
<br />
In this method, it reads the data that was written before to the pipe and writes it to the wire. Once this is done, the Protocol status is also updated to <b><i>REQUEST_DONE</i></b>.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiAx-RQPv64AapWoygWDLootc7hGQ-1qqbDWtaOjx3Wyu_gxMmKtKCDcoRSVqGcreHD2Wf2TrnLyvw624evwj5rClVp7WdTosv3LP5r5JIX-Ya-dZfkARMwlwCM5B1qgw2r2xzRn2cO/s1600/write_to_wire.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="389" data-original-width="1600" height="154" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiAx-RQPv64AapWoygWDLootc7hGQ-1qqbDWtaOjx3Wyu_gxMmKtKCDcoRSVqGcreHD2Wf2TrnLyvw624evwj5rClVp7WdTosv3LP5r5JIX-Ya-dZfkARMwlwCM5B1qgw2r2xzRn2cO/s640/write_to_wire.png" width="640" /></a></div>
<br />
<br />
There you go! Now you know how the request messages are being passed on from the Worker threads to the IO threads within WSO2 ESB.<br />
<br />
<br />Evanthikahttp://www.blogger.com/profile/02913709559298376105noreply@blogger.com0tag:blogger.com,1999:blog-59077094557892.post-72789763604904693522017-05-28T07:39:00.000-07:002017-05-28T07:46:48.850-07:00How to send an email with a text that has new lines (\n) in ESB 5.0.0<div class="separator" style="clear: both; text-align: center;">
<br /></div>
Assume that we want to send an email with the following text.<br />
<br />
<span style="border: 2px solid rgb(192, 192, 192); display: block; padding: 5px;">
<span style="font-size: x-small;">Hello world!!!<br /><br />My Name is Evanthika Amarasiri.<br /><br />I work for the support team.</span></span><br />
<br />
I need to send this email in the above format with new lines between each sentence.<br />
<br />
How can we make this possible with WSO2 ESB?<br />
<br />
So to support this, what you first need is to configure the WSO2 ESB to support email sending. This can be done by following the configuration mentioned in our <a href="https://docs.wso2.com/display/ESB500/MailTo+Transport">product documentation</a>.<br />
<br />
Once done, start up the ESB server and create a Proxy service with the following configuration.<br />
<br />
<span style="border: 2px solid rgb(192, 192, 192); display: block; padding: 5px;">
<?xml version="1.0" encoding="UTF-8"?><br />
<proxy xmlns="http://ws.apache.org/ns/synapse"<br />
name="EmailSender"<br />
transports="https http"<br />
startOnLoad="true"><br />
<description/><br />
<target><br />
<endpoint><br />
<address uri="http://localhost:9000/services/SimpleStockQuoteService"/><br />
</endpoint><br />
<inSequence><br />
<log/><br />
<property name="messageType" value="text/xml" scope="axis2" type="STRING"/><br />
<property name="ContentType" value="text/xml" scope="axis2"/><br />
<property name="Subject" value="Testing ESB" scope="transport"/><br />
<property name="OUT_ONLY" value="true"/><br />
<property name="FORCE_SC_ACCEPTED" value="true" scope="axis2"/><br />
<payloadFactory media-type="xml"><br />
<format><br />
<ns:text xmlns:ns="http://ws.apache.org/commons/ns/payload">$1</ns:text><br />
</format><br />
<args><br />
<arg evaluator="xml"<br />
expression="concat('Hello world!!!','&#10;','&#10;', 'My Name is Evanthika Amarasiri.','&#10;','&#10;', 'I work for the support team.')"/><br />
</args><br />
</payloadFactory><br />
<log level="full"/><br />
<send><br />
<endpoint><br />
<address uri="mailto:evanthika@wso2.com"/><br />
</endpoint><br />
</send><br />
</inSequence><br />
<outSequence><br />
<send/><br />
</outSequence><br />
</target><br />
</proxy><br />
</span>
<br />
<br />
Note the below line that is inside the PayloadFactory mediator.<br />
<br />
<span style="border: 2px solid rgb(192, 192, 192); display: block; padding: 5px;">
<arg evaluator="xml" expression="concat('Hello world!!!', '&#10;','&#10;', 'My Name
is Evanthika Amarasiri.','&#10;','&#10;', 'I work for the support team.')"/></span><br />
<br />
To support new lines what you need to add is '
' in between the text you want the new line to be.<br />
<br />
Once the above proxy service is deployed, send a request to the proxy service and you should get an email attachment with the below content.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjbY0ALy_dk0CBgprnrb-t8ednWC043S-yy3UJJoH73CdQ3cHzIk-x-q8g8Jpns19mhOiuB6T37qOJd0HATVlnMk3YiIwESv0Gv34Q3lAIMbTmnnyMSwV9napgxdiu-Bp_Qk6_4p0Ly/s1600/Screen+Shot+2017-05-28+at+7.54.25+PM.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="230" data-original-width="818" height="89" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjbY0ALy_dk0CBgprnrb-t8ednWC043S-yy3UJJoH73CdQ3cHzIk-x-q8g8Jpns19mhOiuB6T37qOJd0HATVlnMk3YiIwESv0Gv34Q3lAIMbTmnnyMSwV9napgxdiu-Bp_Qk6_4p0Ly/s320/Screen+Shot+2017-05-28+at+7.54.25+PM.png" width="320" /></a></div>
NOTE: In WSO2 ESB 4.8.1 this cannot be done from the UI and has a known issue. Therefore, as a solution, you need to add the configuration to the physical proxy configuration file which resides under wso2esb-4.8.1/repository/deployment/server/synapse-configs/default/proxy-services<br />
Evanthikahttp://www.blogger.com/profile/02913709559298376105noreply@blogger.com0tag:blogger.com,1999:blog-59077094557892.post-75861106620918201802017-05-26T01:24:00.003-07:002017-05-26T01:24:27.731-07:00Validating JSON arrays when the payload is sent as a query parameter with WSO2 ESBIn my previous <a href="http://evanthika.blogspot.com/2017/05/validating-json-payloads-when-payload.html">post</a>, I explained how JSON payloads can be validated when it's sent as a query parameter. Using the same Synapse configuration without doing any changes, we will see how JSON arrays can be validated by tweaking the JSON schema.<br />
<br />
Assume that my requirement is to send a JSON array as a query parameter as shown below.<br />
<span style="border: 2px solid rgb(192, 192, 192); display: block; padding: 5px;">
http://localhost:8280/jsonAPI/jsonapi?jsonPayload=[{"getQuote": {"request": {"symbol": "WSO2"}}},{"getQuote": {"request": {"symbol": "MSFT"}}}]
</span>
<br />
<br />
Create an API using the same configuration which we have used in the <a href="http://evanthika.blogspot.com/2017/05/validating-json-payloads-when-payload.html">previous post</a>.<br />
<br />
<span style="border: 2px solid rgb(192, 192, 192); display: block; padding: 5px;">
<api context="/jsonAPI" name="jsonAPI"><br /> <resource methods="GET" protocol="http" uri-template="/jsonapi"><br /> <inSequence><br /> <property expression="$url:jsonPayload"<br /> name="jsonKeyValue" scope="default" type="STRING"/><br /> <payloadFactory media-type="json"><br /> <format>$1</format><br /> <args><br /> <arg evaluator="xml" expression="get-property('jsonKeyValue')"/><br /> </args><br /> </payloadFactory><br /> <validate><br /> <schema key="conf:/schema/StockQuoteSchema.json"/><br /> <on-fail><br /> <payloadFactory media-type="json"><br /> <format>{"Error":"$1"}</format><br /> <args><br /> <arg evaluator="xml" expression="$ctx:ERROR_MESSAGE"/><br /> </args><br /> </payloadFactory><br /> <respond/><br /> </on-fail><br /> </validate><br /> <respond/><br /> </inSequence><br /> </resource><br /> </api><br />
</span><br />
The <b>StockQuoteSchema.json</b> which you have created under the path conf:/schema/StockQuoteSchema.json should be written in the following format.<br />
<br />
<span style="border: 2px solid rgb(192, 192, 192); display: block; padding: 5px;">
{<br /> "$schema": "http://json-schema.org/draft-04/schema#",<br /> "type": "<span style="color: blue;"><b>array</b></span>",<br /> "<span style="color: blue;"><b>items</b></span>": <b><span style="color: blue;">[</span></b>{<br /> "getQuote": {<br /> "type": "object",<br /> "properties": {<br /> "request": {<br /> "type": "object",<br /> "properties": {<br /> "symbol": {<br /> "type": "string"<br /> }<br /> },<br /> "required": [<br /> "symbol"<br /> ]<br /> }<br /> },<br /> "required": [<br /> "request"<br /> ]<br /> }<br /> }<span style="color: blue;"><b>]</b></span>,<br /> "required": [<br /> "getQuote"<br /> ]<br />}<br />
</span><br />
Note the text marked in blue. In the previous example, when a simple JSON payload was sent, the value of the <b>type </b>was set to object whereas in this scenario, since it's handling JSON arrays, it should be set to <b>array</b>.<br />
<br />
On the other hand, since your JSON payload is sending an array, the schema should list elements to be checked inside a block called <b>items</b> with the JSON body wrapped inside square brackets i.e.; [] as highlighted above. <br />
<br />
So once the above configuration is done, and the GET request is sent to the API, you should see the following output if everything goes well.<br />
<br />
<span style="border: 2px solid rgb(192, 192, 192); display: block; padding: 5px;">
[<br /> {<br /> "getQuote": {<br /> "request": {<br /> "symbol": "WSO2"<br /> }<br /> }<br /> },<br /> {<br /> "getQuote": {<br /> "request": {<br /> "symbol": "MSFT"<br /> }<br /> }<br /> }<br />] <br />
</span>
Evanthikahttp://www.blogger.com/profile/02913709559298376105noreply@blogger.com0tag:blogger.com,1999:blog-59077094557892.post-87454957613339078592017-05-25T22:56:00.002-07:002017-05-25T23:02:12.703-07:00Validating JSON payloads when the payload is sent as a query parameter in WSO2 ESBIn cases where we want to validate a JSON payload against a particular schema that is being sent by the client before sending it to the backend, we can use the Validate mediator of WSO2 ESB. This support has been added from WSO2 ESB v5.0.0 onward. The samples given in the <a href="https://docs.wso2.com/display/ESB500/Validate+Mediator#json">WSO2 ESB documentation</a> are for scenarios where the JSON payload is sent as a message body. <br />
<br />
However, if the JSON payload is being sent as a query parameter, the configuration given in the samples will not work and we will have to tweak the configuration to support this. Given below is an example scenario which explains this in detail.<br />
<br />
I have an API deployed in WSO2 ESB which does a GET call by passing the JSON message payload as a query parameter.<br />
<br />
<span style="border: 2px solid rgb(192, 192, 192); display: block; padding: 5px;">
http://localhost:8280/jsonAPI/jsonapi?jsonPayload={"getQuote": {"request": {"symbol": "WSO2"}}}<br />
</span>
<br />
The schema (StockQuoteSchema.json) used to validate the incoming payload is as below. Note that this schema is saved in the registry under the path <b>/_system/config/schema</b><br />
<br />
<span style="border: 2px solid rgb(192, 192, 192); display: block; padding: 5px;">
{<br /> "$schema": "http://json-schema.org/draft-04/schema#",<br /> "type": "object",<br /> "properties": {<br /> "getQuote": {<br /> "type": "object",<br /> "properties": {<br /> "request": {<br /> "type": "object",<br /> "properties": {<br /> "symbol": {<br /> "type": "string"<br /> }<br /> },<br /> "required": [<br /> "symbol"<br /> ]<br /> }<br /> },<br /> "required": [<br /> "request"<br /> ]<br /> }<br /> },<br /> "required": [<br /> "getQuote"<br /> ]<br />} <br />
</span><br />
To validate the JSON object passed as a query parameter in the URL from the parameter <b>jsonPayload</b> the following API configuration should be used.<br />
<br />
<span style="border: 2px solid rgb(192, 192, 192); display: block; padding: 5px;">
<api context="/jsonAPI" name="jsonAPI"><br /> <resource methods="GET" protocol="http" uri-template="/jsonapi"><br /> <inSequence><br /> <property expression="$url:jsonPayload"<br /> name="jsonKeyValue" scope="default" type="STRING"/><br /> <payloadFactory media-type="json"><br /> <format>$1</format><br /> <args><br /> <arg evaluator="xml" expression="get-property('jsonKeyValue')"/><br /> </args><br /> </payloadFactory><br /> <validate><br /> <schema key="conf:/schema/StockQuoteSchema.json"/><br /> <on-fail><br /> <payloadFactory media-type="json"><br /> <format>{"Error":"$1"}</format><br /> <args><br /> <arg evaluator="xml" expression="$ctx:ERROR_MESSAGE"/><br /> </args><br /> </payloadFactory><br /> <respond/><br /> </on-fail><br /> </validate><br /> <respond/><br /> </inSequence><br /> </resource><br /> </api><br />
</span>
<br />
<br />
With this Synapse configuration in place, the validation should happen flawlessly.<br />
<br />
<br />
<br />Evanthikahttp://www.blogger.com/profile/02913709559298376105noreply@blogger.com0tag:blogger.com,1999:blog-59077094557892.post-69572279266168091772017-05-23T09:52:00.003-07:002017-05-23T09:57:04.540-07:00Mediation flow of WSO2 ESB<div style="text-align: center;">
</div>
<br />
<a href="https://docs.wso2.com/display/ESB500/WSO2+Enterprise+Service+Bus+Documentation">WSO2 ESB</a> is one of the most important products in the WSO2 product stacks which enables users to do all sorts of transformations. Instead of having to make each of your applications communicate directly with each other in all their various formats, each application simply communicates with the WSO2 ESB, which handles transforming and routing the messages to their appropriate destinations. While working with this product, we believe it is important to understand how the messages flow through ESB. So when a message comes inside ESB, it goes through the transport layer and then the Axis2 engine which converts the incoming message into a SOAP envelope.<br />
<br />
Once converted, it is then handed over to the Mediation engine, which is considered as the backbone of the product. This is where all the mediation work happens. In this post, I will be explaining in detail what happens to a message which comes inside ESB and the path it takes until a response is delivered back to the client.<br />
<br />
To explain the scenario, I will use the below Proxy Service which talks to a simple back-end and logs a message in the inSequence as well as the outSequence.<br />
<br />
<span style="border: 2px solid rgb(192, 192, 192); display: block; padding: 5px;">
<proxy name="DebugProxy" startOnLoad="true" transports="https http"><br />
<description/><br />
<target><br />
<endpoint><br />
<address uri="http://localhost:9000/services/SimpleStockQuoteService"/><br />
</endpoint><br />
<inSequence><br />
<log level="full"><br />
<property name="IN_SEQ" value="Executing In Sequence"/><br />
</log><br />
</inSequence><br />
<outSequence><br />
<log level="full"><br />
<property name="OUT_SEQ" value="Inside the out sequence"/><br />
</log><br />
<send/><br />
</outSequence><br />
<faultSequence><br />
<log level="full"><br />
<property name="FAULT_SEQ" value="Inside Fault Sequence"/><br />
</log><br />
</faultSequence><br />
</target><br />
</proxy> <proxy name="DebugProxy" startonload="true" transports="https http"><br /> <description> </description></proxy>
</span>
<br />
The entry point to the mediation engine for a message which comes in to a Proxy Service, is the receive method of the <i>ProxyServiceMessageReceiver</i> while for the message out-flow, the entry point is <i>SynapseCallbackReceiver</i>. Below I've listed down each method that is being called in each class inside the Mediation engine.<br />
<br />
<div style="text-align: center;">
<b>In-flow </b></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjXzRKpW0m7pd69nyUy5nkMdzENcjzSpy4DR2ifi_HHyW_0mS-6v_76BXGio0U1QC0cjYXB3b97qlhdnPbOlfNlbT_jB5XwIZTK75jNPoKB5n7aA9MjqImdmyEEvE7i3uRI4RTnrMcj/s1600/inflow.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="371" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjXzRKpW0m7pd69nyUy5nkMdzENcjzSpy4DR2ifi_HHyW_0mS-6v_76BXGio0U1QC0cjYXB3b97qlhdnPbOlfNlbT_jB5XwIZTK75jNPoKB5n7aA9MjqImdmyEEvE7i3uRI4RTnrMcj/s640/inflow.png" width="640" /></a></div>
<br />
<div style="text-align: center;">
<b>Out-flow </b></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjjyVuGLTJsndMiODjoy4683I46Gn-q9ugEze9GyNBmSemiLylFjMoRbgSRVo2ZP98nFeczhBXEZB1IVqESzzwmzVp8k4sbkYdV2urYPPrkNXR6bUGoLRKF0FaYt6-ckV7D6Mh-vJpo/s1600/outflow.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="158" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjjyVuGLTJsndMiODjoy4683I46Gn-q9ugEze9GyNBmSemiLylFjMoRbgSRVo2ZP98nFeczhBXEZB1IVqESzzwmzVp8k4sbkYdV2urYPPrkNXR6bUGoLRKF0FaYt6-ckV7D6Mh-vJpo/s640/outflow.png" width="640" /></a></div>
<br />Evanthikahttp://www.blogger.com/profile/02913709559298376105noreply@blogger.com0tag:blogger.com,1999:blog-59077094557892.post-81812003592718330232017-04-25T05:31:00.001-07:002017-11-27T18:57:46.456-08:00Enabling SSL Tunneling through a Squid Proxy Server with authenticationThis post will describe how we can proxy our outgoing requests through ESB using a Squid Proxy Server. For more information on the scenario, you can refer the <a href="https://docs.wso2.com/display/ESB481/Enabling+SSL+Tunneling+through+a+Proxy+Server">WSO2 ESB documentation</a>.<br />
<br />
<b>Step 1 - Setting up Squid Proxy Server</b><br />
<br />
To setup a Squid Proxy Server locally, you can follow the instructions available <a href="https://help.ubuntu.com/14.04/serverguide/squid.html">here</a>.<br />
<br />
<b>Step 2 - Configuring Squid Proxy Server - updating the squid.conf file</b><br />
<br />
Add the following line under the <b>acl</b> section<br />
<br />
<span style="border: 2px solid rgb(192, 192, 192); display: block; padding: 5px;">
acl squid.proxy.server src appserver.wso2.com<br />
</span>
<br />
<br />
Note: If you will not be able to start the squid server with the above config, you might have to set an /etc/hosts entry for the host <i>appserver.wso2.com</i>.<br />
<br />
The following should be added before the <b>http_access TAG</b><br />
<br />
<span style="border: 2px solid rgb(192, 192, 192); display: block; padding: 5px;">
http_access allow squid.proxy.server<br />
</span>
<br />
<br />
Note: We will be referring to this proxy server instance by the name squid.proxy.server. Hence, you need to add this entry to the /etc/hosts file which resides in your local instance as well as to the instance where the Squid server is running.<br />
<br />
Add the following port information before the <b>https_port TAG section</b><br />
<br />
<span style="border: 2px solid rgb(192, 192, 192); display: block; padding: 5px;">
http_port 8888<br />
</span>
<br />
<br />
Once the above is added to the squid.conf file, restart the Squid server<br />
<br />
<span style="border: 2px solid rgb(192, 192, 192); display: block; padding: 5px;">
sudo service squid3 restart
</span>
<br />
<br />
<b>Step 3 - Enabling the proxy configuration in WSO2 ESB</b><br />
<br />
To do this, add the below configuation to the axis2.xml under the PassThroughHttpSender, PassThroughHttpSSLSender configuration<br />
<br />
<span style="border: 2px solid rgb(192, 192, 192); display: block; padding: 5px;">
<parameter name="http.proxyHost" locked="false">squid.proxy.server</parameter>
<parameter name="http.proxyPort" locked="false">8888</parameter>
</span>
<br />
<br />
<b>Step 4 - Creating a Proxy Service </b><br />
<br />
Once the above configurations are done and the WSO2 ESB server is restarted, you can create a simple Passthrough Proxy service to test the scenario.<br />
Note that as the endpoint, I am using a backend where I'm referring to from a host name called appserver.wso2.com. This was the hostname which we added to the squid.conf file above under the <b>acl</b> section. <br />
<br />
<span style="border: 2px solid rgb(192, 192, 192); display: block; padding: 5px;"><proxy name="SSLTunnelingProxy"<br /> transports="https http"<br /> startOnLoad="true"<br /> trace="disable"><br /> <description/><br /> <target><br /> <inSequence><br /> <send><br /> <endpoint><br /> <address uri="https://appserver.wso2.com/services/SimpleStockQuoteService"/><br /> </endpoint><br /> </send><br /> </inSequence><br /> <outSequence><br /> <send/><br /> </outSequence><br /> </target><br /> </proxy></span>
<br />
<br />
<b>Step 5 - Setting up the backend</b><br />
<b> </b><br />
For this scenario, you can take an WSO2 Application Server instance and start it up with ports 443 and 80 as default ports. Then, set the HostName parameter in carbon.xml to appserver.wso2.com. Deploy the SimpleStockQuoteService and you are ready to go.<br />
<br />
<b><b>Step 6 - Invoking the Proxy Service</b> </b><br />
<br />
Using a preferred client of yours you can test the scenario. If the message is sent through the Proxy server, you should see logs as shown below in /var/logs/squid/access.log file.<br />
<br />
<span style="border: 2px solid rgb(192, 192, 192); display: block; padding: 5px;">
1493112155.126 49234 127.0.0.1 TCP_MISS/200 2335 CONNECT appserver.wso2.com:443 - HIER_DIRECT/192.168.53.176 -<br />1493112888.241 0 10.100.7.144 TCP_DENIED_REPLY/403 3429 CONNECT appserver.wso2.com:443 - HIER_NONE/- text/html<br />
</span>
<br />
<br />
<b>Step 7 - Configure authentication in Squid</b><br />
<br />
To enable authentication in Squid, the following configuration needs to be done.<br />
<br />
Add the following to the squid.conf profile under <i><b>TAG: auth_param</b></i><br /><br />
<span style="border: 2px solid rgb(192, 192, 192); display: block; padding: 5px;">auth_param basic program /usr/lib/squid3/ncsa_auth /etc/squid3/passwords<br />auth_param basic realm proxy</span><br />
<br />
Note: In ubuntu 12 - the file should be <b>ncsa_auth</b> & in ubuntu 14 - the file is <b>basic_ncsa_auth</b>.<br />
<br />
Next, under the <i><b>TAG: acl</b></i> add the following<br /><br /><span style="border: 2px solid rgb(192, 192, 192); display: block; padding: 5px;">acl authenticated proxy_auth REQUIRED<br /></span>
<br />
The following should be added under the <i><b>TAG: http_access</b></i>.<br /><br /><span style="border: 2px solid rgb(192, 192, 192); display: block; padding: 5px;">http_access allow authenticated</span><br />
<br />
<b>Step 8 - Setting up a user</b><br />
<br />
As a pre-requisite Apache2 Utils will have to be installed.<br />
<br /><span style="border: 2px solid rgb(192, 192, 192); display: block; padding: 5px;">
sudo apt-get install apache2-utils</span><br />
<br />
To create a new user, use the following command.<br />
<br /><span style="border: 2px solid rgb(192, 192, 192); display: block; padding: 5px;">
sudo htpasswd -c /etc/squid3/passwords <<username_you_like>></username_you_like></span><br />
<br />
When it prompts for the password, specify a password of your choice.<br />
<br />
<br />
<br />
<br />
<br />
<br />Evanthikahttp://www.blogger.com/profile/02913709559298376105noreply@blogger.com0tag:blogger.com,1999:blog-59077094557892.post-47600546593975029062017-04-25T02:45:00.003-07:002017-04-25T03:00:37.031-07:00Reason for "PasswordInvalidAsk Password Feature is disabled" error when adding through RemoteUserStoreManagerWhen trying to add users from RemoteUserStoreManager it returned the following SOAP fault.<br />
<br />
<br />
<span style="border: 2px solid rgb(192, 192, 192); display: block; padding: 5px;"><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><br /> <soapenv:Body><br /> <soapenv:Fault><br /> <faultcode>soapenv:Server</faultcode><br /> <faultstring>PasswordInvalidAsk Password Feature is disabled</faultstring><br /> <detail/><br /> </soapenv:Fault><br /> </soapenv:Body><br /></soapenv:Envelope><br />
</span>
<br />
<br />
The reason for this issue is that I have forgotten to add the <ser:credential> element in the SOAP message. Once this element was added, I was able to successfully create the user.</ser:credential>Evanthikahttp://www.blogger.com/profile/02913709559298376105noreply@blogger.com0tag:blogger.com,1999:blog-59077094557892.post-64598656523925876602017-03-29T05:25:00.004-07:002017-03-29T05:25:32.682-07:00Why doesn't my WSO2 server restart as expected when the Windows instance restarts when WSO2 server is installed as a serviceWhen the <b>Startup Type</b> of a Carbon server that is configured as a Windows service is set to <b><i>Manual</i></b> and when the instance that the WSO2 server is running on restarts, the WSO2 Server will not get restarted along with it.<br />
<br />
For the WSO2 server to be restarted when the Windows instance restarts, you need to set <b>Startup Type</b> to <i><b>Automatic</b></i> instead as shown below. See attachment below.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgi9LUGOXB1IZR7H_1MJAr_ZaBxZEpBzMabxbySpNBGU9bQs20WZsrbpkugNKDCdRtvnq1mGDGw1AM5K7HUSiyvW4Jmrn_hTTImQLZxWYggeRIS03ENyDODtH5IejEwFx0__1IwXWfY/s1600/windows_service.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="93" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgi9LUGOXB1IZR7H_1MJAr_ZaBxZEpBzMabxbySpNBGU9bQs20WZsrbpkugNKDCdRtvnq1mGDGw1AM5K7HUSiyvW4Jmrn_hTTImQLZxWYggeRIS03ENyDODtH5IejEwFx0__1IwXWfY/s320/windows_service.png" width="320" /></a></div>
<br />
<br />
<br />
<br />
<br />To change this setting, go to <b>Control Panel\All Control Panel Items\Administrative Tools\Services </b>and change the type from <i><b>Manual</b></i> to <i><b>Automatic</b></i>.<br />
Evanthikahttp://www.blogger.com/profile/02913709559298376105noreply@blogger.com0tag:blogger.com,1999:blog-59077094557892.post-46756969310454651082016-12-10T00:36:00.000-08:002016-12-10T02:26:02.888-08:00How to configure Elasticsearch, Filebeat and Kibana to view WSO2 Carbon logsThis blog will explain the most basic steps one should follow to configure Elasticsearch, Filebeat and Kibana to view WSO2 product logs.<br />
<h4>
Pre-requisites</h4>
I have written this document assuming that we are using the below product versions.<br />
<br />
Download the below versions of Elasticsearch, filebeat and Kibana.<br />
Elasticsearch - <a href="https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.1.1.deb">5.1.1</a><br />
Filebeat - <a href="https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-5.1.1-amd64.deb">5.1.1</a><br />
Kibana - <a href="https://www.elastic.co/downloads/kibana">5.1.1</a><br />
<h3>
<b>How to configure Filebeat</b></h3>
1. Download Filebeat to the server where you Carbon Product is running.<br />
2. You can install it in any of the methods mentioned at [1].<br />
3. Then, open up the <i>filebeat.yml</i> file and change the file path mentioned under <b>filebeat.prospectors.</b><br />
<br />
<span style="border: 2px solid rgb(192, 192, 192); display: block; padding: 5px;">
filebeat.prospectors:<br />
- input_type: log<br />
paths:<br />
- /home/ubuntu/wso2esb-4.9.0/repository/logs/wso2carbon.log<br />
</span><br />
<br />
4. Configure the <i>output.elasticsearch</i> and point to the server where you are running Elasticsearch.<br />
<br />
<span style="border: 2px solid rgb(192, 192, 192); display: block; padding: 5px;">
output.elasticsearch:<br />
hosts: ["192.168.52.99:9200"]<br />
</span>
<br />
5. If you are using a template other that what's being used by default, you can change the configuration as below.<br />
<br />
<span style="border: 2px solid rgb(192, 192, 192); display: block; padding: 5px;">
output.elasticsearch:<br />
hosts: ["192.168.52.99:9200"]<br />
template.name: "filebeat"<br />
template.path: "filebeat.template-es2x.json"<br />
template.overwrite: false <br />
</span><br />
<br />
<br />
6. Once the above configuration are done, start your Filebeat server using the options given at [2].<br />
<br />
<br />
<br />
<h3>
Configuring ElasticSearch</h3>
1. For better performance, it is requested to use Elasticsearch on JDK 1.8. Hence, as the first step, make sure you install JDK 1.8.0 on your machine before continuing with the rest of the steps mentioned here.<br />
<br />
2. Install Elasticsearch using the below command<br />
<br />
<span style="border: 2px solid rgb(192, 192, 192); display: block; padding: 5px;">
sudo dpkg -i elasticsearch-5.1.1.deb<br />
</span>
<br />
<br />
3. For the most basic scenario, you only need to configure the host by specifying the IP of the node that Elasticsearch is running on.<br />
<br />
<span style="border: 2px solid rgb(192, 192, 192); display: block; padding: 5px;">
network.host: 192.168.52.99
</span>
<br />
<br />
4. Now start the ElasticSearch server.<br />
<br />
<span style="border: 2px solid rgb(192, 192, 192); display: block; padding: 5px;">
sudo service elasticsearch start
</span>
<br />
<h3>
Viewing the logs from Kibana</h3>
1. Extract Kibana to a preferred location.<br />
<br />
2. Open the <i>kibana.yml</i> file and point to your Elasticsearch server.<br />
<br />
<span style="border: 2px solid rgb(192, 192, 192); display: block; padding: 5px;">
elasticsearch.url: "http://192.168.52.99:9200"
</span>
<br />
<br />
3. Access the Kibana server from the URL <b>http://localhost:5601</b> and you can view the WSO2 carbon logs.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiuHoRtKzqlMfd03FWNcg7KBjJKT9VFkYFd1LY-IoaVFdmU5AnulwVS88zMbOA6lsuUKGvmn89PVHHTKMKpPpi9jAAx6Xd7yxmld2NprPOR4GWl-Mecah4RtDX3MnZfd63RLdQ_-VIP/s1600/Kibana.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="163" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiuHoRtKzqlMfd03FWNcg7KBjJKT9VFkYFd1LY-IoaVFdmU5AnulwVS88zMbOA6lsuUKGvmn89PVHHTKMKpPpi9jAAx6Xd7yxmld2NprPOR4GWl-Mecah4RtDX3MnZfd63RLdQ_-VIP/s320/Kibana.png" width="320" /></a></div>
<br />
<br />
[1] - https://www.elastic.co/guide/en/beats/filebeat/5.x/filebeat-installation.html<br />
[2] - https://www.elastic.co/guide/en/beats/filebeat/5.x/filebeat-starting.htmlEvanthikahttp://www.blogger.com/profile/02913709559298376105noreply@blogger.com0tag:blogger.com,1999:blog-59077094557892.post-9633651208492644632016-12-06T01:27:00.001-08:002017-10-11T02:31:51.950-07:00How to access an ActiveMQ queue from WSO2 ESB which is secured with a username/passwordBy default, a queue in ActiveMQ can be accessed without providing any credentials. However, in real world scenarios, you will have to deal with secured queues. So in this blog, I will explain how we can enable security for ActiveMQ and what configurations are required to be done in WSO2 ESB.<br />
<br />
<b>Pr-requisites - </b>Enable the JMS transport for WSO2 ESB as explained in [1].<br />
<br />
<b>Step 1 - Secure the ActiveMQ instance with credentials.</b><br />
<br />
To do this, add the below configuration to the activemq.xml under the <broker> tag and start the server.<br />
<br />
<span style="border: 2px solid rgb(192, 192, 192); display: block; padding: 5px;"><plugins><br /> <simpleAuthenticationPlugin anonymousAccessAllowed="true"><br /> <users><br /> <authenticationUser username="system" password="system" groups="users,admins"/><br /> <authenticationUser username="admin" password="admin" groups="users,admins"/><br /> <authenticationUser username="user" password="user" groups="users"/><br /> <authenticationUser username="guest" password="guest" groups="guests"/><br /> </users><br /> </simpleAuthenticationPlugin><br /></plugins></span><br />
<br />
<b>Step 2 - Enable the JMS Listener configuration and configure it as shown below.</b><br />
<b><br /></b>
<span style="border: 2px solid rgb(192, 192, 192); display: block; padding: 5px;"> <!--Uncomment this and configure as appropriate for JMS transport support, after setting up your JMS environment (e.g. ActiveMQ)--><br /> <transportReceiver name="jms" class="org.apache.axis2.transport.jms.JMSListener"><br /> <parameter name="myTopicConnectionFactory" locked="false"><br /> <parameter name="java.naming.factory.initial" locked="false">org.apache.activemq.jndi.ActiveMQInitialContextFactory</parameter><br /> <parameter name="java.naming.provider.url" locked="false">tcp://localhost:61616</parameter><br /> <parameter name="java.naming.security.principal" locked="false">admin</parameter><br /> <parameter name="java.naming.security.credentials" locked="false">admin</parameter><br /> <parameter locked="false" name="transport.jms.UserName">admin</parameter><br /> <parameter locked="false" name="transport.jms.Password">admin</parameter><br /> <parameter name="transport.jms.ConnectionFactoryJNDIName" locked="false">TopicConnectionFactory</parameter><br /> <parameter name="transport.jms.ConnectionFactoryType" locked="false">topic</parameter><br /> </parameter><br /><br /> <parameter name="myQueueConnectionFactory" locked="false"><br /> <parameter name="java.naming.factory.initial" locked="false">org.apache.activemq.jndi.ActiveMQInitialContextFactory</parameter><br /> <parameter name="java.naming.provider.url" locked="false">tcp://localhost:61616</parameter><br /> <parameter name="java.naming.security.principal" locked="false">admin</parameter><br /> <parameter name="java.naming.security.credentials" locked="false">admin</parameter><br /> <parameter locked="false" name="transport.jms.UserName">admin</parameter><br /> <parameter locked="false" name="transport.jms.Password">admin</parameter><br /> <parameter name="transport.jms.ConnectionFactoryJNDIName" locked="false">QueueConnectionFactory</parameter><br /> <parameter name="transport.jms.ConnectionFactoryType" locked="false">queue</parameter><br /> </parameter><br /><br /> <parameter name="default" locked="false"><br /> <parameter name="java.naming.factory.initial" locked="false">org.apache.activemq.jndi.ActiveMQInitialContextFactory</parameter><br /> <parameter name="java.naming.provider.url" locked="false">tcp://localhost:61616</parameter><br /> <parameter name="java.naming.security.principal" locked="false">admin</parameter><br /> <parameter name="java.naming.security.credentials" locked="false">admin</parameter><br /> <parameter locked="false" name="transport.jms.UserName">admin</parameter><br /> <parameter locked="false" name="transport.jms.Password">admin</parameter><br /> <parameter name="transport.jms.ConnectionFactoryJNDIName" locked="false">QueueConnectionFactory</parameter><br /> <parameter name="transport.jms.ConnectionFactoryType" locked="false">queue</parameter><br /> </parameter><br /> </transportReceiver></span><br />
<br />
<b>Step 3 - Create a Proxy service to listen to a JMS queue in ActiveMQ.</b><br />
<b><br /></b>
Once the ESB server is started, create the below Proxy service and let it listen to the queue generated in ActiveMQ.<br />
<br />
<br />
<span style="border: 2px solid rgb(192, 192, 192); display: block; padding: 5px;"> <proxy name="StockQuoteProxy1" transports="jms" startOnLoad="true"><br /> <target><br /> <endpoint><br /> <address uri="http://localhost:9000/services/SimpleStockQuoteService"/><br /> </endpoint><br /> <inSequence><br /> <property name="OUT_ONLY" value="true"/><br /> </inSequence><br /> <outSequence><br /> <send/><br /> </outSequence><br /> </target><br /> <publishWSDL uri="file:repository/samples/resources/proxy/sample_proxy_1.wsdl"/><br /> <parameter name="transport.jms.ContentType"><br /> <rules><br /> <jmsProperty>contentType</jmsProperty><br /> <default>application/xml</default><br /> </rules><br /> </parameter><br /> </proxy></span><br />
Once the above proxy service is deployed, send a request to the queue and observe how the message is processed and send to the backend. You can use the sample available in [2] to test this scenario out.<br />
<br />
If you are sending a JMS request you can use the username and the password in the URL as shown below.<br />
<span style="border: 2px solid rgb(192, 192, 192); display: block; padding: 5px;">
ant stockquote -Dmode=placeorder -Dtrpurl="jms:/StockQuoteProxy1?transport.jms.DestinationType=queue&transport.jms.ContentTypeProperty=contentType&java.naming.provider.url=tcp://localhost:61616&java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory&transport.jms.UserName="admin"&transport.jms.Password="admin"&transport.jms.ConnectionFactoryType=queue&transport.jms.ConnectionFactoryJNDIName=QueueConnectionFactory"
</span><br />
<br />
<br />
[1] - https://docs.wso2.com/display/ESB490/Configure+with+ActiveMQ<br />
[2] - https://docs.wso2.com/display/ESB490/Sample+250%3A+Introduction+to+Switching+TransportsEvanthikahttp://www.blogger.com/profile/02913709559298376105noreply@blogger.com0tag:blogger.com,1999:blog-59077094557892.post-59055606353343876052016-11-25T00:58:00.000-08:002016-11-25T01:00:53.935-08:00Disabling API Console/Swagger tools menu available from store console for anonymous/logged in usersIf you need to disable the API Console/Swagger from the Store UI for anonymous users/logged in users, you can try out the below methods.<br />
<br />
There is no straightforward configuration readily available with API Manager to do this. However, by doing a minor config change, this is possible. What you actually need to do is change the code of the <b>block.jag</b> which resides under <i>wso2am-1.8.0/repository/deployment/server/jaggeryapps/store/site/blocks/api/api-info</i> folder.<br />
<br />
<u><b>Method 1</b></u><br />
<br />
Assuming you want the API Console (RESTClient) to be disable for anonymous users only, this can be done by changing/adding the below lines of code to the block.jag.<br />
<br />
<i><b>Step 1</b></i><br />
Change the below code of line from<br />
<br />
<span class="code-quote" style="color: #009100;">
var showConsole=true;<br />
</span>
to<br />
<br />
<span class="code-quote" style="color: #009100;">
var showConsole=false;<br />
</span>
<br />
<i><b>Step 2</b></i><br />
Then add the below lines of code right after the line _var showConsole=false;_<br />
<br />
<span class="code-quote" style="color: #009100;">
if(user){<br />
showConsole=true<br />
}<br />
</span>
<br />
<u><b>Method 2</b></u><br />
<br />
If you need this feature to be completely invisible for anonymous and logged in users, all you have to do is change the below code.<br />
Change the parameter from<br />
<br />
<span class="code-quote" style="color: #009100;">
var showConsole=true;<br />
</span>
to<br />
<br />
<span class="code-quote" style="color: #009100;">
var showConsole=false;<br />
</span>
<br />
Once the above changes are done, restart the API manager server and you will notice that the RESTClient tool is visible only to logged in users/not visible at all for anyone.Evanthikahttp://www.blogger.com/profile/02913709559298376105noreply@blogger.com0tag:blogger.com,1999:blog-59077094557892.post-42787035194150171792016-11-09T02:03:00.000-08:002016-11-25T01:45:09.085-08:00How to create custom references(usedBy, ownedBy, etc) that can be used to associate artifacts in WSO2 Governance Registry 5.3.0 onwardThis support was available from G-Reg 5.3.0 onward. For more information, refer [1]. <br />
<br />
1. Added a new rxt with the below config.<br />
<br />
<span style="border: 2px solid rgb(192, 192, 192); display: block; padding: 5px;">
<artifactType hasNamespace="true" iconSet="10" pluralLabel="Tests" shortName="tests"<br />singularLabel="Test" type="application/vnd.wso2-tests+xml"><br /> <storagePath>/tests/@{details_name}</storagePath><br /> <nameAttribute>details_name</nameAttribute><br /> <namespaceAttribute>details_address</namespaceAttribute><br /> <ui><br /> <list><br /> <column name="Name"><br /> <data href="@{storagePath}" type="path" value="details_name"/><br /> </column><br /> </list><br /> </ui><br /> <content><br /> <table name="Details"><br /> <field required="true" type="text"><br /> <name>Name</name><br /> </field><br /> <field required="true" type="text"><br /> <name>Address</name><br /> </field><br /> <field required="true" type="text"><br /> <name>ContactNumber1</name><br /> </field><br /> <field required="true" type="text"><br /> <name>ContactNumber2</name><br /> </field><br /> </table><br /> </content><br /> </artifactType></span> <br />
2. From the publisher, added a new artifact of type tests (I've added a test artifact by the name Test3)<br />
3. Added the below config to the <G-REG_HOME</repository/conf/governance.xml file;<br />
<tests reverseAssociation ="tests" iconClass="fw-globe">tests</tests><br />
so that the <Association type="soapservice"> looks like what's given below.<br />
<br />
<span style="border: 2px solid rgb(192, 192, 192); display: block; padding: 5px;">
<Association type="soapservice"><br />
<security reverseAssociation ="secures" iconClass="fw-security">policy</security><br />
<ownedBy reverseAssociation ="owns" iconClass="fw-user">soapservice,restservice,wsdl</ownedBy><br />
<usedBy reverseAssociation ="depends" iconClass="fw-globe">soapservice,restservice,wsdl</usedBy><br />
<depends reverseAssociation ="usedBy" iconClass="fw-store">soapservice,restservice,wsdl,endpoint</depends><br />
<contacts reverseAssociation ="refers" iconClass="fw-globe">contacts</contacts><br />
<tests reverseAssociation ="tests" iconClass="fw-globe">tests</tests><br />
</Association><br />
<br />
</span>
<br />
4. From the publisher, try to select the added test type artifact for your SOAP service. I typed in the name Test3 and it would list to be selected and added as an association for the SOAP Service.<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEguqBkBP_Qvcy6pThWAsWWEpzmne6S5rLxCK4bveEggOvTmFdQfryQMoLsMNvjfSVwvhO0CbfVKF5jVIqw2CjqfKfCobpcOSprDdOziaOxNeSP3uVQyl1RaAtyj67rMUoKvUEwiapF3/s1600/soapService.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="192" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEguqBkBP_Qvcy6pThWAsWWEpzmne6S5rLxCK4bveEggOvTmFdQfryQMoLsMNvjfSVwvhO0CbfVKF5jVIqw2CjqfKfCobpcOSprDdOziaOxNeSP3uVQyl1RaAtyj67rMUoKvUEwiapF3/s320/soapService.png" width="320" /></a></div>
<br />
<br />
Note that as mentioned in our documentation when doing the above, you need to add the values you defined as short name in the RXT file of the artifact, within the <Association type> element, to define the association types enabled for that particular asset type<br />
<br />
[1] - https://docs.wso2.com/display/Governance520/Adding+Associations+for+an+AssetEvanthikahttp://www.blogger.com/profile/02913709559298376105noreply@blogger.com0tag:blogger.com,1999:blog-59077094557892.post-43213345344446524552016-06-28T09:18:00.002-07:002016-06-28T09:19:14.549-07:00How to list admin services used by WSO2 carbon based serversWe are given admin services by WSO2 products to perform various tasks but there is no documentation on the list of the services that are being provided. Therefore to list all these admin services, all you have to do is start the server with -DosgiConsole and type in the command <i><b>listAdminServices</b></i><span style="font-family: "times" , "times new roman" , serif;"><b> </b></span><span style="font-family: "times" , "times new roman" , serif;">in</span> the osgi console.<br />
<br />
This is clearly explained in the stack overflow question at [1].<br />
<br />
[1] - http://stackoverflow.com/questions/21219907/list-admin-services-used-by-wso2-carbon-based-serversEvanthikahttp://www.blogger.com/profile/02913709559298376105noreply@blogger.com0tag:blogger.com,1999:blog-59077094557892.post-85140295182175757712016-05-23T07:18:00.002-07:002016-05-23T07:19:56.657-07:00[WSO2 Governance Registry] - How to analyse the history of registry resources Assume that you are working on a setup where you need to analyse the history of registry resources. One might want to know what type of operations have been done to the resource throughout it’s lifetime. This is possible from a simple DB query.<br />
<br />
<span style="border: 2px solid rgb(192, 192, 192); display: block; padding: 5px;">select * from REG_LOG where REG_PATH=‘resource_name’;<br /><br />i.e. select * from REG_LOG where REG_PATH='/_system/governance/apimgt/statistics/ga-config.xml';</span>
<br />
<br />
As an example, assume I want to find out the actions taken on the resource ga-config.xml. So when I query the table REG_LOG, below is the result I would receive.<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhW2GV9hEwcHs0vvuL51WSJDMrBYov0pxv8u2Er81nTa0Jpu5DCH-QVBlso0ktB2qRO61pgsds4pORs-lTCdwFhY1yD8sQiwujRjLZiSuTJ67QFBntVXXE3sRM-eeA3XaMojmtH-YCZ/s1600/REG_LOG.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="91" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhW2GV9hEwcHs0vvuL51WSJDMrBYov0pxv8u2Er81nTa0Jpu5DCH-QVBlso0ktB2qRO61pgsds4pORs-lTCdwFhY1yD8sQiwujRjLZiSuTJ67QFBntVXXE3sRM-eeA3XaMojmtH-YCZ/s640/REG_LOG.png" width="640" /></a></div>
<br />
<br />
When you look at the above result set, you would notice that the column <b>REG_ACTION</b> shows different values in each row. The actions that represents these values are configured in the class Activity.java. For example, <i>REG_ACTION=10<b></b></i> means that the resource have been moved from it’s current location. <b>REG_ACTION=7<i></i></b> means that it has been deleted from the system. Likewise, when you go through [1], you can find out the rest of the actions which you can take on these registry resources.<br />
<br />
Therefore as explained above, by going through the REG_LOG of the registry database table, you can audit the actions taken on each and every resource.<br />
<br />
[1] - https://github.com/wso2/carbon-kernel/blob/4.4.x/core/org.wso2.carbon.registry.api/src/main/java/org/wso2/carbon/registry/api/Activity.javaEvanthikahttp://www.blogger.com/profile/02913709559298376105noreply@blogger.com2tag:blogger.com,1999:blog-59077094557892.post-70584735456098711992015-10-30T03:45:00.001-07:002015-10-30T21:13:44.858-07:00Working with PostgreSQL 9.3 & WSO2 products<div style="text-align: justify;">
As you all know, WSO2 products support a wide range of <a href="https://docs.wso2.com/display/compatibility/Tested+DBMSs">RDBMs</a>. In this post, I will explain how you can install PostgreSQL 9.3 on your Linux machine and what commands you have to run to create users/databases and grant permission for databases etc. In the latter part of the post, I will briefly explain on the configuration that needs to be done to connect WSO2 products to a PostgreSQL database.</div>
<span style="font-size: large;"><b>
Installing PostgreSQL</b></span><br />
<br />
You can install using the apt-get command on Linux as below.<br />
<br />
<i><b>Step 1 - To get information on the newest versions of packages and dependencies</b></i><br />
<span style="border: 2px solid rgb(192, 192, 192); display: block; padding: 5px;">
sudo apt-get update<br />
</span>
<br />
<br />
<i><b>Step 2 - To install PostgreSQL v9.3</b></i><br />
<br />
<span style="border: 2px solid rgb(192, 192, 192); display: block; padding: 5px;">
sudo apt-get install postgresql-9.3 </span><br />
<br />
<b>
Configure PostgreSQL password</b><br />
<br />
To setup a password to login to PostgreSQL, issue the below commands.<br />
<br />
<span style="border: 2px solid rgb(192, 192, 192); display: block; padding: 5px;">
sudo -u postgres psql template1<br />
</span>
<br />
<span style="border: 2px solid rgb(192, 192, 192); display: block; padding: 5px;">
ALTER USER postgres with encrypted password 'postgres';<br />
</span>
<br />
Note: To quit from the console, press Ctrl + D<br />
<br />
<span style="font-size: large;"><b>
Additional configuration for PostgreSQL</b></span><br />
<br />
<b><i>Step 1 - Configure md5 Authentication</i> </b><br />
<br />
1. Open the pg_hba.conf<br />
<br />
<span style="border: 2px solid rgb(192, 192, 192); display: block; padding: 5px;">
sudo vim /etc/postgresql/9.3/main/pg_hba.conf<br />
</span>
<br />
2. Find the below line<br />
<br />
<span style="border: 2px solid rgb(192, 192, 192); display: block; padding: 5px;">
local all postgres<br />
</span>
<br />
and change it to <br />
<br />
<span style="border: 2px solid rgb(192, 192, 192); display: block; padding: 5px;">
local all postgres md5</span><br />
<br />
<i><b>Step 2 - Enable TCP/IP connections</b></i><br />
<br />
1. Open the postgresql.conf file<br />
<br />
<span style="border: 2px solid rgb(192, 192, 192); display: block; padding: 5px;">
sudo vim /etc/postgresql/9.3/main/postgresql.conf<br />
</span>
<br />
2. Locate the line and uncomment it<br />
<br />
<span style="border: 2px solid rgb(192, 192, 192); display: block; padding: 5px;">
#listen_addresses = 'localhost'</span><br />
<br />
<span style="font-size: large;"><b>
Creating a user, a database and then granting permission for the database.</b></span><br />
<br />
<i><b>Step 1 - Creating a Linux user</b></i><br />
<br />
<span style="border: 2px solid rgb(192, 192, 192); display: block; padding: 5px;">
CREATE USER apim WITH PASSWORD 'apim';<br />
</span>
<br />
Note: Give the password as 'apim'<br />
<br />
<i><b>Step 2 - Login as super user</b></i><br />
<br />
<span style="border: 2px solid rgb(192, 192, 192); display: block; padding: 5px;">
sudo su - postgres<br />
</span>
<br />
If successfully logged in, you should get a prompt as below<br />
<br />
<span style="border: 2px solid rgb(192, 192, 192); display: block; padding: 5px;">
postgres@ubuntu2:~$</span><br />
<br />
<i><b>Step 3 - Then connect to the database serve </b></i><br />
<br />
<span style="border: 2px solid rgb(192, 192, 192); display: block; padding: 5px;">
psql -d template1 -U postgres</span><br />
<br />
<i><b>Step 4 - Create a user</b></i><br />
<br />
<span style="border: 2px solid rgb(192, 192, 192); display: block; padding: 5px;">
CREATE USER apim WITH PASSWORD 'apim';</span><br />
<br />
<i><b>Step 5 - Create a database</b></i><br />
<br />
<span style="border: 2px solid rgb(192, 192, 192); display: block; padding: 5px;">
CREATE DATABASE apim;<i><b></b></i><br />
</span>
<br />
<br />
<i><b>Step 6 - Grant permission for the user to the database</b></i><br />
<br />
<br />
<span style="border: 2px solid rgb(192, 192, 192); display: block; padding: 5px;">
GRANT ALL PRIVILEGES ON DATABASE apim to apim;
</span>
<i><b><br /> </b></i><br />
Now that you have created the user, database and granted permission, you can provide these credentials and try to connect your WSO2 server with this newly created database.<br />
<br />
<b><span style="font-size: large;"><span style="font-weight: normal;">Configuring WSO2 Products with PostgreSQL</span></span></b><br />
<br />
<span style="font-size: small;"><i><b>Step 1 - Configuring master-datasources.xml</b></i></span><br />
<br />
Open the master-datasources.xml of the product you have selected and provide the configuration as below<br />
<br />
<span style="border: 2px solid rgb(192, 192, 192); display: block; padding: 5px;">
<datasource><br /> <name>WSO2AM_DB</name><br /> <description>The datasource used for API Manager database</description><br /> <jndiConfig><br /> <name>jdbc/WSO2AM_DB</name><br /> </jndiConfig><br /> <definition type="RDBMS"><br /> <configuration><br /> <url>jdbc:postgresql://localhost:5432/apim</url><br /> <username>apim</username><br /> <password>apim</password><br /> <defaultAutoCommit>false</defaultAutoCommit><br /> <driverClassName>org.postgresql.Driver</driverClassName><br /> <maxActive>50</maxActive><br /> <maxWait>60000</maxWait><br /> <testOnBorrow>true</testOnBorrow><br /> <validationQuery>SELECT 1</validationQuery><br /> <validationInterval>30000</validationInterval><br /> </configuration><br /> </definition><br /> </datasource><br />
<br />
</span>
<i><b>Step 2 - Downloading the correct DB driver</b></i><br />
<br />
You have to download the correct <a href="https://jdbc.postgresql.org/download/postgresql-9.3-1104.jdbc4.jar">database driver</a> from the <a href="https://jdbc.postgresql.org/download.html">PostgreSQL site</a>. Once downloaded, drop it to $CARBON_HOME/repository/component/lib.<br />
<br />
<i><b>Step 3 - Starting up the server</b></i><br />
<br />
Now start up the server using the -Dsetup command and it will create the relevant tables in the database.<br />
<br />Evanthikahttp://www.blogger.com/profile/02913709559298376105noreply@blogger.com0tag:blogger.com,1999:blog-59077094557892.post-89451356760201034322015-08-14T10:47:00.000-07:002015-08-14T23:00:45.367-07:00Enabing E-mail User Login for WSO2 ProductsThis post explains different ways e-mail login can be enabled and how users/tenants can login to WSO2 products.<br />
<br />
<b>Pre-requisites</b><br />
<br />
Users, tenants and their e-mail addresses that will be used for this scenario are as follows.<br />
<br />
<span style="border: 2px solid rgb(192, 192, 192); display: block; padding: 5px;"><b>Super Admin User Name</b> - admin<br /><b>A user of Super Admin</b> - adminUser<br /><b>Email of Super Admin user</b> - admin@yahoo.com<br /><b>Email of a user of Super Admin</b> - adminUser@gmail.com<br /><b>Tenant Domain</b> - tenantdomain.com<br /><b>Tenant Admin</b> - admin@tenantdomain.com<br /><b>Tenant User</b> - tenantDomainUser@tenantdomain.com<br /><b>Tenant Admin Email</b> - admin@hotmail.com<br /><b>Tenant User Email</b> - tenantDomainUser@aol.com</span><br />
<u>How to create tenants</u><br />
<br />
When creating tenants, you have to give the tenant <b>Admin Username</b> as something like admin@gmail.com & not as admin<br />
<br />
<u>Scenario 1</u><br />
<br />
Configuration that needs to be done<br />
<br />
<b><i>carbon.xml </i></b><br />
<br />
<EnableEmailUserName><span style="color: red;"><b>true</b></span></EnableEmailUserName><br />
<br />
<i><b>user-mgt.xml</b></i><br />
<br />
For JDBC User Stores<br />
<br />
<Property name="UsernameWithEmailJavaScriptRegEx"><b>[a-zA-Z0-9@._-|//]{3,30}$</b></Property><br />
<br />
For LDAP based User Stores<br />
<br />
<Property name="UserNameSearchFilter"><b>(&(objectClass=person)(|(mail=?)(uid=?)))</b></Property><br />
<br />
& Comment out the following<br />
<br />
<!--Property name="UserDNPattern"><b>uid={0},ou=Users,dc=wso2,dc=org</b></Property--><br />
<br />
<br />
So when you do the above configuration, you can login from the following types of users<br />
<br />
<b>- admin<br />
- admin@yahoo.com<br />
- admin@yahoo.com@carbon.super<br />
- adminUser<br />
- adminUser@gmail.com<br />
- adminUser@gmail.com@carbon.super<br />
- admin@hotmail.com@tenantdomain.com<br />
- tenantDomainUser@aol.com@tenantdomain.com</b>
<br />
You <i><b>cannot</b></i> login as<br />
<br />
- admin@tenantdomain.com<br />
- tenantDomainUser@tenantdomain.com<br />
<br />
<br />
Senario 2 - Without configuring EnableEmailUserName property in carbon.xml<br />
<br />
Configuration that needs to be done<br />
<br />
<i>carbon.xml </i><br />
<br />
<EnableEmailUserName><span style="color: red;"><b>false</b></span></EnableEmailUserName><br />
<br />
<i>user-mgt.xml</i><br />
<br />
Same as in Scenario 1 above<br />
<br />
You should be able to login from the below users/email addresses<br />
<br />
<b>- admin<br />
- admin@yahoo.com@carbon.super<br />
- adminUser<br />
- adminUser@gmail.com@carbon.super<br />
- admin@hotmail.com@tenantdomain.com<br />
- tenantDomainUser@aol.com@tenantdomain.com<br />
- tenantDomainUser@tenantdomain.com</b>
<br />
Cannot login from<br />
<br />
- admin@yahoo.com<br />
- adminUser@gmail.com<br />
- admin@tenantdomain.com<br />
<br />
To create users with email addresses, you need to change the following properties of the LDAP user store configuration.<br />
<br />
<Property name="UserNameAttribute"><b>mail</b></Property><br />
<Property name="UsernameJavaRegEx"><b>[a-zA-Z0-9@._-|//]{3,30}$</b></Property><br />
<Property name="UserNameSearchFilter"><b>(&(objectClass=person)(mail=?))</b></Property><br />
<br />
After configuring your server with the above configs, you should be able to add users with email addresses as well as with uids.<br />
For more information, go through the detailed <a href="http://xacmlinfo.org/2014/10/07/email-username-with-identity-server/">blog</a> written by Asela Pathberiya.Evanthikahttp://www.blogger.com/profile/02913709559298376105noreply@blogger.com0