File tree Expand file tree Collapse file tree 7 files changed +44
-29
lines changed
spring-security-login-error-handling/src/main
java/org/baeldung/persistence/model Expand file tree Collapse file tree 7 files changed +44
-29
lines changed Original file line number Diff line number Diff line change @@ -66,4 +66,33 @@ public Integer getRole() {
6666 public void setRole (Integer role ) {
6767 this .role = role ;
6868 }
69+
70+ @ Override
71+ public int hashCode () {
72+ final int prime = 31 ;
73+ int result = 1 ;
74+ result = prime * result + ((role == null ) ? 0 : role .hashCode ());
75+ return result ;
76+ }
77+
78+ @ Override
79+ public boolean equals (final Object obj ) {
80+ if (this == obj )
81+ return true ;
82+ if (obj == null )
83+ return false ;
84+ if (getClass () != obj .getClass ())
85+ return false ;
86+ final Role role = (Role ) obj ;
87+ if (!role .equals (role .role ))
88+ return false ;
89+ return true ;
90+ }
91+
92+ @ Override
93+ public String toString () {
94+ final StringBuilder builder = new StringBuilder ();
95+ builder .append ("Role [role=" ).append (role ).append ("]" ).append ("[id=" ).append (id ).append ("]" );
96+ return builder .toString ();
97+ }
6998}
Original file line number Diff line number Diff line change 11# ################## DataSource Configuration ##########################
22jdbc.driverClassName =com.mysql.jdbc.Driver
3- jdbc.url =jdbc:mysql://localhost:3306/spring_hibernate4_02?createDatabaseIfNotExist=true
3+ jdbc.url =jdbc:mysql://localhost:3306/AUTHDATA
44jdbc.user =tutorialuser
55jdbc.pass =tutorialmy5ql
66init-db =false
77# ################## Hibernate Configuration ##########################
88hibernate.dialect =org.hibernate.dialect.MySQLDialect
9- hibernate.show_sql =false
10- hibernate.hbm2ddl.auto =create-drop
11-
9+ hibernate.show_sql =true
10+ hibernate.hbm2ddl.auto =validate
Original file line number Diff line number Diff line change 11<%@ taglib prefix =" c" uri =" http://java.sun.com/jsp/jstl/core" %>
2- <%@ taglib prefix =" sec" uri =" http://www.springframework.org/security/tags" %>
2+ <%@ taglib prefix =" sec"
3+ uri =" http://www.springframework.org/security/tags" %>
34<%@taglib uri =" http://www.springframework.org/tags" prefix =" spring" %>
45<html >
5- <sec:authorize ifAnyGranted =" ROLE_USER" >
6- <spring:message code =" message.unauth" ></spring:message >
7- </sec:authorize >
6+
87<head >
98<link href =" <c:url value=" /resources /bootstrap.css " />" rel =" stylesheet" >
109</head >
11- <<<<<<< HEAD
12- =======
13-
14- >>>>>>> FETCH_HEAD
1510<body >
11+ <sec:authorize ifAnyGranted =" ROLE_USER" >
12+ <spring:message code =" message.unauth" ></spring:message >
13+ </sec:authorize >
1614 <sec:authorize ifAnyGranted =" ROLE_ADMIN" >
1715 <H1 >Hello Admin</H1 >
1816 </sec:authorize >
Original file line number Diff line number Diff line change 11<%@ taglib prefix =" c" uri =" http://java.sun.com/jsp/jstl/core" %>
2- <%@ taglib prefix =" security" uri =" http://www.springframework.org/security/tags" %>
2+ <%@ taglib prefix =" sec"
3+ uri =" http://www.springframework.org/security/tags" %>
34<html >
4-
55<head >
66<link href =" <c:url value=" /resources /bootstrap.css " />" rel =" stylesheet" >
77</head >
88<body >
99 <h1 >This is the landing page for the admin</h1 >
10- <security :authorize access =" hasRole('ROLE_USER')" >
10+ <sec :authorize access =" hasRole('ROLE_USER')" >
1111 This text is only visible to a user
1212 <br />
13- </security :authorize >
14- <security :authorize access =" hasRole('ROLE_ADMIN')" >
13+ </sec :authorize >
14+ <sec :authorize access =" hasRole('ROLE_ADMIN')" >
1515 This text is only visible to an admin
1616 <br />
17- </security :authorize >
17+ </sec :authorize >
1818 <a href =" <c:url value=" /j_spring_security_logout " />" >Logout</a >
1919 <a href =" <c:url value=" /admin.html " />" >Administrator Page</a >
2020</body >
Original file line number Diff line number Diff line change 11<%@ taglib prefix =" c" uri =" http://java.sun.com/jsp/jstl/core" %>
2- <<<<<<< HEAD
3- <%@ taglib prefix =" sec"
4- uri =" http://www.springframework.org/security/tags" %>
5- =======
62<%@ taglib prefix =" sec" uri =" http://www.springframework.org/security/tags" %>
7- >>>>>>> FETCH_HEAD
83<%@ page session =" true" %>
94<html >
105<head >
2722 <a href =" <c:url value=" /home.html " />" >Home</a >
2823 <a href =" <c:url value=" /admin.html " />" >Administrator Page</a >
2924</body >
30- <<<<<<< HEAD
31- =======
32-
33- >>>>>>> FETCH_HEAD
3425</html >
Original file line number Diff line number Diff line change 44<%@ taglib uri =" http://java.sun.com/jsp/jstl/fmt" prefix =" fmt" %>
55<fmt:setBundle basename =" messages" />
66<%@ page session =" true" %>
7-
87<fmt:message key =" message.password" var =" noPass" />
98<fmt:message key =" message.username" var =" noUser" />
109<html >
Original file line number Diff line number Diff line change 11<%@ taglib prefix =" c" uri =" http://java.sun.com/jsp/jstl/core" %>
22<%@ taglib prefix =" sec" uri =" http://www.springframework.org/security/tags" %>
33<%@taglib uri =" http://www.springframework.org/tags" prefix =" spring" %>
4-
54<html >
65
76<head >
You can’t perform that action at this time.
0 commit comments