Merge pull request #38 from egmp777/master

Security Registration Code
This commit is contained in:
Eugen 2014-08-25 22:43:59 +03:00
commit 75968ea1c4
25 changed files with 195 additions and 71 deletions

View File

@ -17,16 +17,18 @@
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"> <classpathentry exported="true" kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes> <attributes>
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/> <attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"> <classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
<attributes> <attributes>
<attribute name="owner.project.facets" value="java"/> <attribute name="owner.project.facets" value="java"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry exported="true" kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
<classpathentry exported="true" kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/>
<classpathentry kind="output" path="target/classes"/> <classpathentry kind="output" path="target/classes"/>
</classpath> </classpath>

View File

@ -26,7 +26,7 @@
</arguments> </arguments>
</buildCommand> </buildCommand>
<buildCommand> <buildCommand>
<name>org.eclipse.wst.validation.validationbuilder</name> <name>org.jboss.tools.jst.web.kb.kbbuilder</name>
<arguments> <arguments>
</arguments> </arguments>
</buildCommand> </buildCommand>
@ -40,6 +40,11 @@
<arguments> <arguments>
</arguments> </arguments>
</buildCommand> </buildCommand>
<buildCommand>
<name>org.eclipse.wst.validation.validationbuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec> </buildSpec>
<natures> <natures>
<nature>org.eclipse.jem.workbench.JavaEMFNature</nature> <nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
@ -50,5 +55,6 @@
<nature>org.eclipse.wst.common.project.facet.core.nature</nature> <nature>org.eclipse.wst.common.project.facet.core.nature</nature>
<nature>org.eclipse.wst.jsdt.core.jsNature</nature> <nature>org.eclipse.wst.jsdt.core.jsNature</nature>
<nature>org.hibernate.eclipse.console.hibernateNature</nature> <nature>org.hibernate.eclipse.console.hibernateNature</nature>
<nature>org.jboss.tools.jst.web.kb.kbnature</nature>
</natures> </natures>
</projectDescription> </projectDescription>

View File

@ -7,13 +7,11 @@
<name>spring-security-login-and-registration</name> <name>spring-security-login-and-registration</name>
<packaging>war</packaging> <packaging>war</packaging>
<version>1.0.0-BUILD-SNAPSHOT</version> <version>1.0.0-BUILD-SNAPSHOT</version>
<parent> <parent>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId> <artifactId>spring-boot-starter-parent</artifactId>
<version>1.1.5.RELEASE</version> <version>1.1.5.RELEASE</version>
</parent> </parent>
<dependencies> <dependencies>
<!-- Spring --> <!-- Spring -->
<dependency> <dependency>
@ -29,9 +27,6 @@
<groupId>org.springframework</groupId> <groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId> <artifactId>spring-context-support</artifactId>
</dependency> </dependency>
<!-- Validation -->
<!-- logging --> <!-- logging -->
<dependency> <dependency>
<groupId>org.slf4j</groupId> <groupId>org.slf4j</groupId>
@ -40,57 +35,47 @@
<dependency> <dependency>
<groupId>ch.qos.logback</groupId> <groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId> <artifactId>logback-classic</artifactId>
<!-- <scope>runtime</scope> -->
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.slf4j</groupId> <groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId> <artifactId>jcl-over-slf4j</artifactId>
<!-- <scope>runtime</scope> --> <!-- some spring dependencies need to compile against jcl --> <!-- <scope>runtime</scope> --> <!-- some spring dependencies need to compile against jcl -->
</dependency> </dependency>
<dependency> <!-- needed to bridge to slf4j for projects that use the log4j APIs directly --> <dependency> <!-- needed to bridge to slf4j for projects that use the log4j APIs directly -->
<groupId>org.slf4j</groupId> <groupId>org.slf4j</groupId>
<artifactId>log4j-over-slf4j</artifactId> <artifactId>log4j-over-slf4j</artifactId>
</dependency> </dependency>
<!-- @Inject --> <!-- @Inject -->
<dependency> <dependency>
<groupId>javax.inject</groupId> <groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId> <artifactId>javax.inject</artifactId>
<version>${javax.inject.version}</version> <version>${javax.inject.version}</version>
</dependency> </dependency>
<!-- Servlet --> <!-- Servlet -->
<dependency> <dependency>
<groupId>javax.servlet</groupId> <groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId> <artifactId>javax.servlet-api</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>javax.servlet.jsp</groupId> <groupId>javax.servlet.jsp</groupId>
<artifactId>javax.servlet.jsp-api</artifactId> <artifactId>javax.servlet.jsp-api</artifactId>
<version>${javax.servlet.jsp-api.version}</version> <version>${javax.servlet.jsp-api.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>javax.servlet</groupId> <groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId> <artifactId>jstl</artifactId>
</dependency> </dependency>
<!-- Taglibs --> <!-- Taglibs -->
<dependency> <dependency>
<groupId>org.springframework.security</groupId> <groupId>org.springframework.security</groupId>
<artifactId>spring-security-taglibs</artifactId> <artifactId>spring-security-taglibs</artifactId>
</dependency> </dependency>
<!-- Test --> <!-- Test -->
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>
<artifactId>junit</artifactId> <artifactId>junit</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<!-- Spring Data JPA dependencies --> <!-- Spring Data JPA dependencies -->
<dependency> <dependency>
<groupId>org.springframework.data</groupId> <groupId>org.springframework.data</groupId>
@ -104,7 +89,6 @@
<groupId>org.hibernate</groupId> <groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId> <artifactId>hibernate-validator</artifactId>
</dependency> </dependency>
<!-- DB dependencies --> <!-- DB dependencies -->
<dependency> <dependency>
<groupId>mysql</groupId> <groupId>mysql</groupId>
@ -129,7 +113,6 @@
<version>${guava.version}</version> <version>${guava.version}</version>
</dependency> </dependency>
</dependencies> </dependencies>
<build> <build>
<finalName>spring-security-login-and-registration</finalName> <finalName>spring-security-login-and-registration</finalName>
<resources> <resources>
@ -144,22 +127,16 @@
<org.springframework-version>3.1.1.RELEASE</org.springframework-version> <org.springframework-version>3.1.1.RELEASE</org.springframework-version>
<org.springframework.security.version>3.2.5.RELEASE</org.springframework.security.version> <org.springframework.security.version>3.2.5.RELEASE</org.springframework.security.version>
<org.aspectj-version>1.6.10</org.aspectj-version> <org.aspectj-version>1.6.10</org.aspectj-version>
<!-- logging --> <!-- logging -->
<org.slf4j.version>1.7.6</org.slf4j.version> <org.slf4j.version>1.7.6</org.slf4j.version>
<logback.version>1.1.1</logback.version> <logback.version>1.1.1</logback.version>
<!-- javax jsp --> <!-- javax jsp -->
<javax.servlet.jsp-api.version>2.3.2-b01</javax.servlet.jsp-api.version> <javax.servlet.jsp-api.version>2.3.2-b01</javax.servlet.jsp-api.version>
<!-- Inject --> <!-- Inject -->
<javax.inject.version>1</javax.inject.version> <javax.inject.version>1</javax.inject.version>
<!-- Spring Data Jpa --> <!-- Spring Data Jpa -->
<spring-data-jpa.version>1.4.5.RELEASE</spring-data-jpa.version> <spring-data-jpa.version>1.4.5.RELEASE</spring-data-jpa.version>
<!-- guava --> <!-- guava -->
<guava.version>17.0</guava.version> <guava.version>17.0</guava.version>
</properties> </properties>
</project> </project>

View File

@ -23,6 +23,7 @@ public class Role {
@JoinColumn(name = "user_id") @JoinColumn(name = "user_id")
private User user; private User user;
@Column(name = "role") @Column(name = "role")
private Integer role; private Integer role;

View File

@ -0,0 +1,22 @@
package org.baeldung.persistence.service;
import javax.validation.Constraint;
import javax.validation.Payload;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
@Target({TYPE,ANNOTATION_TYPE})
@Retention(RUNTIME)
@Constraint(validatedBy = PasswordMatchesValidator.class)
@Documented
public @interface PasswordMatches {
String message() default "Passwords don't match";
Class<?>[] groups() default {};
Class<? extends Payload>[] payload() default {};
}

View File

@ -0,0 +1,16 @@
package org.baeldung.persistence.service;
import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
public class PasswordMatchesValidator implements ConstraintValidator<PasswordMatches, Object> {
@Override
public void initialize(PasswordMatches constraintAnnotation) {
}
@Override
public boolean isValid(Object obj, ConstraintValidatorContext context){
UserDto user = (UserDto) obj;
return user.getPassword().equals(user.getMatchingPassword());
}
}

View File

@ -12,7 +12,6 @@ import org.springframework.stereotype.Service;
public class RepositoryService implements UserService { public class RepositoryService implements UserService {
@Autowired @Autowired
private UserRepository repository; private UserRepository repository;
@Autowired @Autowired
private Environment env; private Environment env;

View File

@ -1,9 +1,24 @@
package org.baeldung.persistence.service; package org.baeldung.persistence.service;
import javax.validation.constraints.NotNull;
import org.hibernate.validator.constraints.NotEmpty;
@PasswordMatches
public class UserDto { public class UserDto {
@NotNull
@NotEmpty
private String firstName; private String firstName;
@NotNull
@NotEmpty
private String lastName; private String lastName;
@NotNull
@NotEmpty
private String password; private String password;
@NotNull
@NotEmpty
private String matchingPassword;
@ValidUsername
@NotNull
@NotEmpty
private String username; private String username;
private Integer role; private Integer role;
@ -46,6 +61,12 @@ public class UserDto {
public void setPassword(String password) { public void setPassword(String password) {
this.password = password; this.password = password;
} }
public String getMatchingPassword() {
return matchingPassword;
}
public void setMatchingPassword(String matchingPassword) {
this.matchingPassword = matchingPassword;
}
@Override @Override
public String toString() { public String toString() {

View File

@ -0,0 +1,28 @@
package org.baeldung.persistence.service;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
public class UsernameValidator implements ConstraintValidator<ValidUsername, String> {
private Pattern pattern;
private Matcher matcher;
private static final String EMAIL_PATTERN = "^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@" + "[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$";
@Override
public void initialize(ValidUsername constraintAnnotation) {
}
@Override
public boolean isValid(String username, ConstraintValidatorContext context) {
return (validateEmail(username));
}
public boolean validateEmail(String email) {
pattern = Pattern.compile(EMAIL_PATTERN);
matcher = pattern.matcher(email);
return matcher.matches();
}
}

View File

@ -0,0 +1,24 @@
package org.baeldung.persistence.service;
import javax.validation.Constraint;
import javax.validation.Payload;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
@Target({ TYPE, FIELD, ANNOTATION_TYPE })
@Retention(RUNTIME)
@Constraint(validatedBy = UsernameValidator.class)
@Documented
public @interface ValidUsername {
String message() default "Invalid Email";
Class<?>[] groups() default {};
Class<? extends Payload>[] payload() default {};
}

View File

@ -1,7 +1,9 @@
package org.baeldung.spring; package org.baeldung.spring;
import java.util.Locale; import java.util.Locale;
import org.baeldung.persistence.service.UserValidator;
import org.baeldung.persistence.service.PasswordMatchesValidator;
import org.baeldung.persistence.service.UsernameValidator;
import org.springframework.context.MessageSource; import org.springframework.context.MessageSource;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.ComponentScan;
@ -81,11 +83,17 @@ public class MvcConfig extends WebMvcConfigurerAdapter {
messageSource.setCacheSeconds(0); messageSource.setCacheSeconds(0);
return messageSource; return messageSource;
} }
@Bean
public UsernameValidator usernameValidator() {
UsernameValidator userNameValidator = new UsernameValidator();
return userNameValidator;
}
@Bean @Bean
public UserValidator userValidator() { public PasswordMatchesValidator passwordMatchesValidator() {
UserValidator userValidator = new UserValidator(); PasswordMatchesValidator passwordMatchesValidator = new PasswordMatchesValidator();
return userValidator; return passwordMatchesValidator;
} }
} }

View File

@ -5,16 +5,14 @@ import org.baeldung.persistence.model.User;
import org.baeldung.persistence.service.EmailExistsException; import org.baeldung.persistence.service.EmailExistsException;
import org.baeldung.persistence.service.UserDto; import org.baeldung.persistence.service.UserDto;
import org.baeldung.persistence.service.UserService; import org.baeldung.persistence.service.UserService;
import org.baeldung.persistence.service.UserValidator;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.MessageSource;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.ui.Model; import org.springframework.ui.Model;
import org.springframework.validation.BindingResult; import org.springframework.validation.BindingResult;
import org.springframework.validation.Errors; import org.springframework.validation.Errors;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder;
import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
@ -23,17 +21,11 @@ import org.springframework.web.servlet.ModelAndView;
@Controller @Controller
public class RegistrationController { public class RegistrationController {
private final Logger LOGGER = LoggerFactory.getLogger(getClass()); private final Logger LOGGER = LoggerFactory.getLogger(getClass());
private UserService service; private UserService service;
@Autowired @Autowired
private UserValidator validator; private MessageSource messages;
@InitBinder
protected void initBinder(WebDataBinder binder) {
binder.setValidator(this.validator);
}
@Autowired @Autowired
public RegistrationController(UserService service) { public RegistrationController(UserService service) {
@ -50,13 +42,11 @@ public class RegistrationController {
@RequestMapping(value = "/user/registration", method = RequestMethod.POST) @RequestMapping(value = "/user/registration", method = RequestMethod.POST)
public ModelAndView registerUserAccount(@ModelAttribute("user") @Valid UserDto userAccountData, BindingResult result, WebRequest request, Errors errors) { public ModelAndView registerUserAccount(@ModelAttribute("user") @Valid UserDto userAccountData, BindingResult result, WebRequest request, Errors errors) {
boolean goodEmailCheck = validator.validateEmail(userAccountData.getUsername());
if (!goodEmailCheck) User registered = new User();
result.rejectValue("username", "message.badEmail");
User registered = null;
if (!result.hasErrors()) if (!result.hasErrors())
registered = createUserAccount(userAccountData, result); registered = createUserAccount(userAccountData, result);
if (registered == null && !userAccountData.getUsername().isEmpty() && goodEmailCheck) { if (registered == null) {
result.rejectValue("username", "message.regError"); result.rejectValue("username", "message.regError");
} }
if (result.hasErrors()) { if (result.hasErrors()) {

View File

@ -8,3 +8,4 @@ init-db=false
hibernate.dialect=org.hibernate.dialect.MySQLDialect hibernate.dialect=org.hibernate.dialect.MySQLDialect
hibernate.show_sql=false hibernate.show_sql=false
hibernate.hbm2ddl.auto=create-drop hibernate.hbm2ddl.auto=create-drop

View File

@ -14,4 +14,18 @@ label.user.email=Email
label.user.firstName=First name label.user.firstName=First name
label.user.lastName=Last name label.user.lastName=Last name
label.user.password=Password label.user.password=Password
label.login=Login here label.login=Login here
ValidUsername.user.username=Invalid Username (Email)
UniqueUsername.user.username=An account with that username/email already exists
NotNull.user.firstName=First name required
NotEmpty.user.firstName=First name required
NotNull.user.lastName=Last name required
NotEmpty.user.lastName=Last name required
NotNull.user.username=Username(Email) required
NotEmpty.user.username=Username(Email) required
NotNull.user.password=Password required
NotEmpty.user.password=Password required
NotNull.user.matchingPassword=Required
NotEmpty.user.matchingPassword=Required
PasswordMatches.user:Password does not match!
Email.user.username=Invalid Username (Email)

View File

@ -14,4 +14,18 @@ label.user.email=Email
label.user.firstName=Nombre label.user.firstName=Nombre
label.user.lastName=Apellido label.user.lastName=Apellido
label.user.password=Clave label.user.password=Clave
label.login=Autehtifiquese aqui label.login=Autehtifiquese aqui
ValidUsername.user.username=Email no es valido
UniqueUsername.user.username=Ya existe una cuenta con ese nombre de usuario
NotNull.user.firstName=Por favor ingrese su nombre
NotEmpty.user.firstName=Por favor ingrese su nombre
NotNull.user.lastName=Por favor ingrese su apellido
NotEmpty.user.lastName=Por favor ingrese su apellido
NotNull.user.username=Por favor ingrese su cuenta de email
NotEmpty.user.username=Por favor ingrese su cuenta de email
NotNull.user.password=Por favor ingrese su clave
NotEmpty.user.password=Por favor ingrese su clave
NotNull.user.matchingPassword=Campo obligatirio
NotEmpty.user.matchingPassword=Campo obligatrio
PasswordMatches.user:Las claves no coinciden!
Email.user.username=Email no es valido

View File

@ -5,8 +5,6 @@
xsi:schemaLocation=" xsi:schemaLocation="
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.2.xsd http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.2.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd"> http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd">
<http use-expressions="true"> <http use-expressions="true">
<intercept-url pattern="/login*" access="permitAll" /> <intercept-url pattern="/login*" access="permitAll" />
<intercept-url pattern="/logout*" access="permitAll" /> <intercept-url pattern="/logout*" access="permitAll" />
@ -16,7 +14,6 @@
<intercept-url pattern="/registration*" access="permitAll" /> <intercept-url pattern="/registration*" access="permitAll" />
<intercept-url pattern="/resources/**" access="permitAll" /> <intercept-url pattern="/resources/**" access="permitAll" />
<intercept-url pattern="/invalidSession*" access="isAnonymous()" /> <intercept-url pattern="/invalidSession*" access="isAnonymous()" />
<!-- <intercept-url pattern="/result*" access="isAnonymous()" /> -->
<intercept-url pattern="/**" access="isAuthenticated()" /> <intercept-url pattern="/**" access="isAuthenticated()" />
<form-login login-page='/login.html' <form-login login-page='/login.html'
authentication-failure-url="/login.html?error=true" authentication-failure-url="/login.html?error=true"
@ -24,13 +21,14 @@
default-target-url="/homepage.html" /> default-target-url="/homepage.html" />
<session-management invalid-session-url="/invalidSession.html" <session-management invalid-session-url="/invalidSession.html"
session-fixation-protection="none" /> session-fixation-protection="none" />
<logout invalidate-session="false" logout-success-url="/logout.html?logSucc=1" <logout invalidate-session="false" logout-success-url="/logout.html?logSucc=true"
logout-url="/j_spring_security_logout" delete-cookies="JSESSIONID" /> logout-url="/j_spring_security_logout" delete-cookies="JSESSIONID" />
</http> </http>
<beans:bean id="myAuthenticationSuccessHandler" <beans:bean id="myAuthenticationSuccessHandler"
class="org.baeldung.security.MySimpleUrlAuthenticationSuccessHandler" /> class="org.baeldung.security.MySimpleUrlAuthenticationSuccessHandler" />
<authentication-manager> <authentication-manager>
<authentication-provider user-service-ref="userDetailsService"> <authentication-provider user-service-ref="userDetailsService">
<!-- <password-encoder ref="passwordEncoder"/> -->
</authentication-provider> </authentication-provider>
</authentication-manager> </authentication-manager>
<beans:bean id="passwordEncoder" <beans:bean id="passwordEncoder"

View File

@ -8,7 +8,10 @@
<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_ADMIN"> <sec:authorize ifAnyGranted="ROLE_ADMIN">
<H1>Hello Admin</H1> <H1>Hello Admin</H1>
@ -17,6 +20,4 @@
<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="/home.html" />">Home</a> <a href="<c:url value="/home.html" />">Home</a>
</body> </body>
</html> </html>

View File

@ -5,20 +5,16 @@
<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')"> <security: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> </security:authorize>
<security:authorize access="hasRole('ROLE_ADMIN')"> <security: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> </security: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

@ -6,7 +6,6 @@
<link href="<c:url value="/resources/bootstrap.css" />" rel="stylesheet"> <link href="<c:url value="/resources/bootstrap.css" />" rel="stylesheet">
<title>Home</title> <title>Home</title>
</head> </head>
<body> <body>
<h1>Welcome back home!</h1> <h1>Welcome back home!</h1>
</body> </body>

View File

@ -1,11 +1,15 @@
<%@ 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>
<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 homepage for the user</h1> <h1>This is the homepage for the user</h1>
@ -23,5 +27,8 @@
<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

@ -5,7 +5,6 @@
<link href="<c:url value="/resources/bootstrap.css" />" rel="stylesheet"> <link href="<c:url value="/resources/bootstrap.css" />" rel="stylesheet">
<title>Home</title> <title>Home</title>
</head> </head>
<body> <body>
<h1 class="alert alert-error"> <h1 class="alert alert-error">
<spring:message code="message.sessionExpired"></spring:message> <spring:message code="message.sessionExpired"></spring:message>

View File

@ -37,13 +37,11 @@
} }
</script> </script>
</head> </head>
<body> <body>
<h1>Login</h1> <h1>Login</h1>
<a href="?lang=en">English</a> | <a href="?lang=en">English</a> |
<a href="?lang=es_ES">Spanish</a> <a href="?lang=es_ES">Spanish</a>
<form name='f' action="j_spring_security_check" method='POST' onsubmit="return validate();"> <form name='f' action="j_spring_security_check" method='POST' onsubmit="return validate();">
<table> <table>
<tr> <tr>
<td>User:</td> <td>User:</td>

View File

@ -11,17 +11,16 @@
<spring:message code="message.logoutError"></spring:message> <spring:message code="message.logoutError"></spring:message>
</div> </div>
</c:if> </c:if>
<c:if test="${param.logSucc == 1}">
<div id="success">
<spring:message code="message.logoutSucc"></spring:message>
</div>
</c:if>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Logged Out</title> <title>Logged Out</title>
</head> </head>
<body> <body>
<c:if test="${param.logSucc == true}">
<div id="success">
<spring:message code="message.logoutSucc"></spring:message>
</div>
</c:if>
<a href="login.html">Login</a> <a href="login.html">Login</a>
</body> </body>

View File

@ -36,6 +36,11 @@
<td><form:input path="password" value="" type="password" /></td> <td><form:input path="password" value="" type="password" /></td>
<form:errors path="password" cssClass="alert alert-error" element="div" /> <form:errors path="password" cssClass="alert alert-error" element="div" />
</tr> </tr>
<tr>
<td><label>Re-enter password:</label></td>
<td><form:input path="matchingPassword" value="" type="password"/></td>
<form:errors cssClass="alert alert-error" element="div" />
</tr>
<input type="hidden" name="role" value="1" /> <input type="hidden" name="role" value="1" />
<button type="submit">submit</button> <button type="submit">submit</button>
</form:form> </form:form>

View File

@ -12,7 +12,6 @@
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Registration Success</title> <title>Registration Success</title>
</head> </head>
<body> <body>
<h1> <h1>
<spring:message code="message.regSucc"></spring:message> <spring:message code="message.regSucc"></spring:message>