Skip to content

Commit 21cbc2b

Browse files
author
Eugen
committed
Merge pull request eugenp#33 from egmp777/master
Login and Registration Error Handling pom changes
2 parents a9c3c08 + b27187d commit 21cbc2b

File tree

16 files changed

+352
-0
lines changed

16 files changed

+352
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<beansProjectDescription>
3+
<version>1</version>
4+
<pluginVersion><![CDATA[3.5.1.201404300732-RELEASE]]></pluginVersion>
5+
<configSuffixes>
6+
<configSuffix><![CDATA[xml]]></configSuffix>
7+
</configSuffixes>
8+
<enableImports><![CDATA[true]]></enableImports>
9+
<configs>
10+
</configs>
11+
<autoconfigs>
12+
</autoconfigs>
13+
<configSets>
14+
</configSets>
15+
</beansProjectDescription>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<configuration>
2+
3+
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
4+
<encoder>
5+
<pattern>web - %date [%thread] %-5level %logger{36} - %message%n
6+
</pattern>
7+
</encoder>
8+
</appender>
9+
10+
<logger name="org.springframework" level="WARN" />
11+
<logger name="org.springframework.transaction" level="WARN" />
12+
13+
<!-- in order to debug some marshalling issues, this needs to be TRACE -->
14+
<logger name="org.springframework.web.servlet.mvc" level="WARN" />
15+
16+
<root level="INFO">
17+
<appender-ref ref="STDOUT" />
18+
</root>
19+
20+
</configuration>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
message.username=Username required
2+
message.password=Password required
3+
message.unauth=Unauthorized Access !!
4+
message.badCredentials=Invalid Username or Password
5+
message.sessionExpired=Session Timed Out
6+
message.logoutError=Sorry, error logging out
7+
message.logoutSucc=You logged out successfully
8+
message.regSucc=You registrated correctly, please log in
9+
message.regError=There was a registration error please go back to registration
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
message.username=Por favor ingrese el nombre de usuario
2+
message.password=Por favor ingrese una clave
3+
message.unauth=Acceso denegado !!
4+
message.badCredentials=Usuario o clave invalida
5+
message.sessionExpired=La sesion expiro
6+
message.logoutError=Lo sentimos, hubo problemas en logout
7+
message.logoutSucc=Logout con exito
8+
message.regSucc=Se registro correctamente, por favor ingrese
9+
message.regError=Hubo un error, por favor vuelva a registrarse
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<beans:beans xmlns="http://www.springframework.org/schema/security"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans"
4+
xmlns:mvc="http://www.springframework.org/schema/mvc"
5+
xsi:schemaLocation="
6+
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.2.xsd
7+
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd">
8+
9+
10+
<http use-expressions="true">
11+
<intercept-url pattern="/login*" access="permitAll" />
12+
<intercept-url pattern="/logout*" access="permitAll" />
13+
<intercept-url pattern="/registration*" access="permitAll" />
14+
<intercept-url pattern="/resources/**" access="permitAll" />
15+
<intercept-url pattern="/invalidSession*" access="isAnonymous()" />
16+
<intercept-url pattern="/**" access="isAuthenticated()" />
17+
<form-login login-page='/login.html'
18+
authentication-failure-url="/login.html?error=true"
19+
authentication-success-handler-ref="myAuthenticationSuccessHandler"
20+
default-target-url="/homepage.html" />
21+
<session-management invalid-session-url="/invalidSession.html"
22+
session-fixation-protection="none" />
23+
<logout invalidate-session="false" logout-success-url="/logout.html?logSucc=1"
24+
logout-url="/j_spring_security_logout" delete-cookies="JSESSIONID" />
25+
</http>
26+
<beans:bean id="myAuthenticationSuccessHandler"
27+
class="org.baeldung.security.MySimpleUrlAuthenticationSuccessHandler" />
28+
<authentication-manager>
29+
<authentication-provider>
30+
<user-service>
31+
<user name="user1" password="user1Pass" authorities="ROLE_USER" />
32+
<user name="admin1" password="admin1Pass" authorities="ROLE_ADMIN" />
33+
</user-service>
34+
</authentication-provider>
35+
</authentication-manager>
36+
</beans:beans>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xmlns:p="http://www.springframework.org/schema/p"
4+
xmlns:mvc="http://www.springframework.org/schema/mvc"
5+
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd">
6+
7+
8+
9+
10+
</beans>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
2+
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
3+
<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%>
4+
<html>
5+
<sec:authorize ifAnyGranted="ROLE_USER">
6+
<spring:message code="message.unauth" ></spring:message>
7+
</sec:authorize>
8+
<head></head>
9+
10+
11+
<body>
12+
13+
<head></head>
14+
<sec:authorize ifAnyGranted="ROLE_ADMIN">
15+
<H1> Hello Admin</H1>
16+
</sec:authorize>
17+
18+
<a href="<c:url value="/j_spring_security_logout" />">Logout</a>
19+
<a href="<c:url value="/home.html" />">Home</a>
20+
</body>
21+
22+
23+
</html>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
2+
<%@ taglib prefix="security" uri="http://www.springframework.org/security/tags" %>
3+
<html>
4+
<head></head>
5+
6+
<body>
7+
<h1>This is the landing page for the admin</h1>
8+
9+
<security:authorize access="hasRole('ROLE_USER')">
10+
This text is only visible to a user
11+
<br/>
12+
</security:authorize>
13+
14+
<security:authorize access="hasRole('ROLE_ADMIN')">
15+
This text is only visible to an admin
16+
<br/>
17+
</security:authorize>
18+
19+
<a href="<c:url value="/j_spring_security_logout" />">Logout</a>
20+
<a href="<c:url value="/admin.html" />">Administrator Page</a>
21+
22+
</body>
23+
</html>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
2+
<%@ page session="true" %>
3+
<html>
4+
<head>
5+
<title>Home</title>
6+
</head>
7+
<body>
8+
<h1>
9+
Welcome back home!
10+
</h1>
11+
12+
</body>
13+
</html>

0 commit comments

Comments
 (0)