data = new HashMap<>();
+ data.put("type", event.getAccessDeniedException().getClass().getName());
+ data.put("message", event.getAccessDeniedException().getMessage());
+ data.put("requestUrl", ((FilterInvocation)event.getSource()).getRequestUrl() );
+ if (event.getAuthentication().getDetails() != null) {
+ data.put("details", event.getAuthentication().getDetails());
+ }
+ publish(new AuditEvent(event.getAuthentication().getName(), AUTHORIZATION_FAILURE,
+ data));
+ }
+}
diff --git a/spring-boot-auditing/src/main/java/org/baeldung/auditing/LoginAttemptsLogger.java b/spring-boot-auditing/src/main/java/org/baeldung/auditing/LoginAttemptsLogger.java
new file mode 100644
index 0000000000..5be8cebfd3
--- /dev/null
+++ b/spring-boot-auditing/src/main/java/org/baeldung/auditing/LoginAttemptsLogger.java
@@ -0,0 +1,25 @@
+package org.baeldung.auditing;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.boot.actuate.audit.AuditEvent;
+import org.springframework.boot.actuate.audit.listener.AuditApplicationEvent;
+import org.springframework.context.event.EventListener;
+import org.springframework.security.web.authentication.WebAuthenticationDetails;
+import org.springframework.stereotype.Component;
+
+@Component
+public class LoginAttemptsLogger {
+ private static final Logger LOGGER = LoggerFactory.getLogger(LoginAttemptsLogger.class);
+
+ @EventListener
+ public void auditEventHappened(AuditApplicationEvent auditApplicationEvent) {
+ AuditEvent auditEvent = auditApplicationEvent.getAuditEvent();
+ LOGGER.debug("Principal " + auditEvent.getPrincipal() + " - " + auditEvent.getType());
+
+ WebAuthenticationDetails details = (WebAuthenticationDetails) auditEvent.getData().get("details");
+ LOGGER.debug(" Remote IP address: " + details.getRemoteAddress());
+ LOGGER.debug(" Session Id: " + details.getSessionId());
+ LOGGER.debug(" Request URL: " + auditEvent.getData().get("requestUrl"));
+ }
+}
diff --git a/spring-boot-auditing/src/main/resources/application.properties b/spring-boot-auditing/src/main/resources/application.properties
new file mode 100644
index 0000000000..cf09473b60
--- /dev/null
+++ b/spring-boot-auditing/src/main/resources/application.properties
@@ -0,0 +1 @@
+logging.level.org.springframework=INFO
\ No newline at end of file
diff --git a/spring-boot-auditing/src/main/resources/logback.xml b/spring-boot-auditing/src/main/resources/logback.xml
new file mode 100644
index 0000000000..78913ee76f
--- /dev/null
+++ b/spring-boot-auditing/src/main/resources/logback.xml
@@ -0,0 +1,14 @@
+
+
+
+
+ web - %date [%thread] %-5level %logger{36} - %message%n
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/spring-boot-auditing/src/main/resources/templates/hello.html b/spring-boot-auditing/src/main/resources/templates/hello.html
new file mode 100755
index 0000000000..46feef7e2c
--- /dev/null
+++ b/spring-boot-auditing/src/main/resources/templates/hello.html
@@ -0,0 +1,13 @@
+
+
+
+ Hello World!
+
+
+ Hello [[${#httpServletRequest.remoteUser}]]!
+
+
+
\ No newline at end of file
diff --git a/spring-boot-auditing/src/main/resources/templates/home.html b/spring-boot-auditing/src/main/resources/templates/home.html
new file mode 100755
index 0000000000..fe4e8b337e
--- /dev/null
+++ b/spring-boot-auditing/src/main/resources/templates/home.html
@@ -0,0 +1,11 @@
+
+
+
+ Spring Security Example
+
+
+ Welcome!
+
+ Click here to see a greeting.
+
+
\ No newline at end of file
diff --git a/spring-boot-auditing/src/main/resources/templates/login.html b/spring-boot-auditing/src/main/resources/templates/login.html
new file mode 100755
index 0000000000..a1785313f5
--- /dev/null
+++ b/spring-boot-auditing/src/main/resources/templates/login.html
@@ -0,0 +1,20 @@
+
+
+
+ Spring Security Example
+
+
+
+ Invalid username and password.
+
+
+ You have been logged out.
+
+
+
+
\ No newline at end of file
diff --git a/spring-boot-servlet/README.md b/spring-boot-servlet/README.md
deleted file mode 100644
index 262a11fc36..0000000000
--- a/spring-boot-servlet/README.md
+++ /dev/null
@@ -1,2 +0,0 @@
-###Relevant Articles:
-- [How to Register a Servlet in a Java Web Application](http://www.baeldung.com/how-to-register-a-servlet-in-a-java-web-application/)
\ No newline at end of file
diff --git a/spring-boot-servlet/pom.xml b/spring-boot-servlet/pom.xml
deleted file mode 100644
index 3818e3468f..0000000000
--- a/spring-boot-servlet/pom.xml
+++ /dev/null
@@ -1,55 +0,0 @@
-
- 4.0.0
- com.baeldung
- spring-boot-servlet
- 0.0.1-SNAPSHOT
- war
- spring-boot-servlet
-
-
- org.springframework.boot
- spring-boot-dependencies
- 1.5.1.RELEASE
-
-
-
-
-
- org.springframework.boot
- spring-boot-starter-web
-
-
- org.springframework.boot
- spring-boot-starter-tomcat
- provided
-
-
-
- org.apache.tomcat.embed
- tomcat-embed-core
- ${tomcat.version}
-
-
- org.apache.tomcat.embed
- tomcat-embed-jasper
- ${tomcat.version}
-
-
-
-
-
-
- org.springframework.boot
- spring-boot-maven-plugin
-
-
-
-
-
- UTF-8
- 1.8
- 8.5.11
-
-
-
diff --git a/spring-boot-servlet/src/main/java/META-INF/MANIFEST.MF b/spring-boot-servlet/src/main/java/META-INF/MANIFEST.MF
deleted file mode 100644
index 69ebae1751..0000000000
--- a/spring-boot-servlet/src/main/java/META-INF/MANIFEST.MF
+++ /dev/null
@@ -1,2 +0,0 @@
-Manifest-Version: 1.0
-Main-Class: com.baeldung.ApplicationMain
diff --git a/spring-boot-servlet/src/main/resources/application.properties b/spring-boot-servlet/src/main/resources/application.properties
deleted file mode 100644
index 4e9e2b4cf1..0000000000
--- a/spring-boot-servlet/src/main/resources/application.properties
+++ /dev/null
@@ -1,10 +0,0 @@
-#Server Configuration
-#server.port=8080
-#server.context-path=/javabootdata
-#Resource Handling
-#spring.resources.static-locations=classpath:/WEB-INF/resources
-#spring.mvc.view.prefix=/WEB-INF/
-#spring.mvc.view.suffix=.jsp
-#spring.resources.cache-period=3600
-servlet.name=dispatcherExample
-servlet.mapping=/dispatcherExampleURL
\ No newline at end of file
diff --git a/spring-boot/README.MD b/spring-boot/README.MD
index d0a02c69fc..78ef3c843c 100644
--- a/spring-boot/README.MD
+++ b/spring-boot/README.MD
@@ -10,3 +10,4 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring
- [The @ServletComponentScan Annotation in Spring Boot](http://www.baeldung.com/spring-servletcomponentscan)
- [A Custom Data Binder in Spring MVC](http://www.baeldung.com/spring-mvc-custom-data-binder)
- [Intro to Building an Application with Spring Boot](http://www.baeldung.com/intro-to-spring-boot)
+- [How to Register a Servlet in a Java Web Application](http://www.baeldung.com/how-to-register-a-servlet-in-a-java-web-application/)
diff --git a/spring-boot/pom.xml b/spring-boot/pom.xml
index e77ab10aff..65b0f247f8 100644
--- a/spring-boot/pom.xml
+++ b/spring-boot/pom.xml
@@ -41,6 +41,24 @@
spring-boot-starter-security