<?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 Oben ISIK on Medium]]></title>
        <description><![CDATA[Stories by Oben ISIK on Medium]]></description>
        <link>https://medium.com/@isikoben?source=rss-2052856b9f78------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*veNfzyTCOSwX3NT1.jpg</url>
            <title>Stories by Oben ISIK on Medium</title>
            <link>https://medium.com/@isikoben?source=rss-2052856b9f78------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 06:42:34 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@isikoben/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[How to Make a Stateless (Session-less) Authentication With Spring]]></title>
            <link>https://medium.com/@isikoben/how-to-make-a-stateless-session-less-authentication-with-spring-61a81d5da?source=rss-2052856b9f78------2</link>
            <guid isPermaLink="false">https://medium.com/p/61a81d5da</guid>
            <category><![CDATA[spring]]></category>
            <category><![CDATA[authentication]]></category>
            <category><![CDATA[java]]></category>
            <dc:creator><![CDATA[Oben ISIK]]></dc:creator>
            <pubDate>Fri, 26 Feb 2016 19:05:59 GMT</pubDate>
            <atom:updated>2016-02-26T19:06:27.212Z</atom:updated>
            <content:encoded><![CDATA[<p>World is changing, trends are changing. Today, making an API means having a REST API with token authentication. In this article, you will discover what is going on with this mechanism.</p><p>If we think about the meaning of authentication, it seems that it is all about a client identifying itself to the server. After client identification is done, the server can remember the client each time the request comes from the client. There are two common approaches to authentication mechanisms: one of them is called “Session Cookie Based” and the other one is “Token Based”.</p><p>In this article, I want to focus on how to deal with automatic re-authentication of each HTTP and HTTPS requests.</p><h4>What Does “Session Cookie Based Authentication” Mean?</h4><p>In today’s world, especially for corporate businesses, the most common usage of authentication is the session-based approach. In the session-based approcah, a session id — which is a kind of server generated token — is generated and stored in a cookie within the JSESSIONID paramter. This means that the server stores the session key in itself so when the server reboots or requests are redirected to another server by load balancers, your “state” of session key becomes useless.</p><h4>What Does “Stateless Authentication” Mean?</h4><p>Whenever you are talking about REST API’s , API keys are mentioned too. Basically, they involve sending custom tokens or custom keys within the HTTP Request header. There are several approaches such as OAUTH1, OAUTH2, Basic Authentication, etc. for implementing stateless authentication and today we will be focus on “Server Signed Token” approach that may be life-saving for your implementations.</p><h3>Server Signed Token Approach</h3><p>First of all, it is easy to imagine that, in this approach; if server gets a request from the client, the client should send a token and the server should check and sign it before giving any response to the client.</p><p>With “Server Signed Tokens” a user identification data is shared with the server for authentication and when the server authenticates the user, it gives a hash key which is called a “token” to the client. After this step, the client can use this token to ask for any request to the server so the server should sign and approve that the token is valid for request.</p><p>Let’s get into the details of the implementation of this approach.</p><p>The first step is authentication. In the authentication step, the client sends its user-specific identification data to the server and if this data is correct, the server response is a token to the client with HTTP 200 OK. If the data is incorrect, the server response is an HTTP 403 Forbidden.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/942/0*nlRSZiLDberB3Sfx.png" /><figcaption>Authentication Mechanism</figcaption></figure><p>After this approval is done, the client can send another requests without giving any user-specific identification data to the server again again. The client only uses this token for further requests.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/897/0*vMvvgEZMtBwLgqB-.png" /><figcaption>Request Response Mechanism</figcaption></figure><h3>The Recipe for Implementing Token Approach With Spring</h3><p>To understand all of the steps easily, it is good to have a scenario. For example, we want to make a login page with the inputs of username and password. And, after the user is logged in successfully, we want to show the user profile page with user information in it.</p><p>In Spring, we have WebSecurityConfigurerAdapters which help to implement the security configurations of our spring project easily. In these adapters, there is a “configure” method for HTTP securities.</p><p>In this configure method, we should add two filters which will be used in login step and the authentication step.</p><blockquote>.addFilterBefore(new LoginFilter(new AntPathRequestMatcher(“/api/auth/login”)), UsernamePasswordAuthenticationFilter.class)<br> .addFilterBefore(new AuthFilter(), UsernamePasswordAuthenticationFilter.class);</blockquote><p><a href="https://github.com/lixylabs/LIXY_CORE/blob/master/ftapi/src/main/java/com/lixy/ftapi/conf/WebSecurityConfiguration.java">Full Verion Of The Java Class Can Be Found Here</a></p><p>As you see in the last two lines, we have a <a href="https://github.com/lixylabs/LIXY_CORE/blob/master/ftapi/src/main/java/com/lixy/ftapi/filter/LoginFilter.java">“Login Filter”</a> which will be called with any request path equals to “/api/auth/login”. Also, for any other requests the “Auth Filter” will be called before each request is processed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/789/0*x8VNK8NDA3z50f6O.png" /></figure><p>Spring provides an “<a href="https://docs.spring.io/spring-security/site/docs/3.2.5.RELEASE/apidocs/org/springframework/security/web/authentication/AbstractAuthenticationProcessingFilter.html">AbstractAuthenticationProcessingFilter</a>” which is used for authentication.</p><p>Because of this helpfull abstract class, we extend our Login Filter from the AbstractAuthenticationProcessingFilter. This filter has “attemptAuthentication”, “successfulAuthentication” and “unsuccessfulAuthentication” methods to override.</p><p>In attemptAuthentication method, the aim is to create an Authentication object (<a href="https://dzone.com/articles/eclipse-javadoc%3A%E2%98%82=ftapi/%5C/Users%5C/obenisik%5C/.m2%5C/repository%5C/org%5C/springframework%5C/security%5C/spring-security-core%5C/4.0.3.RELEASE%5C/spring-security-core-4.0.3.RELEASE.jar%3Corg"><strong>org</strong></a><strong>.</strong><a href="https://dzone.com/articles/eclipse-javadoc%3A%E2%98%82=ftapi/%5C/Users%5C/obenisik%5C/.m2%5C/repository%5C/org%5C/springframework%5C/security%5C/spring-security-core%5C/4.0.3.RELEASE%5C/spring-security-core-4.0.3.RELEASE.jar%3Corg.springframework"><strong>springframework</strong></a><strong>.</strong><a href="https://dzone.com/articles/eclipse-javadoc%3A%E2%98%82=ftapi/%5C/Users%5C/obenisik%5C/.m2%5C/repository%5C/org%5C/springframework%5C/security%5C/spring-security-core%5C/4.0.3.RELEASE%5C/spring-security-core-4.0.3.RELEASE.jar%3Corg.springframework.security"><strong>security</strong></a><strong>.</strong><a href="https://dzone.com/articles/eclipse-javadoc%3A%E2%98%82=ftapi/%5C/Users%5C/obenisik%5C/.m2%5C/repository%5C/org%5C/springframework%5C/security%5C/spring-security-core%5C/4.0.3.RELEASE%5C/spring-security-core-4.0.3.RELEASE.jar%3Corg.springframework.security.core"><strong>core</strong></a><strong>.Authentication</strong>) that stores the authorities, credentials, details, principal object, and authenticationResult.</p><pre>@Override</pre><pre>public Authentication attemptAuthentication(HttpServletRequest request, HttpServletResponse response)</pre><pre>throws AuthenticationException, IOException, ServletException {</pre><pre>UserAuthentication auth = (UserAuthentication) tokenAuthenticationService.getAuthenticationForLogin(request,</pre><pre>response);</pre><pre>if (!auth.isAuthenticated()) {</pre><pre>throw new UserAuthenticationException(&quot;Auth to FTAPI is Failed.&quot;, auth);</pre><pre>}</pre><pre>return auth;</pre><pre>}</pre><p>If the attemptAuthentication method throws a <a href="https://docs.spring.io/spring-security/site/docs/3.1.7.RELEASE/apidocs/org/springframework/security/core/AuthenticationException.html">UserAuthenticationException</a> the unsuccessfullAuthentication method is called, otherwise the successfullAuthentication method will be called.</p><p>So, the aim of this method is to just check whether the username and password is correct or not, and then set the isAuthenticated parameter to true and false. If the parameter is false, it throws an exception to process the success and fail operations.</p><pre>As it is easy to understand from the implementation, the token is created in the addAuthentication method and stored in the security context.</pre><p>A common question is: where do you store the tokens for both client and server. It depends on your requirements. For example, you can create the token and store it in a cache server with a token, user hashmap and when the user sends a request with that token, you can get the token details from this cache server or you can store the token you generated in a database, etc.</p><p>When the server creates the token, this token should be told to the client in the HTTP response. The common best practice of that is to respond to this token in the header of the HTTP reponse with a parameter name which is called “X-AUTH-TOKEN”. This step is very important because the client will always come with this X-AUTH-TOKEN parameter which contains a token for each HTTP request.</p><p>After the token handshake is done, when the client makes a request to the server, <a href="https://github.com/lixylabs/LIXY_CORE/blob/master/ftapi/src/main/java/com/lixy/ftapi/filter/AuthFilter.java">Auth Filter</a> will be called. The working style of the auth filter is very easy because the only job it needs to do is get the X-AUTH-TOKEN value from the request header and get the user object from the cache server. If the user object already exits, that means there is a user that has a valid and not dead token. If the user object does not, all the filter needs to do is changing the response HTTP status code to <a href="https://en.wikipedia.org/wiki/HTTP_403">403</a> which means unforbidden.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=61a81d5da" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Başarı, %99 Oranında Başarısız Olmaktır…]]></title>
            <link>https://medium.com/@isikoben/ba%C5%9Far%C4%B1-99-oran%C4%B1nda-ba%C5%9Far%C4%B1s%C4%B1z-olmakt%C4%B1r-36afa8a475a1?source=rss-2052856b9f78------2</link>
            <guid isPermaLink="false">https://medium.com/p/36afa8a475a1</guid>
            <category><![CDATA[medium-turkish]]></category>
            <category><![CDATA[türkçe]]></category>
            <dc:creator><![CDATA[Oben ISIK]]></dc:creator>
            <pubDate>Sat, 22 Aug 2015 19:54:28 GMT</pubDate>
            <atom:updated>2015-08-22T19:54:28.892Z</atom:updated>
            <content:encoded><![CDATA[<p>“Success is 99% failure.” — Soichiro Honda</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/987/0*eQIbtPgQumSya81t.jpg" /></figure><p>Ben başarısız oldum.</p><p>Sen de başarısız oldun.</p><p><strong>Hepimiz</strong> başarısız olduk…</p><p>Size kendi başarısızlıklarımdan biriyle ilgili örnek vermek istiyorum.</p><p>Herşey 2006 yılında başladı. Halkalı’da %90 ı düz lise, %10 u süper lise olan bir lisede eğitimimi sürdürüyorum. Lise 2.sınıftayım ve birileri bana ÖSS denilen bir sınavdan bahsediyor. Üniversite sınavının hayatım için önemli bir etkisinin olabileceğini o zamanlarda idrak etmeye başlıyorum. Hiç bir şekilde geç mi kaldım yoksa zamanında mı farkına vardım bilmiyorum. Günler ayları, aylar da yılları kovalıyor ve 2007 yılında sınava giriyorum. Sonuç ise başarısızlık, emekler boşa gidiyor ve Türkiye genelinde 11 binincilikle yetiniyorum. Karşındaki etrafındaki insanların yorumlarını dinlemekten kendini bile dinleyemiyorsun, bir anlık toparlanma oldu ve tekrar sınava hazırlanmaya karar verdim. Sonucunda da 1.600 lerde bir sıralama ile 2008 yılındaki sınavı sonlandırdım.</p><p>Aslında anlatmak istediğim şu; hepimizin hayatında sağlam başarısızlıklar yok mu ? Var. Aslında hayatın çoğunda başarısızlıklarımız bizi başarıya götürüyor. Bir konuda başarısız oldukça tecrübemiz artıyor ve ikinci bir konuda başarılı olabilme ihtimalimiz artıyor. Peki nedir başarıyı oluşturan faktörler ? Bence en önemli iki sır her türlü başarı için yol gösterici, hiç öyle düzinelerce liste yapmaya gerek yok</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/72/0*pOzFf9bxbXMmFj0G.png" /></figure><h2>Sır 1 : Mutlaka Ama Mutlaka Öğrenmeye Devam Etmelisin</h2><p>Öğrenmenin yaşı yoktur diye klişe bir laf var değil mi ? O laf her ne kadar artık ezberlediğimiz için bize pek de etkileyici gelmese de, aslında çok ama çok önemli. Hiç bir şeyi en iyi bilen olduğunuzu düşünmeyin ve size göre kat ve kat tecrübeli insandan ne kadar çok şey öğrenebilecekseniz, kat be kat tecrübesiz insanlardan da bir o kadar çok şey öğrenebilirsiniz bunu unutmayın. Mesela, şu anda türev, integral sorusu gelse, üniversiteye ilk başladığınız MAT101 günlerinizin kaç katı daha yavaş çözersiniz soruyu eminim tahmin bile edemiyorsunuzdur</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/72/0*AByskMAOnlc7Jfju.png" /></figure><p>Bu nedenle birileri aslında sizin eskiden çok iyi bildiğiniz şeyleri daha yeni öğrendiği için size bir bilgi tazeleme kaynağı olabilir, bunu aklınızdan çıkarmayın.</p><h2>Sır 2 : Bir An Önce Başarısız Ol</h2><p>Aslında sistem oldukça basit : Create It -&gt; Launch It -&gt; Learn From It and Fail Fast</p><p>Bir fikriniz var, hızlıca bir prototip derecesinde ve beğenmeyeceğiniz bir örneğini oluşturun, hemen yayınlayın, dersler çıkarın ve batırıyorsanız çabucak batırın. Bu size ikinci denemeniz için zaman kazandırır.</p><p>Sizleri güzel bir videoyla başbaşa bırakmak istiyorum;</p><p>Sevgiler,</p><p>Oben</p><p><em>Originally published at </em><a href="https://medium.com/new-story?importUrl=http%3A%2F%2Fwww.obenplus.com%2Fblog%2Fbasari-%2599-oraninda-basarisiz-olmaktir%2F"><em>www.obenplus.com</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=36afa8a475a1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Java’da SimpleDateFormat İle Uğraşırken Dikkatli Olun!]]></title>
            <link>https://medium.com/@isikoben/java-da-simpledateformat-i%CC%87le-u%C4%9Fra%C5%9F%C4%B1rken-dikkatli-olun-9f680dcd496f?source=rss-2052856b9f78------2</link>
            <guid isPermaLink="false">https://medium.com/p/9f680dcd496f</guid>
            <category><![CDATA[java]]></category>
            <dc:creator><![CDATA[Oben ISIK]]></dc:creator>
            <pubDate>Sat, 22 Aug 2015 19:53:19 GMT</pubDate>
            <atom:updated>2015-08-22T19:53:19.717Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/400/0*gh9S2RL9szIzJ_vH.gif" /></figure><p>Java’da SimpleDateFormat ile uğraşırken dikkatli olmak gerekiyor. Çünkü eğer gerçekten çok şanssız biriyseniz her an bir heisenbug ile karşılaşabilirsiniz. (HeisenBug nedir merak ediyorsanız <a href="https://en.wikipedia.org/wiki/Heisenbug">buraya </a>tıklayın)</p><p>İlk olarak JavaDoc da SimpleDateFormat nasıl tarif ediliyor inceleyelim;</p><p>SimpleDateFormat allows you to start by choosing any user-defined patterns for date-time formatting. However, you are encouraged to create a date-time formatter with either getTimeInstance, getDateInstance, or getDateTimeInstance in DateFormat. Each of these class methods can return a date/time formatter initialized with a default format pattern. You may modify the format pattern using the applyPattern methods as desired. For more information on using these methods, see DateFormat.</p><p>Yani elinizde kullanıcı tanımlı bir pattern var, bu patterni kullanarak date-time formatlama yapıyorsunuz. Peki, SimpleDateFormat, thread-safe midir ? Maalesef.</p><p>Bu konuda java doc da alt kısımlarda aşağıdaki gibi bir açıklama var;</p><p>Date formats are not synchronized. It is recommended to create separate format instances for each thread. If multiple threads access a format concurrently, it must be synchronized externally.</p><p>Yani thread-safe olmadığı için aynı anda farklı iki thread date formatlama işlemi yaparken, birbirlerinin formatlarını kullanma riski ile karşı karşıyadırlar. Yani aşağıdaki masum görünümlü kod, pek de masum bir kod değil</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/72/0*qSzs6-sT_AkI2Q97.png" /></figure><p>privatestaticfinalDateFormat dateFormatter=newSimpleDateFormat(“yyyy-MM-dd HH:mm:ss”);</p><p>Diyelim ki yukarıdaki gibi bir dateformatter değişkenine sahipsiniz ve bu static instance ı kullanarak farklı threadler üzerinden işlemler yapıyorsunuz. Muhtemelen denemelerin çok büyük çoğunluğunda sorun yaşamazsınız fakat yüzlerce yıl geriden gelen hatalı bir date sonucu almamanız imkansız da değil.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/72/0*a51aQxKzlCx1Yu90.png" /></figure><p>Bu tarz sorunları yaşama riskini ortadan kaldırmak için ne gibi çözümler var diyecek olursanız da;</p><h2>1. syncronized Kullanımı</h2><h2>2. FastDateFormat Kullanımı</h2><p>Apache Commons’un <a href="https://commons.apache.org/proper/commons-lang/javadocs/api-2.6/org/apache/commons/lang/time/FastDateFormat.html">FastDateFormat </a>class ı thread-safe işlem yapmak üzere uygundur.</p><h2>3. Joda Time Kütüphanesi</h2><p>Ben kendi uygulamalarımda genel olarak <a href="http://joda-time.sourceforge.net/">JodaTime </a>kullanmayı tercih ediyorum. Çünkü sadece date formatlamasının thread-safe olması değil, bir çok özelliği de beraberinde getirmesi benim için oldukça avantaj.</p><h2>4. Java 8 ile gelen DateTimeFormatter Classı</h2><p>Java8 ile thread safe bir class geldi. Adı da <a href="http://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html">DateTimeFormatter</a>. Eğer Java8 ile geliştirme yapıyorsanız SimpleDateFormat classının yerine terih etmenizi öneririm.</p><p>Bir de StackOverFlow da ThreadLocal kullanımının önerildiğini gördüm fakat, ThreadLocal memory leak problemlerine yol açabileceği için bence kullanımı pek de doğru olmayan bir çözüm. Bu nedenle önermiyorum.</p><p><em>Originally published at </em><a href="http://www.obenplus.com/blog/javada-simpledateformat-ile-ugrasirken-dikkatli-olun/"><em>www.obenplus.com</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9f680dcd496f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Java main() Metodu Hakkında İlginç Detaylar]]></title>
            <link>https://medium.com/@isikoben/java-main-metodu-hakk%C4%B1nda-i%CC%87lgin%C3%A7-detaylar-8f2ba7e0542e?source=rss-2052856b9f78------2</link>
            <guid isPermaLink="false">https://medium.com/p/8f2ba7e0542e</guid>
            <category><![CDATA[türkçe]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[java]]></category>
            <dc:creator><![CDATA[Oben ISIK]]></dc:creator>
            <pubDate>Sat, 22 Aug 2015 19:48:00 GMT</pubDate>
            <atom:updated>2015-08-22T19:48:00.234Z</atom:updated>
            <content:encoded><![CDATA[<p>Hepimiz yazılım geliştirme serüvenimiz boyunca sıklıkla main metodları ile karşı karşıya kalırız. Peki bu kadar çok kullandığımız bu metod hakkında yeterli bilgiye sahip miyiz ?</p><h3>main() methodu string array’den farklı input alabilir mi ?</h3><p>Hayır. main() metodunun input argumanı sadece ve sadece string array olabilir.</p><h2>main() metodunun dönüş tipini void den farklı bir tip yapabilir miyiz?</h2><p>Hayır yapamayız. main() metodunun dönüş tipi sadece ve sadece void olabilir. Void haricindeki hiç bir tip kabul edilemez, sistem main metodunu bulamaz.</p><h2>main() metodu neden static olmak zorunda? Olmasa olmaz mı ?</h2><p>Main metodu static olmak zorundadır. Çünkü eğer static olmasaydı, JVM başlangıçtaclass ın bir instenceına sahip olmadığı için ilgili class ı instentiate edemezdi. Instentiate etmek için static metod kullanmasaydık, constructor a ihtiyaç olacaktı. Bu durumda da default constructor değil de custom constructor sahibi olan class ların inputuna karar verilemeyeceği için başlatmak da mümkün olmayacaktı.</p><h2>main() metodunu private ya da protected olarak tanımlayabilir miyiz?</h2><p>Hayır, main() metodu sadece public olmalıdır. private ya da protected olarak tabiki overload ederek main metodu tanımlayabilirsiniz fakat JVM tarafından accecible olmaz bu metodlar.</p><h2>main() metodu override edilebilir mi ?</h2><p>Hayır edemezsiniz. Çünkü main() metodu compile time da bound edilir. Java’da zaten hiç bir static metodu override edemezsiniz.</p><h2>main() metodu syncronized edilebilir mi ?</h2><p>Evet edebilirsiniz. Buna engel bir durum yoktur. main() metodunun süslü parantezleri içersinde java nın sunduğu her kodu yazabilirsiniz.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8f2ba7e0542e" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>