Buscar este blog

Theme images by MichaelJay. Powered by Blogger.

Datos personales

QA UX/DX Engineer

We are looking for a full-time Quality Assurance UX/DX Engineer, that will help customers to evolve their internal quality processes. As a...

Author Info

Video Of Day

Flickr

We deliver intelligence

Team of experts working to fulfill your software needs

About Us


Expertise

We are a team of professionals with extensive experience in the field of enterprise application development.

Our Services

We provide various services according to the needs of your business.

Efficiency

Trust in our knowledge, coding is our passion.

Contact

Feel free to contact, tell us your needs and we'll help you out.

Are you interested in what we do so far?
Let's talk about your project !

GET IN TOUCH

Technologies


Flowing Blog
Explore our ideas

Tuesday, December 4, 2018

Wednesday, November 14, 2018

Monday, September 24, 2018

Developing modern web-apps with Vaadin @ UNL

Last Wednesday we gave a presentation in Universidad Nacional del Litoral, where we explained some concepts related to developing web applications using the latest version of the Finnish platform.
We started explaining what it means to develop a client-server application nowadays, and then some key features of the platform, like the lack of need of browser plugins and the fact that it is completely open-source.
Then we introduced Web Components, a key technology, that is the ground base for the good looking components that are built-in in the platform. Also some introduction for Polymer Project. For more information about these technologies, we recommend reading about it in the WebComponents official site, the Polymer Project official site, and also at Vaadin's site.
Then we started talking about Flow, the Java API for creating modern web-apps using Vaadin's components in the client side. We showed some small examples covering the most significant features like server side DOM manipulation, routing, data binding and synchronization.
If you want to learn more about Flow, the official documentation site is a good place to start.

Students at Universidad Nacional del Litoral


Finally we developed a small application using Flow, showing how easy is to create a good looking web application that can edit data from a back end using Grid, one of the most advanced components.
After the speech, the students were interested in knowing more about the framework and some real life examples. So we decided to upload to GitHub the application that we developed in front of the audience. We added some tags that show each step in the process, feel free to download the sources and try modifying it to cover other use cases!

Lot of questions!

We also recommended another article that we wrote, telling the main steps for developing a complete application that covers how to invoke external REST APIs from the server side.
The experience was great and we found a lot of interest in the framework, so probably we are going to repeat the presentation again soon in another place.
Keep in touch with us for updates!

Javier explaining Flow basics


Tuesday, July 3, 2018

Vaadin 10 + Spring Demo application: World Cup Rusia 2018 stats

To test out some new interesting web technologies, we decided to go ahead and build a small demo application that will point out ideas that could potentially help a developer when trying to decide which ones to use in a new project. We decided to create a small application with responsiveness in mind, that would show real time and aggregated data about the current Football World Cup event that is taking place in Russia.

Technologies

The chosen technologies where:
  • Vaadin 10: The brand new version of the popular framework, that is powered by the new standards being pushed by the most popular browsers.
  • SpringFramework: The almost de-facto standard dependency injection framework, that stands as the backbone of almost every java project that are currently being built.
  • REST API: Our project uses the API available here. That API exposes data as a REST API with information being delivered in JSON format.

Features

This is a short list of currently supported features:
  • The application is responsive, it will correctly display information regardless the device being used. This feature is achieved by using Vaadin & Polymer technologies.
  • Depending on the device that you're browsing the site (especially mobile phones), you can add the application to the home screen, so it will look like a native application. The only catch is that it will not function in offline mode (yet, maybe sooner).
  • You can follow the matches in realtime. Using WebSockets, the application maintains an opened communication pipe between the browser and the server, so the updates can be informed to the client as soon as they are received from the API

Construction

You need to have a good starting point to start any new project. For us it was the Vaadin Base Project with String starter. By choosing this option, we could benefit of the fact that it already has a tested and working Spring configuration, so it was an easy decision. 

Responsiveness

We achieved this goal, by starting also a parallel development: a new Addon for the Vaadin platform that helps you to build new applications using a simple skeleton that takes care of building the usual visual elements present in a responsive application: hamburger menu, paper-cards and more.
Besides that, we also used some CSS techniques as media queries to make the final touches.

PWA

To allow the application to be added to the home screen of your device, and then showing it as a native application, we generated a PWA manifest, with some properties that you can easily mimic, by using a tool like the App Manifest Generator.

Realtime updates

This feature is really easy to implement, given Vaadin's @Push tecnology, based on websockets. Just adding a simple annotation to your main layout will give life to your bubbling screen.
You can learn more about this technology in Vaadin's official documentation.

Roadmap

These are the things we would like to implement in the near future:
  • Support for offline message that tells you that you need connectivity to use the app
  • Support for notifications
  • Localization
You can reach the demo online, by accessing: http://worldcup.flowingcode.com/ ... Try adding it to the home screen of your mobile device!
If you want to give us feedback, feel free to create issues in the GithHub page.
Finally some interesting links regarding these technologies:

Monday, April 9, 2018

ComboBox lazy loading with REST API in Vaadin 8

In this post we'll explore how to access a REST service in order to display items in a ComboBox in Vaadin 8.
First, we'll implement a REST service with Spring Boot, as described here
The web service will be exposed at http://127.0.0.1:8081/api/countries. It will receive no parameters and return an array containing the name of all the countries known by the JVM (the Geography knowledge of the JVM is amazing!).

@RestController
public class CountriesController {

    @RequestMapping("/api/countries")
    public String[] getCountries() {
        return countries().toArray(String[]::new);
    }    

    private static Stream<String> getCountries() {
        return Stream.of(Locale.getISOCountries())
            .map(countryCode -> new Locale("", countryCode))
            .map(locale->locale.getDisplayCountry(Locale.ENGLISH))
            .sorted();
    }
}
Next, we'll implement a REST client that consumes our REST API
public class CountriesClient {        

    private static String ALL_COUNTRIES_URI = "http://127.0.0.1:8081/api/countries";

    public Stream<String> getAllCountries() {
        RestTemplate restTemplate = new RestTemplate();
        String[] countries = restTemplate.getForObject(ALL_COUNTRIES_URI, String[].class);
        return Stream.of(countries);
    }
}
We'll need to add the dependencies for spring-web and jackson-databind in the project's POM (for a detailed explanation of consuming REST services with Spring, you can check this tutorial https://spring.io/guides/gs/consuming-rest/)
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-web</artifactId>
        <version>5.0.2.RELEASE</version>
    </dependency>

    <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-databind</artifactId>
        <version>2.9.4</version>
    </dependency>
Now, we'll write a small application that loads the countries form the REST client, and displays them in a combobox:
    @Theme(ValoTheme.THEME_NAME)
    public class MyUI extends UI {

        private CountriesClient client = new CountriesClient();

        @Override
        protected void init(VaadinRequest vaadinRequest) {
            VerticalLayout layout = new VerticalLayout();
            ComboBox<String> cbCountry = new ComboBox<>();
            cbCountry.setWidth(300, Unit.PIXELS);
            initializeItems(cbCountry);

            layout.addComponents(cbCountry);
            setContent(layout);
        }

        private void initializeItems(ComboBox<String> cbCountry) {
            cbCountry.setItems(client.getAllCountries());
        }

        @WebServlet(urlPatterns = "/simple", asyncSupported = true)
        @VaadinServletConfiguration(ui = MyUI.class, productionMode = false)
        public static class MyUIServlet extends VaadinServlet {
        }

    }
While this approach works, there is a drawback: all the items are loaded when the UI initializes, and setItems instantiates a ListDataProvider, which stores all the items in memory until the combobox itself is disposed. (This is not so critical in this case, since there are only 250 countries, but imagine a combobox loaded with thousands of items...)
Fortunately, we can do it better by specifying an smarter DataProvider that will take the responsibility of fetching items on demand. For this we'll use the method setDataProvider of ComboBox, that instead of a stream/collection/array of items, receives as parameter a DataProvider<T, String>.
DataProvider<T,F> is an interface where the type parameter T refers to the data type (in this case, the ComboBox<T> item type), and the second parameter is the filter type (which for ComboBox is always String, since the ComboBox is filtered by the text the user writes inside). The Vaadin framework supplies an implementation of DataProvider, named CallbackDataProvider, which has the following constructor:
public CallbackDataProvider(
        FetchCallback<T, F> fetchCallback,
        CountCallback<T, F> countCallback)
The fetch callback returns a stream with the items matching a Query, and the count callback returns the number of items matching a Query (a Query is another object in the Vaadin framework, that contains information about index, limits, sorting and filtering):
    @FunctionalInterface
    public interface FetchCallback<T, F> extends Serializable {
        public Stream<T> fetch(Query<T, F> query);
    }

    @FunctionalInterface
    public interface CountCallback<T, F> extends Serializable {
        public int count(Query<T, F> query);
    }

    public class Query<T, F> implements Serializable {
        private final int offset;
        private final int limit;
        private final List<QuerySortOrder> sortOrders;
        private final Comparator<T> inMemorySorting;
        private final F filter;
        //...
    }
In order to take advantage from the CallbackDataProvider, we'll need to introduce a couple of changes to our REST service (CountriesController).
First, we'll need a method that returns a subset of <count> items, matching a given <filter> and starting at a given <offset>.
    @RequestMapping("/api/countries/list")
    public String[] getCountries(
            @RequestParam(value="filter") String filter,
            @RequestParam(value="offset") int offset, 
            @RequestParam(value="limit")  int count) {
        return countries().filter(country->filter(country,filter))
            .skip(offset).limit(count).toArray(String[]::new);
    }       

    private boolean filter(String country, String filter) {
        return filter.isEmpty() || country.toLowerCase().contains(filter.toLowerCase());
    }
Then, we'll need a method that returns the count of items matching a given <filter>
    @RequestMapping("/api/countries/count")
    public int getCountries(
            @RequestParam(value="filter") String filter) {
        return (int) countries().filter(country->filter(country,filter)).count();
    }
Now, we proceed to adapt the REST client (CountriesClient) to these changes, by adding the following methods:
    private static String GET_COUNTRIES_URI = "http://127.0.0.1:8081/api/countries/list?offset={1}&limit={2}&filter={3}";

    private static String COUNT_URI = "http://127.0.0.1:8081/api/countries/count?filter={1}";

    public Stream<String> getCountries(int offset, int limit, String filter) {
        RestTemplate restTemplate = new RestTemplate();
        String[] countries = restTemplate.getForObject(GET_COUNTRIES_URI, String[].class, offset, limit, filter);
        return Stream.of(countries);
    }

    public int getCount(String filter) {
        RestTemplate restTemplate = new RestTemplate();
        Integer count = restTemplate.getForObject(COUNT_URI, Integer.class, filter);
        return count;
    }
Finally, we integrate the modified service in the UI code:
private void initializeItems(ComboBox<String> cbCountry) {
    cbCountry.setDataProvider(new CallbackDataProvider<>(
        query-> 
            client.getCountries(query.getOffset(),query.getLimit(), getFilter(query)),
        query->
            (int) client.getCount(getFilter(query))
        ));
    }

    private String getFilter(Query<?,String> query) {
        return ((String)query.getFilter().orElse(null));
    }
As a final note, there are other components that also use DataProvider, such as Grid and TwinColSelect.
You can download and run the complete code of this example from github.

Sunday, April 1, 2018

Our first year in review


Today we are celebrating the first birthday of our startup. It's been a long year filled with a lot of experiences and we want to review some of them:
After we started to exist, we also started to grow, new developers joined our team, and accepted new challenges.
We completed all the necessary steps for becoming a full blown company according the laws of our country.
After searching a lot, we found our place in the world, and, of course, we celebrated this achievement!
We wrote a lot of technical notes, as a way of sharing the result of our knowledge and experience with the community. We created an organization in GitHub and then started to contribute with some interesting projects. We also created some social media accounts to share articlesopinions and nice pictures of our #FlowingCodeLife with the community.
Because we think that is never too late to incorporate new knowledge, we started a new internal program called Learning Fridays were we acquire concepts regarding the following subjects:

  • First experience writing a Vaadin 10 Addon
  • Bower, WebJars and Vaadin 10
  • Spring Reactive
  • Domain Driven Architectures
  • Modern Web Layout with Flexbox and CSS Grid
  • Vaadin's Flow
  • Vaadin's Drag & Drop
  • JavaScript Objects and Prototypes 
  • Progressive Web Apps
  • Scaling Java Applications Through Concurrency
  • Machine Learning
  • Refactoring to a System of Systems (Micro services)
  • TensorFlow
  • Microservices with Spring Boot
  • Clean Architecture: Patterns, Practices, and Principles

Finally, we completely defined the internal benefits program of the company and started a recruiting process to make our team bigger.
We think that this new year it's going to be full of new challenges and experiences, so feel free to contact us to know more!

Friday, February 9, 2018

Vaadin Widgetset compiling: Tips & Hints

Hi everyone!
The purpose of this post is enumerating the most common issues when trying to compile the widgetset in Vaadin. But before digging into this, let's explain a little bit what this compiling thing is about.
In Vaadin version 6, 7 & 8, the visual components have two important parts.
The first one is server side, and it's implemented in classic Java classes that are compiled to JVM bytecode.
The second part, on the other hand, is the client side code, written mostly in Java and then compiled in Javascript using GWT project. GWT is basically a Java to Javascript compiler. All of these components (widgets) belong to a set known as widgetset.
The widgetset compilation process is done by executing the GWT compiler to produce the Javascript code associated to all of the Vaadin components that have server and client side code.
That being said, let's go on with those tips!

Verify that everything is correctly configured

There are a lot of ways to compile the widgetset, in this case we will focus in projects that use maven as the build tool, because is the most commonly tool used for this purpose.
The vaadin-maven-plugin will help you on this process, which is a derivation of the gwt-maven-plugin.
Depending on the Vaadin version used, there a are a lot of different configurations, the best thing to do, is to create a small maven project, based on the simplest vaadin maven archetype (com.vaadin:vaadin-archetype-application)
These are the steps for doing this:

  1. Run the command "mvn archetype:generate" from a terminal or command line window
  2. Enter "vaadin" to filter the list of the available archetypes
  3. Choose 5 (currently that's the number of the com.vaadin:vaadin-archetype-application archetype, it could change in the future)
  4. Choose the number before the Vaadin version that you're using (ie: 127 -> 7.7.13, etc.)
  5. Complete the parameters that maven will prompt
After that, maven will generate a small project, and if you take a look to the pom.xml file that was generated, you are going to find something like this:


...

 <build>
  <plugins>
...
   <plugin>
    <groupId>com.vaadin</groupId>
    <artifactId>vaadin-maven-plugin</artifactId>
    <version>${vaadin.plugin.version}</version>
    <executions>
     <execution>
      <goals>
       <goal>update-theme</goal>
       <goal>update-widgetset</goal>
       <goal>compile</goal>
       <!-- Comment out compile-theme goal to use on-the-fly theme compilation -->
       <goal>compile-theme</goal>
      </goals>
     </execution>
    </executions>
   </plugin>
...

You can copy the <plugin> definition to your pom.xml file. Take into account that the version is parametrized to use the vaadin.plugin.version maven variable, define it if you don't have it in your pom.xml file.
With this change, whenever you build your project, the vaadin-maven-plugin will try to compile the widgetset if needed.

Check that you have the Java sources of the addons available in your project

One thing that is usually unknown, is that maven needs the sources of the client side code of all of the addons (besides Vaadin itself) that are needed to generate the final widgetset. If you're using an addon (and you add it as a dependency), you have to be sure that the jar contains internally the Java files of the client side classes. If they are not there, the addon will not be included in the widgetset compilation and you are not going to see any error, but you will not be able to use it at runtime.
If you build a custom addon by yourself, to include the sources you have to add this into the <build/> section of your pom.xml file:


...

  <!-- This is needed for the sources required by the client-side compiler to be 
   included in the produced JARs -->
  <resources>
   <resource>
    <directory>src/main/java</directory>
    <excludes>
      <exclude>rebel.xml</exclude>
    </excludes>
   </resource>
   <resource>
    <directory>src/main/resources</directory>
   </resource>
  </resources>

...

Just package your project

If everything is correctly configured up to this point, you should be able to compile your widgetset as a part of the normal compilation phase of your project.
Just run the command mvn install and the compilation will be done correctly.
In the possible scenario that the compilation is not being executed, you could force it by clicking on the compile widgetset button of the Vaadin Eclipse Plugin, that will force it to happen.

Check if your addon was indeed compiled

If the compilation finishes without errors, is not exactly clear if a particular addon was included in the compilation or not. There are two ways of verifying that:

  • The first one: analyzing the output of the build process, and trying to find a string similar to this:

...
[INFO] auto discovered modules [com.yourapplication.DemoWidgetSet]
[INFO] Compiling module com.yourapplication.DemoWidgetSet
[INFO]    Computing all possible rebind results for 'com.vaadin.client.metadata.ConnectorBundleLoader'
[INFO]       Rebinding com.vaadin.client.metadata.ConnectorBundleLoader
[INFO]          Invoking generator com.vaadin.server.widgetsetutils.ConnectorBundleLoaderFactory
[INFO]             Populating eager bundle
...
[INFO]                Visiting YourComponentConnector with ConnectorInitVisitor
[INFO]                   YourComponentConnector will be in the eager bundle
...

YourComponentConnector is the name of the Connector of your addon, if it includes one.
  • Another possibility, is inspecting the generated widgetset and search for a string representing the name of a client side class that should be generated. That file usually resides in yourapplication\src\main\webapp\VAADIN\widgetsets\com.yourapplication.DemoWidgetSet, given that the name of your widgetset is "com.yourapplication.DemoWidgetSet". The file has a name pattern similar to this: "499F6D1A40C61E05F11FB78D20D50A78.cache.js" and usually is a big file (1 megabyte or so). For instance, you could search for a string with the name of your connector, it should be there, if not, probably there is a configuration problem.
Well, that's it, if you have more tips regarding this, feel free to share them!



Tuesday, December 12, 2017

Debugging GWT client side code in Vaadin with Eclipse

You know, if you're developing a Vaadin application, it is not necessary to understand how to code client side using GWT, unless you're building your own custom component, and you need to add some special client-side code. In that case, you are going to realize that whenever you want to test your component, debugging it can be tricky.
The problem is that client side code is not executed by the JVM, instead that code is going to be executed by the browser, and because of this all of the debugging facilities provided by the Java platform are useless.
Let me tell you what you need to take into account for being able to successfully debug your code.

1 - Modify your .gwt.xml file

The first thing you need to do is to modify the file that contains all of your widgetset information, by adding this line inside the tag <module/>:

    <set-configuration-property name="devModeRedirectEnabled" value="true" />

2 - Run your code server

This is a special process that will provide the browser with the source code of your client side code. There are a lot of ways of running this process, one way is to setup a new Eclipse Run Configuration (Run → Run configurations... → Java Application → New). There you'll have to provide your project's name and use com.google.gwt.dev.codeserver.CodeServer as the main class. As an argument you need to enter the fully qualified name of your widgetset. If your widgetset descriptor has a name "MyWidgetset.gwt.xml" and it's located in the java package: "com.myapplication", then the FQN will be: com.myapplication.MyWidgetset.
Another option would be to use Maven, as explained in the gwt-maven-plugin documentation site.
This process has to be up whenever you want to debug your code, so leave it running in the background.

3 - Optionally: install the Eclipse debugger for GWT SuperDevMode

This step is not necessary, but it will enable you to debug the client side code using Eclipse, which is better suited for that task than Chrome. You have to go to Help → Install New Software ..., and then enter this to the Work with dropdown list: http://sdbg.github.io/p2/
After that choose JavaScript Debugger with Source Mapping Support, and then install it. Probably you're going to need to restart your IDE.
To be completely sure that this step was performed correctly, just go to Run → Run Configurations ... and see if there is a Launch Chrome configuration.

4 - Run your application and enable SuperDevMode

Just run it normally, as you would do to debug server-side code. Just one important thing to take into account: Production Mode has to be disabled to be able to debug client side code. If you want to know a little bit more about this, you can check out the official documentation.
After the application is up-and-running, you have two options:

  • Debug it using Chrome: you just need to open your application using that browser, and then use the Chrome Developer Tools
  • Use Eclipse for debugging: Go to Run → Debug Configurations ... → Launch Chrome (provided by the Eclipse debugger for GWT SuperDevMode plugin we installed in the previous point), and create a new configuration, specifying the url and the associated project.
In either way, after the browser is showing the screen of your application you'll need to open Vaadin's Debug Window by adding ?debug at the end of your URL (if you're using Navigator, remember that the ?debug goes before the #view).
Then in the Debug Window select the little gear icon on the upper right section and then press on the black dot (enable SuperDevMode). That will launch the widgetset compilation process once again (be patient). One quick way of doing this, is to append ?debug=&superdevmode= instead of just ?debug at the end of your URL.

Client Side Debugging


And that's it! Whichever you're using Eclipse or Chrome, you are going to be able to put a breakpoint on your client-side code, and inspect the variables in there. If you're using Eclipse, just do it in the same way as if you were debugging server-side code; if you're using just Chrome, you'll need to open the Developer tools, and find the sources of your application in the Sources tab. You will find those under a folder with the FQN of your widgetset.

Please leave a comment if you have any trouble with this.

Happy debugging!

Tuesday, November 28, 2017

Main HQ Inauguration & Vaadin talks

Last Tuesday we organized a little event, that targeted two primary objectives: Let the developers of the surrounding area know us and our installations, and kickstart our planned set of technology speeches, targeted for next year.
We offered a couple of presentations, the first one was related to Vaadin 8, where we gave an overview of the framework, the architecture, and a list of the best new features since Vaadin 7.
Then we presented the new Vaadin 10 platform, explaining the new technologies behind the framework, and the new features available in the developer preview.
After that, we invited everyone to taste some snacks and drinks in the open balcony with a starry sky as a background, talking about new technologies and making some good networking.
Here we share some photos of the event!


Wednesday, November 22, 2017

Monday, October 30, 2017

Implementing Spring Security on a Vaadin application

Today I'm going to write a little bit about my experience of trying to secure a simple Vaadin application using one of the most popular security frameworks: the security extensions of SpringFramework.
This post will cover the part of configuring a default setting to make it work, of course after this, there are a lot of things to do in your project to finish implementing this, such as storing and retrieving your user details from the underlying datastore of your choice, choosing the password-hashing algorithm, and so on. But at least you will have an overview of what needs to be done to accomplish this.

Starting point

The first requisite you're going to need to build this application is Maven. Using this command-line tool you can create a blank application using the following command:

mvn archetype:generate

After executing that command, maven will list a lot of predefined archetypes, you can filter that list using a keyword. If you enter "vaadin", the list will be shortened, I choose "com.vaadin:vaadin-archetype-application". After entering all of the required information (we are using 8.1.5 version of Vaadin), maven will create a small application that you can compile, package and ran using a built-in Jetty configuration just by launching this command:

mvn jetty:run

After this, you're ready to go with the rest of steps.

Adding Spring Framework

The first thing you'll need to do is to add the spring framework dependency to your project. For achieving this, you'll need to modify your project's pom.xml file, and add this inside the <dependencies> section:

<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-spring</artifactId>
<version>1.2.0</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
<version>4.2.3.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
<version>4.2.3.RELEASE</version>
</dependency>

<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.1</version>
</dependency>


This will add all of the required dependencies that you're going to need to implement this. We are considering using 4.2.3.RELEASE, that is the last stable version of that part of the framework at the time this article was written. And also, we are using Vaadin-Spring addon version 2.0.1 (latest stable version).

Adding some classes

With Spring Framework, and Servlet 3.0 specification, you can get rid of all of the old xml configurations and just create some classes to configure the framework. We are going to need the creation of:

  • User model class: This class will model the user that is currently logged in. It has to implement the interface org.springframework.security.core.userdetails.UserDetails, that will you implement some methods, of which these ones are worth mentioning:
    • getUsername & getPassword: This methods should return the stored username and password of your logged in user.
    • getAuthorities: This method should return the granted authorities that will be useful for choosing which functionalities of your application this user can see/execute
    • isAccountNonExpired, isAccountNonLocked, isCredentialsNonExpired and isEnabled: This methods are useful if you want to apply different security policies to control the availability of your user / credentials
  • User Service: Is the class responsible for loading the previous model from the underlying database. In this little example, this class is just creating and returning a new simple User.
  • SecurityConfig: This is the class that controls the security configuration of your application. There are a lot of interesting things in this class to mention:
    • Through the method authenticationProvider(), we are configuring the previous service as the mechanism to retrieve the user from the database.
    • The method configure() is the most important one, and allows a lot of configurations to be set. We are using the minimal ones to allow some unprotected url patterns (like the login form page) and restrict everything else to allow only the access to logged in users.
    • We are also setting some standard configurations regarding the session utilizing the method sessionControlAuthenticationStrategy().
    • Another interesting thing is to create a Session Registry, that is a class that will allow spring to store the security sessions detail in memory.
    • Finally there is a method encoder() that will allow you to hash the password, so no plain password are going to be stored on the database. Just because this is a simple example, we are using a NoOpPasswordEncoder.
  • SecurityWebApplicationInitializer: This class will be responsible of assigning the class SecurityConfig as the base class of spring configuration.
  • LoginUI: Because we are going to secure some urls, and others are going to be left unsecured, we need to create a new UI, that will render the login form. In this class we are using one interesting Vaadin component: the LoginForm, this will render a login form in vaadin using some interesting features like being able to tell the browser to remember the user credentials.
Finally we have to modify the MainUI, a little bit to allow using a SpringVaadinServlet instead the default one. And also we are adding a logout button, that will be doing the logout process, invoking some class of spring security.
After adding this classes you're ready to go and test the application. If you try to access to the default url, you're going to be redirected to the LoginUI and your credentials are going to be asked. Just enter "admin" as username and "admin" as password and you are going to be granted the access to the application.
After that if you click in the logout button, you are going to be logged out of the application and then be redirected to the login page.
That's it. All of the sources are uploaded into a small github project so if you want, you can take a look there. If you have any issues please comment!
Hope this could be useful to someone.


Our Services


Development
Enterprise Application Level

Java development for your company's needs.

Outsourcing and Projects Get in touch
Consulting
Architectural and Design support

Team of high qualified engineers will help you build your software infrastructure.

Outsourcing and Projects Get in touch
SCM
Build pipeline definition

We'll help you define how your build your software in an industrial level.

Consulting Get in touch
Open Source
Community driven development

Checkout our projects at GitHub. Be part of our community.

Contribute Get in touch

Contact Us


Flowing Code S.A.
Boulevard Galvez 1933 - Oficina 3 - Santa Fe
Santa Fe, Argentina
+54 342 4123621
[email protected]



Interested for our works and services?
Get more of our update !