New Cleanup

Added hashCode, equals and toString to Role
This commit is contained in:
egmp777 2014-08-25 15:25:58 -05:00
parent 6272a5383f
commit 2f22feaf46
7 changed files with 44 additions and 29 deletions

View File

@ -66,4 +66,33 @@ public class Role {
public void setRole(Integer role) { public void setRole(Integer role) {
this.role = role; this.role = role;
} }
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((role == null) ? 0 : role.hashCode());
return result;
}
@Override
public boolean equals(final Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
final Role role = (Role) obj;
if (!role.equals(role.role))
return false;
return true;
}
@Override
public String toString() {
final StringBuilder builder = new StringBuilder();
builder.append("Role [role=").append(role).append("]").append("[id=").append(id).append("]");
return builder.toString();
}
} }

View File

@ -1,11 +1,10 @@
################### DataSource Configuration ########################## ################### DataSource Configuration ##########################
jdbc.driverClassName=com.mysql.jdbc.Driver jdbc.driverClassName=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/spring_hibernate4_02?createDatabaseIfNotExist=true jdbc.url=jdbc:mysql://localhost:3306/AUTHDATA
jdbc.user=tutorialuser jdbc.user=tutorialuser
jdbc.pass=tutorialmy5ql jdbc.pass=tutorialmy5ql
init-db=false init-db=false
################### Hibernate Configuration ########################## ################### Hibernate Configuration ##########################
hibernate.dialect=org.hibernate.dialect.MySQLDialect hibernate.dialect=org.hibernate.dialect.MySQLDialect
hibernate.show_sql=false hibernate.show_sql=true
hibernate.hbm2ddl.auto=create-drop hibernate.hbm2ddl.auto=validate

View File

@ -1,18 +1,16 @@
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags"%> <%@ taglib prefix="sec"
uri="http://www.springframework.org/security/tags"%>
<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%> <%@taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<html> <html>
<sec:authorize ifAnyGranted="ROLE_USER">
<spring:message code="message.unauth"></spring:message>
</sec:authorize>
<head> <head>
<link href="<c:url value="/resources/bootstrap.css" />" rel="stylesheet"> <link href="<c:url value="/resources/bootstrap.css" />" rel="stylesheet">
</head> </head>
<<<<<<< HEAD
=======
>>>>>>> FETCH_HEAD
<body> <body>
<sec:authorize ifAnyGranted="ROLE_USER">
<spring:message code="message.unauth"></spring:message>
</sec:authorize>
<sec:authorize ifAnyGranted="ROLE_ADMIN"> <sec:authorize ifAnyGranted="ROLE_ADMIN">
<H1>Hello Admin</H1> <H1>Hello Admin</H1>
</sec:authorize> </sec:authorize>

View File

@ -1,20 +1,20 @@
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="security" uri="http://www.springframework.org/security/tags"%> <%@ taglib prefix="sec"
uri="http://www.springframework.org/security/tags"%>
<html> <html>
<head> <head>
<link href="<c:url value="/resources/bootstrap.css" />" rel="stylesheet"> <link href="<c:url value="/resources/bootstrap.css" />" rel="stylesheet">
</head> </head>
<body> <body>
<h1>This is the landing page for the admin</h1> <h1>This is the landing page for the admin</h1>
<security:authorize access="hasRole('ROLE_USER')"> <sec:authorize access="hasRole('ROLE_USER')">
This text is only visible to a user This text is only visible to a user
<br /> <br />
</security:authorize> </sec:authorize>
<security:authorize access="hasRole('ROLE_ADMIN')"> <sec:authorize access="hasRole('ROLE_ADMIN')">
This text is only visible to an admin This text is only visible to an admin
<br /> <br />
</security:authorize> </sec:authorize>
<a href="<c:url value="/j_spring_security_logout" />">Logout</a> <a href="<c:url value="/j_spring_security_logout" />">Logout</a>
<a href="<c:url value="/admin.html" />">Administrator Page</a> <a href="<c:url value="/admin.html" />">Administrator Page</a>
</body> </body>

View File

@ -1,10 +1,5 @@
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<<<<<<< HEAD
<%@ taglib prefix="sec"
uri="http://www.springframework.org/security/tags"%>
=======
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags"%> <%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags"%>
>>>>>>> FETCH_HEAD
<%@ page session="true"%> <%@ page session="true"%>
<html> <html>
<head> <head>
@ -27,8 +22,4 @@
<a href="<c:url value="/home.html" />">Home</a> <a href="<c:url value="/home.html" />">Home</a>
<a href="<c:url value="/admin.html" />">Administrator Page</a> <a href="<c:url value="/admin.html" />">Administrator Page</a>
</body> </body>
<<<<<<< HEAD
=======
>>>>>>> FETCH_HEAD
</html> </html>

View File

@ -4,7 +4,6 @@
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%> <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<fmt:setBundle basename="messages" /> <fmt:setBundle basename="messages" />
<%@ page session="true"%> <%@ page session="true"%>
<fmt:message key="message.password" var="noPass" /> <fmt:message key="message.password" var="noPass" />
<fmt:message key="message.username" var="noUser" /> <fmt:message key="message.username" var="noUser" />
<html> <html>

View File

@ -1,7 +1,6 @@
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags"%> <%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags"%>
<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%> <%@taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<html> <html>
<head> <head>