Browsed by
Tag: english

Apache Shiro part 2 – securing a JSF Java EE 7 application

Apache Shiro part 2 – securing a JSF Java EE 7 application

apache shiro logo

In the first part I described why I chose Apache Shiro as an Authentication framework. In this part I will describe the simplest working solution to secure a Java EE7 application with JSF/Primefaces frontend. To be honest I wont use much of Primefaces in this sample but the application for which I did this research uses it so I added the dependency here and added an Primefaces component to this demo project.

Bootstrapping

I created an empty Java EE project via maven and added the needed Shiro dependencies as well as the Primefaces dependency to

the pom file.

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>de.are_you_ready</groupId>
    <artifactId>shirotest</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>war</packaging>

    <properties>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
        <failOnMissingWebXml>false</failOnMissingWebXml>

        <apache-shiro.version>1.3.2</apache-shiro.version>
        <primefaces.version>6.0</primefaces.version>
        <junit.version>4.12</junit.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>javax</groupId>
            <artifactId>javaee-api</artifactId>
            <version>7.0</version>
            <scope>provided</scope>
        </dependency>

        <!-- Security -->
        <dependency>
            <groupId>org.apache.shiro</groupId>
            <artifactId>shiro-core</artifactId>
            <version>${apache-shiro.version}</version>
        </dependency>

        <dependency>
            <groupId>org.apache.shiro</groupId>
            <artifactId>shiro-web</artifactId>
            <version>${apache-shiro.version}</version>
        </dependency>

        <dependency>
            <groupId>org.apache.shiro</groupId>
            <artifactId>shiro-ehcache</artifactId>
            <version>${apache-shiro.version}</version>
        </dependency>

        <!-- PrimeFaces -->
        <dependency>
            <groupId>org.primefaces</groupId>
            <artifactId>primefaces</artifactId>
            <version>${primefaces.version}</version>
        </dependency>

        <!-- Testing -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>${junit.version}</version>
            <scope>test</scope>
        </dependency>

        <!-- Logging -->
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.17</version>
        </dependency>
    </dependencies>

    <build>
        <finalName>shirotest</finalName>
    </build>
</project>

Read More Read More

Java Forum Nord 2016

Java Forum Nord 2016

Java Forum Nord
Last week (October 20th) I attended the second “Java Forum Nord” in Hannover. The Java Forum is now in its second year but is the evolution of an older and smaller conference in Göttingen (Source Talk Tage). The relocation and renaming of the conference was necessary because it wasn’t possible to attract an audience huge enough to get top speakers to Göttingen. To make the transfer possible the JUG Deutschland which is located in Göttingen and hosted the Source Talk cooperates now with the JUG Bremen, JUG Hamburg, JUG Hessen (Kassel), JUG Ostfalen, SUN User Group Deutschland and the local JUG Hannover.
As a result the conference professionalized very quickly and the audience grew by a huge number. After the first edition in 2015 took place in a small Hotel at the Hannover main train station and was quickly sold out they relocated to the bigger Hotel Dormero in Hannover which had space for 400 participants and was sold out, too. After I would consider last year as a transition year I had this year the feeling to be on a very serious one day conference which had definitively left the amateur status. What makes this conference so special is that it is organized by the JUGs (Java User Groups) and aims for no profit which makes it possible to give very cheap tickets away.

Read More Read More

Removing Excel rows with POI

Removing Excel rows with POI

https://poi.apache.org
https://poi.apache.org

When generating Excel Sheets it is sometimes necessary to remove rows which match a given criteria afterwards. The first idea for this would be to use removeRow(Row row) but this has the problem that it deletes all the row contents and leaves the empty row in your sheet which is probably not what you want. To remove the rows as a whole the shiftRows(int startRow, int endRow, int n) is needed.
Lets say we have a xls file with column A being the title which is always filled but we want to remove every row in which the data column B is not filled. For this case the following snippet would be appropriate

Read More Read More

Started into blogging again with a little help

Started into blogging again with a little help

simpleprogrammer

As this Blog is fairly old (I started it in 2006 and therefore it will have 10th anniversary later this year) I have to admit it wasn’t very active during the last years and at some point it was nearly forgotten. During the period from getting to my masters degree in software engineering to becoming a professional software developer I stopped blogging because I had so much to learn and so much work to do to get on track with all the technologies and methodologies that are wanted by the industry that I thought I couldn’t manage to write quality blog posts.

Now, some years later I still constantly learn a lot of new things but it adjusted to my normal everyday live and after going to some conferences and meeting people at local user groups etc. I read many blogs of speakers and attendees and it got me thinking that it would be a fun to reactivate my own blog. At first I decided to make some changes. Over the years the stats of this blog showed that the most read articles were how tos, problem solutions or technology reviews. As a result of this it makes perfect sense to write about my programming and technology experiences.

After that decision was made I coincidentally listened to an episode of “Software Engineering Radio” with guest John Sonmez wo is the founder of simpleprogrammer.com. Not knowing him until then I read some of his blog articles and watched a couple of his videos when I found his 6 week eMail course about creating a blog and decided to try this to see what a successful blogger has to say about what is important at blogging. The course is for free and to be honest it doesn’t give you information you have never heard of or couldn’t come up with by yourself but what it really does is it gave me motivation to give it an honest second chance and John makes very clear what he thinks are the most important things to be successful with a blog (obviously success can’t be granted but it seems clear that it is easy to make fundamental mistakes). If you are interested in creating a blog I can definitely recommend the course. It doesn’t take much time and is a good starter by an experienced blogger.