<?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 Anirudh Sharma on Medium]]></title>
        <description><![CDATA[Stories by Anirudh Sharma on Medium]]></description>
        <link>https://medium.com/@anirudh03sharma?source=rss-c075f509e501------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*MWj_NLANEFKQDmcp.</url>
            <title>Stories by Anirudh Sharma on Medium</title>
            <link>https://medium.com/@anirudh03sharma?source=rss-c075f509e501------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 20:56:19 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@anirudh03sharma/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[Overriding Out Of The Box (OOTB) servlet in AEM]]></title>
            <link>https://medium.com/@anirudh03sharma/overriding-out-of-the-box-ootb-servlet-in-aem-63859d29efa5?source=rss-c075f509e501------2</link>
            <guid isPermaLink="false">https://medium.com/p/63859d29efa5</guid>
            <category><![CDATA[apache-sling]]></category>
            <category><![CDATA[apache-felix]]></category>
            <category><![CDATA[servlet]]></category>
            <category><![CDATA[adobe-experience-manager]]></category>
            <category><![CDATA[osgi]]></category>
            <dc:creator><![CDATA[Anirudh Sharma]]></dc:creator>
            <pubDate>Sat, 25 May 2019 17:28:12 GMT</pubDate>
            <atom:updated>2019-05-25T17:28:12.387Z</atom:updated>
            <content:encoded><![CDATA[<p>Sometimes it happens that we want to override a default behaviour in AEM.</p><p>If the behaviour that we want to override is a component in crx/de, then we can easily use Overlaying/Overriding concepts in Sling.</p><p>But if we wish to override an OOTB sling servlet, then things get tricky. This blog post tackles this situation. It discusses step by step process of overriding an OOTB sling servlet.</p><h3>Concept</h3><p>We know that Servlets in AEM are basically OSGi services which implement <strong><em>javax.servlet.Servlet</em></strong> interface. For more information about servlets in AEM, see this <a href="https://aem.redquark.org/2018/10/day-05-working-with-sling-servlets-in_10.html">post</a>.</p><p>A service listener (<strong><em>org.apache.sling.servlets.resolver.internal.SlingServletResolver</em></strong>) listens for the OSGi services implementing <strong>javax.servlet.Servlet</strong> interface and registers its reference.</p><p>When a request hits the server, this <strong><em>SlingServletResolver</em></strong> kicks in to executes its sling script resolution procedure to choose the right servlet to respond to the request.</p><h3>Problem Statement</h3><p>There is one servlet OOTB that handles the RSS/Atom feed requests in AEM. We need to override this behaviour. As of now, we do not have any idea about how to override this functionality. We only have our request now.</p><p>The request in this use case is — <a href="http://localhost:4502/editor.html/content/we-retail/language-masters/en/men.feedentry.rss.xml">http://&lt;host&gt;:&lt;port&gt;/&lt;content-path&gt;.feedentry.rss.xml</a>. With the help of this request, we will proceed further</p><h3>Steps</h3><h4>Step #1</h4><p>Navigate to <a href="http://localhost:4502/system/console/requests">http://&lt;host&gt;:&lt;port&gt;/system/console/requests</a> and search for your request</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/0*BaFBTM4RisNqsLvH.png" /><figcaption>Recent requests in AEM</figcaption></figure><h4>Step #2</h4><p>Click on the request to see the RequestProgressTrackerInfo. There you will find the servlet that is handling this request.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/0*NDzERmH9qai-jRyG.png" /><figcaption>Request progress tracker</figcaption></figure><p>Here you can see that this request is being handled by <strong><em>com.day.cq.commons.servlets.FeedRendererServlet</em></strong>.</p><h4>Step #3</h4><p>Now, we have to find the parameters on which this servlet has been registered. To do this, navigate to <a href="http://localhost:4502/system/console/depfinder">http://&lt;host&gt;:&lt;port&gt;/system/console/depfinder</a> and search for your class. Then you will find the artifact id and group id of the OSGi bundle in which this OOTB servlet is present.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/0*AoWk06K_pQpf-Doq.png" /><figcaption>Depfinder console</figcaption></figure><h4>Step #4</h4><p>Now to know about the properties by which this servlet is registered, navigate to <a href="http://localhost:4502/system/console/bundles">http://&lt;host&gt;:&lt;port&gt;/system/console/bundles</a> and search for the artifact id.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/0*0UWbxF6OuD1LkaOz.png" /><figcaption>Felix Console</figcaption></figure><h4>Step #5</h4><p>Open the bundle details by clicking on it and search for your servlet. Since every servlet is an OSGi service, our servlet must have a service id corresponding to it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/0*J639nDqOrIdlotI2.png" /><figcaption>Servlet details</figcaption></figure><h4>Step #6</h4><p>Click on the service id to open the servlet details i.e. properties by which it is registered</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/0*kgvNzKiY4pZU0j2b.png" /><figcaption>Services</figcaption></figure><p>Note: Sometimes it may happen that the servlet which we are trying to override is registered with a service ranking, then we need to make sure our custom servlet has service ranking greater than that. This can be done by using the property service.ranking. Default service ranking is 0 and if some servlet has ranking other than 0, it will be shown in the above console too.</p><h4>Step #7</h4><p>Since we have all the properties with us, we can now start creating a custom servlet which overrides the OOTB servlet.</p><p>Below is the sample code that I have created to override this servlet.</p><pre><strong>import</strong> <strong>java.io.IOException</strong>;</pre><pre><strong>import</strong> <strong>javax.servlet.Servlet</strong>;</pre><pre><strong>import</strong> <strong>org.apache.sling.api.SlingHttpServletRequest</strong>;<br><strong>import</strong> <strong>org.apache.sling.api.SlingHttpServletResponse</strong>;<br><strong>import</strong> <strong>org.apache.sling.api.servlets.HttpConstants</strong>;<br><strong>import</strong> <strong>org.apache.sling.api.servlets.SlingAllMethodsServlet</strong>;<br><strong>import</strong> <strong>org.osgi.service.component.annotations.Component</strong>;<br><strong>import</strong> <strong>org.slf4j.Logger</strong>;<br><strong>import</strong> <strong>org.slf4j.LoggerFactory</strong>;</pre><pre><em>/**</em><br><em> * @author Anirudh Sharma</em><br><em> *</em><br><em> */</em><br><strong>@Component</strong>(immediate = <strong>true</strong>, service = Servlet.<strong>class</strong>, <br>  property = {<br>    &quot;sling.servlet.methods=&quot; + HttpConstants.<strong>METHOD_GET</strong>,<br>    &quot;sling.servlet.methods=&quot; + HttpConstants.<strong>METHOD_POST</strong>,<br>    &quot;sling.servlet.resourceTypes=&quot; + &quot;sling/servlet/default&quot;,<br>    &quot;sling.servlet.selectors=&quot;+&quot;feed&quot;,<br>    &quot;sling.servlet.selectors=&quot;+&quot;feedentry&quot;,<br>    &quot;sling.servlet.extensions=&quot;+&quot;xml&quot;, &quot;service.ranking=&quot; + 101})<br><strong>public</strong> <strong>class</strong> <strong>CustomFeedRendererServlet</strong> <strong>extends</strong> SlingAllMethodsServlet {<br> <br> <strong>private</strong> <strong>final</strong> Logger log = LoggerFactory.<strong>getLogger</strong>(<strong>this</strong>.<strong>getClass</strong>());</pre><pre><em>// Generated serialVersionUID</em><br> <strong>private</strong> <strong>static</strong> <strong>final</strong> <strong>long</strong> serialVersionUID = <strong>362516459145838595L</strong>;<br> <br> <strong>@Override</strong><br> <strong>protected</strong> <strong>void</strong> <strong>doGet</strong>(SlingHttpServletRequest request, SlingHttpServletResponse response) {<br>  <strong>try</strong> {<br>   log.<strong>info</strong>(&quot;Inside GET method&quot;);<br>   response.<strong>getWriter</strong>().<strong>println</strong>(&quot;Custom servlet invoked from GET&quot;);<br>  } <strong>catch</strong> (IOException e) {<br>   e.<strong>printStackTrace</strong>();<br>  }<br> }<br> <br> <strong>@Override</strong><br> <strong>protected</strong> <strong>void</strong> <strong>doPost</strong>(SlingHttpServletRequest request, SlingHttpServletResponse response) {<br>  <strong>try</strong> {<br>   log.<strong>info</strong>(&quot;Inside POST method&quot;);<br>   response.<strong>getWriter</strong>().<strong>println</strong>(&quot;Custom servlet invoked from POST&quot;);<br>  } <strong>catch</strong> (IOException e) {<br>   e.<strong>printStackTrace</strong>();<br>  }<br> }</pre><pre>}</pre><h4>Step #8</h4><p>Build and deploy the code. Hit your request again and this time you will see your custom servlet getting executed. You can verify this at Recent requests console as well.</p><p>Similarly, you can override any OOTB servlet in AEM.</p><h3>Conclusion</h3><p>Congratulations! 🙋 you have successfully overridden OOTB servlet in AEM.</p><p>I would love to hear your thoughts on this post and would like to have suggestions from you to make this post better.</p><p>Feel free to befriend me on <a href="https://www.facebook.com/Anir35">Facebook</a>, <a href="https://twitter.com/I_am_Anirudh">Twitter</a> or <a href="https://www.linkedin.com/in/anirshar/">Linked In</a> or say Hi by <a href="/service/mailto:anirudh03sharma@gmail.com">email</a>.</p><p>This post was originally published on <a href="https://aem.redquark.org/2019/05/overriding-out-of-box-ootb-servlet.html">AEM Ninja</a> blog.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=63859d29efa5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Create users in AEM from excel file]]></title>
            <link>https://medium.com/@anirudh03sharma/create-users-in-aem-from-excel-file-6a540cff04f1?source=rss-c075f509e501------2</link>
            <guid isPermaLink="false">https://medium.com/p/6a540cff04f1</guid>
            <category><![CDATA[java]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[adobe-experience-manager]]></category>
            <category><![CDATA[jcr]]></category>
            <category><![CDATA[osgi]]></category>
            <dc:creator><![CDATA[Anirudh Sharma]]></dc:creator>
            <pubDate>Sat, 25 May 2019 17:18:47 GMT</pubDate>
            <atom:updated>2019-05-25T17:18:47.608Z</atom:updated>
            <content:encoded><![CDATA[<p>Sometimes it so happens that we need to create many users in the AEM and to add them in the desired group. We can do this in AEM Useradmin console manually. But this process is tedious and inefficient.</p><p>In most of the cases, we get the users in a file with their details (first name, last name, username, group, email, password etc.). Wouldn’t it be easier if we just upload the file in our AEM instance and the users are created in the AEM server automatically?</p><p>Therefore, I decided to create an AEM project that does exactly that. In this project, a user can go to a custom console that is created and upload an excel file with the details of the users.</p><p>Let’s go through the steps one by one -</p><h3>Step #1</h3><p>Download the code package from <a href="https://drive.google.com/file/d/1caPxwzr-2W0Au_fufRbwZYHvXkJU3Axf/view?usp=sharing">here</a>. Install this package into your AEM instance using the package manager</p><h3>Step #2</h3><p>Create a system user with the name <strong><em>createUsersServiceUser </em></strong>from /crx/explorer and add it to the <strong><em>administrators</em></strong> group from the useradmin console.</p><h3>Step #3</h3><p>Navigate to <strong><em>./system/console/configMgr</em></strong> and search for the term <strong><em>Apache Sling Service User Mapper Service</em></strong> and create the following mapping as shown below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/0*pHOUVl332u8S4k7E.png" /><figcaption>Mapping service user to the subservice</figcaption></figure><p>Create a service user mapping</p><h3>Step #4</h3><p>Navigate to the link — <a href="http://localhost:4502/apps/bulkusercreation/admin/ext/createusers/content/createusers.html">http://&lt;host&gt;:&lt;port&gt;/apps/bulkusercreation/admin/ext/createusers/content/createusers.html</a></p><h3>Step #5</h3><p>Click on the <strong><em>Bulk Users</em></strong> icon as shown below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/0*tflGdzgxxqPBomh6.png" /><figcaption>Tools -&gt; Red Quark</figcaption></figure><p>Click in the ‘Bulk Users’ icon</p><h3>Step #6</h3><p>Now, you will get a screen where you can upload your excel file (.xlsx) with the user details. After you click on the <strong><em>“Upload” </em></strong>button, your users will be created in the AEM.</p><p>As of now, the excel file should look like this</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/505/0*AeENgunlNcaO8XkK.png" /><figcaption>Sample contents in excel file</figcaption></figure><p>Sample Excel file with user details</p><h3>Caution:</h3><p>For this project, we have overlayed the path <strong><em>/libs/cq/core/content/nav/tools </em></strong>into <strong><em>/apps/bulkusercreation/cq/core/content/nav/tools</em></strong>. Since the overlayed path is not directly in /apps but in /apps/bulkusercreation, we have to change the sling resource resolver setting in the system.</p><p>We can do this by navigating to the ./system/console/configMgr and search for <strong><em>Apache Sling Resource Resolver Factory </em></strong>and change the Resource Search path from <strong><em>/apps</em></strong> to <strong><em>/apps/bulkusercreation </em></strong>and save.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/0*x8LXxunlsz-3etxh.png" /><figcaption>Changing the default search path in AEM</figcaption></figure><p>Apache Sling Resource Resolver Factory configuration</p><p>However, if you do not wish to change the default configuration, you just have to move <strong><em>/apps/bulkusercreation/cq</em></strong> to <strong><em>/apps/cq </em></strong>in crx/de.</p><h3>Conclusion</h3><p>The Bulk User Creation utility enables you to just upload an excel file with the user details and your work is done.</p><p>If you wish to see the complete code of this project and contribute towards the same with your suggestions and code, then you can find it on my <a href="https://github.com/ani03sha/BulkUserCreation">GitHub</a>.</p><p>I hope this will help you in your projects and speed up your development.</p><p>I would love to hear your thoughts on this post and would like to have suggestions from you to make this post better.</p><p>Feel free to befriend me on <a href="https://www.facebook.com/Anir35">Facebook</a>, <a href="https://twitter.com/I_am_Anirudh">Twitter</a> or <a href="https://www.linkedin.com/in/anirshar/">Linked In</a> or say Hi by <a href="/service/mailto:anirudh03sharma@gmail.com">email</a>.</p><p>Happy Learning 😊</p><p>This story was originally published on <a href="https://aem.redquark.org/2019/05/create-users-in-aem-from-excel-file.html">AEM Ninja</a> blog.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6a540cff04f1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Threads in Java — Masterclass (Part 0)]]></title>
            <link>https://medium.com/@anirudh03sharma/threads-in-java-masterclass-part-0-51ec8e4de2be?source=rss-c075f509e501------2</link>
            <guid isPermaLink="false">https://medium.com/p/51ec8e4de2be</guid>
            <category><![CDATA[threads]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[multithreading]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[synchronization]]></category>
            <dc:creator><![CDATA[Anirudh Sharma]]></dc:creator>
            <pubDate>Sat, 08 Dec 2018 18:41:56 GMT</pubDate>
            <atom:updated>2018-12-08T18:41:56.707Z</atom:updated>
            <content:encoded><![CDATA[<h3>Threads in Java — Masterclass (Part 0)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/633/0*V7A9nquLnib1JFub.png" /><figcaption><strong>Threads in Java</strong></figcaption></figure><p>Multithreading is a way to introduce concurrency in a program. In any case, if there are parallel paths in our program (parts which do not depend on the result from another part), we can make use of multithreading. One should exploit this feature, especially with all these multiple core machines nowadays. Below are a few reasons why we should use multithreading -</p><h3>1. Keep a process responsive</h3><p>There was once a time when you would print a document in MS Word and the application would freeze for an annoyingly long amount of time until the job finished. Eventually, Microsoft solved this problem by running a printing job parallel to the main thread/ GUI thread.</p><p>To be clear though, not only GUI apps but Network services have to keep an ear to the ground for new clients, dropped connections and cancellation requests. In either case, it is critical to do the heavy lifting on a secondary thread to keep the user satisfied.</p><h3>2. Keep a processor busy</h3><p>Keeping a processor busy can be a tough task even for the top programmers. There are all kinds of reasons that make a processor stall. The most prevalent and mundane is common disk and network I/O. When a single-threaded application accesses a file, calls a web service, or streams from your webcam, processor sits idly and kills time.</p><p>Occasionally, there isn’t much to do but to wait for the I/O to complete. For example, let’s say you have a date on Valentine’s day 💖 and you call up a restaurant for bookings. While you are waiting for your confirmation, you can do another task such as ordering flowers 🎕. That way you are utilizing your time instead of sitting idle.</p><p>Similarly, we can design our application in a way so that we can keep our processor busy and get maximum utilization of it. Try to think ahead.</p><h3>3. Keep multiple processors busy</h3><p>Let’s say you have a single threaded application that has a monomaniacal focus on computation. It uses minimum I/O, effective use of caching, and has predictable loops that your compiler can turn into a data-parallel operation. You are golden.</p><p>Unless you have more than one processor.</p><p>Today’s hardware is not getting more Hertz, it is getting more pipelines, more cores and additional processors. This means if we max out one process calculating a billion digits of 𝜫, the other processors wondering what the fuss is all about.</p><p>If we run multiple processors, that is. multiple distinct applications or multiple instances of a single application, the OS will come to rescue and goad those other processors into action. But if we want our application to utilize the maximum amount of hardware it is on, we need to give OS scheduler multiple things to work on simultaneously. And we can achieve this via multiple threads.</p><h3>4. Simplify coding of cooperating tasks</h3><p>Just as many programming problems both have iterative and recursive implementations, many programming problems also have both serial and concurrent variations. The version we choose depends on the nature of the specific problem.</p><p>For instance, the recursive version of Quicksort makes a whole lot more sense than the iterative version. Similarly, trying to write a multi-client network service with just one thread, though possible, isn’t fun, isn’t natural. When we refactor it into multiple threads, the code becomes logically simpler. One thread per client, one thread to rule them all.</p><p>The key in using threads to simplify code is to try to keep our functions and methods on one train thought. Rather than turn our code into an arthritic mess trying to interleave multiple simultaneous tasks, code each task separately. Code each line block with one mind. Let the OS thread scheduler do the interleaving.</p><p>As you can see since there are various use cases of multithreading in programming, it is one of the most important concepts and it almost always beneficial to master this concept. Keeping this thing in mind, I have created a series of blog posts discussing various concepts of Multithreading in Java.</p><p>This blog post lists all the topics that are covered in the threads’ masterclass.</p><ul><li><a href="https://codeleague.redquark.org/2018/11/threads-in-java-basics-part-1.html">Part 1 — Basics</a></li><li><a href="https://codeleague.redquark.org/2018/11/threads-in-java-lifecycle-part-2.html">Part 2 — Lifecycle</a></li><li><a href="https://codeleague.redquark.org/2018/11/threads-in-java-main-thread-part-3.html">Part 3- Main thread</a></li><li><a href="https://codeleague.redquark.org/2018/11/threads-in-java-yield-sleep-and-join.html">Part 4 — yield(), sleep() and join()</a></li><li><a href="https://codeleague.redquark.org/2018/11/threads-in-java-inter-thread.html">Part 5 — Interthread communication</a></li><li><a href="https://codeleague.redquark.org/2018/11/threads-in-java-start-method-and-thread.html">Part 6 — start() method and thread Priority</a></li><li><a href="https://codeleague.redquark.org/2018/11/threads-in-java-joining-part-7.html">Part 7 — Joining</a></li><li><a href="https://codeleague.redquark.org/2018/11/threads-in-java-synchronization-part-8.html">Part 8 — Synchronization</a></li><li><a href="https://codeleague.redquark.org/2018/11/threads-in-java-volatile-keyword-part-9.html">Part 9 — Volatile keyword</a></li><li><a href="https://codeleague.redquark.org/2018/11/threads-in-java-thread-pools-part-10.html">Part 10 — Thread Pools</a></li><li><a href="https://codeleague.redquark.org/2018/12/threads-in-java-semaphores-part-11.html">Part 11 — Semaphores</a></li><li><a href="https://codeleague.redquark.org/2018/12/threads-in-java-countdownlatch-part-12.html">Part 12 — CountDownLatch</a></li><li><a href="https://codeleague.redquark.org/2018/12/threads-in-java-reentrant-lock-part-13.html">Part 13 — Reentrant Lock</a></li><li><a href="https://codeleague.redquark.org/2018/12/threads-in-java-cyclicbarrier-part-14.html">Part 14 — Cyclic Barrier</a></li><li><a href="https://codeleague.redquark.org/2018/12/threads-in-java-callable-and-future.html">Part 15 — Callable and Future</a></li><li><a href="https://codeleague.redquark.org/2018/12/threads-in-java-deadlock-part-16.html">Part 16 — Deadlock</a></li><li><a href="https://codeleague.redquark.org/2018/12/threads-in-java-daemon-thread-part-17.html">Part 17 — Daemon Thread</a></li></ul><p>All of these posts include code examples to understand the concept. You can find the code of these examples on my <a href="https://github.com/ani03sha/Java-Kickstarter/tree/master/src/org/redquark/kickstarter/threads">GitHub</a> repository. Feel free to fork or open issues, if any.</p><p>I would love to hear your thoughts on this and would like have suggestions from you to make it better.</p><p>Feel free to befriend me on <a href="https://www.facebook.com/Anir35">Facebook</a>, <a href="https://twitter.com/I_am_Anirudh">Twitter</a> or <a href="https://www.linkedin.com/in/anirshar/">Linked In</a> or say Hi by <a href="/service/mailto:anirudh03sharma@gmail.com">email</a>.</p><p>Happy Coding 😊</p><p><em>Originally published at </em><a href="https://codeleague.redquark.org/2018/12/threads-in-java-masterclass-part-0.html"><em>codeleague.redquark.org</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=51ec8e4de2be" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Day 00: AEM Developer Series]]></title>
            <link>https://medium.com/@anirudh03sharma/day-00-aem-developer-series-b91f9a746352?source=rss-c075f509e501------2</link>
            <guid isPermaLink="false">https://medium.com/p/b91f9a746352</guid>
            <category><![CDATA[java]]></category>
            <category><![CDATA[entrepreneurship]]></category>
            <category><![CDATA[osgi]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[adobe-experience-manager]]></category>
            <dc:creator><![CDATA[Anirudh Sharma]]></dc:creator>
            <pubDate>Sat, 20 Oct 2018 18:19:41 GMT</pubDate>
            <atom:updated>2018-10-20T18:19:41.001Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*3bCvtkU9OJheeNBN.png" /><figcaption>image source: <a href="https://solutionpartners.adobe.com/">https://solutionpartners.adobe.com/</a></figcaption></figure><p>Hello everyone! Welcome to this AEM development series. We can all see that the revolution of Digital Marketing today. Companies are dying to be a part of it and they have made this a war for the Digital Marketing tools.</p><p>Adobe was way ahead in this war and have gained a lot of market capture. They are leaders in the Digital Marketing platforms since 2014–15. One of the flagship product in their Digital Marketing suite is <strong><em>Adobe Experience Manager (AEM)</em></strong>.</p><p>Since AEM is in huge demand, the people who know how to develop on AEM are also in huge demand. But developing on AEM is not easy as it is made up of various open-source technologies such as Apache Felix (OSGi), Apache Sling, Apache Oak and Adobe’s own technologies like Granite, HTL etc. Learning all these technologies in conjunction can sometimes become confusing and frustrating 😫.</p><p>When I first started learning AEM in 2016, I was dumbfounded to see there is so much going on under the hood. I then spent months to gather all the resources (mostly Adobe’s official <a href="https://helpx.adobe.com/support/experience-manager/6-4.html">documentation</a>) but it was so overwhelming (my personal experience 😕).</p><p>Therefore, I decided to create a series which can help a newbie in AEM development to learn this Amazing tool. This series is my learning experience to get the knack of AEM Development. I have tried to put the posts in an order in which they should be learned.</p><ul><li><a href="https://aem.redquark.org/2018/10/day-00-aem-developer-series.html">Day 00: AEM Developer Series</a></li><li><a href="https://aem.redquark.org/2018/10/day-01-introduction-to-aem.html">Day 01: Introduction to AEM</a></li><li><a href="https://aem.redquark.org/2018/10/day-02-aem-architecture.html">Day 02: AEM Architecture</a></li><li><a href="https://aem.redquark.org/2018/10/day-03-setting-up-aem-development.html">Day 03: Setting up AEM Development Environment</a></li><li><a href="https://aem.redquark.org/2018/10/day-04-developing-first-osgi-bundle.html">Day 04: Developing First OSGi Bundle</a></li><li><a href="https://aem.redquark.org/2018/10/day-05-working-with-sling-servlets-in_10.html">Day 05: Working with Sling Servlets in AEM</a></li><li><a href="https://aem.redquark.org/2018/10/day-06-playing-with-sling-post-servlet.html">Day 06: Playing with Sling Post Servlet</a></li><li><a href="https://aem.redquark.org/2018/10/day-07-creating-your-first-component-in.html">Day 07: Creating your first component in AEM</a></li><li><a href="https://aem.redquark.org/2018/10/day-08-dueling-with-javascript-use-api.html">Day 08: Dueling with JavaScript Use API</a></li><li><a href="https://aem.redquark.org/2018/10/day-09-dueling-with-java-use-api.html">Day 09: Dueling with Java User API</a></li><li><a href="https://aem.redquark.org/2018/10/day-10-getting-to-know-sling-models.html">Day 10: Getting to know Sling Models</a></li><li><a href="https://aem.redquark.org/2018/10/day-11-client-libraries-in-action.html">Day 11: Client Libraries in Action</a></li><li><a href="https://aem.redquark.org/2018/10/day-12-creating-your-custom-osgi.html">Day 12: Creating your custom OSGi Configuration</a></li><li><a href="https://aem.redquark.org/2018/10/day-13-schedulers-in-aem.html">Day 13: Schedulers in AEM</a></li><li><a href="https://aem.redquark.org/2018/10/day-14-eventing-in-aem.html">Day 14: Eventing in AEM</a></li><li><a href="https://aem.redquark.org/2018/10/day-15-custom-workflows-in-aem.html">Day 15: Custom Workflows in AEM</a></li><li><a href="https://aem.redquark.org/2018/10/day-16-creating-jmx-mbeans-in-aem.html">Day 16: Creating JMX Beans in AEM</a></li><li><a href="https://aem.redquark.org/2018/10/day-17-working-with-query-builder-api.html">Day 17: Working with QueryBuilder API</a></li><li><a href="https://aem.redquark.org/2018/10/day-18-working-with-granite-datasources.html">Day 18: Working with Granite Datasources in AEM</a></li><li><a href="https://aem.redquark.org/2018/10/day-19-replication-api-in-action.html">Day 19: Replication API in Action</a></li><li><a href="https://aem.redquark.org/2018/10/day-20-working-with-user-and-groups-in.html">Day 20: Working with Users and Groups in AEM</a></li></ul><p>Though order is not a compulsion, I would suggest a new AEM developer follow the order for a better understanding of the concepts.</p><p>You can find the complete code of these 20 posts on my <a href="https://github.com/ani03sha/aem-demo">GitHub</a>. Feel free to fork or open issues, if any.</p><p>I would love to hear your thoughts on this and would like have suggestions from you to make it better.</p><p>Feel free to befriend me on <a href="https://www.facebook.com/Anir35">Facebook</a>, <a href="https://twitter.com/I_am_Anirudh">Twitter</a> or <a href="https://www.linkedin.com/in/anirshar/">Linked In</a> or say Hi by <a href="/service/mailto:anirudh03sharma@gmail.com">email</a>.</p><p>Happy Coding 😊 and Happy Learning 😊</p><p><em>originally published at </em><a href="https://aem.redquark.org/">aem.redquark.org</a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b91f9a746352" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Cryptography — Science of secret messages]]></title>
            <link>https://medium.com/@anirudh03sharma/cryptography-science-of-secret-messages-81d03428b7a5?source=rss-c075f509e501------2</link>
            <guid isPermaLink="false">https://medium.com/p/81d03428b7a5</guid>
            <category><![CDATA[security]]></category>
            <category><![CDATA[cryptography]]></category>
            <category><![CDATA[encryption]]></category>
            <category><![CDATA[hashing]]></category>
            <category><![CDATA[digital-signatures]]></category>
            <dc:creator><![CDATA[Anirudh Sharma]]></dc:creator>
            <pubDate>Mon, 20 Aug 2018 08:00:13 GMT</pubDate>
            <atom:updated>2018-08-20T08:00:13.956Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/620/0*iXCDL3VxIaNQqgyB.jpeg" /><figcaption>source: <a href="https://spectrum.ieee.org/">IEEE</a></figcaption></figure><p>Do you love sending secret messages? Do you love how Harvard professor <a href="http://danbrown.wikia.com/wiki/Robert_Langdon">Robert Langdon</a> solves the puzzles and reveals the truth? or, do you love how Nazis created the <a href="http://www.bbc.co.uk/history/topics/enigma">Enigma Machine</a> and caused problems to the Allied powers during the WW2? If answers to the above questions are yes, then I am sure you’d love cryptography. In this introductory post, we will discuss the basics of Cryptography (mostly in the context of computer science) and in the later posts in this series, we will look into various algorithms in cryptography. So, without any much delay, let’s jump into the fascinating world of secret/secured communications, ciphers, codes and many more.</p><h3>Cryptography</h3><p>Let’s say Alice wants to send some message to Bob but she fears that someone might intercept it. She doesn’t want that. NO ONE wants that! (remember the Cambridge Analytica <a href="https://www.vox.com/policy-and-politics/2018/3/23/17151916/facebook-cambridge-analytica-trump-diagram">fiasco</a> by Facebook?). To achieve the secrecy, Alice encrypts the message and replaces alphabets with numbers and numbers with alphabets in the message.</p><p>For e.g., if the message is — “I want 2 sugar cubes in my tea”, then it will be encrypted as — “9 23 1 14 20 B 19 21 7 1 18 3 19 2 5 19 9 14 13 25 20 5 1”.</p><p>Now, if in between Charlie wants to read this message he will not be able to do so as the numbers and a single alphabet won’t make sense to him.</p><p>Hence, Alice has <em>encrypted </em>the message. She will now explain Bob to replace numbers with alphabets and vice-versa. Bob, then will apply the reverse procedure and will be able to read the message. Thus, Bob has <strong><em>decrypted</em></strong> the message.</p><p>The mechanism of converting numbers to alphabets and vice-versa is called the <em>key </em>of the process. Thus, to encrypt a message we need a key and to decrypt it also, we need a key.</p><p>If I put in simple words, <strong><em>Cryptography is the science of keeping a message secret.</em></strong></p><h3>Terminology</h3><p>Some commonly used terms in cryptography are described below -</p><ul><li><strong>Plaintext</strong> — message which is in the human readable form and needs to be encrypted. The process of disguising a message is encryption. An encrypted message is a <em>ciphertext</em>. The process of turning ciphertext back into plaintext is decryption.</li><li><strong>Cipher (or Cypher) — </strong>an algorithm for performing encryption or decryption</li><li><strong>Cryptosystem — </strong>an implementation of cryptographic techniques and their accompanying infrastructure to provide information security services. A cryptosystem is also referred to as a cipher system.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/0*UtnPx34zIHOFPv4g.png" /></figure><ul><li><strong>Symmetric Algorithm — </strong>This is the simplest kind of encryption that involves only one secret key to cipher and decipher information. t uses a secret key that can either be a number, a word or a string of random letters. It is blended with the plain text of a message to change the content in a particular way. The sender and the recipient should know the secret key that is used to encrypt and decrypt all the messages.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/0*Rhgw3B2ILGtbPCNB.png" /><figcaption>source: <a href="https://www.ssl2buy.com/wiki/symmetric-vs-asymmetric-encryption-what-are-differences">ssl2buy</a></figcaption></figure><ul><li><strong>Asymmetric Algorithm — </strong>It uses two keys to encrypt a plain text. Secret keys are exchanged over the Internet or a large network. It ensures that malicious persons do not misuse the keys.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/0*lk-8vdPL8LiS7ExP.png" /><figcaption>source: <a href="https://www.ssl2buy.com/wiki/symmetric-vs-asymmetric-encryption-what-are-differences">ssl2buy</a></figcaption></figure><p>Public and Private key pair helps to encrypt information that ensures data is protected during transmission.</p><p>Public key uses asymmetric algorithms that convert messages into an unreadable format. A person who has a public key can encrypt the message intended for a specific receiver. The receiver with the private key can only decode the message, which is encrypted by the public key. The key is available via the publicly accessible directory.</p><p>The private key is a secret key that is used to decrypt the message and the party knows it that exchange message. In the traditional method, a secret key is shared within communicators to enable encryption and decryption of the message, but if the key is lost, the system becomes void. To avoid this weakness, PKI (public key infrastructure) came into force where a public key is used along with the private key. PKI enables internet users to exchange information in a secure way through the use of a public and private key.</p><h3>Digital Signatures</h3><p>As per Wikipedia, “A digital signature is a mathematical scheme for presenting the authenticity of digital messages or documents. A valid digital signature gives a recipient reason to believe that the message was created by a known sender (authentication), that the sender cannot deny having sent the message (non-repudiation), and that the message was not altered in transit (integrity)”.</p><h4>Applying the signature</h4><ul><li>Using a mathematical algorithm, a hash of the document is created. This hash is specific to this particular document; even the slightest change would result in a different hash.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/470/0*K1u_f3CzanzAJpZB.png" /><figcaption>source: <a href="https://www.globalsign.com/en-in/blog/how-do-digital-signatures-work/">globalsign</a></figcaption></figure><ul><li>Now, this hash is encrypted using the private key and combined with the public key to form a digital signature and appended to the document. Now, this digital signature is distributed.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/0*QrbRvzuoBUJ8jYG_.png" /><figcaption>source:<a href="https://www.globalsign.com/en-in/blog/how-do-digital-signatures-work/">globalsign</a></figcaption></figure><ul><li>If the document is opened by any digital signature-capable program, it automatically uses the signer’s public key to decrypt the document hash.</li><li>The program calculates a new hash for the document. If this new hash matches the decrypted hash from Step 1, the program knows the document has not been altered.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/348/0*iHP8RKg5xUyPDlOM.png" /><figcaption>source: <a href="https://www.globalsign.com/en-in/blog/how-do-digital-signatures-work/">globalsign</a></figcaption></figure><p>The program also validates that the public key used in the signature belongs to the signer and displays the signer’s name.</p><h3>Conclusion</h3><p>In this post, we discussed the basics of cryptography, common terminologies, and concepts of digital signature and keys. I hope you enjoyed this post. In the upcoming posts, we will look into various algorithms that are used in cryptography and their implementation using code. You can also follow me on <a href="https://twitter.com/I_am_Anirudh">Twitter</a>. Happy learning!! 😊</p><p><em>Originally published at </em><a href="https://codeleague.redquark.org/2018/08/cryptography-code-and-decode.html"><em>codeleague.redquark.org</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=81d03428b7a5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introduction to Blockchain — Conceptualization and Applications (Part 4)]]></title>
            <link>https://medium.com/@anirudh03sharma/introduction-to-blockchain-conceptualization-and-applications-part-4-20c7a71ad92b?source=rss-c075f509e501------2</link>
            <guid isPermaLink="false">https://medium.com/p/20c7a71ad92b</guid>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[bitcoin]]></category>
            <dc:creator><![CDATA[Anirudh Sharma]]></dc:creator>
            <pubDate>Mon, 13 Aug 2018 16:18:08 GMT</pubDate>
            <atom:updated>2018-08-13T16:18:08.237Z</atom:updated>
            <content:encoded><![CDATA[<p>It’s been a long time since my last post as I got stuck in some work. This is the last part of the introduction to blockchain series. In this post, we will touch upon a few more concepts of blockchain and their applications. At the end of the post, we will also look into the concept of Hyperledger Fabric in brief.</p><h3>Permission-less model</h3><p>In this model, anyone can join the network, participate in the process of block verification to create consensus and also create smart contracts. For e.g. Bitcoin and Ethereum network.</p><ul><li>In a permissionless world, one does not have to prove their identity to the ledger.</li><li>As long as you are willing to commit processing power to be part of the network and extending the blockchain, you are allowed to play.</li><li>Any miner who is playing the game by the rule may be able to solve the hash puzzle and verify the block of transactions to win the mining reward (Higher the mining power, better the chances of winning the mining reward).</li><li>It is good for financial applications like banking using cryptocurrency.</li><li>Each block in a blockchain is connected to all the blocks before and after it. Thus, it is difficult to tamper with a single record because a hacker would need to change the block containing that record as well as those linked to it to avoid detection.</li><li>Network participants have their own private keys that are assigned to the transactions they make and act as a personal digital signature. If a record is altered, the signature will become invalid and the peer network will know right away that something has happened. Early notification is crucial to preventing further damage.</li><li>Blockchains are decentralized and distributed across P2P networks that are continually updated and kept in sync. Hence, blockchains don’t have a single point of failure and cannot be changed from a single computer. It would require massive amounts of computing power to access every instance (or at least a 51% majority) of a certain blockchain and alter them all at the same time.</li><li>For bitcoin, the transactions are pseudo-anonymous i.e. transactions are sent to cryptographically generated addresses.</li><li>Let’s say You want to send some cryptocurrency to your friend. Then her wallet listens for the transaction.</li><li>Your wallet will encrypt the transaction and only your friend’s wallet will be able to decrypt it and accept it.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/0*Hq46zPWHo0GCMI5y.jpg" /><figcaption>source: <a href="https://coins.ph/blog/how-does-a-bitcoin-transaction-work/how-a-bitcoin-transaction-works-infographic/">coins.ph</a></figcaption></figure><ul><li>But the transaction amount is open to all the nodes in the network for validation.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/364/0*bIuu1mEEvD7B5l06.jpg" /><figcaption>source: <a href="https://www.ness.com/bitcoin-block-chain-proof-of-work-and-how-they-are-all-connected/">www.ness.com</a></figcaption></figure><p>According to Satoshi Nakamoto’s <a href="https://bitcoin.org/bitcoin.pdf">paper</a>, the steps to run the network are as follows:</p><ol><li>New transactions are broadcast to all nodes.</li><li>Each node collects new transactions into a block.</li><li>Each node works on finding a difficult proof-of-work for its block.</li><li>When a node finds a proof-of-work, it broadcasts the block to all nodes.</li><li>Nodes accept the block only if all transactions in it are valid and not already spent.</li><li>Nodes express their acceptance of the block by working on creating the next block in the chain, using the hash of the accepted block as the previous hash.</li></ol><p>Nodes always consider the longest chain to be the correct one and will keep working on extending it. If two nodes broadcast different versions of the next block simultaneously, some nodes may receive one or the other first. In that case, they work on the first one they received, but save the other branch in case it becomes longer. <strong><em>The tie will be broken when the next proof-of-work is found and one branch becomes longer</em></strong>; the nodes that were working on the other branch will then switch to the longer one.</p><p>I’d also recommend having a look at this <a href="https://www.mangoresearch.co/understanding-longest-chain-rule/">link</a> which explains this concept in an interesting way.</p><ul><li>A closed ecosystem in which each participant is well defined.</li><li>Allow an organization to efficiently exchange information and record transactions</li><li>Run by the members of an organization. Stakeholders “opt-in” to form a blockchain network.</li><li>Only pre-approved entities can run the nodes that validate transaction blocks and execute smart contracts on the blockchain.</li></ul><p>Some of the key attributes of a permissioned blockchain system include:</p><p>The degree of decentralization is based on how the members of the consortium choose to structure their business relationships. The concept of ‘no central control’ is not relevant here since the organizations are managed entities.</p><p>It all depends upon how the business relationships are set up and how the blockchain is configured. Most permissioned blockchains do not have cryptoeconomic incentives built into them. The primary incentive of permissioned blockchain participants is to minimize the cost, time, and ease of sharing information.</p><p>They offer fine-grained visibility into transaction details, along with metadata about those transactions.</p><p>Governance is largely decided and agreed upon by the members of the blockchain business network. Economic incentives, code quality, code changes, and power allocation among peers are based on the business dynamics and the common purpose for which the network has been designed and built. This allows companies to move quickly and in ways that best fit their business needs.</p><p>They generally don’t employ a cryptoeconomic model or monetary tokens due to the nature of these business networks.</p><h3>Permissioned Blockchain Applications</h3><p>Below are the few applications of the permissioned blockchain -</p><h3>1. Provenance Tracking</h3><p>By this, we can track the origin and movement of high-value items across a supply chain, such as luxury goods, pharmaceuticals, cosmetics, and electronics.</p><p>When a high-value item is created, a corresponding digital token is issued by a trusted authority, which acts to authenticate its point of origin.</p><p>Every time, the physical item changes hands, the digital token is moved in parallel.</p><p>A digital token is very tough to steal or forge than a piece of paper.</p><h3>2. Hyperledger Fabric</h3><ul><li>It is a permissioned blockchain that provides an enterprise-grade foundation for transactional applications.</li><li>A shared ledger that supports smart contracts and ensures the security and integrity of recorded transactions.</li><li>Unlike Bitcoin and Ethereum, it supports privacy and confidential transactions.</li></ul><h3><strong>Conclusion</strong></h3><p>Pheww! so finally we have reached the end of this post and with this, we have also completed the first stepping stone in understanding the concept of the blockchain.</p><p>In the next series of posts, we will look into the details of cryptographic concepts that make a fundamental blockchain.</p><p>I hope you are liking my efforts. Please share your thoughts in the comments. You can also follow me on <a href="https://twitter.com/I_am_Anirudh">Twitter</a>.</p><p>Stay tuned for the next post. Happy learning!! 🌝</p><p><em>Originally published at </em><a href="http://blockchain.redquark.org/2018/08/introduction-to-blockchain_13.html"><em>blockchain.redquark.org</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=20c7a71ad92b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Parsing XML using Retrofit]]></title>
            <link>https://medium.com/@anirudh03sharma/parsing-xml-using-retrofit-ac43cc0b7628?source=rss-c075f509e501------2</link>
            <guid isPermaLink="false">https://medium.com/p/ac43cc0b7628</guid>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Anirudh Sharma]]></dc:creator>
            <pubDate>Sun, 12 Aug 2018 16:01:15 GMT</pubDate>
            <atom:updated>2018-08-12T16:01:15.129Z</atom:updated>
            <content:encoded><![CDATA[<p>Developing our own type-safe HTTP library to interface with a REST API can be a real pain as we have to handle many aspects -</p><ul><li>making connections</li><li>caching</li><li>retrying failed requests</li><li>threading</li><li>response parsing</li><li>error handling, and more.</li></ul><p>Retrofit, on the other hand, is a well-planned, documented and tested library that will save you a lot of precious time and headaches. In this tutorial, we are going to discuss how we can parse the XML response returned from <a href="https://timesofindia.indiatimes.com/rssfeedstopstories.cms">https://timesofindia.indiatimes.com/rssfeedstopstories.cms</a> using the Retrofit library.</p><p>To work with Retrofit, we need three classes -</p><ul><li>Model class to map the JSON data</li><li>Interfaces which defines the possible HTTP operations</li><li>Retrofit.Builder class — Instance which uses the interface and the Builder API which allows defining the URL endpoint for the HTTP operation.</li></ul><p>Every method of the above interface represents on possible API call. The request type is specified by using appropriate annotations (GET, POST). The response is returned as a <strong><em>Call</em></strong> object.</p><p>So, without any further delays, let’s get our hands dirty with some code.</p><h3>Project setup</h3><p>To create a project in Eclipse IDE, follow below steps -</p><ol><li>Navigate to File ⇨ New ⇨ Project ⇨ Maven ⇨ Maven Project ⇨ Next</li><li>Select archetype for the maven project and then Next</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/0*q3aCzzHdZhoGHEat.png" /></figure><p>3. Add project details and click on Finish.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/0*Huc7JpYP2NxdKqnM.png" /></figure><p>4. Now add following dependencies in the <strong><em>pom.xml</em></strong> file.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5ae58e2f748d43de59d79dc66a40feb9/href">https://medium.com/media/5ae58e2f748d43de59d79dc66a40feb9/href</a></iframe><p>A sample XML RSS feed response looks likes</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a7870429d6c29cd83c80038473b09b90/href">https://medium.com/media/a7870429d6c29cd83c80038473b09b90/href</a></iframe><h3>Code in Action</h3><p>First, we need to create the model classes — one for each article and other for the feed. Let’s first create a class for the article.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b0fbd6e8de8b7b4da6e8ff22126a42a7/href">https://medium.com/media/b0fbd6e8de8b7b4da6e8ff22126a42a7/href</a></iframe><p>Let us understand the code now. We have used different annotations in this class</p><ol><li><strong>@Root — </strong>This indicates that the class is serialized/deserialized. It represents the element in the XML. The <strong>name </strong>property signifies the element name. If it is not defined, then the class name is used as the element name. With <strong>strict </strong>set to <strong><em>false</em></strong>, strict parsing is disabled. This tells the parser to not fail and throw an exception if an XML element or attribute is found for which no mapping is provided.</li><li><strong>@Element — </strong>It represents an XML element.</li></ol><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c65a86870d6b5afd765c39668d8a24d9/href">https://medium.com/media/c65a86870d6b5afd765c39668d8a24d9/href</a></iframe><p>If no name is specified, the field name will be used.</p><p>Now, let us create the model class for the RSS feed.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c65a86870d6b5afd765c39668d8a24d9/href">https://medium.com/media/c65a86870d6b5afd765c39668d8a24d9/href</a></iframe><p>Some other annotations used are</p><ol><li><strong>@ElementList — </strong>This indicates the collection is being used. With inline set to true, it is determined that the elements of the Collection are inlined. That means, that they have no enclosing element and are listed one after another within the XML response.</li><li><strong>@Path — </strong>We can provide a path to an XML element inside the XML tree.</li></ol><p>Now, after creating the models, let’s expose the API via an interface.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c5acdd7f162768fd0e53931aa25a1bc9/href">https://medium.com/media/c5acdd7f162768fd0e53931aa25a1bc9/href</a></iframe><p>To call the API, let’ss create a controller that creates a Retrofit client and handles the result.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8e833c9ab02865465f43cd187eacc789/href">https://medium.com/media/8e833c9ab02865465f43cd187eacc789/href</a></iframe><p>Now, to run this application below is the main class</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/eb57af9678b1e483e1102877d4fde503/href">https://medium.com/media/eb57af9678b1e483e1102877d4fde503/href</a></iframe><h3>Result</h3><p>After running the application, the output will be as below</p><p><strong><em>Channel Title: Times of India</em></strong></p><p><strong><em>— — — — — — — — — — — — — — — — — — — — — — —</em></strong></p><p><strong><em>Title: RS Dy chair poll: BJD, TRS boost to NDA; oppn questions Cong strategy</em></strong></p><p><strong><em>Link: </em></strong><a href="https://timesofindia.indiatimes.com/india/rs-dy-chairperson-election-bjd-trs-boost-to-nda-oppn-questions-congress-strategy/articleshow/65342145.cms"><strong><em>https://timesofindia.indiatimes.com/india/rs-dy-chairperson-election-bjd-trs-boost-to-nda-oppn-questions-congress-strategy/articleshow/65342145.cms</em></strong></a></p><p><strong><em>Title: Kerala rains live: 26 dead, CM says situation grim</em></strong></p><p><strong><em>Link: </em></strong><a href="https://timesofindia.indiatimes.com/city/kochi/heavy-rains-hit-life-in-kerala/articleshow/65335799.cms"><strong><em>https://timesofindia.indiatimes.com/city/kochi/heavy-rains-hit-life-in-kerala/articleshow/65335799.cms</em></strong></a></p><p><strong><em>Title: AAP won’t join oppn alliance for LS polls: Kejriwal</em></strong></p><p><strong><em>Link: </em></strong><a href="https://timesofindia.indiatimes.com/india/aap-will-not-join-opposition-alliance-for-2019-lok-sabha-polls-kejriwal/articleshow/65344573.cms"><strong><em>https://timesofindia.indiatimes.com/india/aap-will-not-join-opposition-alliance-for-2019-lok-sabha-polls-kejriwal/articleshow/65344573.cms</em></strong></a></p><p><strong><em>Title: Samsung launches Galaxy Note 9: Specs and more</em></strong></p><p><strong><em>Link: </em></strong><a href="https://www.gadgetsnow.com/mobiles/samsung-galaxy-note-9-with-improved-s-pen-launched-price-specifications-and-availability/articleshow/65342896.cms"><strong><em>https://www.gadgetsnow.com/mobiles/samsung-galaxy-note-9-with-improved-s-pen-launched-price-specifications-and-availability/articleshow/65342896.cms</em></strong></a></p><p><strong><em>Title: US-China trade war may bring cheaper oil to India</em></strong></p><p><strong><em>Link: </em></strong><a href="https://timesofindia.indiatimes.com/business/india-business/how-us-china-trade-war-may-bring-cheaper-oil-to-indian-shores/articleshow/65333316.cms"><strong><em>https://timesofindia.indiatimes.com/business/india-business/how-us-china-trade-war-may-bring-cheaper-oil-to-indian-shores/articleshow/65333316.cms</em></strong></a></p><p><strong><em>Thus, we have seen that it is very easy to parse the XML response using the Retrofit library. A lot of boilerplate code has been eliminated. This increases the faster time to market and maintenance of code becomes very easy. You can find the complete code on </em></strong><a href="https://github.com/ani03sha/RetrofitXMLParser"><strong><em>GitHub</em></strong></a><strong><em>.</em></strong></p><p>That’s it for today. I hope you enjoyed this post. Happy Coding!! 😊</p><p><em>Originally published at </em><a href="https://codeleague.redquark.org/2018/08/parsing-xml-using-retrofit.html"><em>codeleague.redquark.org</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ac43cc0b7628" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introduction to Blockchain — Architectural Overview (Part 3)]]></title>
            <link>https://medium.com/@anirudh03sharma/introduction-to-blockchain-architectural-overview-part-3-196c34bb2da9?source=rss-c075f509e501------2</link>
            <guid isPermaLink="false">https://medium.com/p/196c34bb2da9</guid>
            <category><![CDATA[cryptocurrency]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[smart-contracts]]></category>
            <dc:creator><![CDATA[Anirudh Sharma]]></dc:creator>
            <pubDate>Fri, 03 Aug 2018 19:44:17 GMT</pubDate>
            <atom:updated>2018-08-03T19:44:17.063Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/640/0*odtyYVPgT4UZa4oU.jpeg" /><figcaption>source: <a href="http://www.documentarytube.com/">www.documentarytube.com</a></figcaption></figure><p>In today’s post, we will look into the architectural details of the blockchain technology. In doing so, we will touch upon the concepts of Smart Contracts and later on, about the internal details of a block that comprises the Bitcoin blockchain.</p><h3>Interesting project but no money ☹️</h3><p>Let us say your friend Alice has an interesting project idea and she wants to start it as soon as possible but she has no (or little) funding to start it. She is very upset and then as a good friend you come to her rescue (A friend in need is a friend indeed 😊). You suggest her that she should <strong>crowdfund</strong> the project. She is now intrigued and inquires about it.</p><h4>What is crowdfunding and how it works?</h4><p>Put simply, crowdfunding is the process of getting a large crowd of people to pay a small amount of money to invest in an idea or product, with the promise that when the said idea comes to fruition, they will get first access to it. The idea can be anything, from an innovative piece of tech to a video game to a novelty gift.</p><ul><li>Both the product team and the supporters need to trust the crowdfunding platform (or a Kickstarter).</li><li>The product team expects the money to be paid as the project progresses.</li><li>The supporters expect the money to go to the project.</li></ul><p>As it is clear that this is a centralized system and the major drawback is that some monetary benefit goes to the Kickstarter for their efforts in managing the entire process. The solution to this problem leads us to the concept of “Smart Contracts” which is a decentralized version of the same platform.</p><h3>Smart Contracts</h3><p>In 1994, Nick Szabo realized that a decentralized system could be used for smart contracts or self-executing contracts. Here, contracts are converted into computer code, stored and replicated on the system and supervised by the network of computers that run the blockchain.</p><p>Thus, smart contracts help us exchange money, property, shares, or anything of value in a transparent, conflict-free way while avoiding the services of a middleman.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/0*IF0gQZgJcQDSi6PM.jpg" /><figcaption>source:<a href="https://blockgeeks.com/">blockgeeks.com</a></figcaption></figure><p>The best way to describe smart contracts is to compare the technology to a vending machine. Ordinarily, you would go to a lawyer or a notary, pay them, and wait while you get the document. With smart contracts, you simply drop a bitcoin into the vending machine (i.e. ledger), and your escrow, driver’s license, or whatever drops into your account. More so, smart contracts not only define the rules and penalties around an agreement in the same way that a traditional contract does, but also automatically enforce those obligations.</p><p>if we apply Smart Contracts to our example of crowdfunding, then the following things will happen -</p><ol><li>The contract is written in a “code” which is available to the stakeholders — product team (Alice) and the supporters (Note — a typical example of a blockchain)</li><li>The code automatically transfers money as certain goals (contracts) of the project are accomplished.</li><li>If the project goals (or contracts) fail, then the code will transfer money back to the supporters.</li></ol><h4>Advantages of Smart Contracts</h4><ul><li>Immutable — No party will be able to change the contract once it is written to the public ledger.</li><li>Distributed — Every stakeholder can validate the contract</li></ul><p>In this section, we will look into the nitty gritty details of the fundamental entity in a blockchain, that is, the block. A chain of many such blocks makes a blockchain. On high level, a block has two components -</p><ol><li>Block Header</li><li>Transactions</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/0*thnH13Y8vOlaS5Zx.png" /><figcaption>source:<a href="https://read.acloud.guru/">read.acloud.guru</a></figcaption></figure><p>Let us look into these components one by one -</p><p>The header contains metadata about a block. There are three different sets of metadata:</p><ul><li>The previous block hash — in a blockchain, every block inherits from the previous block as it uses the previous block’s hash to create the new block’s hash. For every block N, the hash of the block N-1 is used.</li><li>Mining competition — each block in a blockchain has the timestamp, the nonce and the difficulty. It should be complicated enough to make the block tamper-proof. The nonce is a random variable that makes it possible for the hash of the Nth block with predefined complexity. For e.g., for bitcoin, this complexity is that there should be 20 zeros at the prefix.</li><li>Merkle tree root — data structure that summarizes the transactions in the block.The root is the verification of all the transactions. I discussed Merkle algorithm in detail in my first post <a href="http://blockchain.redquark.org/2018/07/introduction-to-blockchain.html">here</a>.</li></ul><h4>Transactions</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/0*u68ydLdhqb2M2wI7.png" /><figcaption>source:<a href="https://hackernoon.com/merkle-trees-181cb4bc30b4">HackerNoon</a></figcaption></figure><p>Transactions are organized as a Merkle Tree whose root is used to construct the block hash. A Merkle tree is constructed by recursively hashing pairs of nodes ( in this case, transactions ), until there is only one hash, called the root or Merkle root. If we stay in the Bitcoin world, the cryptographic hash algorithm used is SHA256. This is applied twice each time.</p><p>This <a href="https://dev.to/damcosset/blockchain-what-is-in-a-block-48jo">link</a> discusses the Merkle tree in more detail.</p><p>This provides us the capability to determine almost accurately if someone tampers a block. If some malicious attacker tries to tamper one transaction, then the hash of that transaction will be changed and thus there will be changes in the hashes of the subsequent blocks. Thus complexity of determing the hash of a block is so tough that it would take a lot of computing power and time to corrupt the subsequent blocks before a new block is generated. Thus, it is almost impossible for a attacker to reach the end of the blocks and making all of them corrupt.</p><h3>Blockchain Replicas</h3><ul><li>Every peer in a blockchain network maintains a local copy of the blockchain.</li><li>All the replicas need to be updated with the latest mined block.</li><li>All the replicas need to be consistent i.e. all the copies of the blockchain with peers must be exactly similar.</li></ul><h4>Distributed Consensus</h4><p>Distributed consensus, also known as Nakamoto consensus, is a method of establishing canonical state in a system. Think of it this way: There are an infinite amount of possible wrong answers, but only one right answer. In typical systems, this is done by a central authority that determines validity and provides data, also known as a trusted third party (TTP).</p><p>The problem of infinite wrong answers means there must be a way to find validity in blocks. Instead of using a central authority, distributed nodes receive new blocks, and either choose to withhold or propagate them. In such a system, there is assumed to be an “uncoordinated, honest majority” that prevents a few malicious nodes from propagating incorrect blocks. This is also called Byzantine Fault Tolerance (BFT).</p><p>Using the consensus rules of Bitcoin, for example, transactions must have valid signatures, originating from spends that are available (there must be enough balance to spend), be put into a Merkle tree with SHA-256d, and have a Hashcash-style proof of work attached that is under the widely agreed upon network difficulty, and other rules. If there are multiple blocks that are valid but branch off at some point, pick the longest series of blocks. Ultimately, because there is such an overwhelming majority that follows Bitcoin consensus rules exactly as they are written, consensus can be established through the Internet without any real problems.</p><p>Few key points related to distributed consensus are -</p><ol><li>Ensure that all the nodes in the network see the same data at nearly the same point of time.</li><li>All nodes need to agree on a regualr basis, that the data stored by them are same.</li><li>No single point of failure — as the data is decentralized</li><li>Challenge-Response Protocol — In this, the network poses a challenge to the peers. The node thay solves the challenge first declares that it has solved the challenge and the transaction is veirfied.</li><li>Good challenge is the one in which different nodes win in different runs of the challenge. This ensures that no single node controls the network.</li><li>Proof of Work — this ensures consensus over a permissions-less setting based on challenge-response.</li></ol><h3>Economics of Blockchain consensus</h3><p>The challenge-response requires that every node spends large amount of computation power to solve a mathematical challenge in each iteration of the consensus. But why should they do it? What is the incentive for them? The answer to these questions is that when a node expends computational power to solve the problem, they are paid by the cryptocurrency generated and managed by the network.</p><p>With this, we have reached the end of this post. In this post, we discussed the architecture of a blockchain on a high level along with a good application — Smart Contracts.</p><p>In the next post, we will further explore the concepts of blockchain. Stay tuned 😊</p><p><em>Originally published at </em><a href="http://blockchain.redquark.org/2018/08/introduction-to-blockchain.html"><em>blockchain.redquark.org</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=196c34bb2da9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introduction to Blockchain — Evolution (Part 2)]]></title>
            <link>https://medium.com/@anirudh03sharma/introduction-to-blockchain-evolution-part-2-11bdb17c94a?source=rss-c075f509e501------2</link>
            <guid isPermaLink="false">https://medium.com/p/11bdb17c94a</guid>
            <category><![CDATA[cryptocurrency]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[hashing]]></category>
            <category><![CDATA[bitcoin]]></category>
            <dc:creator><![CDATA[Anirudh Sharma]]></dc:creator>
            <pubDate>Fri, 27 Jul 2018 11:33:24 GMT</pubDate>
            <atom:updated>2018-07-27T11:34:17.350Z</atom:updated>
            <content:encoded><![CDATA[<p>In the last <a href="http://blockchain.redquark.org/2018/07/introduction-to-blockchain.html">part</a> of this <a href="http://blockchain.redquark.org/">series</a>, we discussed the basic concepts of blockchain technology. In this post, we are going to discuss the evolution of blockchain and it the latter part of the post, I will introduce the concept of bitcoin technology at a high level.</p><h3>Hashing and Hash Functions</h3><p>The concept of hashing is the backbone of the blockchain technology and it helps us to speed up the searching process. Hashing allows us to map any data to a fixed size. The entity which performs hashing is called a <strong>Hash Function. </strong>For e.g, <strong><em>H(x) = x%n </em></strong>(<strong><em>%</em></strong> is the modulo operator — returns remainder when x is divided by <strong><em>n</em></strong>)<em>, </em>as it is evident that <strong><em>x</em></strong> can be of any value but <strong><em>H(x)</em></strong> will always be in the range <strong><em>[0, n-1]</em></strong><em>.</em></p><p><strong><em>x</em></strong> is called <em>Message</em></p><p><strong><em>H(x)</em></strong> is called <em>Message Digest</em></p><h3>Cryptographic Hash Function</h3><p>It is a mathematical algorithm that maps data of arbitrary size to a bit string of a fixed size (a hash). It is a one-way function i.e. we can find <em>H(x) </em>if <em>x </em>and<em> n </em>are given but if <strong><em>H(x)</em></strong> and <strong><em>n</em></strong> are given, we cannot find <strong><em>x</em></strong>. The only way to find <strong><em>x</em></strong> is by using brute-force and this gets tougher as the number of possibilities increase.</p><p>The ideal cryptographic hash function has five main properties:</p><ul><li>The same message should always result in the same hash.</li><li>Significantly fast to calculate the hash of any message.</li><li>Only one way</li><li>A significantly different hash is generated even if there is a very small change in message.</li><li>No two different messages should generate the same hash.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/0*Os9_2k5DE9jgPFxS.png" /></figure><p>Avalanche Effect courtesy: Wikipedia</p><p>If you look at the above figure closely and notice the word “over”, you will find that the hash function changes drastically. This is called <em>Avalanche Effect</em>. This is very important from the security aspect as if the message is encoded, it makes it very hard for someone to guess the message.</p><p>Merkle Trees (or hash trees) are a fundamental part of the blockchain technology. It efficiently verifies the consistency of a large content of data. Bitcoin and Ethereum both use Merkle Tree concept.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/0*C1FFGqlKcfIdwIm9.png" /></figure><p>Merkle Tree (courtesy: Medium)</p><p>They follow the<strong> bottom-up </strong>approach by hashing pair of nodes repeatedly until only one node/hash is left. This hash is called <strong>Root Hash</strong> or <strong>Merkle Root</strong>.</p><p>Each leaf node represents the hash of the transactional data while each non-leaf node represents the hash of the combination of hashes of the previous nodes. Merkle trees are binary trees and therefore require an even number of leaf nodes. If the number of transactions is odd, the last hash will be duplicated once to create an even number of leaf nodes.</p><p>Later in 1991, Stuart Haber and W. Scott Stornetta published a paper called <a href="https://www.anf.es/pdf/Haber_Stornetta.pdf">How to Time-Stamp a Digital Document</a> in which they used Merkle Trees to timestamp a digital document so that the people who edited the documents and at specific timestamps can be easily determined. In this scheme, each edit depends on the previous edit’s hash. Hence, if anyone tries to tamper the timestamp, the hash would change and the person can be caught easily. Thus, security increases many folds.</p><p>In 2009, Satoshi Nakamoto (the fact no one knows who is/are he/she/they — intrigues me 😵) published a whitepaper and introduced the concept of Bitcoin. In this section, we will discuss high-level details of Bitcoin and its working.</p><p>The bitcoin is a completely <strong><em>decentralized</em></strong>, <strong><em>peer-to-peer</em></strong>, <strong><em>permissionless</em></strong> electronic cash system. The keywords in above definition are:</p><ol><li><strong>Decentralized — </strong>No central party for ordering or recording anything, not even government.</li><li><strong>Peer-to-peer — </strong>The software runs on the machines of all stakeholders to form the system.</li><li><strong>Permissionless</strong> — No identity; no need to signup anywhere to use; no access control — anyone can participate in any role — be it, sender, receiver or miner.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/0*sKuOYhK_U1x_fN_I.jpg" /></figure><p>Typical bitcoin transaction (courtesy: Twitter)</p><p>In bitcoin, each individual has a copy of the most updated blockchain or public ledger. Let us try to understand the life cycle of a typical bitcoin transaction -</p><ul><li>Sender opens his/her account</li><li>Provides the address of the receiver and specify the amount to transfer</li><li>Sends</li><li>The wallet constructs a transaction and signs it using the sender’s private key (to ensure the validity and authenticity of the transaction)</li><li>Once the transaction is constructed, it is broadcast to the network.</li><li>The network nodes validate the transaction based on the existing blockchain and propagate it to the miners.</li><li>The miners include the transaction to the next block to be mined.</li><li>Miners collect all transactions within a fixed time interval (10 minutes for BTC)</li><li>Then they construct a new block and try to connect it with the existing blockchain through a cryptographic hash function</li><li>Once the block is generated, it is included in the blockchain and the updated blockchain is broadcast to the network.</li><li>The hash of each block is generated based on the hash of the previous block and the task of each miner is to solve this hash problem in a difficult manner (under the hood, the miners need to solve a hard mathematical problem — such as the hash should contain 20 trailing zeros — so each combination needs to be checked until the condition is met).</li><li>The receiver opens his/her bitcoin wallet and refreshes, the blockchain gets updated.</li><li>The transaction gets reflected in the receiver’s account.</li></ul><p>Many mainstream companies are exploring to use the blockchain for building alternate systems other than transactions for uses in manufacturing, supply chain, governance, IoT etc. This revolution is being termed as Blockchain 2.0.</p><p>Phew! we have reached the end of this post and we discussed the evolution of the blockchain and the principles it works. Later on, we discussed high-level details of a typical bitcoin transaction. In the next post of this series, we will look into the blockchain architecture. I hope you enjoyed this post. Stay tuned!</p><p><em>Originally published at </em><a href="http://blockchain.redquark.org/2018/07/introduction-to-blockchain-evolution.html"><em>blockchain.redquark.org</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=11bdb17c94a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introduction to Blockchain]]></title>
            <link>https://medium.com/@anirudh03sharma/introduction-to-blockchain-b13d7fb742a4?source=rss-c075f509e501------2</link>
            <guid isPermaLink="false">https://medium.com/p/b13d7fb742a4</guid>
            <category><![CDATA[decentralized]]></category>
            <category><![CDATA[cryptocurrency]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[decentralized-apps]]></category>
            <category><![CDATA[distributed-systems]]></category>
            <dc:creator><![CDATA[Anirudh Sharma]]></dc:creator>
            <pubDate>Thu, 26 Jul 2018 03:30:29 GMT</pubDate>
            <atom:updated>2018-07-26T03:30:29.726Z</atom:updated>
            <content:encoded><![CDATA[<p>The blockchain isn’t just the backbone of cryptocurrency — it could change the world. Applications are endless. It is one of the most sought-after skills these days. Blockchain developers are in huge demand but there are only a few who can elegantly develop a blockchain application.</p><p>I will admit that I am a newbie to this field and all the related terminology. Recently I have decided to dive into this field and after learning a few nuances, I thought it would be a good idea to share my understanding with everyone. Hence, this blog.</p><p>This is the first blog of this series and without further ado let’s learn together the awesome concepts of Blockchain technology.</p><p><em>It is a </em><strong><em>decentralized</em></strong><em> platform which enables multiple </em><strong><em>domains</em></strong><em>, who do not trust each other to collaborate in a </em><strong><em>decision-making process</em></strong><em>.</em></p><p>Main keywords from the above definition are -</p><ol><li><strong>Decentralized — </strong>There is no single centralized authority that makes decisions on behalf of all the concerned parties. Instead, each party, also called a peer, makes local autonomous decisions towards its individual goals.</li><li><strong>Domains — </strong>Parties who are skeptical about the authenticity of other parties.</li><li><strong>Decision-Making Process — </strong>A common process executed by all the peers such as validating a transaction.</li></ol><p>There are broadly three types of systems — centralized, distributed and decentralized. Below is the most widely used diagram that depicts these three.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*FHHWPXVPmpwYYry0.jpeg" /></figure><p><em>It is kind of multiple client-single server like architecture where the server computer is the one where all of the major processing is done.</em></p><p>Client machines connect to the server computer (master computer) and submit their requests. For e.g. a <strong>web application server</strong> that hosts all the business logic, runs the database etc. Various client machines connect to the web application server and send/receive requests/responses through the HTTP application layer protocol.</p><p>This mechanism poses the following problems -</p><ol><li><strong>Single point of failure — </strong>If the master goes down, clients won’t be able to serve user request since the machine that runs core logic is dead.</li><li><strong>Limited scalability — </strong>Only vertical scaling is possible i.e. to add more storage, I/O bandwidth, CPU processing power for the master. Surely, there will be a limit after which increasing these parameters is not feasible.</li></ol><p><em>A distributed system is a model in which components located on networked computers communicate and coordinate their actions by passing messages.</em></p><p>Thus, it is a system where components might span geographical boundaries but are owned and controlled by a single entity (cloud computing). Trust in such a system is still centralized. For e.g. Google.</p><p>Here all the processing is not done by a single machine instead they allow to distribute work among various nodes and each of them can serve requests equally. For e.g. <a href="http://cassandra.apache.org/doc/latest/architecture/index.html">Cassandra data store</a>.</p><ol><li>There isn’t really any single point of failure because client machines aren’t relying on a single server to fulfill all requests. The system comprises multiple nodes which might be still available to process user requests.</li><li>We can scale-out the system by adding more nodes — <strong>Horizontal Scaling.</strong></li></ol><p>In blockchain, everyone works on their local copy of a common document and it is the responsibility of the underlying process to ensure the consistency. Let us understand this with an example -</p><ul><li>Suppose, there are four friends Alice, Bob, Carol, and Dwayne.</li><li>There is one public ledger which holds records of bank accounts of these four friends.</li><li>Let’s say one entry in that public ledger shows Alice has $100 in her account.</li><li>Since each of the above four persons has a separate copy of the public ledger, each one now knows that Alice has $100 in her account.</li><li>Now, suppose Alice transfers $40 to Bob. This is a transaction and it will be updated as a new entry in the public ledger copy of Alice (after successful validation).</li><li>Due to the underlying blockchain mechanism, this entry will be validated first by Bob, Carol, and Dwayne and if successful, they update the same in their respective copies of public ledger.</li><li>Now as a second transaction, suppose Alice tries to transfer $80 to Carol. This is an invalid transaction as Alice only has $60 left in her account. Thus, the validity of transaction fails and this entry will not be added in the public ledger.</li></ul><p>From above, when a new transaction or an edit to an existing transaction comes in to a blockchain, generally a majority of the nodes within a blockchain implementation must execute algorithms to evaluate and verify the history of the individual blockchain block that is proposed.</p><p>If a majority of the nodes come to a consensus that the history and signature are valid, the new block of transactions is accepted into the ledger and a new block is added to the chain of transactions. If a majority does not concede to the addition or modification of the ledger entry, it is denied and not added to the chain.</p><p>This distributed consensus model is what allows blockchain to run as a distributed ledger without the need for some central, unifying authority saying what transactions are valid and (perhaps more importantly) which ones are not.</p><ol><li><strong>Protocols for Commitment — </strong>This ensures that every valid transaction from the clients are committed and included in the blockchain in a finite time.</li><li><strong>Consensus — </strong>This ensures that local copies are consistent and updated.</li><li><strong>Security — </strong>The data needs to be tamper proof. Note that the clients may act maliciously or can be compromised.</li><li><strong>Privacy and Authenticity — </strong>The privacy and authenticity of transactions need to be ensured.</li></ol><p>Overall, the blockchain technology has the potential to revolutionize several industries from advertising to energy distribution. Its main power lies in its abilities of not requiring trust and being decentralized.</p><p>In future posts, we will dive deeper into the various concepts of this technology. Stay tuned! 🌝</p><p><em>Originally published at </em><a href="http://blockchain.redquark.org/2018/07/introduction-to-blockchain.html"><em>blockchain.redquark.org</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b13d7fb742a4" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>