<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Amalanathan Thushanthan on Medium]]></title>
        <description><![CDATA[Stories by Amalanathan Thushanthan on Medium]]></description>
        <link>https://medium.com/@thushaamal93?source=rss-fea2253afc3------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*vDawy3MNi0uiaFRyyzgn0g.jpeg</url>
            <title>Stories by Amalanathan Thushanthan on Medium</title>
            <link>https://medium.com/@thushaamal93?source=rss-fea2253afc3------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 03:23:50 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@thushaamal93/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Integrating the Coinbase crypto payment gateway with your web application]]></title>
            <link>https://medium.com/@thushaamal93/integrating-the-coinbase-crypto-payment-gateway-with-your-web-application-c939edae1468?source=rss-fea2253afc3------2</link>
            <guid isPermaLink="false">https://medium.com/p/c939edae1468</guid>
            <category><![CDATA[coinbase]]></category>
            <category><![CDATA[coinbase-payment-gateway]]></category>
            <category><![CDATA[react-crypto-integration]]></category>
            <category><![CDATA[coinbase-commerce]]></category>
            <category><![CDATA[crypto-payment-gateway]]></category>
            <dc:creator><![CDATA[Amalanathan Thushanthan]]></dc:creator>
            <pubDate>Sat, 02 Jul 2022 08:15:27 GMT</pubDate>
            <atom:updated>2022-07-02T08:15:27.493Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>Nowadays, the majority of businesses and e-commerce platforms already start to accept bitcoin for their transactions as its market acceptance has grown.</blockquote><h4>Why CoinBase?</h4><p><a href="https://commerce.coinbase.com/?lang=en">Coinbase Commerce</a> is one of the leading crypto platforms that enable individuals or businesses to buy, sell and store cryptocurrency completely in a decentralized manner. It allows over 30+ well-known trending cryptocurrencies and stablecoins.</p><p>The great part for developers is that Coinbase offers <a href="https://commerce.coinbase.com/integrate">pre-build integration plugins</a> and enhanced organized <a href="https://commerce.coinbase.com/docs/">API Documentation</a> for integration. They also have blogs, FAQs, and tutorials for anyone without any experience in development.</p><p><strong>Let&#39;s jump into the topic,</strong></p><h4>Create your own checkout using Coinbase</h4><p><strong>Step 1:</strong> Create an account with <a href="https://www.coinbase.com/">Coinbase commerce</a> and verify your email.</p><figure><img alt="https://www.coinbase.com/signup" src="https://cdn-images-1.medium.com/max/1024/1*Yvas1jzlCWFfxuqNE3krlw.png" /></figure><p><strong>Step 2: </strong>Get to know more about their <a href="https://beta.commerce.coinbase.com/balances">dashboard</a> and its functionalities.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uD3juRrLnCZGFhP4yOMuHw.png" /></figure><p><strong>Step 3: </strong>Go to the checkout tab and click the blue color <strong>“Create a checkout” </strong>button at the right top corner.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*36j7HtDxKnoaLdnNq24Etg.png" /></figure><p><strong>Step 4: </strong>Fill in the details about your product or service and click<strong> “Create checkout” </strong>at the bottom to create checkout.</p><p>They have a fantastic price-setting function. You have two options: either set the price beforehand or let the customers decide. Additionally, you may collect the visitor’s contact details, including name, email, address, and phone number.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2fj5PyA9eTET_0fHqBpVbw.png" /></figure><p><strong>Step 5:</strong> The last phase of checkout construction is where you are redirected to a page that contains Embedded code and a shareable link.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3y_Xvd4L-2VMZTCsBjEx_Q.png" /></figure><p>Now your new checkout plugin is visible under the checkout tab. You can also edit the information by selecting the relevant checkout plugin.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3h4_Ru64ksXUnP1me2iSdQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*A3VxpQh_cfs2aD8Yp3K1aA.png" /></figure><h4><strong>Integrate created checkout into your code</strong></h4><p>Use the embedded code that is displayed in your checkout wherever you like by copying it. By default, they place the link into an anger tag. Depending on your needs, you can utilize something similar.</p><pre>&lt;div&gt;<br>      &lt;a class=&quot;donate-with-crypto&quot;<br>        href=&quot;https://commerce.coinbase.com/checkout/e35069ce-2c48-477e-81e1-cce71fb58a4b&quot;&gt;<br>        Donate with Crypto<br>      &lt;/a&gt;<br>      &lt;script src=&quot;https://commerce.coinbase.com/v1/checkout.js?version=201807&quot;&gt;<br>      &lt;/script&gt;<br>&lt;/div&gt;</pre><p>Here is the example I modified as a button:</p><pre>&lt;div className=&quot;test mt-5&quot;&gt;<br> &lt;Button className=&quot;donate-with-crypto&quot; href=&quot;https://commerce.coinbase.com/checkout/e35069ce-2c48-477e-81e1-cce71fb58a4b&quot;&gt;Donate with Crypto<br> &lt;/Button&gt;<br> &lt;script src=&quot;https://commerce.coinbase.com/v1/checkout.js?version=201807&quot;&gt;&lt;/script&gt;<br>&lt;/div&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*smsWQMIR2UaAS7kldMtP_w.png" /></figure><p>Once we click the <strong>“Donate with Crypto” </strong>button it will redirect to your corresponding crypto payment gateway. Customer can enter their details and do their payment either using a Coinbase account or from any accepted cryptocurrency wallet.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WhG_rW1RcZbKElv_ZGzEiA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HbbtBxPEMU4UURjwYXEocg.png" /></figure><blockquote><strong>That&#39;s it. Now we integrated the CoinBase Payment gateway within our web application.</strong></blockquote><p>You can able to use their own dedicated APIs to get all the checkout and account information if necessary for your project. You may explore further and obtain your own API keys by reading the Coinbase <a href="https://commerce.coinbase.com/docs/api/#introduction">developer API documentation</a>.</p><h4>Coinbase gateway for E-Commerce Platforms</h4><p>Coinbase provides payment gateway plugins for major two e-commerce platforms <a href="https://www.shopify.com/free-trial/3s?term=shopify&amp;adid=566143522046&amp;campaignid=15433369425&amp;branded_enterprise=1&amp;BOID=brand&amp;gclid=Cj0KCQjwtvqVBhCVARIsAFUxcRvBodWMID7jbLbdmLgMlSX9fPOiYrV6c4hTpZ9rTGsjZcTu6BD8waYaAmF8EALw_wcB&amp;cmadid=516585705;cmadvertiserid=10730501;cmcampaignid=26990768;cmplacementid=324494758;cmcreativeid=163722649;cmsiteid=5500011"><strong>Shopify</strong></a> and <a href="https://woocommerce.com/?utm_source=google&amp;utm_medium=cpc&amp;utm_campaign=acquisition_search_brand_row&amp;utm_content=woocommerce&amp;gclid=Cj0KCQjwtvqVBhCVARIsAFUxcRua8E_3xaiulffbnaQkkzTsa69ieOqHqqMnaVJWDXRjb9N_ozcB3MUaAqNHEALw_wcB"><strong>WooCommerce</strong></a>. It provides separate integration tutorials and developer guidelines on its <a href="https://commerce.coinbase.com/integrate"><strong>website</strong></a>.</p><blockquote>Shopify integration guidlines → <a href="https://commerce.coinbase.com/docs/#shopify">here</a></blockquote><blockquote>WooCommerce integration guidlines → <a href="https://commerce.coinbase.com/integrate/woocommerce">here</a></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/607/1*FV8W596uxjv_XQmRr4gn0Q.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c939edae1468" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[“Docker” the Container-Based Application]]></title>
            <link>https://blog.devops.dev/docker-the-container-based-application-8248429df82?source=rss-fea2253afc3------2</link>
            <guid isPermaLink="false">https://medium.com/p/8248429df82</guid>
            <category><![CDATA[docker-container]]></category>
            <category><![CDATA[docker-image]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[what-is-docker]]></category>
            <category><![CDATA[docker-command]]></category>
            <dc:creator><![CDATA[Amalanathan Thushanthan]]></dc:creator>
            <pubDate>Tue, 31 May 2022 09:24:10 GMT</pubDate>
            <atom:updated>2022-06-01T11:32:51.789Z</atom:updated>
            <content:encoded><![CDATA[<h3>What is Docker?</h3><blockquote>Docker is a software platform for developing applications based on containers, which are tiny and lightweight execution environments that share the operating system kernel but execute in isolation.</blockquote><p>Let’s break it down into containers and learn more about it.</p><p><strong><em>To begin, we must comprehend why container-based development has become so popular.</em></strong></p><p>The basic software deployment is straightforward: we have a computer with hardware and a specified operating system installed. On top of the operating system, we may install our program and libraries. Boom. It works perfectly. But the machine has lots of unused resources (CPU, Ram) to run that application. Also if we need to make our application higher available, we need to buy another machine to do the same process. It cost a lot and consumes more time to do the setup process.</p><p>The age of <strong>virtualization</strong> has begun to sort the issue. We have a computer or a virtual server with specific hardware and an operating system. A Virtualization layer (hypervisor, Oracle virtual box, etc ) sits on top of the operating system and helps to virtualize the host (CPU, RAM, and Network) and demarcate virtual machines. Then we install the relevant full-blown operating system on the virtual machines, install the libraries on top of the virtual OS, and execute the application as if it is in traditional deployment.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/632/1*cGywRXfGtcdqbdt_erQPtA.png" /><figcaption>Microservice Architecture</figcaption></figure><p>Installing a full-blown operating system into the virtual machine would take up a lot of space. We also need to start the virtual machine OS and launch the program if we wish to use it. Both actions need more space and time.</p><p>Now the <strong>Container-based application</strong> comes into play and becomes famous. Here the basic structure is the same. We have a computer or a virtual server with specific hardware and an operating system. Instead of a Virtualization layer here we have a Container runtime engine. On top of it, we can create our containers with our operating system and run the application in that Operating system.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/665/1*cGQU2IUU1mzEE4Ws95RVCw.png" /><figcaption>Docker Architecture</figcaption></figure><blockquote>What? Are we going to install the Operating system again within the container? What is the difference between Microservice and Container?</blockquote><p>Yes. Within the container, we’re working on the operating system. However, we did not create a full-blown operating system. Instead, it virtualized the operating system’s underlying kernel and added the essential operating system features. Let’s keep things simple. The Docker container should indeed run the Ubuntu operating system. Ubuntu’s basic kernel is Linux. When Docker creates a container, it virtualizes the Linux kernel and adds Ubuntu features. The container only takes around 100MB to develop the OS, but if we use the microservice, the OS will take at least 2GB to construct.</p><blockquote>What is Docker Image and why do we need that?</blockquote><p>Docker Image is a file containing a collection of instructions for constructing a Docker container. The image contains instructions such as the operating system going to use by the container, a list of comments that helps to install basic functionality to run the service into that container, and so on. Once we run the docker image, It helps to create the container for us to build our application.</p><blockquote>What is <a href="https://hub.docker.com/">docker hub</a></blockquote><p>Docker Hub is a large-scale library management service run by the Docker team, with thousands of pre-built public and private images to make our jobs simpler. It also facilitates in the management and sharing of container images across our team.</p><h3>Let&#39;s get to know some basic comments</h3><blockquote><strong>Installing Docker</strong></blockquote><p><strong><em>System requirement :</em></strong></p><ul><li>64-bit kernel and CPU support for virtualization</li><li>4GB system RAM</li></ul><p><strong>Find more:</strong> <a href="https://docs.docker.com/engine/install/">Docker system requirement</a></p><p><strong><em>Installation:</em></strong></p><p>Ubuntu introduced the graphical interface for most of the OS to easier our work</p><ul><li>Ubuntu: <a href="https://docs.docker.com/engine/install/">Installation Guide</a></li><li>Windows: <a href="https://docs.docker.com/desktop/windows/install/">Installation Guide</a></li><li>macOS: <a href="https://docs.docker.com/desktop/mac/install/">Installation Guide</a></li></ul><blockquote><strong>Check the installation of Docker</strong></blockquote><p>Check the version</p><pre>&gt; docker -v</pre><p>Checking docker working with docker hub</p><pre>&gt; docker run hello-world</pre><blockquote><strong>Useful comments</strong></blockquote><h4><strong>Find the list of docker images</strong></h4><pre>&gt; docker images </pre><h4><strong>Find the list of docker container</strong></h4><pre>&gt;docker container ls</pre><pre><strong>Getting all containers </strong><br>&gt; docker container ls -a</pre><h4><strong>Stat and attach with the docker container</strong></h4><pre>&gt; docker start &lt;container name&gt;<br>&gt; docker attach &lt;container name or container id&gt;<br><strong>OR</strong> <br>&gt; docker start -ai &lt;container name&gt;</pre><h4><strong>Run docker image</strong></h4><pre><strong>When we exit from container the entire container exit.</strong><br>&gt; docker run -it &lt;image name&gt; /bin/bash</pre><pre><strong>When we exit from container, exec help to exit from the control of the container but the container still exist.</strong><br>&gt; docker exec -it &lt;image name&gt; /bin/bash</pre><pre><strong>Add New Container </strong><br>&gt; docker run -it --name &lt;Container Name&gt; &lt;Image Name&gt; /bin/bash</pre><h4><strong>Remove docker image</strong></h4><pre>&gt; docker image rm &lt;image id&gt;</pre><h4><strong>Remove docker containers</strong></h4><pre>&gt; docker container rm &lt;container id&gt;</pre><pre><strong>Remove all container <br></strong>&gt; docker container rm $(docker container ls -a -q)</pre><pre><strong>Remove all stopped contailers </strong><br>&gt; docker container prune </pre><h4><strong>Exit from a docker container</strong></h4><pre>&gt; #exit </pre><h4><strong>Get docker container statistics (CPU Usage, Memory, etc)</strong></h4><pre>&gt; docker stats &lt;Container name&gt;</pre><pre><strong>Instand statistics</strong><br>&gt; docker stats --no-stream &lt;Container name&gt;</pre><pre><strong>Instand statistics for all Container<br></strong>&gt; docker stats --no-stream --all</pre><h4><strong>Get all information about Container</strong></h4><pre>&gt; docker inspect &lt;Container name&gt;</pre><h4><strong>Search pre-define public images from </strong><a href="https://hub.docker.com/"><strong>Docker Hub</strong></a></h4><pre>&gt; docker search ubuntu</pre><h4><strong>Get pre-define public images from </strong><a href="https://hub.docker.com/"><strong>Docker Hub</strong></a></h4><pre>&gt; docker pull ubuntu</pre><h4><strong>Upload the locally created images to </strong><a href="https://hub.docker.com/"><strong>Docker Hub</strong></a></h4><pre>&gt; docker build -t &lt;image name&gt; //create image<br>&gt; docker push &lt;image name&gt; //push the image into docker hub </pre><h4><strong>Creating a docker image for an existing container</strong></h4><ul><li><strong>Manual way (Commit)</strong></li></ul><p><em>Once we create the image, We can re-use the image and build our new containers with all available facilities installed in the earlier available container. We don&#39;t want to install it again and again. Also, it&#39;s not recommended because it does not execute the old container’s runtime comments ( services).</em></p><pre>&gt; docker commit &lt;available container name&gt; &lt;new image name&gt;</pre><ul><li><strong>Automatic way (Build)</strong></li></ul><p><em>Here we create a file (Dockerfile) that contains all the instructions and build that file to create an image. Using this Build we can able to overcome the problem mentioned manually.</em></p><p><em>sample Dockerfile File :</em></p><pre>FROM ubuntu<br>RUN apt-get update -y<br>RUN apt-get install nginx -y<br>ENTRYPOINT bash &amp;&amp; service nginx start</pre><p><em>When we create an image using the code mentioned below, the first three lines execute from Dockerfile while creating the image and saving the last line in the memory. The last comment (ENTRYPOINT ) executes only when we create a container.</em></p><pre>&gt; docker build -t &lt;new image Name&gt; &lt;Sample Dockerfile Location&gt;</pre><pre><strong>Without Cache<br></strong>&gt; docker build --no-cache -t &lt;new image Name&gt; &lt;Sample Dockerfile Location&gt;</pre><h4>Create docker volume</h4><p><em>Docker volume helps to create a persistent volume for a container, at the same time it helps to attach (mount) a specific volume with multiple containers. Even if we delete all the containers that use volume, not affect the data in the Docker volume.</em></p><ul><li><strong>Create new volume</strong></li></ul><pre>&gt; docker volume create &lt;volume name&gt;</pre><ul><li><strong>List volume</strong></li></ul><pre>&gt; docker volume ls</pre><ul><li><strong>View all details of the volume</strong></li></ul><pre>&gt; docker inspect &lt;volume name&gt;</pre><ul><li><strong>Mount the volume with multiple containers</strong></li></ul><pre>&gt; docker run -it --name &lt;Container Name&gt; -v &lt;volume name&gt;:/&lt;volume name&gt; &lt;Image Name&gt;</pre><pre>&gt; docker run -it --name &lt;Container 2 Name&gt; -v &lt;volume name&gt;:/&lt;volume name&gt; &lt;Image Name&gt;</pre><h4><strong>Accessing containers using external entities by creating a linkage between server port and container port</strong></h4><p><strong>Step1: </strong>We need to add the running port in our <em>Dockerfile while creating the image using EXPOSE</em></p><pre>EXPOSE 8080</pre><p><strong>Step2: </strong>Creating a linkage between server port and container port while creating the container</p><pre>&gt; docker run -itd -p 23422:8080 --name  &lt;container name&gt; &lt;image name&gt;</pre><p><em>Here the image runs in port </em>8080. <em>when we access the port number 23422, It will redirect and display whatever runs in the container with the port 8080</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8248429df82" width="1" height="1" alt=""><hr><p><a href="https://blog.devops.dev/docker-the-container-based-application-8248429df82">“Docker” the Container-Based Application</a> was originally published in <a href="https://blog.devops.dev/">DevOps.dev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Microservice vs Monolithic? Which one to choose for a full-fledged application?]]></title>
            <link>https://medium.com/@thushaamal93/micro-service-vs-monolithic-which-one-should-i-choose-for-a-full-fletch-application-bb21d6e37eb6?source=rss-fea2253afc3------2</link>
            <guid isPermaLink="false">https://medium.com/p/bb21d6e37eb6</guid>
            <category><![CDATA[monolithic-architecture]]></category>
            <category><![CDATA[virtual-machine]]></category>
            <category><![CDATA[microservices]]></category>
            <category><![CDATA[monolithicvsmicroservice]]></category>
            <dc:creator><![CDATA[Amalanathan Thushanthan]]></dc:creator>
            <pubDate>Mon, 09 May 2022 06:15:41 GMT</pubDate>
            <atom:updated>2022-05-09T07:09:11.539Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>Based on my experience and research it all relies on the application and customer. At the same time If you plan for long term and broad scale perspective, Micro Services is always my recommendation.</blockquote><p>Let us begin with the fundamentals of Microservices and Monolithic Architecture.</p><h4><strong>What is Monolithic or Monolithic Architecture</strong></h4><p>Monolithic is a traditional architecture style for software development that helps to construct and handle multiple services within a single service.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QwIGWSeKTztPbC06cU5eKQ.png" /><figcaption>Monolithic Architecture</figcaption></figure><p>Let&#39;s make it simple,</p><p>Consider the above social media application architecture as an example of the traditional monolithic architecture. The core idea is that a single machine executes and manages the whole application. In other words, all services are centralized in one location. Anyone who wants to use any single service must make a single request to the entire service and get back a response.</p><blockquote>It&#39;s easy, right? Single request and single response. It all happened in a flash. So why are Microservices required?</blockquote><p>If we discover a bug in the application’s sub-service, or if we need to update the application with a new sub-service, we need to modify the sub-service, or if we need to delete the sub-service. The only option is to completely shut down the application and update it.</p><p>A new employee has been hired to maintain an application’s sub-system. Is it necessary to understand the full code in order to maintain the subsystem? Is this a viable solution?</p><p>Consider the following scenario: we have an architecture that decentralizes the sub-services and a gateway that helps to route the sub-services. So, if we need to update, we don’t want to shut down the entire service. All we have to do now is shut down the particular sub-services and update them. At the same time, rather than worrying about the full application code, the employee may focus on his assigned sub-services.</p><h4><strong>What is Microservice or Microservice Architecture</strong></h4><p>Microservices is an architecture style for software development that helps to structure the application into small and autonomous services that communicate via well-defined APIs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CShhLAiqBdf2cnlkV3v38g.png" /><figcaption>Microservice architecture</figcaption></figure><p>Consider the above social media application architecture as an example of a microservice. In this architecture, we separate the entire services into multiple sub-services and those are hosted in different machines. Also, there is a gateway in the middle to route the requests to access the microservices that come from clients.</p><h3><strong>Micro Services vs Monolithic</strong></h3><ul><li>Microservice is language independent but Monolithic is not. We can use different programming languages to develop different services but in Monolithic, we should use the same language for entire services.</li><li>Small scale projects, Monolithic is faster than Microservices. Monolithic needs to send a single request to access one service but Microservices need to send multiple requests to access one service.</li><li>Microservice allows developers to build and deploy services independently from Monolithic.</li><li>Only the corresponding service may be updated and redeployed when a change is necessary for a specific section of the application. The complete application does not need to be modified and redeployed. But Monolithic, we need to shut down and redeployed the entire application.</li><li>If one of the microservice fails, the others will keep working in the Microservice Architecture. But the entire application affects is monolithic.</li><li>Microservices are scalable and easy to integrate with third-party services compare to monolithic.</li><li>Developers must commit more time and effort to implement the communication mechanism between services in microservices. Comparatively, it&#39;s less monolithic.</li><li>Comparatively Monolithic is easy to Develop than Microservices. i.e) less complexity</li></ul><h3>Time for Q&amp;A</h3><blockquote><strong><em>Which Architecture should I choose for my application? monolithic or microservice</em></strong></blockquote><p>As I said at the beginning, It depends. Monolithic is the preferable option if your application is tiny in size, does have a small number of services, and you have a small team. Faster and also more cost-effective due to reduced complexity.</p><p>Microservices are preferable if your project has a high number of services or if you want to increase your services in the future. Because it will be easy to add more services in the future and adapt to new technologies.</p><blockquote><strong><em>I have an existing application that developed using monolithic. How to migrate monolithic to microservice?</em></strong></blockquote><p>The migration from monolithic to microservice architecture is not simple. It’s the same as rewriting the entire program from scratch. It takes a significant amount of time and work.</p><p>The recommended option is to first investigate the importance of migration. If the existing application does not require it, we can consider developing future services as microservices. As a result, the old monolithic application now functions as one of the microservice with the new microservices.</p><blockquote><strong><em>Which one is cost effective ? monolithic or microservice?</em></strong></blockquote><p>Monolithic is more cost-effective than microservice. However, the difference is not noticeable. Imagine your application is running on a 7GB virtual machine with three services. When using microservices, you may need three virtual machines with a total capacity of 3GB.</p><blockquote><strong><em>Do i need to build the monolithic based application in a single machine? Can’t I use multiple virtual machine?</em></strong></blockquote><p>Yes. If necessary, you can use multiple virtual machines to run your monolithic-based application.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bb21d6e37eb6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Implementing SQL Transaction management with the Unit of Work pattern]]></title>
            <link>https://medium.com/@thushaamal93/implementing-sql-transaction-management-with-the-unit-of-work-pattern-c219eb7fea1c?source=rss-fea2253afc3------2</link>
            <guid isPermaLink="false">https://medium.com/p/c219eb7fea1c</guid>
            <category><![CDATA[database]]></category>
            <category><![CDATA[database-connection]]></category>
            <category><![CDATA[transaction-management]]></category>
            <category><![CDATA[unitofwork]]></category>
            <dc:creator><![CDATA[Amalanathan Thushanthan]]></dc:creator>
            <pubDate>Sun, 13 Oct 2019 13:43:37 GMT</pubDate>
            <atom:updated>2019-11-01T22:20:52.295Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>What is <strong>SQL Transaction management?</strong></blockquote><p>It is totally about how we handle the SQL queries. Some queries need to update frequently and some need to update as a bunch of queries. Transaction management manages all those transactions.</p><p>Further finding: <a href="https://medium.com/@thushaamal93/jdbc-transaction-management-2c19bc795925">https://medium.com/@thushaamal93/jdbc-transaction-management-2c19bc795925</a></p><blockquote>What is <strong>Unit of Work pattern?</strong></blockquote><p><strong>Unit of Work </strong>is a well-known<strong> </strong>design pattern in the Transaction management era.</p><p>In general, design patterns are the reusable solution to the commonly occurring problem in software design. A design pattern isn’t a finished design that can be transformed directly into code. It is a description or template for how to solve a problem that can be used in many different situations.</p><blockquote>How does the <strong>Unit of Work pattern </strong>contribute to Transaction management?</blockquote><p><strong>The unit of work</strong> mainly focuses on handling multiple requests at once. It maintains and stores the multiple requests (a bunch of multiple inserts, update, and delete SQL requests) internally and send that all as one transaction to the database.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6XfX3ZhZt3kd1tgEbOmxvw.png" /></figure><p>Let’s consider, A bank money transaction from one account to another. Bob needs to transfer 100$ to Alice account through bank X. Bank debit the money from Bob’s account and updates his remaining balance. Then the bank deposits that money into Alice account. At the same time, the bank needs to maintain this money transaction record as well. Here there are three transactions that need to achieve without and interruption. i.e) The transactions for all of these three records should succeed or all of them should fail. We use the <strong>Unit of Work pattern </strong>to achieve these kinds of issues.</p><blockquote>Why the <strong>Unit of Work pattern </strong>and Why not traditional <strong>Database Transaction?</strong></blockquote><p>In general, <strong>Database</strong> <strong>Transaction</strong> using connection.commit() to commit the SQL statements and if either one of the SQL statements within the transaction block is failed, abort and rollback everything using the connection.rollback() within transaction block.<br>In the complicated transactions, Multiple times we are starting a transaction and commit/rollback it to end the transaction within a method. When we start the transaction in multiple places, it will take more execution time and increase the concurrent issue.</p><p>When we apply UnitOfWork design pattern, First it will maintain a list of objects in-memory which have been changed (SQL operation) during a transaction then once all the transaction is completed, all these updates are sent as one unit of work to be persisted physically and commit it as a single transaction. If something happens within this internal commit process then it will rollback all the action taken within that unit of work.</p><h3>Complete sample approach for Unit of Work</h3><p>Whenever the user wants to create a database connection then the user can call getDBConnection(). After connection creation, the backend maintains a map with connection and data source. If the user tries to get the same database connection again then it directly gets the connection from the mapping.<br>The user can start the transaction by calling beginTransaction(). It will start to create a new threatLocal and increase the transaction depth count. The user can able to create multiple transactions within the same method.<br>In the end, the user can end the transaction by calling commitTransaction() or rollbackTransaction(). It decreases the transaction depth count. When the transaction depth count reaches zero then it commits or rollbacks all connection maintained by the threadLocal.<br>Finally, we can call closeTransaction() to close all the threatLocal and database connections.</p><p>eg :<br> →begin new Transaction 1 (depth =0 =&gt; 0+1) <br> → begin new Transaction 2 (depth =1 =&gt; 1+1)<br> → begin new Transaction3 (depth =2 =&gt; 2+1)<br> — — — — — — — — — — — — — — — -<br>← end the Transaction 3 (depth =2 =&gt; 3–1)<br>←end the Transaction 2 (depth =1 =&gt; 2–1)<br> ←end the Transaction 1 (depth =0 =&gt; 1–1) ( this is the place the actual commit / rolback occurs)<br> → finally close all the threatLocal and connections.</p><blockquote>Sample Java code for <strong>UnitOfWork </strong>implementation.</blockquote><ul><li><strong>UnitOfWork </strong>class maintain all Transaction</li></ul><pre>public class UnitOfWork {<br><br>    private static final Log <em>log </em>= LogFactory.<em>getLog</em>(UnitOfWork.class);<br>    private static ThreadLocal&lt;UnitOfWorkTransactionContext&gt; <em>transactionContextThreadLocal </em>= new ThreadLocal&lt;&gt;();<br><br>    public UnitOfWork() {<br><br>        super();<br>    }<br><br>    <em>/**<br>     * Begin the transaction process.<br>     */<br>    </em>public static UnitOfWork beginTransaction() {<br><br>        UnitOfWorkTransactionContext UnitOfWorkTransactionContext = <em>transactionContextThreadLocal</em>.get();<br>        if (UnitOfWorkTransactionContext == null) {<br>            UnitOfWorkTransactionContext = new UnitOfWorkTransactionContext();<br>            <em>transactionContextThreadLocal</em>.set(UnitOfWorkTransactionContext);<br>        }<br>        UnitOfWorkTransactionContext.incrementTransactionDepth();<br>        return new UnitOfWork();<br>    }<br><br>    <em>/**<br>     * Returns an database connection.<br>     *<br>     * </em><strong><em>@param </em></strong><em>dataSource dataSource of the connection.<br>     * </em><strong><em>@return </em></strong><em>current connection<br>     * </em><strong><em>@Deprecated </em></strong><em>The getDBConnection should handle both transaction and non-transaction connection. Earlier it<br>     * handle only the transactionConnection. Therefore this method was deprecated and changed as handle both<br>     * transaction and non-transaction connection. getDBConnection(DataSource dataSource, boolean autoCommit) method<br>     * used as alternative of this method.<br>     */<br>    </em>@Deprecated<br>    public Connection getDBConnection(DataSource dataSource) throws SQLException {<br><br>        return getDBConnection(dataSource, true);<br>    }<br><br>    <em>/**<br>     * Returns an database connection.<br>     *<br>     * </em><strong><em>@param </em></strong><em>dataSource dataSource of the connection.<br>     * </em><strong><em>@param </em></strong><em>autoCommit autocommit state of the connection.<br>     * </em><strong><em>@return </em></strong><em>current connection<br>     */<br>    </em>public Connection getDBConnection(DataSource dataSource, boolean autoCommit) throws SQLException {<br><br>        UnitOfWorkTransactionContext unitOfWorkTransactionContext = <em>transactionContextThreadLocal</em>.get();<br>        if (unitOfWorkTransactionContext == null) {<br>            throw new UnitOfWorkException(<br>                    &quot;Can not get a connection as Transaction context is not started for dataSource : &quot; + dataSource);<br>        }<br>        Connection connection = unitOfWorkTransactionContext.getDBConnection(dataSource);<br><br>        if (!autoCommit &amp;&amp; connection.getAutoCommit()) {<br>            //We need only set &quot;autocommit==false&quot;, which indicate start of database transaction.<br>            connection.setAutoCommit(autoCommit);<br>        }<br>        return connection;<br>    }<br><br>    <em>/**<br>     * End the transaction by committing to the transaction.<br>     */<br>    </em>public void commitTransaction() {<br><br>        try {<br>            UnitOfWorkTransactionContext unitOfWorkTransactionContext = <em>transactionContextThreadLocal</em>.get();<br>            if (unitOfWorkTransactionContext == null) {<br>                throw new UnitOfWorkException(&quot;Can not get a connection as Transaction context is not started&quot;);<br><br>            }<br>            unitOfWorkTransactionContext.decrementTransactionDepth();<br>            if (unitOfWorkTransactionContext.getTransactionDepth() == 0 &amp;&amp; !unitOfWorkTransactionContext<br>                    .isErrorOccurred()) {<br>                unitOfWorkTransactionContext.commitAllConnection();<br>            }<br>        } catch (SQLException e) {<br>            <em>log</em>.error(&quot;Error occurred while commit connection&quot;, e);<br>        }<br>    }<br><br>    <em>/**<br>     * Revoke the transaction when catch then sql transaction errors.<br>     */<br>    </em>public void rollbackTransaction() {<br><br>        try {<br>            UnitOfWorkTransactionContext unitOfWorkTransactionContext = <em>transactionContextThreadLocal</em>.get();<br>            unitOfWorkTransactionContext.setErrorOccurred();<br>            if (unitOfWorkTransactionContext == null) {<br>                throw new UnitOfWorkException(&quot;Can not get a connection as Transaction context is not started&quot;);<br>            }<br>            unitOfWorkTransactionContext.decrementTransactionDepth();<br>            if (unitOfWorkTransactionContext.getTransactionDepth() == 0 &amp;&amp; unitOfWorkTransactionContext<br>                    .isErrorOccurred()) {<br>                unitOfWorkTransactionContext.rollbackAllConnection();<br>            }<br>        } catch (SQLException e) {<br>            <em>log</em>.error(&quot;Error occurred while rollback connection&quot;, e);<br>        }<br>    }<br><br>    <em>/**<br>     * close all the remaining transaction and the connections<br>     */<br>    </em>public void closeTransaction() {<br><br>        try {<br>            UnitOfWorkTransactionContext unitOfWorkTransactionContext = <em>transactionContextThreadLocal</em>.get();<br>            if (unitOfWorkTransactionContext == null) {<br>                throw new UnitOfWorkException(&quot;Can not get a connection as Transaction context is not started&quot;);<br>            }<br>            unitOfWorkTransactionContext.closeConnection();<br>            <em>transactionContextThreadLocal</em>.remove();<br><br>        } catch (SQLException e) {<br>            <em>log</em>.error(&quot;Error occurred while close all the transaction and connection&quot;, e);<br>        }<br>    }<br><br>}</pre><ul><li><strong>UnitOfWorkTransactionContext</strong> class maintains the Connection and Transaction mapping(this class is internally handled by <strong>UnitOfWork </strong>class).</li></ul><pre><em>/**<br> * Support class to maintain a mapping between dataSource and connection. At the same time it maintains commit and<br> * rollback transaction.<br> * By calling commitAllConnection() method user can commit all the transaction. If something happen at the middle<br> * then it will rollback the remaining connection.<br> * By calling rollbackAllConnection() method user can rollback all the transaction. If something happen at the middle<br> * then it will ignore the current transaction and rollback the remaining transaction.<br> * By calling closeConnection() method user can closs all the open connection. If something happen at the middle<br> * then it will ignore the current connection and close the remaining connections.<br> */<br></em>public class UnitOfWorkTransactionContext {<br><br>    private static final Log <em>log </em>= LogFactory.<em>getLog</em>(UnitOfWorkTransactionContext.class);<br>    private HashMap&lt;DataSource, Connection&gt; activeConnection = new HashMap();<br>    private int transactionDepth = 0;<br>    private boolean errorOccurred = false;<br><br>    <em>/**<br>     * Commit all the transaction, if something happened at the middle then it throw all committed transaction and it<br>     * will rollback the remaining transaction.<br>     */<br>    </em>void commitAllConnection() {<br><br>        StringBuilder commitErrorHandling = null;<br>        List&lt;DataSource&gt; listOfCommittedDataSource = null;<br>        HashMap&lt;DataSource, Connection&gt; rollBackConnections = null;<br><br>        for (Map.Entry entry : activeConnection.entrySet()) {<br>            try {<br>                Connection connection = (Connection) entry.getValue();<br>                if (connection != null) {<br>                    connection.commit();<br>                }<br>            } catch (SQLException e) {<br>                if (commitErrorHandling.equals(null)) {<br>                    commitErrorHandling = new StringBuilder();<br>                }<br>                if (listOfCommittedDataSource.equals(null)) {<br>                    listOfCommittedDataSource = new ArrayList&lt;&gt;();<br>                }<br>                if (rollBackConnections.equals(null)) {<br>                    rollBackConnections = new HashMap();<br>                }<br>                //get all the transaction that are committed before error occurs.<br>                for (Map.Entry activeEntry : activeConnection.entrySet()) {<br>                    if (!entry.getKey().equals(activeEntry.getKey())) {<br>                        listOfCommittedDataSource.add((DataSource) activeEntry.getKey());<br>                    } else {<br>                        break;<br>                    }<br>                }<br>                commitErrorHandling.append(&quot;Error occurred while committing the connection. Connection: &quot;)<br>                        .append(entry.getValue())<br>                        .append(&quot;. We have committed few transaction before error occurred. Committed dataSource : &quot;)<br>                        .append(listOfCommittedDataSource.toString()).append(&quot;. &quot;);<br>                //get all the transaction that are not committed.<br>                for (Map.Entry activeEntry : activeConnection.entrySet()) {<br>                    if (!listOfCommittedDataSource.contains(activeEntry.getKey())) {<br>                        rollBackConnections.put((DataSource) activeEntry.getKey(), (Connection) activeEntry.getValue());<br>                    }<br>                }<br>                // this method do the rollback for all uncommitted transaction list get above.<br>                internalRollbackConnection(rollBackConnections, commitErrorHandling);<br>                <em>log</em>.error(commitErrorHandling.toString(), e);<br>            }<br>        }<br>    }<br><br>    <em>/**<br>     * Rollback the remaining transaction if something happened at the middle while committing.<br>     *<br>     * </em><strong><em>@param </em></strong><em>rollBackConnections the connection map need to be rollback.<br>     * </em><strong><em>@param </em></strong><em>commitErrorHandling the error handling message.<br>     */<br>    </em>private void internalRollbackConnection(HashMap&lt;DataSource, Connection&gt; rollBackConnections,<br>            StringBuilder commitErrorHandling) {<br><br>        boolean internalRollback = false;<br>        for (Map.Entry entry : rollBackConnections.entrySet()) {<br>            try {<br>                Connection connection = (Connection) entry.getValue();<br>                if (connection != null) {<br>                    connection.rollback();<br>                }<br>            } catch (SQLException e) {<br>                commitErrorHandling.append(&quot;Error occurred while rollback the connection for dataSource: &quot;)<br>                        .append(entry.getKey()).append(&quot;, &quot;).append(e).append(&quot;. &quot;);<br>                internalRollback = true;<br>            }<br>        }<br>        if (!internalRollback) {<br>            commitErrorHandling<br>                    .append(&quot;Successfully rollback the remaining open connection due to this commit error. &quot;);<br>        }<br>    }<br><br>    <em>/**<br>     * Rollback all the transaction, if something happened at the middle then it will continue and rollback all the<br>     * connection as much as possible.<br>     */<br>    </em>void rollbackAllConnection() {<br><br>        StringBuilder rollbackErrorHandling = null;<br>        boolean rollbackErrorOccurred = false;<br>        for (Map.Entry entry : activeConnection.entrySet()) {<br>            try {<br>                Connection connection = (Connection) entry.getValue();<br>                if (connection != null) {<br>                    connection.rollback();<br>                }<br>            } catch (SQLException e) {<br>                if (rollbackErrorHandling.equals(null)) {<br>                    rollbackErrorHandling = new StringBuilder();<br>                }<br>                rollbackErrorHandling.append(&quot;Error occurred while rollback the connection for dataSource: &quot;)<br>                        .append(entry.getKey()).append(&quot;, &quot;).append(e).append(&quot;. &quot;);<br>                rollbackErrorOccurred = true;<br>            }<br>        }<br>        if (rollbackErrorOccurred) {<br>            <em>log</em>.error(rollbackErrorHandling);<br>        }<br>    }<br><br>    <em>/**<br>     * Set and return the connection.<br>     *<br>     * </em><strong><em>@param </em></strong><em>dataSource dataSource of the connection<br>     * </em><strong><em>@return </em></strong><em>the current connection<br>     */<br>    </em>public Connection getDBConnection(DataSource dataSource) throws SQLException {<br><br>        Connection currentConnectionForDataSource = activeConnection.get(dataSource);<br>        if (currentConnectionForDataSource == null) {<br>            currentConnectionForDataSource = dataSource.getConnection();<br>            activeConnection.put(dataSource, currentConnectionForDataSource);<br>        }<br>        return currentConnectionForDataSource;<br>    }<br><br>    <em>/**<br>     * Get the transaction level.<br>     *<br>     * </em><strong><em>@return </em></strong><em>transaction level<br>     */<br>    </em>int getTransactionDepth() {<br><br>        return transactionDepth;<br>    }<br><br>    <em>/**<br>     * Get the transaction level.<br>     *<br>     * </em><strong><em>@return </em></strong><em>transaction level<br>     */<br>    </em>boolean isErrorOccurred() {<br><br>        return errorOccurred;<br>    }<br><br>    <em>/**<br>     * Increment the transaction depth by one to store the level of a transaction.<br>     */<br>    </em>void setErrorOccurred() {<br><br>        this.errorOccurred = true;<br>    }<br><br>    <em>/**<br>     * Increment the transaction depth by one to store the level of a transaction.<br>     */<br>    </em>void incrementTransactionDepth() {<br><br>        transactionDepth++;<br>    }<br><br>    <em>/**<br>     * Decrement the transaction depth by one to notice the remaining levels of a transaction.<br>     */<br>    </em>void decrementTransactionDepth() {<br><br>        transactionDepth--;<br>    }<br><br>    <em>/**<br>     * Close all the db connection.<br>     */<br>    </em>void closeConnection() {<br><br>        boolean connectionErrorOccurred = false;<br>        StringBuilder connectionErrorHandling = null;<br>        for (Map.Entry entry : activeConnection.entrySet()) {<br>            Connection connection = (Connection) entry.getValue();<br>            try {<br>                connection.close();<br>            } catch (SQLException e) {<br>                if (connectionErrorHandling.equals(null)) {<br>                    connectionErrorHandling = new StringBuilder();<br>                }<br>                connectionErrorOccurred = true;<br>                connectionErrorHandling.append(&quot;Error occurred while close the connection:  &quot;)<br>                        .append(connectionErrorHandling).append(&quot;, Error was : &quot;).append(e).append(&quot;. &quot;);<br><br>            }<br>        }<br>        if (connectionErrorOccurred) {<br>            <em>log</em>.error(connectionErrorHandling);<br>        }<br>    }<br>}</pre><p><strong>UnitofWorkException</strong> class handles the UnitofWork exceptions</p><pre><em>/**<br> * Support class to handle the exceptions throw by the Unit of work patten.<br> */<br></em>public class UnitOfWorkException extends SQLException {<br><br>    public UnitOfWorkException() {<br>        super();<br>    }<br><br>    public UnitOfWorkException(String message, Throwable cause) {<br>        super(message, cause);<br>    }<br><br>    public UnitOfWorkException(String message, boolean convertMessage) {<br>        super(message);<br>    }<br><br>    public UnitOfWorkException(String message) {<br>        super(message);<br>    }<br><br>    public UnitOfWorkException(Throwable cause) {<br>        super(cause);<br>    }<br>}</pre><ul><li>************************ End **************************</li></ul><figure><a href="https://usejournal.com/?utm_source=medium.com&amp;utm_medium=noteworthy_blog&amp;utm_campaign=tech&amp;utm_content=guest_post_image"><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PYxBP_WV7LI6zc-zdUkNqQ.png" /></a></figure><p>📝 Read this story later in <a href="https://usejournal.com/?utm_source=medium.com&amp;utm_medium=noteworthy_blog&amp;utm_campaign=tech&amp;utm_content=guest_post_read_later_text">Journal</a>.</p><p>👩‍💻 Wake up every Sunday morning to the week’s most noteworthy stories in Tech waiting in your inbox. <a href="https://usejournal.com/newsletter/noteworthy-in-tech/?utm_source=medium.com&amp;utm_medium=noteworthy_blog&amp;utm_campaign=tech&amp;utm_content=guest_post_text">Read the Noteworthy in Tech newsletter</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c219eb7fea1c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[OSGi (Open Services Gateway initiative) fundamentals]]></title>
            <link>https://medium.com/@thushaamal93/osgi-open-services-gateway-initiative-fundamentals-6f7247d53536?source=rss-fea2253afc3------2</link>
            <guid isPermaLink="false">https://medium.com/p/6f7247d53536</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[osgi]]></category>
            <category><![CDATA[java-frameworks]]></category>
            <dc:creator><![CDATA[Amalanathan Thushanthan]]></dc:creator>
            <pubDate>Wed, 26 Jun 2019 05:42:35 GMT</pubDate>
            <atom:updated>2019-06-28T21:11:58.279Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FJC7k70OqOaTjFTSgy83WQ.png" /></figure><p>Let&#39;s consider this complex architecture,</p><p>In the developer perspective, it is hard to understand what is happening here?. At the same time, we can not do any modification on the code level as we like because some classes internally depend on other classes.</p><p>Do you believe that there is a single solution will solve all the issues mentioned above? Yes, OSGi service will solve all of these issues.</p><p>Before going into deeper we go through some basic concepts that help to understand more about OSGi.</p><h4><strong>Modularity</strong></h4><p>Modularity is not something new, simply says other than writing a complex program divide the program into small chunks and put some borders according to their functionality and dependencies. Each divided chunks call as an <strong>independent module</strong>.</p><p>Within the module, we can have multiple classes based on the module functionality. The module can able to decide which classes need to be available for public usage and which are private (means which can be used by other modules).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NN_R1dYLpMrxfdxqeb7IQw.png" /></figure><p>In here, we can easily understand the concept of the program, like which module is responsible for which purpose. Also, we can do the modification at any place that we want and we can reduce the coupling issues.</p><p>On the other hand, we can deploy and test the program separate and independent manner.</p><p>OSGi service deploys based on the Modularity.</p><p>Let&#39;s have a brief look at what is OSGi and OSGi architecture.</p><p><strong>What is OSGi?</strong></p><blockquote>The OSGi specification is developed by the members in an open process and made available to the public free of charge under the OSGi Specification License. It is a Java framework for developing and deploying modular software programs and libraries. Each bundle is a tightly coupled, dynamically loadable collection of classes, jars, and configuration files that explicitly declare their external dependencies (if any). &lt;<a href="https://en.wikipedia.org/wiki/OSGi">wiki</a>&gt;</blockquote><p>As we mentioned above, OSGi based on the Java framework for developing and deploying modular software programs and libraries. ie) we can install, uninstall, start, stop and updates in the form of bundles for deployment without a restart. Also, we have many well known and predefined OSGi container infrastructure such as Equinox, Knopflerfish, Apache Felix etc.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Z5GvymGZFlGb804wAHRWfg.png" /></figure><p>OSGi is a layered architecture. There are six primary layers in the OSGI architecture.</p><ul><li>Bundles: It is responsible for packaging the software components as jar archives with metadata.</li><li>Services: These are responsible for interact and communicates between bundles.</li><li>Service registry: These are clearly defined method for managing communication among various services.</li><li>Life Cycle: It defines how the bundles are dynamically installed and manage in the OSGi framework.</li><li>Modules: It defines the declaration of dependencies (how a bundle can import and export code).</li><li>Security: It is responsible for handles the security aspects by limiting bundle functionality to pre-defined capabilities.</li></ul><h3>Bundles</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TEQfUFDDQd4q2OZoulHx-g.png" /></figure><p>The software components of an OSGi framework are called bundles. The bundle packed as a jar archive. It is the collection of Java class files, resource files (icons, XML and HTML ﬁles), and the metadata (manifest ﬁle). In addition to that, a bundle can have other jar archives that used as input libraries.</p><p>The bundle manifest ﬁle is the one differentiate the bundle from normal jar archives. The bundle manifest contains important information related to the corresponding bundle like bundle name, version number, import and export packages, etc.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-SudXuqJ8wvLQz1XgbIhpQ.png" /><figcaption>sample manifest.mf file</figcaption></figure><h3>Services</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*k6mMkOVMV9JNSVtTGvdrPQ.png" /></figure><p>The services help to interact between bundles. i.e) service provider bundles publish their available public services from the service registry. The services can publish from the service registry with one or more interface names. Then the service requester bundles who need that services can search the services using interface name and get it from the service registry.</p><h3>Life Cycle</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hKSn_0NnrvcxKPb3yBqupw.png" /></figure><p>The Life cycle briefly describes how bundles are dynamically installed and manage in the OSGi framework. It allows the user dynamically administrate to installed, started, stopped, and uninstalled independently from the life cycle of the JVM. Also, bundles can safely add and remove from the framework whenever they want without restart the server.</p><p>At the initial point, the life cycle starts with installed bundles. After that life cycle layer ensures that all their dependencies are resolved because of avoiding the exception like ClassNotFoundException at run time. After the resolved check it moves to the basic flow as Start the bundle then active it and finally stop. If the life cycle layer finds any unresolved dependencies then the OSGi framework reports the issue and life cycle layer stops at that point and never goes to the starting state.</p><p>Each bundle can provide a bundle activator class that the framework calls as part of bundle start and stop events.</p><p>Here is an activator.class sample.</p><pre>package com.hazelcast.internal.osgi;<br><br>import com.hazelcast.core.Hazelcast;<br>import com.hazelcast.core.HazelcastInstance;<br>import com.hazelcast.logging.ILogger;<br>import com.hazelcast.logging.Logger;<br>import java.lang.reflect.Method;<br>import org.osgi.framework.BundleActivator;<br>import org.osgi.framework.BundleContext;<br><br>public class Activator implements BundleActivator {<br>    private static final String HAZELCAST_OSGI_START = &quot;hazelcast.osgi.start&quot;;<br>    private static final ILogger LOGGER = Logger.getLogger(Activator.class);<br>    private HazelcastInstance hazelcastInstance;<br><br>    public Activator() {<br>    }<br><br>   <strong> public void start(BundleContext context) throws Exception {<br>        this.activateJavaxScripting(context);<br>        if (Boolean.getBoolean(&quot;hazelcast.osgi.start&quot;)) {<br>            this.hazelcastInstance = Hazelcast.newHazelcastInstance();<br>        }<br><br>    }</strong><br><br>  <strong>  public void stop(BundleContext context) throws Exception {<br>        if (this.hazelcastInstance != null) {<br>            this.hazelcastInstance.shutdown();<br>        }<br><br>    }</strong><br><br>    private void activateJavaxScripting(BundleContext context) throws Exception {<br>        if (!this.isJavaxScriptingAvailable()) {<br>            LOGGER.warning(&quot;javax.scripting is not available, scripts from Management Center cannot be executed!&quot;);<br>        } else {<br>            Class&lt;?&gt; clazz = context.getBundle().loadClass(&quot;com.hazelcast.internal.osgi.ScriptEngineActivator&quot;);<br>            Method register = clazz.getDeclaredMethod(&quot;registerOsgiScriptEngineManager&quot;, BundleContext.class);<br>            register.invoke(clazz, context);<br>        }<br>    }<br><br>    private boolean isJavaxScriptingAvailable() {<br>        try {<br>            Class.forName(&quot;javax.script.ScriptEngineManager&quot;);<br>            return true;<br>        } catch (ClassNotFoundException var2) {<br>            return false;<br>        }<br>    }<br>}</pre><ul><li>************************** <strong>END</strong> *****************************</li></ul><figure><a href="https://usejournal.com/?utm_source=medium.com&amp;utm_medium=noteworthy_blog&amp;utm_campaign=tech&amp;utm_content=guest_post_image"><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PYxBP_WV7LI6zc-zdUkNqQ.png" /></a></figure><p>📝 Read this story later in <a href="https://blog.usejournal.com/r/?url=https%3A%2F%2Fusejournal.com%2F%3Futm_source%3Dmedium.com%26utm_medium%3Dnoteworthy_blog%26utm_campaign%3Dtech%26utm_content%3Dguest_post_read_later_text">Journal</a>.</p><p>👩‍💻 Wake up every Sunday morning to the week’s most noteworthy stories in Tech waiting in your inbox. <a href="https://blog.usejournal.com/r/?url=https%3A%2F%2Fusejournal.com%2Fnewsletter%2Fnoteworthy-in-tech%2F%3Futm_source%3Dmedium.com%26utm_medium%3Dnoteworthy_blog%26utm_campaign%3Dtech%26utm_content%3Dguest_post_text">Read the Noteworthy in Tech newsletter</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6f7247d53536" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[JDBC Transaction Management]]></title>
            <link>https://blog.devops.dev/jdbc-transaction-management-2c19bc795925?source=rss-fea2253afc3------2</link>
            <guid isPermaLink="false">https://medium.com/p/2c19bc795925</guid>
            <category><![CDATA[jdbc]]></category>
            <category><![CDATA[mysql]]></category>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[transaction-management]]></category>
            <dc:creator><![CDATA[Amalanathan Thushanthan]]></dc:creator>
            <pubDate>Wed, 26 Jun 2019 05:23:09 GMT</pubDate>
            <atom:updated>2022-07-05T04:07:12.416Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Why we need Transaction Management?</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jZYhhAkd_cxXAU1jD8RBqQ.png" /></figure><p>Consider Bob needs to transfer 100$ to Alice account through bank X. Bank debit the money from Bob’s account and updates his remaining balance. Then the bank deposits that money into Alice account. If there are no intermediate errors while depositing money then its happy path. Think, While depositing the money there is a connection/intermediate error occurs. Then the amount does not add into Alice account. But Bob thinks that he has transferred the money to Alice but Alice does not get the money. Then it will be big trouble for the bank. To overcome these kinds of issues we need proper transaction management to manage the processes.</p><p>Let&#39;s consider the same process with transaction management. This time Bank starts the transaction. As a first step bank debit the money from bob account but does not update his account balance. Then the bank system deposit that money into Alice’s account. If there are no intermediate errors then the bank will update both accounts with the new balances at the end of this transaction. If some intermediate errors occur then the bank safely reverts the process and it does not affect the transaction.</p><p>Now we will go through how this process works in JDBC and some important topics about <strong>Transaction Management.</strong></p><h4><strong>auto-commit mode</strong></h4><p>When we start the connection the connection will start with auto-commit mode. Auto-commit is the one starts the transaction in the SQL. By Default the auto-commit is true. We can change the value of auto-commit according to our needs.</p><p><strong>set auto-commit as true</strong>: When the auto-commit state is true then each SQL statements considers as one single transaction. The SQL statements automatically commit after each SQL statement has executed.</p><p><strong>set auto-commit as false:</strong> When the auto-commit state is false then multiple SQL statements process within one single transaction. The multiple SQL statements get committed after executing all the SQL statements.</p><p>We can divide the entire transaction process into two main parts,</p><ol><li>Start the Transaction</li><li>End the Transaction</li></ol><h4>1. Start the Transaction</h4><p>As we mention before transaction start when setting the AutoCommit. Mostly we use default AutoCommit to start the single SQL statements.</p><p>If we are dealing with a group of multiple SQL statements then we enable a manual- transaction to increase the performance and maintain the integrity of business processes.</p><pre>connection.setAutoCommit(false);</pre><h4><strong>2. End the transaction</strong></h4><p>When we use default AutoCommit to start the single SQL statements. It will automatically commit the transaction. So we don&#39;t want to take this as a serious issue.</p><p>When we enable a manual- transaction,</p><p>We should call the <strong>commit()</strong> method to commit the changes into the database. This method commits all the SQL statements together as a <strong>unit</strong>.</p><pre>connection.commit();</pre><p>If some intermediate error/ connection error occurs or if we want to revert the queries executed by the specific connection, we can revert the queries using <strong>rollback() </strong>method. There are two ways to revert the updates done by the SQL connection,</p><ol><li><strong>Rollback connection</strong>: If something goes wrong before committing or if we want to revert all the queries executed by the specific connection we can rollback the updates using <strong>rollback() </strong>method.</li></ol><pre>connection.rollback();</pre><p>2. <strong>Rollback to savepoint: </strong>If you want to revert the updates until certain points we can revert using savepoint.</p><p>For that, we need to initialize savepoints until where we want to undo. We can achieve this by calling <strong>setSavepoint()</strong> method.</p><pre>Savepoint savepoint = connection.setSavepoint();</pre><p>Then if something went wrong after savepoint we can rollback the transaction until the place we put savepoint by calling rollback method with the savepoint name.</p><pre>connection.rollback(savepoint);</pre><h4>Sample code</h4><pre>try{<br>   <strong>conn.setAutoCommit(false);</strong><br>   Statement stmt = conn.createStatement();<br>   String SQL = &quot;INSERT INTO Employees  &quot; +<br>                &quot;VALUES (162, 131, &#39;Alice&#39;, &#39;Bob&#39;)&quot;;<br>   x=1;<br>   stmt.executeUpdate(SQL);  <br>   <strong>Savepoint savepoint = conn.setSavepoint();</strong><br>   String SQL = &quot;INSERTED IN Employees  &quot; +<br>                &quot;VALUES (17, 223, &#39;Ram&#39;, &#39;Raja&#39;)&quot;;<br>   x=2;<br>   stmt.executeUpdate(SQL);<br>   <strong>conn.commit();</strong><br>}catch(SQLException se){<br>   if(x==2) {<br>     <strong> conn.rollback();</strong><br>   } else {<br>      <strong>conn.rollback(savepoint);</strong><br>   }<br>}</pre><h4><strong>Common mistakes developers do while working with Transaction Management</strong></h4><ul><li>When we work with a manual- transaction we should commit or rollback the transaction at the end. If we missed committing then it is not updated into the database.</li></ul><pre>try{<br> <strong>  conn.setAutoCommit(false);</strong><br>   Statement stmt = conn.createStatement();<br>   <br>   String SQL = &quot;INSERT INTO Employees  &quot; +<br>                &quot;VALUES (106, 20, &#39;Rita&#39;, &#39;Tez&#39;)&quot;;<br>   stmt.executeUpdate(SQL);  <br>   String SQL = &quot;INSERTED IN Employees  &quot; +<br>                &quot;VALUES (107, 22, &#39;Sita&#39;, &#39;Singh&#39;)&quot;;<br>   stmt.executeUpdate(SQL);<br>}</pre><ul><li>We can not add two or more commits within one transaction.</li></ul><pre>try{<br>   conn.setAutoCommit(false);<br>   Statement stmt = conn.createStatement();<br>   <br>   String SQL = &quot;INSERT INTO Employees  &quot; +<br>                &quot;VALUES (106, 20, &#39;Rita&#39;, &#39;Tez&#39;)&quot;;<br>   stmt.executeUpdate(SQL);  <br>  <strong> conn.commit();</strong><br>   String SQL = &quot;INSERTED IN Employees  &quot; +<br>                &quot;VALUES (107, 22, &#39;Sita&#39;, &#39;Singh&#39;)&quot;;<br>   stmt.executeUpdate(SQL);<br>  <strong> conn.commit();</strong><br>}catch(SQLException se){<br>   conn.rollback();<br>}</pre><ul><li>We can not add commit and rollback at once because it is useless.</li></ul><pre>try{<br>   conn.setAutoCommit(false);<br>   Statement stmt = conn.createStatement();<br>   <br>   String SQL = &quot;INSERT INTO Employees  &quot; +<br>                &quot;VALUES (106, 20, &#39;Rita&#39;, &#39;Tez&#39;)&quot;;<br>   stmt.executeUpdate(SQL);  <br>   String SQL = &quot;INSERTED IN Employees  &quot; +<br>                &quot;VALUES (107, 22, &#39;Sita&#39;, &#39;Singh&#39;)&quot;;<br>   stmt.executeUpdate(SQL);<br>  <strong> conn.commit();<br>   conn.rollback();</strong><br>}</pre><p>****************************** END *******************************</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2c19bc795925" width="1" height="1" alt=""><hr><p><a href="https://blog.devops.dev/jdbc-transaction-management-2c19bc795925">JDBC Transaction Management</a> was originally published in <a href="https://blog.devops.dev/">DevOps.dev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What is OpenID Connect?]]></title>
            <link>https://medium.com/identity-beyond-borders/what-is-openid-connect-998b955d5a47?source=rss-fea2253afc3------2</link>
            <guid isPermaLink="false">https://medium.com/p/998b955d5a47</guid>
            <category><![CDATA[openid-connect]]></category>
            <category><![CDATA[oauth]]></category>
            <category><![CDATA[wso2is]]></category>
            <category><![CDATA[oauth2]]></category>
            <dc:creator><![CDATA[Amalanathan Thushanthan]]></dc:creator>
            <pubDate>Sun, 19 May 2019 18:00:35 GMT</pubDate>
            <atom:updated>2019-05-21T05:40:32.559Z</atom:updated>
            <content:encoded><![CDATA[<h3>The wide story of OpenID Connect</h3><blockquote>“OpenID Connect is a simple identity layer on top of the OAuth 2.0 protocol. It allows Clients to verify the identity of the End-User based on the authentication performed by an Authorization Server, as well as to obtain basic profile information about the End-User in an interoperable and REST-like manner.”</blockquote><h4>Why we need OpenId Connect and what is the major difference from OAuth2.0?</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iVMIDEi4kDqxxh66YHfU9Q.png" /></figure><p>As mention in the definition, OpenId Connect (OIDC) is the identity layer on top of the OAuth 2.0 protocol. The basic access token flow in the OAuth 2.0 protocol is the Resouce owner (user) request for service from the client (third-party application). The Client (third-party application) sends the access request with its <strong>own identity</strong> to the authorization server ( facebook). The authorization server (Facebook) gets the authentication request and verifies the identification of the third party application. After verification, authorization server requests to the resource owner(user) to authenticate them self and get consent to allow the client (third-party application) to access their resources mention in the concent interface. After getting positive consent from the resource owner, the authorization server sends the <strong>Access token</strong> to the client application for access the resource server. (follow <a href="https://medium.com/identity-beyond-borders/oauth-2-0-a436a0bfbcf2">OAuth2.0</a> to know more about OAuth and Access delegation)</p><p>In this flow, the Client request for access the Authorization server then the server returns the access token to the client for access the resource. The client application doesn&#39;t know anything about user-related information. To overcome this issue, we apply the OpenID Connect (OIDC) as an identity layer on top of the OAuth 2.0 protocol to know about user information from the client side.</p><p>We can obtain client information with the help of three common widely used OpenID flows.</p><h3>1. OpenID with <strong>Authorization code flow</strong></h3><p>Authorization code flow was used by OAuth2 and provides a way to retrieve token on a back-channel.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ocf1RbFWsGYKoDEL43fO4A.png" /></figure><p>Step1: The Resouce owner (user) request for service from the client (third party application)</p><p>Step2: Client sent the authorization request to the Authorization Server with the <strong>response_type </strong>as <strong>code </strong>and <strong>scope </strong>as <strong>openid</strong></p><pre><a href="https://server.example.com/authorize?">https://server.example.com/authorize?</a><br>    response_type=code<br>    &amp;client_id=s6BhdRkqt3<br>    &amp;redirect_uri=https%3A%2F%2Fclient.example.org%2Fcb<br>    &amp;scope=openid%20profile<br>    &amp;state=af0ifjsldkj</pre><p>Step3: Authorization server gets the authentication request and verifies the identification of the third party application. After verification, authorization server requests to the resource owner(user) to authenticate them self and get consent to allow the client (third-party application) to access their resources mention in the concent interface.</p><p>Step 4: After getting positive consent from the resource owner, If the end-user grants the access request then the Authorization Server sends the success message with a <strong>code</strong>.</p><p>Step5: The client sends the access token request to the Authorization Server token endpoint with the <strong>code</strong>.</p><pre>POST /token HTTP/1.1<br>  Host: server.example.com<br>  Authorization: Basic czZCaGRSa3F0MzpnWDFmQmF0M2JW<br>  Content-Type: application/x-www-form-urlencoded</pre><pre>  grant_type=authorization_code&amp;code=SplxlOBeZQQYbYS6WxSbIA<br>    &amp;redirect_uri=https%3A%2F%2Fclient%2Eexample%2Ecom%2Fcb</pre><p>Step6: The client verifies the code and sends back the <strong>Access Token</strong> along with the <strong>ID-Token</strong>. The<strong> ID token</strong> contains the user information.</p><blockquote><strong>Further more details visit: </strong><a href="https://openid.net/specs/openid-connect-basic-1_0.html"><strong>https://openid.net/specs/openid-connect-basic-1_0.html</strong></a></blockquote><h3><strong>2. </strong>OpenID with <strong>Implicit flow</strong></h3><p>The Implicit flow depends on the front-channel (browser-based calls) to retrieve tokens. We can not generate a refresh token using Implicit flow. Therefore it’s not recommended for sort validity period access token generation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RtwWK01WyqsCwmDXEq_TuQ.png" /></figure><p>Step 1: The Resouce owner (user) request for service from the client (third party application)</p><p>Step 2: The Client (third-party application) sends the access request with its <strong>own identification</strong>. In addition, Client sents the <strong>openid </strong>as <strong>scope</strong> and <strong>response type</strong> as <strong>id token</strong>.</p><pre>https://server.example.com/authorize?<br>    response_type=id_token%20token<br>    &amp;client_id=s6BhdRkqt3<br>    &amp;redirect_uri=https%3A%2F%2Fclient.example.org%2Fcb<br>    &amp;scope=openid%20profile<br>    &amp;state=af0ifjsldkj<br>    &amp;nonce=n-0S6_WzA2Mj</pre><p>Step 3: Authorization server gets the authentication request and verifies the identification of the third party application. After verification, authorization server requests to the resource owner(user) to authenticate them self and get consent to allow the client (third-party application) to access their resources mention in the concent interface.</p><p>Step 4: After getting positive consent from the resource owner, the authorization server sends the<strong> Access Token</strong> and <strong>ID token</strong> to the client application. The<strong> ID token</strong> contains the user information.</p><pre>HTTP/1.1 302 Found<br>  Location: https://client.example.org/cb#<br>    access_token=SlAV32hkKG<br>    &amp;token_type=bearer<br>    &amp;id_token=eyJ0 ... NiJ9.eyJ1c ... I6IjIifX0.DeWt4Qu ... ZXso<br>    &amp;expires_in=3600<br>    &amp;state=af0ifjsldkj</pre><blockquote><strong>Further more details visit: </strong><a href="https://openid.net/specs/openid-connect-implicit-1_0.html"><strong>https://openid.net/specs/openid-connect-implicit-1_0.html</strong></a></blockquote><h3><strong>3.</strong> OpenID with <strong>Hybrid flow</strong></h3><p>It is the combination of Implicit and authorization code flow. It allows requesting a combination of ID-Token, Access Token and Code via front-channel.</p><p>There are three major Hybrid flows,</p><p><strong>3.1 Code Token</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TMP26K9maZBZwaNEysfk-Q.png" /></figure><p>Step1: The Resouce owner (user) request for service from the client (third-party application).</p><p>Step2: Client sent the authorization request to the Authorization Server.</p><blockquote>https://localhost:9443/oauth2/authorize?response_type=code token&amp;client_id=&lt;Client ID&gt;&amp;nonce=asd&amp;redirect_uri=<a href="http://localhost:8080/playground2/oauth2client&amp;scope=openid">http://localhost:8080/playground2/oauth2client&amp;scope=openid</a></blockquote><p>Step3: Authorization server gets the authentication request and verifies the identification of the third party application. After verification, authorization server requests to the resource owner(user) to authenticate them self and get consent to allow the client (third-party application) to access their resources mention in the concent interface.</p><p>Step 4: After getting positive consent from the resource owner, If the end-user grants the access request then the Authorization Server sends the success message with a <strong>code </strong>and<strong> Access token</strong>.</p><p>Step5: The client sends the token request to the Authorization Server token endpoint with the <strong>code, Client-ID, </strong>and<strong> Client-Secret</strong>.</p><blockquote>curl -k -v — user &lt;Client ID&gt;:&lt;Client secret&gt; -d “grant_type=authorization_code&amp;code=99b34587–5483–374d-8b25–50485498e761&amp;redirect_uri=http://localhost:8080/playground2/oauth2client&quot; <a href="https://localhost:9443/oauth2/token">https://localhost:9443/oauth2/token</a></blockquote><p>Step6: The client verifies the code and sends back the <strong>Access Token</strong> along with the <strong>ID-Token</strong>.</p><p><strong>3.2 Code ID-Token</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6QAp--BPovrAMB_PBuD2TA.png" /></figure><p>Step1: The Resouce owner (user) request for service from the client (third-party application).</p><p>Step2: Client sent the authorization request to the Authorization Server.</p><blockquote>https://localhost:9443/oauth2/authorize?response_type=code id_token&amp;client_id=&lt;Client ID&gt;&amp;nonce=asd&amp;redirect_uri=<a href="http://localhost:8080/playground2/oauth2client&amp;scope=openid">http://localhost:8080/playground2/oauth2client&amp;scope=openid</a></blockquote><p>Step3: Authorization server gets the authentication request and verifies the identification of the third party application. After verification, authorization server requests to the resource owner(user) to authenticate them self and get consent to allow the client (third-party application) to access their resources mention in the concent interface.</p><p>Step 4: After getting positive consent from the resource owner, If the end-user grants the access request then the Authorization Server sends the success message with a <strong>code </strong>and<strong> ID-Token</strong>.</p><p>Step5: The client sends the token request to the Authorization Server token endpoint with the <strong>code, Client-ID, </strong>and<strong> Client-Secret</strong>.</p><p>Step6: The client verifies the code and sends back the <strong>Access Token</strong> along with the <strong>ID-Token</strong>.</p><p><strong>3.3 Code ID-Token Token</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_MaaXk8RAYmZMGeVc4gnuA.png" /></figure><p>Step1: The Resouce owner (user) request for service from the client (third-party application).</p><p>Step2: Client sent the authorization request to the Authorization Server.</p><blockquote>https://localhost:9443/oauth2/authorize?response_type=code id_token token&amp;client_id=&lt;Client ID&gt;&amp;nonce=asd&amp;redirect_uri=<a href="http://localhost:8080/playground2/oauth2client&amp;scope=openid">http://localhost:8080/playground2/oauth2client&amp;scope=openid</a></blockquote><p>Step3: Authorization server gets the authentication request and verifies the identification of the third party application. After verification, authorization server requests to the resource owner(user) to authenticate them self and get consent to allow the client (third-party application) to access their resources mention in the concent interface.</p><p>Step 4: After getting positive consent from the resource owner, If the end-user grants the access request then the Authorization Server sends the success message with a <strong>code, Access token, and ID-Token</strong>.</p><p>Step5: The client sends the token request to the Authorization Server token endpoint with the <strong>code, Client-ID, </strong>and<strong> Client-Secret</strong>.</p><p>Step6: The client verifies the code and sends back the <strong>Access Token</strong> along with the <strong>ID-Token</strong>.</p><blockquote><strong>Further more details visit: </strong><a href="https://docs.wso2.com/display/IS570/OpenID+Connect+Hybrid+Flow"><strong>https://docs.wso2.com/display/IS570/OpenID+Connect+Hybrid+Flow</strong></a></blockquote><h3><strong>ID Token</strong></h3><p>ID Token is a simple JSON Web Token(JWT) that contain the user information sent by the Authorization server. Using ID Token, we can find who is the user got authenticated, when he got authenticated, how he got authenticated, what are the attributes that the user can share and why the user shares that attribute.</p><p>In general, ID-Token sign by the JSON web signature and encrypted by the JSON web encryption to increase the authenticity and security. We can decode ID-Token and can see the user information using <a href="https://jwt.io/">jwt.io</a>.</p><p><strong>sample ID token,</strong></p><blockquote><strong>eyJ4NXQiOiJOVEF4Wm1NeE5ETXlaRGczTVRVMVpHTTBNekV6T0RKaFpXSTRORE5sWkRVMU9HRmtOakZpTVEiLCJraWQiOiJOVEF4Wm1NeE5ETXlaRGczTVRVMVpHTTBNekV6T0RKaFpXSTRORE5sWkRVMU9HRmtOakZpTVEiLCJhbGciOiJSUzI1NiJ9</strong>.eyJhdF9oYXNoIjoiSnJaWTlNdFlWRUlJSlV4LUREQm13dyIsInN1YiI6ImFkbWluIiwiYXVkIjpbIm5jemJnNW01eHh0NnRQNFVNWndCNlB0UW9Rb2EiXSwiYXpwIjoibmN6Ymc1bTV4eHQ2dFA0VU1ad0I2UHRRb1FvYSIsImlzcyI6Imh0dHBzOlwvXC9sb2NhbGhvc3Q6OTQ0M1wvb2F1dGgyXC90b2tlbiIsImV4cCI6MTUxMDgzMTAxMCwibm9uY2UiOiJhc2QiLCJpYXQiOjE1MTA4MzEwMDd9.<strong>XKV0ioEvflR4MHGthO3cwXwC88msNgqR4l1O83mfhxOMtO1PG3ABWB5E4aFXFpR9t-8zJs09slhLsDTDhmC33KE8Die61UK9_Vb5aNA4XCkawyJt8dCX6clc6UUbTEO5N1ubXA18QFgwAEWpvoTz1hKx8XLnvOSehbdEKsoPunoHDmXpYJe_9hBg5V3kN-VHxdKdGOtl9u-Aml42s5p45cZY0mlFVcKjatBAf7hqWNPlUebyujDWG1Iyk_-AXNQ2wYi0F77uG7_HstP_tp0sOctu0TYCK8bwBTXEJYMPt1CqOqcae05m8N8hb0zs6Yxvyx_udCJPG-8n2zRB-T-kcg</strong></blockquote><p>The ID-Token contains three main parts separated by a full stop.</p><p><strong>1.HEADER: </strong>It contains the metadata of the token (ALGORITHM &amp; TOKEN TYPE).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0FbPwmzH4AgNyCZccZcJFA.png" /><figcaption>Decoded header</figcaption></figure><p>2. <strong>PAYLOAD: </strong>It contains the user’s information.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iBBErZSn5A2rDTWx-2sjXQ.png" /><figcaption>Decoded payload</figcaption></figure><ul><li><strong>sub</strong>: Identity of the user</li><li><strong>aud</strong>: Audiences that this ID Token is intended for (client)</li><li><strong>iss</strong>: Issuer Authority</li><li><strong>exp</strong>: Expiration time</li><li><strong>iat</strong>: The time that JWT was issued</li></ul><p><strong>3. VERIFY SIGNATURE: </strong>It contains validated and trust the token from the application site.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_JO879SZp1jI50bXWkVHxQ.png" /><figcaption>Decoded verify signature</figcaption></figure><blockquote>WSO2 Identity server supports the OpenID connect for get the user information. Please visit <a href="https://wso2.com/identity-and-access-management/">https://wso2.com/identity-and-access-management/</a> for further information.</blockquote><blockquote>try openID connect tutorials with WSO2 Identity server, <a href="https://docs.wso2.com/display/IS530/OpenID+Connect">https://docs.wso2.com/display/IS570/OpenID+Connect</a></blockquote><p>*************************** END *************************</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=998b955d5a47" width="1" height="1" alt=""><hr><p><a href="https://medium.com/identity-beyond-borders/what-is-openid-connect-998b955d5a47">What is OpenID Connect?</a> was originally published in <a href="https://medium.com/identity-beyond-borders">Identity Beyond Borders</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What is SAML?]]></title>
            <link>https://medium.com/identity-beyond-borders/what-is-saml-f1c7254a79f0?source=rss-fea2253afc3------2</link>
            <guid isPermaLink="false">https://medium.com/p/f1c7254a79f0</guid>
            <category><![CDATA[aml]]></category>
            <category><![CDATA[identity-management]]></category>
            <category><![CDATA[wso2]]></category>
            <category><![CDATA[saml2]]></category>
            <dc:creator><![CDATA[Amalanathan Thushanthan]]></dc:creator>
            <pubDate>Tue, 07 May 2019 05:15:54 GMT</pubDate>
            <atom:updated>2019-05-07T05:27:11.674Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>“The Security Assertion Markup Language (SAML) is an XML-based open security standard framework for authentication and authorization across two different systems (Service Provider and an Identity Provider)”</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iznZMVJAHeyQEIn2JxQZLA.png" /></figure><h3><strong>Why we need SAML?</strong></h3><p>Let&#39;s consider, There is a user needs to access some web services to full fill his requirement. Each web services they have their own secure authentication process and own identity providers for the authentication. So the user needs to maintain and memorize many credentials for access the web services. The user works with different URLs, so it allows hackers to do the phishing attack. In the other hand, each web services need to maintain user information on their own server and take more security efforts to secure the user information and authentication process. At the same time, the same user and user’s information were duplicated in many places.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ScscAX6e_kfLja-u4IGJKg.png" /></figure><p>What will happen if we introduce one common identity provider on behalf of all web application?</p><p>Simply all the problems were getting solved. There are only one service provider and one place for authentication. So no need to maintain and memorize many credentials, all user information maintain at one place, there is less chance for phishing attacks because the user needs to verify only one URL and also the web services vendors don&#39;t want to take too much effort in the security site.</p><p>Here SAML help the Service provider to communicate with Identity Providers for authentication and authorization process. It helps to pass the authentication information, user-related attributes, and entitlement issues.</p><h4>What is a SAML Provider?</h4><p>SAML provider is a system that helps the user to access the service that they need. The most common SAML providers are Service Provider(SP) and Identity Provider(Idp).</p><ul><li><strong>Service Provider</strong>: The system that provides a SAML service is called Service Provider.</li><li><strong>Identity Provider</strong>: The system that helps to identify and authenticate the user. At the same time send the authentication response with user’s access rights for the service to the service provider is called Identity Provider.</li></ul><h4>What is a SAML Assertion?</h4><p>SAML Assertion is an XML document that contains does the user have the rights to access the service, the user identification, the time the user locked in, the authentication method that the user used, user information and etc. In general, the SAML Assertion sent by the Identity provider to Service Provider.</p><h3>Single-Sign-On and Single-log-out SAML workflow</h3><blockquote><strong>Note: </strong>SAML helps to enable Single-Sign-On (SSO) and Single-log-out (SLO) from both Service provider and Identity Provider sides.</blockquote><h4>1. Service Provider Initiated Single-Sign-On (SSO) flow</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5092lkz2NkYUnVh4Vh05XQ.png" /></figure><p>Step1: The user request for a service from the service provider.</p><p>Step2: The service provider creates a login request(SAML request).</p><p>Step3: The created message (<strong>payload</strong> which contains service provider name) passed through the User-agent (browser) from the service provider to the identity provider.</p><p>Step4: Identity provider identifies the principals and authenticates with the user.</p><p>Step5: After authentication, the identity provider sends the response message (SAML response) to the service provider through the User-agent. The response includes the authenticated user, requested attribute, etc.</p><p>Step6: Based on the Identity provider response the service provider give the service to the end user (If authentication fails then it returns an error message and if the authentication success then it creates an application session).</p><h4>2. Identity Provider Initiated Single-Sign-On (SSO) flow</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3obpl13NFLB6-BjKEGp1aQ.png" /></figure><p>Step1: User directly call the identity provider endpoint with the service provider name.</p><p>Step2: Identity provider identifies the principals and authenticates with the user.</p><p>Step3: After identification, the identity provider sends the response message (SAML response) to the service provider through the User-agent. The response includes the authenticated user, requested attribute, etc.</p><p>Step4: Based on the Identity provider response the service provider give the service to the end user (If authentication fails then it returns an error message and if the authentication success then it creates an application session)</p><h4>3. Service Provider Initiated Single-log-out (SLO) flow</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*owgteZCdfloFMQ1f" /></figure><p>Step1: Session participant (eg: salesforce) send the logout request (SAML request) with the session index(this session index comes from the IDP response in the Single-Sign-On flow).</p><p>Step2: Using the session index, The identity provider identifies the available session participants that are logged-in with the same session index.</p><p>Step3: The Identity provider sends the logout request (SAML request) to one of the available session participants.</p><p>Step4: The Session participant sends back the logout response (SAML response) to the Identity Provider.</p><p><strong>Note:</strong> The Step3 and Step4 are repeated until logged-out all the available session participants identified by the identity provider.</p><p>Step5: Finally, the Identity Provider sends the logged out response (SAML response) to the original Session Participant.</p><h4>4. Identity Provider Initiated Single-log-out (SLO) flow</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ntp1-ddpy3-h2wJln7-WhQ.png" /></figure><p>Step1: User directly call the identity provider endpoint with the session index.</p><p>Step2: Using the session index, The identity provider identifies the available session participants that are logged-in with the same session index.</p><p>Step3: The Identity provider sends the logout request (SAML request) to one of the available session participants.</p><p>Step4: The Session participant sends back the logout response (SAML response) to the Identity Provider.</p><p><strong>Note:</strong> The Step3 and Step4 are repeated until logged-out all the available session participants identified by the identity provider.</p><blockquote>WSO2 Identity server supports the SAML and product optimized for identity federation and SSO with comprehensive support for <a href="https://wso2.com/identity-and-access-management/adaptive-authentication/">adaptive</a> and strong authentication. Please visit <a href="https://wso2.com/identity-and-access-management/">https://wso2.com/identity-and-access-management/</a> for further information.</blockquote><blockquote>try some tutorials with WSO2 Identity server, <a href="https://docs.wso2.com/display/IS570/Configuring+Single+Sign-On">https://docs.wso2.com/display/IS570/Configuring+Single+Sign-On</a></blockquote><p>*************************** END *************************</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f1c7254a79f0" width="1" height="1" alt=""><hr><p><a href="https://medium.com/identity-beyond-borders/what-is-saml-f1c7254a79f0">What is SAML?</a> was originally published in <a href="https://medium.com/identity-beyond-borders">Identity Beyond Borders</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[OAuth 2.0]]></title>
            <link>https://medium.com/identity-beyond-borders/oauth-2-0-a436a0bfbcf2?source=rss-fea2253afc3------2</link>
            <guid isPermaLink="false">https://medium.com/p/a436a0bfbcf2</guid>
            <category><![CDATA[oauth2]]></category>
            <category><![CDATA[identity-management]]></category>
            <category><![CDATA[oauth]]></category>
            <category><![CDATA[wso2is]]></category>
            <dc:creator><![CDATA[Amalanathan Thushanthan]]></dc:creator>
            <pubDate>Mon, 08 Apr 2019 03:21:27 GMT</pubDate>
            <atom:updated>2019-04-16T07:34:23.774Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Access delegation via OAuth 2.0</strong></h3><h3>What is OAuth2?</h3><p>“<em>OAuth is an open-standard authorization protocol, Which provides the client application with secure and delegated access”</em></p><p>Initially, we start with the basic authentication flow,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Fn8AOf3awPM0EDmpVJCNhg.png" /></figure><p>Let&#39;s describe the basic authentication flow with the example,</p><p>The user needs to get his photo already uploaded in the google drive. First, the user login into the system using his personal credentials(username and password). If the credential is correct then the google allows the user to access the google drive. There are no issues arise in this flow.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HIn-2761iJxH52o78p-VRg.png" /></figure><p>Let’s consider someone is going to use your information on behalf of you. Are you willing to provide your personal credentials to other third party applications? The answer is always <strong><em>NO.</em></strong></p><p>How these applications access our information without our credentials? Here the OAuth protocol comes into the picture. The OAuth allows third-party applications to provide some limited access to get the service on behalf of the user. It uses a kind of token called “<strong>access tokens”</strong> instead of username and password.</p><h3><strong>Roles</strong></h3><p>Basically, there are four peoples play major roles in OAuth protocol,</p><ol><li>Resource owner: The person who is going to give some portion of access from their account. eg: the user who is going to use that application.</li><li>Client: The third party application that is attempting to get access on behalf of the resource owner. eg: it can be any third party mobile or web application.</li><li>Authorization server: This is the place where the resource owners store their credential resources and the place where you are authenticated. eg: Google, Facebook etc.</li><li>Resource server: This is the place where the resource owners store and access their actual resource. eg: Dropbox, GoogleDrive etc.</li></ol><h3><strong>How OAuth works</strong></h3><p>In the below diagram, the user wants to know that “Will he have a love marriage or arranged marriage ?” using a third-party application. For the analysis, the third-party application needs the user’s friend list from facebook. But the problem is the user doesn’t like to share his facebook credential with that third-party application. So the OAuth comes into the picture and the below diagram that illustrates the flow of access delegation via OAuth.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dJCykEraJkut8jcXt4qfNg.png" /></figure><p>Step 1: The Resouce owner (user) request for service from the client (third party application)</p><p>Step 2: The Client (third-party application) sends the access request with its <strong>own identification</strong> and <strong>Scope</strong> to the authorization server ( facebook). Scope includes the access limitation (friend list of the resource owner) to the client.</p><p>Step 3: Authorization server (Facebook) gets the authentication request and verifies the identification of the third party application. After verification, authorization server requests to the resource owner(user) to authenticate them self and get consent to allow the client (third-party application) to access their resources mention in the concent interface.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*DzR5eWrlpxDBaIDGGYLS8g.png" /><figcaption>Concent interface</figcaption></figure><p>Step 4: After getting positive consent from the resource owner, the authorization server sends the token to the client application for access the resource server. The token that sends by the authorization server belongs to the client request <strong>grant type</strong>(third-party application request).</p><p>Step 5: Client (third-party application) sends the resource request with the access token to the resource owner for accessing the resources(friend list of the user).</p><p>Step 6: Now the resource server validates the access token with the authorization server (facebook). If the access token is valid and not expired then the resource server gives access to the client(third-party application) to use the resource (friend list) until the access token expired.</p><p>In this flow, we need to concentrate on two major parts.</p><h4><strong>1. Grant type</strong></h4><p>Based on the client and their requirements, the client can choose their grant types. In general, there are five major and well-defined grant types available in the OAuth.</p><ol><li><strong>Authorization Code</strong> — The authorization code grant type is optimized for confidential clients. It provides a few important security benefits such as the ability to authenticate the client and transmission of the access token directly to the client without passing it through the resource owner’s user-agent and potentially exposing it to others (including the resource owner).</li><li><strong>Implicit </strong>— It is mainly used for clients that are not capable of keeping the client’s own credentials secret.</li><li><strong>Password</strong> — The resource owner password credentials grant type is suitable in cases where the resource owner has a trust relationship with the client (e.g., a service’s own mobile client) and in situations where the client can obtain the resource owner’s credentials.</li><li><strong>Client Credential</strong> — This grant is suitable for machine-to-machine authentication or for a client making requests to an API that does not require the user’s permission. This grant should be allowed for use only by trusted clients.</li><li><strong>Refresh Token </strong>— The refresh token grant can be used when the current access token is expired or when a new access token is needed.</li></ol><h4>2. Token</h4><ul><li><strong>Access Token</strong>: This is the token that uses by the client application to access the resource owner. It will expire after certain minutes. We can get the access token using any of the grant types mentions above.</li><li><strong>Refresh Token:</strong> This is the token that uses by the client to get the new access token when the access token expired. It has a longer period of life compared with the access token.</li></ul><p>The diagram describes the flow of getting access token using the refresh token.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tMHCQN4KeMd_zsxkWvjN4A.png" /><figcaption>Getting access token using a refresh token</figcaption></figure><p>After the client sends the request for service, the client will validate the access token that already has with the resource owner. From the response code sent by the resource server, If the access token has expired then the client uses the refresh token and send an access token request to the Authorization server using the Refresh Token grant type. If the refresh token is valid then the authorized server sends a new access token to the client. The client can use the new access token and send a fresh resource request and continue their service without any interruption.</p><p><strong>Note:</strong> If the user wants they can have a facility in OAuth to revoke the access token and refresh token by sending a revoke request to the Authorization server. After revoking the client cant access the resources using Access token and also they cant generates their new access token using the refresh token.</p><h3><strong>OAuth 1.0 vs OAuth 2.0</strong></h3><p>OAuth 2.0 is completely different from OAuth 1.0 by the structure and the performance wise. Nowadays most of the application use OAuth 2.0.</p><p>The OAuth 1.0 use only three flows and also we didn&#39;t scale. OAuth 1.0 has cryptographic requirements. It is hard to implement.</p><p>On the other hand, OAuth 2.0 has six flows. It is much faster and easier to implement compared with OAuth 1.0. Tokens no longer need to be encrypted on the endpoints in OAuth 2.0 since they are encrypted in transit.</p><p>******************************** END *****************************</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a436a0bfbcf2" width="1" height="1" alt=""><hr><p><a href="https://medium.com/identity-beyond-borders/oauth-2-0-a436a0bfbcf2">OAuth 2.0</a> was originally published in <a href="https://medium.com/identity-beyond-borders">Identity Beyond Borders</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to integrate a complex SAML application flow with WSO2 Identity Server]]></title>
            <link>https://medium.com/identity-beyond-borders/how-to-integrate-a-complex-saml-application-flow-with-wso2-identity-server-37040637f485?source=rss-fea2253afc3------2</link>
            <guid isPermaLink="false">https://medium.com/p/37040637f485</guid>
            <category><![CDATA[wso2is]]></category>
            <category><![CDATA[wso2]]></category>
            <dc:creator><![CDATA[Amalanathan Thushanthan]]></dc:creator>
            <pubDate>Mon, 01 Apr 2019 15:24:10 GMT</pubDate>
            <atom:updated>2019-04-04T08:16:54.289Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Consider this use case scenario:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hkrJwo9pEZ7NQqmITvtjNg.png" /></figure><p>The user wants to login into the Application. Here, he uses one identity provider to log in the system. After successfully logged in, he has multiple applications that need to be log in with different Identity Provider. At the same time, the first Identity Provider worked as a federated service provider for this second Identity Providers.</p><p>Here we are using <a href="https://wso2.com/identity-and-access-management/">WSO2 Identity Server</a> as an Identity provider for the Explanation and SAML for all authentication requests.</p><h4>Setting up the WSO2 Identity Server instances</h4><ol><li>Download the WSO2 Identity Server from <a href="https://wso2.com/identity-and-access-management/">here</a>.</li><li>Extract the file to a dedicated directory. For the purposes of this scenario, this is referred to as &lt;IS_HOME_PRIMARY&gt; in this topic.</li><li>Make a copy of this folder in the same location and rename it. For the purposes of this scenario, this is referred to as &lt;IS_HOME_SECONDARY&gt; in this topic.</li><li>By default, the HTTPS port of the primary IS instance is 9443. Let this be left as it is. Go to the &lt;IS_HOME_SECONDARY&gt;/repository/conf directory and open the carbon.xmlfile. Change the &lt;Offset&gt; value under the &lt;Ports&gt; configuration to 2. This changes the HTTPS port in the secondary IS instance to 9445 to avoid conflicts with the primary IS instance.</li><li>Install and run the two Identity Server instances.</li></ol><ul><li>Go to &lt;IS_HOME_PRIMARY&gt; and &lt;IS_HOME_SECONDARY&gt; in your command line and type the following command for each instance.</li><li>On Windows: wso2server.bat --run</li><li>On Linux/Solaris: sh wso2server.sh</li></ul><p>6. The management console for the primary Identity Server can be accessed using the following URL: <a href="https://localhost:9443/carbon">https://localhost:9443/carbon</a> and the management console for the secondary Identity Server can be accessed using the following URL: <a href="https://localhost:9444/carbon">https://localhost:9445/carbon</a>.</p><h4>Creating a Service Provider using primary WSO2IS and log in the first application</h4><ol><li>Go to the management console of the primary IS. Navigate to the <strong>Service Providers</strong> section in the <strong>Main</strong> menu and click <strong>Add</strong>. Add “<strong>FirstApp</strong>” as the <strong>Service Provider Name</strong> for this scenario.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BAh0tjBzsKlSU3_8ZQgMPQ.png" /></figure><p>2. In the form that appears, expand the <strong>Inbound Authentication Configuration</strong> and <strong>SAML2 Web SSO Configuration</strong> sections. Click <strong>Configure </strong>and give the necessary values.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fMMS134TlSz0mO_ZCRzNQQ.png" /></figure><p>3. Click <strong>Update</strong> and then click <strong>Register</strong>. The Sevice provider successfully initiated.</p><p>4. When you call the Application, the application will redirect you to the WSO2-IS. Then WSO2-IS authenticate the application as a Service provider. If the credential is correct then the WSO2-IS will redirect into the Application.</p><h4>Log in the second application with secondary Identity server and Primary Identity server as a Federated Identity provider for secondary Identity server</h4><ol><li><strong>Configure a SAML service provider in the Primary Identity server (Federated IDP).</strong></li></ol><ul><li>Go to the management console of the primary IS. Navigate to the <strong>Service Providers</strong> section in the <strong>Main</strong> menu and click <strong>Add</strong>. Add “<strong>SecoundApp</strong>” as the <strong>Service Provider Name</strong> for this scenario.</li><li>In the form that appears, expand the <strong>Inbound Authentication Configuration</strong> and <strong>SAML2 Web SSO Configuration</strong> sections. Click <strong>Configure </strong>and give the mandatory values. (Assertion Consumer URL: <a href="https://localhost:9445/commonauth"><strong>https://localhost:9445/commonauth</strong></a><strong> </strong>and Issuer:<strong> idp-sp</strong>)</li><li>Click <strong>Update</strong> and then click <strong>Register</strong>. The Sevice provider successfully initiated.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*O_Vo5fIQd8_Lu75kT3MAtQ.png" /></figure><p>2. <strong>Register the created SAML SP as the Federated IDP in the secondary Identity server.</strong></p><ul><li>Go to the management console of the primary IS. Navigate to the <strong>Identity Providers</strong> section in the <strong>Main</strong> menu and click <strong>Add</strong>. Enter the <strong>Identity Provider Name</strong> for this scenario and click register to enter into the system.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*X9KArFzrTqRij6wlvD3D8A.png" /></figure><ul><li>Expand the <strong>Federated Authenticators</strong> section and then expand the <strong>SAML2 Web SSOConfiguration</strong> section. Fill the necessary requirements.</li></ul><p>Note: <strong>Server Provider Entity id </strong>should<strong> </strong>be same as the <strong>Issuer name</strong> given while creating primary identity server as a Federated Identity provider for secondary Identity server.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ti-zjhSKJrXEHr252HgF-g.png" /></figure><p><strong>3. The second application must be set up as a service provider in the secondary Identity Server instance.</strong></p><ul><li>Go to the management console of the primary IS. Navigate to the <strong>Service Providers</strong> section in the <strong>Main</strong> menu and click <strong>Add</strong>. Add “<strong>ThirdApp</strong>” as the <strong>Service Provider Name</strong> for this scenario.</li><li>In the form that appears, expand the <strong>Inbound Authentication Configuration</strong> and <strong>SAML2 Web SSO Configuration</strong> sections. Click <strong>Configure </strong>and give the mandatory values.</li><li>Expand the <strong>Local &amp; Outbound Authentication Configuration</strong> section and select the created IDP name as the Federated IDP in the application as shown below.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FMGRdHNU7kvLRu-RuzkECA.png" /></figure><ul><li>Click <strong>Update</strong> and then click <strong>Register</strong>. The Sevice provider successfully initiated.</li><li>Call the second application using Idp initiated SSO request ( <a href="https://www.google.com/url?q=https://localhost:9445/samlsso?spEntityID%3D&amp;sa=D&amp;source=hangouts&amp;ust=1554219329028000&amp;usg=AFQjCNGAlIgt9yS-i8Dkp4oyugy-sHVNlA"><strong>https://localhost:9445/samlsso?spEntityID=</strong></a><strong>&lt;issuer&gt; </strong>). When you call the second Application then the application will redirect you to the secondary WSO2-IS. Then secondary WSO2-IS redirect to the primary WSO2-IS (Federated Idp). The primary WSO2-IS authenticate the application. If the credential is correct then the primary WSO2-IS will redirect the response to secondary IS. Finally, the Secondary IS redirects it into the Application.</li><li>************************** End *****************************</li></ul><p>WSO2 Identity Server is a fully open source, highly extensible IAM solution that’s used to federate and manage identities in enterprise and cloud service environment. You can try it out <a href="https://wso2.com/identity-and-access-management/">here</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=37040637f485" width="1" height="1" alt=""><hr><p><a href="https://medium.com/identity-beyond-borders/how-to-integrate-a-complex-saml-application-flow-with-wso2-identity-server-37040637f485">How to integrate a complex SAML application flow with WSO2 Identity Server</a> was originally published in <a href="https://medium.com/identity-beyond-borders">Identity Beyond Borders</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>