<?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 Javatechie on Medium]]></title>
        <description><![CDATA[Stories by Javatechie on Medium]]></description>
        <link>https://medium.com/@javatechie4u?source=rss-f5f1cc1bc31------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*4ZJs0DjYvBMvwAaS1n6qlQ.jpeg</url>
            <title>Stories by Javatechie on Medium</title>
            <link>https://medium.com/@javatechie4u?source=rss-f5f1cc1bc31------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 16 Nov 2026 18:15:31 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@javatechie4u/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[Spring Boot Password Encryption using Jasypt]]></title>
            <link>https://javatechie4u.medium.com/spring-boot-password-encryption-using-jasypt-9ee731701e70?source=rss-f5f1cc1bc31------2</link>
            <guid isPermaLink="false">https://medium.com/p/9ee731701e70</guid>
            <dc:creator><![CDATA[Javatechie]]></dc:creator>
            <pubDate>Sun, 28 Feb 2021 18:18:56 GMT</pubDate>
            <atom:updated>2021-03-05T17:36:10.327Z</atom:updated>
            <content:encoded><![CDATA[<iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FLl-Cz6h8s6I%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DLl-Cz6h8s6I&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FLl-Cz6h8s6I%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/5c3e5fe3c282c2305c7a11a4f5dfd8a3/href">https://medium.com/media/5c3e5fe3c282c2305c7a11a4f5dfd8a3/href</a></iframe><p>In this tutorial, I will guide you how to encrypt sensitive information in Spring Boot application configuration file (application.properties or application.yml), such as username and password of a datasource, credentials of SMTP server, etc… using <strong>Jasypt </strong>library</p><p><strong>Jasypt </strong>is a Java library which helps developers with basic encryption in configurations without much effort or in-depth knowledge of encryption implementation. Please go through<a href="http://www.jasypt.org/"> http://www.jasypt.org/</a> for detailed information.</p><p>Let us consider a scenario where we build a spring boot CRUD application , We will need to store information like database connection details or any other sensitive information which will make it vulnerable.</p><p>To avoid this vulnerability issue its recommended to encrypt sensitive information in your config file .</p><p><strong>Steps To Add Encryption Using Jasypt:</strong></p><p><strong>1. Add maven dependency of jasypt:</strong> In the pom.xml file, add maven dependency which can be found easily at <a href="https://mvnrepository.com/artifact/com.github.ulisesbocchio/jasypt-spring-boot-starter">Maven Repository</a></p><p><em>If you want to simplify encryption &amp; decryption process then you can add below maven plugin (</em><strong><em>we will follow the steps using maven plugin</em></strong><em>)</em></p><pre>&lt;<strong>plugin</strong>&gt;<br>    &lt;<strong>groupId</strong>&gt;com.github.ulisesbocchio&lt;/<strong>groupId</strong>&gt;<br>    &lt;<strong>artifactId</strong>&gt;jasypt-maven-plugin&lt;/<strong>artifactId</strong>&gt;<br>    &lt;<strong>version</strong>&gt;3.0.3&lt;/<strong>version</strong>&gt;<br>&lt;/<strong>plugin</strong>&gt;</pre><p><strong>2. Add annotation in the Spring Boot Application main Configuration class:</strong> <strong>@EnableEncryptableProperties</strong> annotation needs to be added to make the application understand the encryptable properties across the entire Spring Environment</p><p><strong>3. Decide a secret key to be used for encryption and decryption</strong> The secret key is used to encrypt the password and later can be used to decrypt the encrypted value to get the actual password. You can choose any value as the secret key.</p><p><strong>4. Encrypt and Decrypt single String value</strong></p><p>Open a new command prompt window. Change the current directory to the project directory where the pom.xml file is in. And type the following command:</p><pre>mvn jasypt:encrypt-value -Djasypt.encryptor.password=javatechie -Djasypt.plugin.value=Password</pre><ul><li><strong>input</strong>: Password (Actual password to be encrypted)</li><li><strong>password</strong>: javatechie (the secret key chosen by you)</li><li><strong>algorithm</strong>: PBEWithMD5AndDES (default algorithm used)</li></ul><p>you would see it prints something like this:</p><p>ENC(nObqvmVPYhxVaykMl09QVtGCQWjpd7al1RJhOsyz1eLkb6J2USMu9Fb//e4a6Vro) (Encrypted value of input)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wnemxdieswCbZ5FZmq3_qg.png" /></figure><p>If you run the above command again, you will see a different encrypted value because the default encryptor uses a random generator. That means a string can be different encrypted value though the private key is the same</p><p>The default encrypt algorithm is bidirectional, which means you can do decryption. Type the following command:</p><pre>mvn jasypt:decrypt-value -Djasypt.encryptor.password=javatechie -Djasypt.plugin.value=nObqvmVPYhxVaykMl09QVtGCQWjpd7al1RJhOsyz1eLkb6J2USMu9Fb//e4a6Vro</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CgIi1-399uAT5MwETWEsIA.png" /></figure><p>So these encrypt and decrypt commands are the very basic ones you should be familiar with.</p><p>Now once you verified your encryption key is correct then you can directly add your encrypted key in application config file like below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*07YBVboUGkDfEhlKEmF-Ww.png" /></figure><p>Now, to run the Spring Boot application you need to pass the private key password as VM arguments in the command prompt like this:</p><pre>java -Djasypt.encryptor.password=javatechie -jar spring-boot-application.jar</pre><p>To run the Spring Boot application in Eclipse or intellij idea IDE, you need to edit the run configuration by passing a VM argument like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zJvwgRQj8Va02RqWH-MMzQ.png" /></figure><p><strong>5. Encrypt credential in application.properties file</strong></p><p>Suppose that you want to encrypt username and password of a Spring data source in the following application.properties file:</p><pre><strong>spring.datasource.driver-class-name</strong>=<strong>com.mysql.cj.jdbc.Driver<br>spring.datasource.url </strong>= <strong>jdbc:mysql://localhost:3306/javatechie<br>spring.datasource.username </strong>= <strong>root<br>spring.datasource.password </strong>= <strong>Password</strong></pre><p>First, wrap the values password inside DEC() as shown below:</p><pre><strong>spring.datasource.driver-class-name</strong>=<strong>com.mysql.cj.jdbc.Driver<br>spring.datasource.url </strong>= <strong>jdbc:mysql://localhost:3306/javatechie<br>spring.datasource.username </strong>= <strong>root<br>spring.datasource.password </strong>= <strong>DEC(Password)</strong></pre><p>Here, DEC() is a placeholder that tells Jasypt what to encrypt, and the remaining values are untouched.</p><p>And in the command prompt, type:</p><pre>mvn jasypt:encrypt -Djasypt.encryptor.password=javatechie</pre><p>Then it will replace the DEC() placeholders in the application.properties file with the encrypted value:</p><pre><strong>spring.datasource.driver-class-name</strong>=<strong>com.mysql.cj.jdbc.Driver<br>spring.datasource.url </strong>= <strong>jdbc:mysql://localhost:3306/javatechie<br>spring.datasource.username </strong>= <strong>root<br>spring.datasource.password </strong>= <strong>ENC(llo8Tfwc2cBLNAzjkksTk9dBj8tIwT3ZUHDQoFQm88D85qJTTY9doPcmQiN/Emtd)</strong></pre><p>Now to run the Spring Boot application in any IDE, you need to pass VM argument which we already discussed above -<em>Djasypt.encryptor.password=javatechie</em></p><p><strong>6. Encrypt credential in application.yml file</strong></p><p>By default, Jasypt will update the application.properties file. In case you’re using application.yml in your project,</p><p>First, wrap the values password inside DEC() as shown below:</p><pre><strong>spring</strong>:<br>  <strong>datasource</strong>:<br>    <strong>username</strong>: root<br>    <strong>password</strong>: DEC(Password)<br>    <strong>url</strong>: jdbc:mysql://localhost:3306/javatechie<br>    <strong>driver-class-name</strong>: com.mysql.cj.jdbc.Driver<br>  <strong>jpa</strong>:<br>    <strong>show-sql</strong>: true<br>    <strong>hibernate</strong>:<br>      <strong>ddl-auto</strong>: update<br>    <strong>properties.hibernate.dialect</strong>: org.hibernate.dialect.MySQL5Dialect</pre><p>then run the below specify the path of the file(application.yml) in the command like this:</p><pre>mvn jasypt:encrypt -Djasypt.encryptor.password=javatechie -Djasypt.plugin.path=&quot;file:src/main/resources/application.yml&quot;</pre><p>Then it will replace the DEC() placeholders in the application.yml file with the encrypted value:</p><pre><strong>spring</strong>:<br>  <strong>datasource</strong>:<br>    <strong>username</strong>: root<br>    <strong>password</strong>: ENC(y3K0rZ78+/nFxd3DXnUBw2qQ4kuEwOsg3rE3iZ9foTtH9tnTMIMzVKVHlLL5fex5)<br>    <strong>url</strong>: jdbc:mysql://localhost:3306/javatechie<br>    <strong>driver-class-name</strong>: com.mysql.cj.jdbc.Driver<br>  <strong>jpa</strong>:<br>    <strong>show-sql</strong>: true<br>    <strong>hibernate</strong>:<br>      <strong>ddl-auto</strong>: update<br>    <strong>properties.hibernate.dialect</strong>: org.hibernate.dialect.MySQL5Dialect</pre><p>Now to run the Spring Boot application by passing VM argument .</p><p><strong>7. Configure encryptor in Spring configuration class</strong></p><p>Jasypt is easy to use, as you’ve seen with the commands above. And it is also highly configurable if you have some knowledge in cryptography and you want to customize settings for the encryptor. For example, create a new Spring configuration class in the project as follows:</p><pre>@Configuration<br><strong>public class </strong>JasyptEncryptorConfig {<br><br>    @Bean(name = <strong>&quot;jasyptStringEncryptor&quot;</strong>)<br>    <strong>public </strong>StringEncryptor getPasswordEncryptor() {<br>        PooledPBEStringEncryptor encryptor = <strong>new </strong>PooledPBEStringEncryptor();<br>        SimpleStringPBEConfig config = <strong>new </strong>SimpleStringPBEConfig();<br>        config.setPassword(<strong>&quot;javatechie&quot;</strong>); <em>// encryptor&#39;s private key<br>        </em>config.setAlgorithm(<strong>&quot;PBEWithMD5AndDES&quot;</strong>);<br>        config.setKeyObtentionIterations(<strong>&quot;1000&quot;</strong>);<br>        config.setPoolSize(<strong>&quot;1&quot;</strong>);<br>        config.setProviderName(<strong>&quot;SunJCE&quot;</strong>);<br>        config.setSaltGeneratorClassName(<strong>&quot;org.jasypt.salt.RandomSaltGenerator&quot;</strong>);<br>        config.setStringOutputType(<strong>&quot;base64&quot;</strong>);<br>        encryptor.setConfig(config);<br>        <strong>return </strong>encryptor;<br>    }<br>}</pre><p>This code will override the default encryption configuration, so you need to write some code to encrypt a password I would recommend to write test case to generate encrypted key</p><pre>@Test<br><strong>public void </strong>testPasswordEncryption() {<br>    PooledPBEStringEncryptor encryptor = <strong>new </strong>PooledPBEStringEncryptor();<br>    SimpleStringPBEConfig config = <strong>new </strong>SimpleStringPBEConfig();<br>    config.setPassword(<strong>&quot;javatechie&quot;</strong>); <em>// encryptor&#39;s private key<br>    </em>config.setAlgorithm(<strong>&quot;PBEWithMD5AndDES&quot;</strong>);<br>    config.setKeyObtentionIterations(<strong>&quot;1000&quot;</strong>);<br>    config.setPoolSize(<strong>&quot;1&quot;</strong>);<br>    config.setProviderName(<strong>&quot;SunJCE&quot;</strong>);<br>    config.setSaltGeneratorClassName(<strong>&quot;org.jasypt.salt.RandomSaltGenerator&quot;</strong>);<br>    config.setStringOutputType(<strong>&quot;base64&quot;</strong>);<br>    encryptor.setConfig(config);<br>    String plainText = <strong>&quot;Password&quot;</strong>;<br>    String encryptedPassword = encryptor.encrypt(plainText);<br>    System.<strong><em>out</em></strong>.println(<strong>&quot;encryptedPassword : &quot; </strong>+ encryptedPassword);<br>}</pre><p>Run the test case</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hvqUK5R1X898EhxuAhvqNg.png" /></figure><p>Next , copy this encrypted key and add it in your application config file with prefix ENC like below</p><pre><strong>spring</strong>:<br>  <strong>datasource</strong>:<br>    <strong>username</strong>: root<br>    <strong>password</strong>: ENC(khgTcS1GHuwhynCBlKTLU2G7xtJsSvcD)<br>    <strong>url</strong>: jdbc:mysql://localhost:3306/javatechie<br>    <strong>driver-class-name</strong>: com.mysql.cj.jdbc.Driver<br>  <strong>jpa</strong>:<br>    <strong>show-sql</strong>: true<br>    <strong>hibernate</strong>:<br>      <strong>ddl-auto</strong>: update<br>    <strong>properties.hibernate.dialect</strong>: org.hibernate.dialect.MySQL5Dialect</pre><p>That’s the tutorial about encrypting passwords in Spring Boot configuration file using Jasypt library</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9ee731701e70" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Access Your REST APIs with HTTPie]]></title>
            <link>https://javatechie4u.medium.com/access-your-rest-apis-with-httpie-dde4d4838371?source=rss-f5f1cc1bc31------2</link>
            <guid isPermaLink="false">https://medium.com/p/dde4d4838371</guid>
            <dc:creator><![CDATA[Javatechie]]></dc:creator>
            <pubDate>Thu, 12 Mar 2020 17:57:37 GMT</pubDate>
            <atom:updated>2020-03-12T17:59:55.306Z</atom:updated>
            <content:encoded><![CDATA[<p>Modern Command Line HTTP Client</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hOdMmr1p7xiRbyzhLWYb2g.jpeg" /></figure><p><strong>Basic Introduction about HTTPie</strong></p><p>HTTPie (pronounced <em>aitch-tee-tee-pie</em>) is a command line HTTP client. Its goal is to make CLI interaction with web services as human-friendly as possible.</p><p>It provides a simple http command that allows for sending arbitrary HTTP requests using a simple and natural syntax, and displays colorized output. HTTPie can be used for testing, debugging, and generally interacting with HTTP servers.</p><h3>Installation (Windows OS)</h3><ol><li>Download the <a href="https://www.python.org/downloads/windows/">Windows x86–64 executable installer</a> and run it.</li></ol><p>2. Once you install this python version then next step we need to Install pip/Python and upgrade pip</p><p><em>python -m pip install — upgrade pip</em></p><p>3. Install pip setup-tools , run below command</p><p><em>pip install — upgrade pip setuptools</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Qjy128_K2BhT0dwc2AQrpw.png" /></figure><p>4. Install HTTPie , run below commands</p><p><em>pip install — upgrade httpie</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GrvRDgue2WQ7x1-Bvw_jMQ.png" /></figure><p>Cool , Now we are done with installation stuff , so let’s begin with Usages</p><p><strong>Example with HTTP Methods</strong></p><p>Already i created one <a href="https://github.com/Java-Techie-jt/spring-boot-crud-example">spring boot CRUD Example</a> let’s access all the REST Endpoints with HTTPie Command Line client</p><p><strong><em>POST Method :</em></strong></p><p>HTTP URL : http POST <a href="http://localhost:9191/addProduct">http://localhost:9191/addProduct</a> name=bike quantity=1 price:=90000</p><p>If you observe /addProduct is Endpoint URL and name,quantity &amp; price are Request Body to access REST API</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aPkpr4bQUnukyH-a9mmrTA.png" /></figure><p><strong><em>GET Method :</em></strong></p><p>HTTP URL : http GET <a href="http://localhost:9191/products">http://localhost:9191/products</a></p><p>This Endpoint will return list of product object available in DataBase</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/680/1*a2zCVOC2AXhr5nxPGEfcaA.png" /></figure><p><strong><em>GET Method with Argument :</em></strong></p><p>HTTP URL : http GET <a href="http://localhost:9191/product">http://localhost:9191/product</a>/mobile</p><p>This Endpoint will return Product object by name where name is request path argument</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/751/1*pQt2j4Su28eev6qCygfbCA.png" /></figure><p><strong><em>HTTP PUT Method:</em></strong></p><p>HTTP URL : http PUT <a href="http://localhost:9191/addProduct">http://localhost:9191/</a>update id=6 name=bike quantity=1 price:=190000</p><p>Usually PUT method used for UPDATE operation , so if you noticed we were giving request body to update (Verify with POST method price for Bike previously it was 90000 now we are updating price to 190000)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JR7hdWvbml3VUeW6m9lujw.png" /></figure><p><strong><em>HTTP DELETE Method :</em></strong></p><p>HTTP URL : http PUT <a href="http://localhost:9191/addProduct">http://localhost:9191/</a>delete/6</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/729/1*21vn1OMQbAApACMPdOv4Iw.png" /></figure><h3>Wrapping Up</h3><p>HTTPie is a light-weight but extremely powerful tool to communicate easily with an HTTP server. The ability to invoke a variety of HTTP methods with an HTTP command and other sensible default values makes it a perfect candidate in RESTful and microservices ecosystem …</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dde4d4838371" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>