RSS

Monthly Archives: March 2017

Spring Security Basics

Episode 63

Welcome to the next installment of the series about Spring-based web applications development. So far we have covered Angular JS fronted, Spring core, webservices, database access and unit tests. Today we are going to take care of our application security – basic authentication and authorization, users, roles, custom login form and method level security.

70d42d4aaa6aede4b84bde43e3dead63

Spring Security project started as Acegi security around 2004 and initially focused on custom authorization, using standard Java Enterprise Edition container managed authentication. Version 1.0.0 became official Spring sub-project in 2006 and year later was re-branded to Spring Security. Say hello to Alice, Bob and Eve.

Foundations

We should briefly clarify some security terminology, which might sometimes by confusing:

Identification is stating a subject identity, like user name, without yet providing any proof for that (Hi, I’m Alice). Read the rest of this entry »

 
Leave a comment

Posted by on March 30, 2017 in Spring, Technology

 

Tags: , , ,

Unit Testing Basics

Episode 62

Previous episode was about talking to database in Spring. Today we will continue exploring basics of building web applications, and talk about unit testing. This time, however, we are going to leave Spring alone for a moment and focus on plain unit tests using JUnit, Mockito and DataProvider.

4d821599ecc582a1ab14fe16e0594e27

As usual, all the code presented in this article is available on my GitHub in the same project as before. This tag corresponds to project state at the time of writing this article. Let’s start with some basic ideas, and why write unit tests in the first place.

Client does not pay for unit tests

Well, I have heard that once. I was in a project where code coverage was around 2%, and when I was actively trying to improve upon that, manager took me to a one on one discussion to a small room. Starting to cover old projects with tests is often difficult, but in the end the business pays much more for not having decent automatic test harness than saving on skipping it and only producing features. It simply pays back in the long run. There are less unnoticed bugs, design is cleaner, the amount of tedious repetitive work is dramatically reduced. Often it is much faster to Read the rest of this entry »

 
3 Comments

Posted by on March 23, 2017 in Clean Code, Spring, Technology

 

Tags: , , ,

Spring Data JPA Basics

Episode 61

In the previous episode, we covered basic concepts of web services in Spring framework. Today we will build upon that foundation and take a look on how to transfer some data between our Spring Boot application and the database. Getting started with this part requires just a bit of effort to set up the aforementioned database and configuring our application, so the two can talk to each other, but no worries I will go through this step by step.

wallup-13611.jpg

As usual, all the code presented in this article is available on my GitHub in the same project as before. This tag corresponds to project state at the time of writing this article. Before we dive into the configuration and code, let’s start with some underlying concepts, namely ORM and JPA.

Foundations

ORM, or Object Relational Mapping is a technique of mapping data between objects in object oriented languages and relational databases. Complications stem from the fact, that objects form graphs in the mathematical sense, and relational databases comprise of Read the rest of this entry »

 
4 Comments

Posted by on March 16, 2017 in Spring, Technology

 

Tags: , , ,

Spring Web Basics

Episode 60

Here is the second part of Spring back-end series for beginners. Part zero appeared half year ago, and was focused on Angular front-end. Part one was two weeks ago, and consisted of some basic concepts of Spring framework including inversion of control, dependency injection, beans, configuration and profiles. Today we are going to look into Spring web, in particular web services and handling incoming HTTP requests. There will be no fancy front-end stuff this time, just naked request and response.

steampunk_spider_lamp_by_catherinetterings-d6ugb5v

As usual the introduction to the topic and going over basic concepts might well be at least one separate article but let’s try to do all at once. We will cover the concept of HTTP protocol, servlets, web services, REST and JSON. If you would like to play with complete application working out of the box, visit my GitHub project Spring Angular Intro. This tag corresponds to project state at the time of writing this article.

Foundations

HTTP or Hypertext Transfer Protocol, belongs to the application layer of Internet Protocol Suite, so it’s the highest-level layer above transport layer (like TCP), network layer (like IP) and link layer (like Ethernet). HTTP request contains Read the rest of this entry »

 
2 Comments

Posted by on March 9, 2017 in Technology

 

Tags: , , , , ,

Boiling Frogs Wrocław 2017

Episode 59

Last Saturday, on February 25, I attended Boiling Frogs – software development conference held in my home city, Wrocław. It’s the second edition of the event, this time it took place at Wrocław Congress Center near Cenntenial Hall, one of the city landmarks. There were 31 talks / lightning talks in total, spread across three tracks covering variety of subjects not tied to any specific programming platform but focusing mostly on more generic aspects of coding, building organizations, solving problems and software craftsmanship in general.

c2d4qvhwiaaalrh

Unfortunately, I arrived a bit late and missed the keynote. Apparently, the closer you live to the place you are supposed to be on time, the lower are the chances of it happening – the universal rule. In addition, the day before I drove 300 km to Kraków and back again, and people need to sleep sometime.

Talks

I managed to be on six talks and one lightning talk in total, basically all of them were really good. let’s do a small recap of each of them. Read the rest of this entry »

 
Leave a comment

Posted by on March 2, 2017 in Technology

 

Tags: ,