diff --git a/spring-security-login-and-registration-frontend/.classpath b/spring-security-login-and-registration-frontend/.classpath deleted file mode 100644 index c0f4868f56..0000000000 --- a/spring-security-login-and-registration-frontend/.classpath +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/spring-security-login-and-registration-frontend/.project b/spring-security-login-and-registration-frontend/.project deleted file mode 100644 index 00da6328b5..0000000000 --- a/spring-security-login-and-registration-frontend/.project +++ /dev/null @@ -1,48 +0,0 @@ - - - spring-security-login-and-registration-frontend - - - - - - org.eclipse.wst.jsdt.core.javascriptValidator - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.wst.common.project.facet.core.builder - - - - - org.eclipse.m2e.core.maven2Builder - - - - - org.springframework.ide.eclipse.core.springbuilder - - - - - org.eclipse.wst.validation.validationbuilder - - - - - - org.eclipse.jem.workbench.JavaEMFNature - org.eclipse.wst.common.modulecore.ModuleCoreNature - org.springframework.ide.eclipse.core.springnature - org.eclipse.jdt.core.javanature - org.eclipse.m2e.core.maven2Nature - org.eclipse.wst.common.project.facet.core.nature - org.eclipse.wst.jsdt.core.jsNature - - diff --git a/spring-security-login-and-registration-frontend/pom.xml b/spring-security-login-and-registration-frontend/pom.xml deleted file mode 100644 index 36774b713c..0000000000 --- a/spring-security-login-and-registration-frontend/pom.xml +++ /dev/null @@ -1,192 +0,0 @@ - - - 4.0.0 - org.baeldung - spring-security-login-and-registration-frontend - spring-security-login-and-registration-frontend - war - 1.0.1-SNAPSHOT - - - org.springframework.boot - spring-boot-starter-parent - 1.1.10.RELEASE - - - - - - - org.springframework.boot - spring-boot-starter-web - - - org.springframework - spring-context-support - - - org.springframework.security - spring-security-config - runtime - - - - - - - - - - - javax.servlet - javax.servlet-api - - - javax.servlet.jsp - javax.servlet.jsp-api - ${javax.servlet.jsp-api.version} - - - javax.servlet - jstl - - - org.springframework.security - spring-security-taglibs - - - javax.el - el-api - 2.2 - - - - org.springframework - spring-test - 4.1.4.RELEASE - test - - - - - org.springframework.data - spring-data-jpa - - - org.hibernate - hibernate-entitymanager - - - - - - - - - org.hibernate - hibernate-validator - - - - - mysql - mysql-connector-java - - - commons-dbcp - commons-dbcp - - - com.fasterxml.jackson.core - jackson-databind - - - javax.mail - mail - 1.4.7 - - - com.google.guava - guava - ${guava.version} - - - - - org.slf4j - slf4j-api - - - ch.qos.logback - logback-classic - - - org.slf4j - jcl-over-slf4j - - - - org.slf4j - log4j-over-slf4j - - - - - junit - junit - test - - - - - - spring-security-login-and-registration-frontend - - - src/main/resources - true - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - - ${java-version} - ${java-version} - - - - - org.apache.maven.plugins - maven-war-plugin - - - - - - - 1.7 - 3.1.4.RELEASE - 3.2.5.RELEASE - - - 1.7.7 - 1.1.2 - - - 2.3.2-b01 - - - 1 - - - 1.7.1.RELEASE - - - 18.0 - - - diff --git a/spring-security-login-and-registration-frontend/src/main/java/org/baeldung/persistence/dao/PasswordResetTokenRepository.java b/spring-security-login-and-registration-frontend/src/main/java/org/baeldung/persistence/dao/PasswordResetTokenRepository.java deleted file mode 100644 index 9ef80fe8b1..0000000000 --- a/spring-security-login-and-registration-frontend/src/main/java/org/baeldung/persistence/dao/PasswordResetTokenRepository.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.baeldung.persistence.dao; - -import org.baeldung.persistence.model.PasswordResetToken; -import org.baeldung.persistence.model.User; -import org.springframework.data.jpa.repository.JpaRepository; - -public interface PasswordResetTokenRepository extends JpaRepository { - - public PasswordResetToken findByToken(String token); - - public PasswordResetToken findByUser(User user); -} diff --git a/spring-security-login-and-registration-frontend/src/main/java/org/baeldung/persistence/dao/PrivilegeRepository.java b/spring-security-login-and-registration-frontend/src/main/java/org/baeldung/persistence/dao/PrivilegeRepository.java deleted file mode 100644 index 3f8016f314..0000000000 --- a/spring-security-login-and-registration-frontend/src/main/java/org/baeldung/persistence/dao/PrivilegeRepository.java +++ /dev/null @@ -1,10 +0,0 @@ -package org.baeldung.persistence.dao; - -import org.baeldung.persistence.model.Privilege; -import org.springframework.data.jpa.repository.JpaRepository; - -public interface PrivilegeRepository extends JpaRepository { - public Privilege findByName(String name); - - public void delete(Privilege privilege); -} diff --git a/spring-security-login-and-registration-frontend/src/main/java/org/baeldung/persistence/dao/RoleRepository.java b/spring-security-login-and-registration-frontend/src/main/java/org/baeldung/persistence/dao/RoleRepository.java deleted file mode 100644 index 90d6de60f2..0000000000 --- a/spring-security-login-and-registration-frontend/src/main/java/org/baeldung/persistence/dao/RoleRepository.java +++ /dev/null @@ -1,10 +0,0 @@ -package org.baeldung.persistence.dao; - -import org.baeldung.persistence.model.Role; -import org.springframework.data.jpa.repository.JpaRepository; - -public interface RoleRepository extends JpaRepository { - public Role findByName(String name); - - public void delete(Role role); -} diff --git a/spring-security-login-and-registration-frontend/src/main/java/org/baeldung/persistence/dao/UserRepository.java b/spring-security-login-and-registration-frontend/src/main/java/org/baeldung/persistence/dao/UserRepository.java deleted file mode 100644 index 12f07d8692..0000000000 --- a/spring-security-login-and-registration-frontend/src/main/java/org/baeldung/persistence/dao/UserRepository.java +++ /dev/null @@ -1,11 +0,0 @@ -package org.baeldung.persistence.dao; - -import org.springframework.data.jpa.repository.JpaRepository; -import org.baeldung.persistence.model.User; - -public interface UserRepository extends JpaRepository { - public User findByEmail(String email); - - public void delete(User user); - -} diff --git a/spring-security-login-and-registration-frontend/src/main/java/org/baeldung/persistence/dao/VerificationTokenRepository.java b/spring-security-login-and-registration-frontend/src/main/java/org/baeldung/persistence/dao/VerificationTokenRepository.java deleted file mode 100644 index f9fc850d41..0000000000 --- a/spring-security-login-and-registration-frontend/src/main/java/org/baeldung/persistence/dao/VerificationTokenRepository.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.baeldung.persistence.dao; - -import org.baeldung.persistence.model.User; -import org.baeldung.persistence.model.VerificationToken; -import org.springframework.data.jpa.repository.JpaRepository; - -public interface VerificationTokenRepository extends JpaRepository { - - public VerificationToken findByToken(String token); - - public VerificationToken findByUser(User user); -} diff --git a/spring-security-login-and-registration-frontend/src/main/java/org/baeldung/persistence/model/PasswordResetToken.java b/spring-security-login-and-registration-frontend/src/main/java/org/baeldung/persistence/model/PasswordResetToken.java deleted file mode 100644 index cfff0135da..0000000000 --- a/spring-security-login-and-registration-frontend/src/main/java/org/baeldung/persistence/model/PasswordResetToken.java +++ /dev/null @@ -1,132 +0,0 @@ -package org.baeldung.persistence.model; - -import java.util.Calendar; -import java.util.Date; - -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.OneToOne; - -@Entity -public class PasswordResetToken { - - private static final int EXPIRATION = 60 * 24; - - @Id - @GeneratedValue(strategy = GenerationType.AUTO) - private Long id; - - private String token; - - @OneToOne(targetEntity = User.class, fetch = FetchType.EAGER) - @JoinColumn(nullable = false, name = "user_id") - private User user; - - private Date expiryDate; - - public PasswordResetToken() { - super(); - } - - public PasswordResetToken(String token) { - super(); - - this.token = token; - this.expiryDate = calculateExpiryDate(EXPIRATION); - } - - public PasswordResetToken(String token, User user) { - super(); - - this.token = token; - this.user = user; - this.expiryDate = calculateExpiryDate(EXPIRATION); - } - - public String getToken() { - return token; - } - - public void setToken(String token) { - this.token = token; - } - - public User getUser() { - return user; - } - - public void setUser(User user) { - this.user = user; - } - - public Date getExpiryDate() { - return expiryDate; - } - - public void setExpiryDate(Date expiryDate) { - this.expiryDate = expiryDate; - } - - private Date calculateExpiryDate(int expiryTimeInMinutes) { - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(new Date().getTime()); - cal.add(Calendar.MINUTE, expiryTimeInMinutes); - return new Date(cal.getTime().getTime()); - } - - public void updateToken(String token) { - this.token = token; - this.expiryDate = calculateExpiryDate(EXPIRATION); - } - - // - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((expiryDate == null) ? 0 : expiryDate.hashCode()); - result = prime * result + ((token == null) ? 0 : token.hashCode()); - result = prime * result + ((user == null) ? 0 : user.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - PasswordResetToken other = (PasswordResetToken) obj; - if (expiryDate == null) { - if (other.expiryDate != null) - return false; - } else if (!expiryDate.equals(other.expiryDate)) - return false; - if (token == null) { - if (other.token != null) - return false; - } else if (!token.equals(other.token)) - return false; - if (user == null) { - if (other.user != null) - return false; - } else if (!user.equals(other.user)) - return false; - return true; - } - - @Override - public String toString() { - final StringBuilder builder = new StringBuilder(); - builder.append("Token [String=").append(token).append("]").append("[Expires").append(expiryDate).append("]"); - return builder.toString(); - } - -} diff --git a/spring-security-login-and-registration-frontend/src/main/java/org/baeldung/persistence/model/Privilege.java b/spring-security-login-and-registration-frontend/src/main/java/org/baeldung/persistence/model/Privilege.java deleted file mode 100644 index c403ffb7a2..0000000000 --- a/spring-security-login-and-registration-frontend/src/main/java/org/baeldung/persistence/model/Privilege.java +++ /dev/null @@ -1,83 +0,0 @@ -package org.baeldung.persistence.model; - -import java.util.Collection; - -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.ManyToMany; - -@Entity -public class Privilege { - @Id - @GeneratedValue(strategy = GenerationType.AUTO) - private Long id; - - private String name; - - @ManyToMany(mappedBy = "privileges") - private Collection roles; - - public Privilege() { - super(); - } - - public Privilege(String name) { - super(); - this.name = name; - } - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public Collection getRoles() { - return roles; - } - - public void setRoles(Collection roles) { - this.roles = roles; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((name == null) ? 0 : name.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 Privilege privilege = (Privilege) obj; - if (!privilege.equals(privilege.name)) - return false; - return true; - } - - @Override - public String toString() { - final StringBuilder builder = new StringBuilder(); - builder.append("Privilege [name=").append(name).append("]").append("[id=").append(id).append("]"); - return builder.toString(); - } -} diff --git a/spring-security-login-and-registration-frontend/src/main/java/org/baeldung/persistence/model/Role.java b/spring-security-login-and-registration-frontend/src/main/java/org/baeldung/persistence/model/Role.java deleted file mode 100644 index c656f134d9..0000000000 --- a/spring-security-login-and-registration-frontend/src/main/java/org/baeldung/persistence/model/Role.java +++ /dev/null @@ -1,98 +0,0 @@ -package org.baeldung.persistence.model; - -import java.util.Collection; - -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.JoinTable; -import javax.persistence.ManyToMany; -import javax.persistence.JoinColumn; - -@Entity -public class Role { - - @Id - @GeneratedValue(strategy = GenerationType.AUTO) - private Long id; - - @ManyToMany(mappedBy = "roles") - private Collection users; - - @ManyToMany - @JoinTable(name = "roles_privileges", joinColumns = @JoinColumn(name = "role_id", referencedColumnName = "id"), inverseJoinColumns = @JoinColumn(name = "privilege_id", referencedColumnName = "id")) - private Collection privileges; - - private String name; - - public Role() { - super(); - } - - public Role(String name) { - super(); - this.name = name; - } - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public Collection getUsers() { - return users; - } - - public void setUsers(Collection users) { - this.users = users; - } - - public Collection getPrivileges() { - return privileges; - } - - public void setPrivileges(Collection privileges) { - this.privileges = privileges; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((name == null) ? 0 : name.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.name)) - return false; - return true; - } - - @Override - public String toString() { - final StringBuilder builder = new StringBuilder(); - builder.append("Role [name=").append(name).append("]").append("[id=").append(id).append("]"); - return builder.toString(); - } -} \ No newline at end of file diff --git a/spring-security-login-and-registration-frontend/src/main/java/org/baeldung/persistence/model/User.java b/spring-security-login-and-registration-frontend/src/main/java/org/baeldung/persistence/model/User.java deleted file mode 100644 index 4fc2d57f5b..0000000000 --- a/spring-security-login-and-registration-frontend/src/main/java/org/baeldung/persistence/model/User.java +++ /dev/null @@ -1,137 +0,0 @@ -package org.baeldung.persistence.model; - -import java.util.Collection; - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.JoinTable; -import javax.persistence.ManyToMany; - -@Entity -public class User { - - @Id - @GeneratedValue(strategy = GenerationType.AUTO) - private Long id; - - private String firstName; - - private String lastName; - - private String email; - - @Column(length = 60) - private String password; - - private boolean enabled; - - private boolean tokenExpired; - - @ManyToMany - @JoinTable(name = "users_roles", joinColumns = @JoinColumn(name = "user_id", referencedColumnName = "id"), inverseJoinColumns = @JoinColumn(name = "role_id", referencedColumnName = "id")) - private Collection roles; - - public User() { - super(); - this.enabled = false; - this.tokenExpired = false; - } - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getFirstName() { - return firstName; - } - - public void setFirstName(String firstName) { - this.firstName = firstName; - } - - public String getLastName() { - return lastName; - } - - public void setLastName(String lastName) { - this.lastName = lastName; - } - - public String getEmail() { - return email; - } - - public void setEmail(String username) { - this.email = username; - } - - public String getPassword() { - return password; - } - - public void setPassword(String password) { - this.password = password; - } - - public Collection getRoles() { - return roles; - } - - public void setRoles(Collection roles) { - this.roles = roles; - } - - public boolean isEnabled() { - return enabled; - } - - public void setEnabled(boolean enabled) { - this.enabled = enabled; - } - - public boolean isTokenExpired() { - return tokenExpired; - } - - public void setTokenExpired(boolean expired) { - this.tokenExpired = expired; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((email == null) ? 0 : email.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 User user = (User) obj; - if (!email.equals(user.email)) - return false; - return true; - } - - @Override - public String toString() { - final StringBuilder builder = new StringBuilder(); - builder.append("User [firstName=").append(firstName).append("]").append("[lastName=").append(lastName).append("]").append("[username").append(email).append("]"); - return builder.toString(); - } - -} \ No newline at end of file diff --git a/spring-security-login-and-registration-frontend/src/main/java/org/baeldung/persistence/model/VerificationToken.java b/spring-security-login-and-registration-frontend/src/main/java/org/baeldung/persistence/model/VerificationToken.java deleted file mode 100644 index a25750d3d0..0000000000 --- a/spring-security-login-and-registration-frontend/src/main/java/org/baeldung/persistence/model/VerificationToken.java +++ /dev/null @@ -1,132 +0,0 @@ -package org.baeldung.persistence.model; - -import java.util.Calendar; -import java.util.Date; - -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.OneToOne; - -@Entity -public class VerificationToken { - - private static final int EXPIRATION = 60 * 24; - - @Id - @GeneratedValue(strategy = GenerationType.AUTO) - private Long id; - - private String token; - - @OneToOne(targetEntity = User.class, fetch = FetchType.EAGER) - @JoinColumn(nullable = false, name = "user_id") - private User user; - - private Date expiryDate; - - public VerificationToken() { - super(); - } - - public VerificationToken(String token) { - super(); - - this.token = token; - this.expiryDate = calculateExpiryDate(EXPIRATION); - } - - public VerificationToken(String token, User user) { - super(); - - this.token = token; - this.user = user; - this.expiryDate = calculateExpiryDate(EXPIRATION); - } - - public String getToken() { - return token; - } - - public void setToken(String token) { - this.token = token; - } - - public User getUser() { - return user; - } - - public void setUser(User user) { - this.user = user; - } - - public Date getExpiryDate() { - return expiryDate; - } - - public void setExpiryDate(Date expiryDate) { - this.expiryDate = expiryDate; - } - - private Date calculateExpiryDate(int expiryTimeInMinutes) { - Calendar cal = Calendar.getInstance(); - cal.setTimeInMillis(new Date().getTime()); - cal.add(Calendar.MINUTE, expiryTimeInMinutes); - return new Date(cal.getTime().getTime()); - } - - public void updateToken(String token) { - this.token = token; - this.expiryDate = calculateExpiryDate(EXPIRATION); - } - - // - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((expiryDate == null) ? 0 : expiryDate.hashCode()); - result = prime * result + ((token == null) ? 0 : token.hashCode()); - result = prime * result + ((user == null) ? 0 : user.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - VerificationToken other = (VerificationToken) obj; - if (expiryDate == null) { - if (other.expiryDate != null) - return false; - } else if (!expiryDate.equals(other.expiryDate)) - return false; - if (token == null) { - if (other.token != null) - return false; - } else if (!token.equals(other.token)) - return false; - if (user == null) { - if (other.user != null) - return false; - } else if (!user.equals(other.user)) - return false; - return true; - } - - @Override - public String toString() { - final StringBuilder builder = new StringBuilder(); - builder.append("Token [String=").append(token).append("]").append("[Expires").append(expiryDate).append("]"); - return builder.toString(); - } - -} diff --git a/spring-security-login-and-registration-frontend/src/main/java/org/baeldung/security/AuthenticationFailureListener.java b/spring-security-login-and-registration-frontend/src/main/java/org/baeldung/security/AuthenticationFailureListener.java deleted file mode 100644 index 3f1702defe..0000000000 --- a/spring-security-login-and-registration-frontend/src/main/java/org/baeldung/security/AuthenticationFailureListener.java +++ /dev/null @@ -1,19 +0,0 @@ -package org.baeldung.security; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.ApplicationListener; -import org.springframework.security.authentication.event.AuthenticationFailureBadCredentialsEvent; -import org.springframework.security.web.authentication.WebAuthenticationDetails; -import org.springframework.stereotype.Component; - -@Component -public class AuthenticationFailureListener implements ApplicationListener { - - @Autowired - private LoginAttemptService loginAttemptService; - - public void onApplicationEvent(AuthenticationFailureBadCredentialsEvent e) { - WebAuthenticationDetails auth = (WebAuthenticationDetails) e.getAuthentication().getDetails(); - loginAttemptService.loginFailed(auth.getRemoteAddress()); - } -} \ No newline at end of file diff --git a/spring-security-login-and-registration-frontend/src/main/java/org/baeldung/security/AuthenticationSuccessEventListener.java b/spring-security-login-and-registration-frontend/src/main/java/org/baeldung/security/AuthenticationSuccessEventListener.java deleted file mode 100644 index dff78ac0db..0000000000 --- a/spring-security-login-and-registration-frontend/src/main/java/org/baeldung/security/AuthenticationSuccessEventListener.java +++ /dev/null @@ -1,19 +0,0 @@ -package org.baeldung.security; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.ApplicationListener; -import org.springframework.security.authentication.event.AuthenticationSuccessEvent; -import org.springframework.security.web.authentication.WebAuthenticationDetails; -import org.springframework.stereotype.Component; - -@Component -public class AuthenticationSuccessEventListener implements ApplicationListener { - - @Autowired - private LoginAttemptService loginAttemptService; - - public void onApplicationEvent(AuthenticationSuccessEvent e) { - WebAuthenticationDetails auth = (WebAuthenticationDetails) e.getAuthentication().getDetails(); - loginAttemptService.loginSucceeded(auth.getRemoteAddress()); - } -} diff --git a/spring-security-login-and-registration-frontend/src/main/java/org/baeldung/security/LoginAttemptService.java b/spring-security-login-and-registration-frontend/src/main/java/org/baeldung/security/LoginAttemptService.java deleted file mode 100644 index d03b50932a..0000000000 --- a/spring-security-login-and-registration-frontend/src/main/java/org/baeldung/security/LoginAttemptService.java +++ /dev/null @@ -1,49 +0,0 @@ -package org.baeldung.security; - -import java.util.concurrent.ExecutionException; -import java.util.concurrent.TimeUnit; - -import org.springframework.stereotype.Service; - -import com.google.common.cache.CacheBuilder; -import com.google.common.cache.CacheLoader; -import com.google.common.cache.LoadingCache; - -@Service -public class LoginAttemptService { - - private final int MAX_ATTEMPT = 10; - private LoadingCache attemptsCache; - - public LoginAttemptService() { - super(); - attemptsCache = CacheBuilder.newBuilder().expireAfterWrite(1, TimeUnit.DAYS).build(new CacheLoader() { - public Integer load(String key) { - return 0; - } - }); - } - - public void loginSucceeded(String key) { - attemptsCache.invalidate(key); - } - - public void loginFailed(String key) { - int attempts = 0; - try { - attempts = attemptsCache.get(key); - } catch (ExecutionException e) { - attempts = 0; - } - attempts++; - attemptsCache.put(key, attempts); - } - - public boolean isBlocked(String key) { - try { - return attemptsCache.get(key) >= MAX_ATTEMPT; - } catch (ExecutionException e) { - return false; - } - } -} diff --git a/spring-security-login-and-registration-frontend/src/main/java/org/baeldung/security/MySimpleUrlAuthenticationSuccessHandler.java b/spring-security-login-and-registration-frontend/src/main/java/org/baeldung/security/MySimpleUrlAuthenticationSuccessHandler.java deleted file mode 100644 index 09b22064b7..0000000000 --- a/spring-security-login-and-registration-frontend/src/main/java/org/baeldung/security/MySimpleUrlAuthenticationSuccessHandler.java +++ /dev/null @@ -1,83 +0,0 @@ -package org.baeldung.security; - -import java.io.IOException; -import java.util.Collection; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import javax.servlet.http.HttpSession; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.security.core.Authentication; -import org.springframework.security.core.GrantedAuthority; -import org.springframework.security.web.DefaultRedirectStrategy; -import org.springframework.security.web.RedirectStrategy; -import org.springframework.security.web.WebAttributes; -import org.springframework.security.web.authentication.AuthenticationSuccessHandler; -import org.springframework.stereotype.Component; - -@Component("myAuthenticationSuccessHandler") -public class MySimpleUrlAuthenticationSuccessHandler implements AuthenticationSuccessHandler { - private final Logger logger = LoggerFactory.getLogger(getClass()); - - private RedirectStrategy redirectStrategy = new DefaultRedirectStrategy(); - - public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException { - handle(request, response, authentication); - HttpSession session = request.getSession(false); - if (session != null) { - session.setMaxInactiveInterval(30); - } - clearAuthenticationAttributes(request); - } - - protected void handle(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException { - String targetUrl = determineTargetUrl(authentication); - - if (response.isCommitted()) { - logger.debug("Response has already been committed. Unable to redirect to " + targetUrl); - return; - } - - redirectStrategy.sendRedirect(request, response, targetUrl); - } - - protected String determineTargetUrl(Authentication authentication) { - boolean isUser = false; - boolean isAdmin = false; - Collection extends GrantedAuthority> authorities = authentication.getAuthorities(); - for (GrantedAuthority grantedAuthority : authorities) { - if (grantedAuthority.getAuthority().equals("READ_PRIVILEGE")) { - isUser = true; - } else if (grantedAuthority.getAuthority().equals("WRITE_PRIVILEGE")) { - isAdmin = true; - isUser = false; - break; - } - } - if (isUser) { - return "/homepage.html?user=" + authentication.getName(); - } else if (isAdmin) { - return "/console.html"; - } else { - throw new IllegalStateException(); - } - } - - protected void clearAuthenticationAttributes(HttpServletRequest request) { - HttpSession session = request.getSession(false); - if (session == null) { - return; - } - session.removeAttribute(WebAttributes.AUTHENTICATION_EXCEPTION); - } - - public void setRedirectStrategy(RedirectStrategy redirectStrategy) { - this.redirectStrategy = redirectStrategy; - } - - protected RedirectStrategy getRedirectStrategy() { - return redirectStrategy; - } -} \ No newline at end of file diff --git a/spring-security-login-and-registration-frontend/src/main/java/org/baeldung/security/MyUserDetailsService.java b/spring-security-login-and-registration-frontend/src/main/java/org/baeldung/security/MyUserDetailsService.java deleted file mode 100644 index bf8c536ab4..0000000000 --- a/spring-security-login-and-registration-frontend/src/main/java/org/baeldung/security/MyUserDetailsService.java +++ /dev/null @@ -1,93 +0,0 @@ -package org.baeldung.security; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.List; - -import javax.servlet.http.HttpServletRequest; - -import org.baeldung.persistence.dao.RoleRepository; -import org.baeldung.persistence.dao.UserRepository; -import org.baeldung.persistence.model.Privilege; -import org.baeldung.persistence.model.Role; -import org.baeldung.persistence.model.User; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.MessageSource; -import org.springframework.security.core.GrantedAuthority; -import org.springframework.security.core.authority.SimpleGrantedAuthority; -import org.springframework.security.core.userdetails.UserDetails; -import org.springframework.security.core.userdetails.UserDetailsService; -import org.springframework.security.core.userdetails.UsernameNotFoundException; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -@Service("userDetailsService") -@Transactional -public class MyUserDetailsService implements UserDetailsService { - - @Autowired - private UserRepository userRepository; - - @Autowired - private MessageSource messages; - @Autowired - private RoleRepository roleRepository; - - @Autowired - private LoginAttemptService loginAttemptService; - - @Autowired - private HttpServletRequest request; - - public MyUserDetailsService() { - super(); - } - - // API - - @Override - public UserDetails loadUserByUsername(final String email) throws UsernameNotFoundException { - final String ip = request.getRemoteAddr(); - if (loginAttemptService.isBlocked(ip)) { - throw new RuntimeException("blocked"); - } - - try { - final User user = userRepository.findByEmail(email); - if (user == null) { - return new org.springframework.security.core.userdetails.User(" ", " ", true, true, true, true, getAuthorities(Arrays.asList(roleRepository.findByName("ROLE_USER")))); - } - - return new org.springframework.security.core.userdetails.User(user.getEmail(), user.getPassword(), user.isEnabled(), true, true, true, getAuthorities(user.getRoles())); - } catch (final Exception e) { - throw new RuntimeException(e); - } - } - - // UTIL - - public final Collection extends GrantedAuthority> getAuthorities(final Collection roles) { - return getGrantedAuthorities(getPrivileges(roles)); - } - - private final List getPrivileges(final Collection roles) { - final List privileges = new ArrayList(); - final List collection = new ArrayList(); - for (final Role role : roles) { - collection.addAll(role.getPrivileges()); - } - for (final Privilege item : collection) { - privileges.add(item.getName()); - } - return privileges; - } - - private final List getGrantedAuthorities(final List privileges) { - final List authorities = new ArrayList(); - for (final String privilege : privileges) { - authorities.add(new SimpleGrantedAuthority(privilege)); - } - return authorities; - } -} diff --git a/spring-security-login-and-registration-frontend/src/main/java/org/baeldung/spring/MvcConfig.java b/spring-security-login-and-registration-frontend/src/main/java/org/baeldung/spring/MvcConfig.java deleted file mode 100644 index 5a3c5d7116..0000000000 --- a/spring-security-login-and-registration-frontend/src/main/java/org/baeldung/spring/MvcConfig.java +++ /dev/null @@ -1,91 +0,0 @@ -package org.baeldung.spring; - -import java.util.Locale; - -import org.springframework.context.MessageSource; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.support.ReloadableResourceBundleMessageSource; -import org.springframework.web.servlet.LocaleResolver; -import org.springframework.web.servlet.ViewResolver; -import org.springframework.web.servlet.config.annotation.EnableWebMvc; -import org.springframework.web.servlet.config.annotation.InterceptorRegistry; -import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; -import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; -import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; -import org.springframework.web.servlet.i18n.CookieLocaleResolver; -import org.springframework.web.servlet.i18n.LocaleChangeInterceptor; -import org.springframework.web.servlet.view.InternalResourceViewResolver; -import org.springframework.web.servlet.view.JstlView; - -@Configuration -// @ComponentScan(basePackages = { "org.baeldung.web" }) -@EnableWebMvc -public class MvcConfig extends WebMvcConfigurerAdapter { - - public MvcConfig() { - super(); - } - - // - - @Override - public void addViewControllers(final ViewControllerRegistry registry) { - super.addViewControllers(registry); - registry.addViewController("/login.html"); - registry.addViewController("/logout.html"); - registry.addViewController("/registration.html"); - registry.addViewController("/homepage.html"); - registry.addViewController("/expiredAccount.html"); - registry.addViewController("/badUser.html"); - registry.addViewController("/emailError.html"); - registry.addViewController("/home.html"); - registry.addViewController("/invalidSession.html"); - registry.addViewController("/console.html"); - registry.addViewController("/admin.html"); - registry.addViewController("/successRegister.html"); - registry.addViewController("/forgetPassword.html"); - registry.addViewController("/updatePassword.html"); - } - - @Override - public void addResourceHandlers(final ResourceHandlerRegistry registry) { - registry.addResourceHandler("/resources/**").addResourceLocations("/", "/resources/"); - } - - @Override - public void addInterceptors(final InterceptorRegistry registry) { - final LocaleChangeInterceptor localeChangeInterceptor = new LocaleChangeInterceptor(); - localeChangeInterceptor.setParamName("lang"); - registry.addInterceptor(localeChangeInterceptor); - } - - // beans - - @Bean - public ViewResolver viewResolver() { - final InternalResourceViewResolver bean = new InternalResourceViewResolver(); - bean.setViewClass(JstlView.class); - bean.setPrefix("/WEB-INF/view/"); - bean.setSuffix(".jsp"); - return bean; - } - - @Bean - public LocaleResolver localeResolver() { - final CookieLocaleResolver cookieLocaleResolver = new CookieLocaleResolver(); - cookieLocaleResolver.setDefaultLocale(Locale.ENGLISH); - return cookieLocaleResolver; - } - - @Bean - public MessageSource messageSource() { - final ReloadableResourceBundleMessageSource messageSource = new ReloadableResourceBundleMessageSource(); - messageSource.setBasename("classpath:messages"); - messageSource.setUseCodeAsDefaultMessage(true); - messageSource.setDefaultEncoding("UTF-8"); - messageSource.setCacheSeconds(0); - return messageSource; - } - -} \ No newline at end of file diff --git a/spring-security-login-and-registration-frontend/src/main/java/org/baeldung/spring/PersistenceJPAConfig.java b/spring-security-login-and-registration-frontend/src/main/java/org/baeldung/spring/PersistenceJPAConfig.java deleted file mode 100644 index d2465af345..0000000000 --- a/spring-security-login-and-registration-frontend/src/main/java/org/baeldung/spring/PersistenceJPAConfig.java +++ /dev/null @@ -1,75 +0,0 @@ -package org.baeldung.spring; - -import java.util.Properties; - -import javax.sql.DataSource; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.PropertySource; -import org.springframework.core.env.Environment; -import org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor; -import org.springframework.data.jpa.repository.config.EnableJpaRepositories; -import org.springframework.jdbc.datasource.DriverManagerDataSource; -import org.springframework.orm.jpa.JpaTransactionManager; -import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; -import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; -import org.springframework.transaction.annotation.EnableTransactionManagement; - -@Configuration -@EnableTransactionManagement -@PropertySource({ "classpath:persistence.properties" }) -@ComponentScan({ "org.baeldung.persistence" }) -@EnableJpaRepositories(basePackages = "org.baeldung.persistence.dao") -public class PersistenceJPAConfig { - - @Autowired - private Environment env; - - public PersistenceJPAConfig() { - super(); - } - - @Bean - public LocalContainerEntityManagerFactoryBean entityManagerFactory() { - final LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean(); - em.setDataSource(dataSource()); - em.setPackagesToScan(new String[] { "org.baeldung.persistence.model" }); - final HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); - em.setJpaVendorAdapter(vendorAdapter); - em.setJpaProperties(additionalProperties()); - return em; - } - - @Bean - public DataSource dataSource() { - final DriverManagerDataSource dataSource = new DriverManagerDataSource(); - dataSource.setDriverClassName(env.getProperty("jdbc.driverClassName")); - dataSource.setUrl(env.getProperty("jdbc.url")); - dataSource.setUsername(env.getProperty("jdbc.user")); - dataSource.setPassword(env.getProperty("jdbc.pass")); - return dataSource; - } - - @Bean - public JpaTransactionManager transactionManager() { - final JpaTransactionManager transactionManager = new JpaTransactionManager(); - transactionManager.setEntityManagerFactory(entityManagerFactory().getObject()); - return transactionManager; - } - - @Bean - public PersistenceExceptionTranslationPostProcessor exceptionTranslation() { - return new PersistenceExceptionTranslationPostProcessor(); - } - - final Properties additionalProperties() { - final Properties hibernateProperties = new Properties(); - hibernateProperties.setProperty("hibernate.hbm2ddl.auto", env.getProperty("hibernate.hbm2ddl.auto")); - hibernateProperties.setProperty("hibernate.dialect", env.getProperty("hibernate.dialect")); - return hibernateProperties; - } - -} diff --git a/spring-security-login-and-registration-frontend/src/main/java/org/baeldung/spring/SecSecurityConfig.java b/spring-security-login-and-registration-frontend/src/main/java/org/baeldung/spring/SecSecurityConfig.java deleted file mode 100644 index ec07c22811..0000000000 --- a/spring-security-login-and-registration-frontend/src/main/java/org/baeldung/spring/SecSecurityConfig.java +++ /dev/null @@ -1,94 +0,0 @@ -package org.baeldung.spring; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; -import org.springframework.security.authentication.dao.DaoAuthenticationProvider; -import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.builders.WebSecurity; -import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; -import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; -import org.springframework.security.core.userdetails.UserDetailsService; -import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; -import org.springframework.security.crypto.password.PasswordEncoder; -import org.springframework.security.web.authentication.AuthenticationSuccessHandler; - -@Configuration -@ComponentScan(basePackages = { "org.baeldung.security" }) -@EnableWebSecurity -public class SecSecurityConfig extends WebSecurityConfigurerAdapter { - - @Autowired - private UserDetailsService userDetailsService; - - @Autowired - private AuthenticationSuccessHandler myAuthenticationSuccessHandler; - - public SecSecurityConfig() { - super(); - } - - @Override - protected void configure(AuthenticationManagerBuilder auth) throws Exception { - auth.authenticationProvider(authProvider()); - } - - @Override - public void configure(WebSecurity web) throws Exception { - web.ignoring().antMatchers("/resources/**"); - } - - @Override - protected void configure(HttpSecurity http) throws Exception { - // @formatter:off - http - .csrf().disable() - .authorizeRequests() - .antMatchers("/j_spring_security_check*","/login*", "/logout*", "/signin/**", "/signup/**", - "/user/registration*", "/regitrationConfirm*", "/expiredAccount*", "/registration*", - "/badUser*", "/user/resendRegistrationToken*" ,"/forgetPassword*", "/user/resetPassword*", - "/user/changePassword*", "/emailError*", "/resources/**").permitAll() - .antMatchers("/invalidSession*").anonymous() - .anyRequest().authenticated() - .and() - .formLogin() - .loginPage("/login.html") - .loginProcessingUrl("/j_spring_security_check") - .defaultSuccessUrl("/homepage.html") - .failureUrl("/login.html?error=true") - .successHandler(myAuthenticationSuccessHandler) - .usernameParameter("j_username") - .passwordParameter("j_password") - .permitAll() - .and() - .sessionManagement() - .invalidSessionUrl("/invalidSession.html") - .sessionFixation().none() - .and() - .logout() - .invalidateHttpSession(false) - .logoutUrl("/j_spring_security_logout") - .logoutSuccessUrl("/logout.html?logSucc=true") - .deleteCookies("JSESSIONID") - .permitAll(); - // @formatter:on - } - - // beans - - @Bean - public DaoAuthenticationProvider authProvider() { - DaoAuthenticationProvider authProvider = new DaoAuthenticationProvider(); - authProvider.setUserDetailsService(userDetailsService); - authProvider.setPasswordEncoder(encoder()); - return authProvider; - } - - @Bean - public PasswordEncoder encoder() { - return new BCryptPasswordEncoder(11); - } - -} \ No newline at end of file diff --git a/spring-security-login-and-registration-frontend/src/main/java/org/baeldung/spring/SetupDataLoader.java b/spring-security-login-and-registration-frontend/src/main/java/org/baeldung/spring/SetupDataLoader.java deleted file mode 100644 index 9f785b3239..0000000000 --- a/spring-security-login-and-registration-frontend/src/main/java/org/baeldung/spring/SetupDataLoader.java +++ /dev/null @@ -1,89 +0,0 @@ -package org.baeldung.spring; - -import java.util.Arrays; -import java.util.Collection; -import java.util.List; - -import org.baeldung.persistence.dao.PrivilegeRepository; -import org.baeldung.persistence.dao.RoleRepository; -import org.baeldung.persistence.dao.UserRepository; -import org.baeldung.persistence.model.Privilege; -import org.baeldung.persistence.model.Role; -import org.baeldung.persistence.model.User; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.ApplicationListener; -import org.springframework.context.event.ContextRefreshedEvent; -import org.springframework.security.crypto.password.PasswordEncoder; -import org.springframework.stereotype.Component; -import org.springframework.transaction.annotation.Transactional; - -@Component -public class SetupDataLoader implements ApplicationListener { - - private boolean alreadySetup = false; - - @Autowired - private UserRepository userRepository; - - @Autowired - private RoleRepository roleRepository; - - @Autowired - private PrivilegeRepository privilegeRepository; - - @Autowired - private PasswordEncoder passwordEncoder; - - // API - - @Override - @Transactional - public void onApplicationEvent(final ContextRefreshedEvent event) { - if (alreadySetup) { - return; - } - - // == create initial privileges - final Privilege readPrivilege = createPrivilegeIfNotFound("READ_PRIVILEGE"); - final Privilege writePrivilege = createPrivilegeIfNotFound("WRITE_PRIVILEGE"); - - // == create initial roles - final List adminPrivileges = Arrays.asList(readPrivilege, writePrivilege); - createRoleIfNotFound("ROLE_ADMIN", adminPrivileges); - createRoleIfNotFound("ROLE_USER", Arrays.asList(readPrivilege)); - - final Role adminRole = roleRepository.findByName("ROLE_ADMIN"); - final User user = new User(); - user.setFirstName("Test"); - user.setLastName("Test"); - user.setPassword(passwordEncoder.encode("test")); - user.setEmail("test@test.com"); - user.setRoles(Arrays.asList(adminRole)); - user.setEnabled(true); - userRepository.save(user); - - alreadySetup = true; - } - - @Transactional - private final Privilege createPrivilegeIfNotFound(final String name) { - Privilege privilege = privilegeRepository.findByName(name); - if (privilege == null) { - privilege = new Privilege(name); - privilegeRepository.save(privilege); - } - return privilege; - } - - @Transactional - private final Role createRoleIfNotFound(final String name, final Collection privileges) { - Role role = roleRepository.findByName(name); - if (role == null) { - role = new Role(name); - role.setPrivileges(privileges); - roleRepository.save(role); - } - return role; - } - -} \ No newline at end of file diff --git a/spring-security-login-and-registration-frontend/src/main/resources/.gitignore b/spring-security-login-and-registration-frontend/src/main/resources/.gitignore deleted file mode 100644 index ec4a72ea93..0000000000 --- a/spring-security-login-and-registration-frontend/src/main/resources/.gitignore +++ /dev/null @@ -1 +0,0 @@ -email.properties \ No newline at end of file diff --git a/spring-security-login-and-registration-frontend/src/main/resources/email.properties.sample b/spring-security-login-and-registration-frontend/src/main/resources/email.properties.sample deleted file mode 100644 index 8e8207d7ab..0000000000 --- a/spring-security-login-and-registration-frontend/src/main/resources/email.properties.sample +++ /dev/null @@ -1,7 +0,0 @@ -################### JavaMail Configuration ########################## -smtp.host=email-smtp.us-east-1.amazonaws.com -smtp.port=465 -smtp.protocol=smtps -smtp.username=AKIAJIKXZAQFFJDXI4VQ -smtp.password= -support.email=eugen@baeldung.com diff --git a/spring-security-login-and-registration-frontend/src/main/resources/logback.xml b/spring-security-login-and-registration-frontend/src/main/resources/logback.xml deleted file mode 100644 index 1146dade63..0000000000 --- a/spring-security-login-and-registration-frontend/src/main/resources/logback.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - web - %date [%thread] %-5level %logger{36} - %message%n - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/spring-security-login-and-registration-frontend/src/main/resources/messages_en.properties b/spring-security-login-and-registration-frontend/src/main/resources/messages_en.properties deleted file mode 100644 index f3ad8d2307..0000000000 --- a/spring-security-login-and-registration-frontend/src/main/resources/messages_en.properties +++ /dev/null @@ -1,67 +0,0 @@ -message.username=Username required -message.password=Password required -message.unauth=Unauthorized Access !! -message.badCredentials=Invalid Username or Password -message.sessionExpired=Session Timed Out -message.logoutError=Sorry, error logging out -message.logoutSucc=You logged out successfully -message.regSucc=You registered successfully. We will send you a confirmation message to your email account. -message.regError=An account for that username/email already exists. Please enter a different username. -message.lastName=Last name is required -message.firstName=First name required -message.badEmail=Invalid email address -message.email.config.error=Error in java mail configuration -token.message=Your token is: -auth.message.disabled=Your account is disabled please check your mail and click on the confirmation link -auth.message.expired=Your registration token has expired. Please register again. -auth.message.invalidUser=This username is invalid, or does not exist. -auth.message.invalidToken=Invalid account confirmation token. -label.user.email=Email: -label.user.firstName=First name: -label.user.lastName=Last name: -label.user.password=Password: -label.user.confirmPass=Confirm password -label.form.submit=Submit -label.form.title=Registration Form -label.form.loginLink=Back to login -label.login=Login here -label.form.loginTitle=Login -label.form.loginEmail=Email -label.form.loginPass=Password -label.form.loginEnglish=English -label.form.loginSpanish=Spanish -label.form.loginSignUp=Sign up -label.pages.logout=Logout -label.pages.admin=Administrator -label.pages.home.title=Home -label.pages.home.message=Welcome Home -label.pages.admin.message=Welcome Admin -label.pages.user.message=Welcome User -label.successRegister.title=Registration Success -label.badUser.title=Invalid Link -ValidEmail.user.email=Invalid email address! -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.email=Invalid Username (Email) -label.form.resendRegistrationToken=Re-send Token -message.resendToken=We will send an email with a new registration token to your email account -message.forgetPassword=Forget Password -message.resetPassword=Reset Password -message.updatePassword=Update Password -message.userNotFound=User Not Found -auth.message.blocked=This ip is blocked for 24 hours -message.accountVerified=Your account verified successfully -message.resetPasswordSuc=Password reset successfully -message.resetYourPassword=Reset your password -message.resetPasswordEmail=You should receive an Password Reset Email shortly -message.error=Error Occurred \ No newline at end of file diff --git a/spring-security-login-and-registration-frontend/src/main/resources/messages_es_ES.properties b/spring-security-login-and-registration-frontend/src/main/resources/messages_es_ES.properties deleted file mode 100644 index 0830f94336..0000000000 --- a/spring-security-login-and-registration-frontend/src/main/resources/messages_es_ES.properties +++ /dev/null @@ -1,67 +0,0 @@ -message.username=Por favor ingrese el nombre de usuario -message.password=Por favor ingrese una clave -message.unauth=Acceso denegado !! -message.badCredentials=Usuario o clave invalida -message.sessionExpired=La sesion expiro -message.logoutError=Lo sentimos, hubo problemas al salir -message.logoutSucc=Salida con exito -message.regSucc=Se registro correctamente. Le enviaremos un mensaje de confirmacion a su direccion de email. -message.regError=Ya existe una cuenta con ese nombre de usuario. Ingrese un nombre de usuario diferente. -message.lastName=Por favor ingrese su apellido -message.firstName=Por favor ingrese su nombre -message.badEmail=Direccion de correo no es valida -message.email.config.error=Error en configuracion de java mail -token.message=Su token es: -auth.message.disabled=Su cuenta no esta habilitada. Hemos enviado a su correo un link para habilitar su cuenta. -auth.message.expired=Su ficha de registro ha caducado, por favor registrese de nuevo. -auth.message.invalidUser=Este nombre de usuario es invalido o no existe. -auth.message.invalidToken=Codigo de confirmacion incorrecto. -label.user.email=Correo Electronico: -label.user.firstName=Nombre: -label.user.lastName=Apellido: -label.user.password=Contrasenia: -label.user.confirmPass=Confirme la contrasenia -label.form.submit=Enviar -label.form.title=Formulario de Registro -label.login=Autehtifiquese aqui -label.form.loginTitle=Ingreso -label.form.loginLink=Regrese a autentificacion -label.form.loginEmail=Correo Electronico -label.form.loginPass=Contrasenia -label.form.loginEnglish=Ingles -label.form.loginSpanish=Espaniol -label.form.loginSignUp=Registrese -label.pages.logout=Salir -label.pages.admin=Administrador -label.pages.home.title=Inicio -label.pages.home.message=Bienveni@ a Casa -label.pages.admin.message=Bienvenid@ Admin -label.pages.user.message=Bienvenid@ Usuari@ -label.successRegister.title=Registro Exitoso -label.badUser.title=Enlace Invalido -ValidEmail.user.email=Cuenta correo invlida! -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 contraseña -NotNull.user.matchingPassword=Campo obligatirio -NotEmpty.user.matchingPassword=Campo obligatrio -PasswordMatches.user:Las claves no coinciden! -Email.user.email=Email no es valido -label.form.resendRegistrationToken=Reenviar mensaje de emergencia -message.resendToken=Te enviaremos un correo electrónico con un nuevo token de registro en su cuenta de correo electrónico -message.forgetPassword=Olvide la contraseña -message.resetPassword=Restablecer contraseña -message.updatePassword=Actualizar contraseña -message.userNotFound=Usuario no encontrado -auth.message.blocked=Esta IP se bloquea durante 24 horas -message.accountVerified=Su cuenta verificada con éxito -message.resetPasswordSuc=Contraseña reajusta correctamente -message.resetYourPassword=Restablecer su contraseña -message.resetPasswordEmail=Te enviaremos un correo electrónico para restablecer su contraseña -message.error=Se produjo un error \ No newline at end of file diff --git a/spring-security-login-and-registration-frontend/src/main/resources/persistence.properties b/spring-security-login-and-registration-frontend/src/main/resources/persistence.properties deleted file mode 100644 index cd282b147b..0000000000 --- a/spring-security-login-and-registration-frontend/src/main/resources/persistence.properties +++ /dev/null @@ -1,10 +0,0 @@ -################### DataSource Configuration ########################## -jdbc.driverClassName=com.mysql.jdbc.Driver -jdbc.url=jdbc:mysql://localhost:3606/registration_02?createDatabaseIfNotExist=true -jdbc.user=tutorialuser -jdbc.pass=tutorialmy5ql -init-db=false -################### Hibernate Configuration ########################## -hibernate.dialect=org.hibernate.dialect.MySQLDialect -hibernate.show_sql=false -hibernate.hbm2ddl.auto=create-drop diff --git a/spring-security-login-and-registration-frontend/src/main/resources/webSecurityConfig.xml b/spring-security-login-and-registration-frontend/src/main/resources/webSecurityConfig.xml deleted file mode 100644 index b929f1ffa9..0000000000 --- a/spring-security-login-and-registration-frontend/src/main/resources/webSecurityConfig.xml +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/spring-security-login-and-registration-frontend/src/main/webapp/META-INF/MANIFEST.MF b/spring-security-login-and-registration-frontend/src/main/webapp/META-INF/MANIFEST.MF deleted file mode 100644 index 5e9495128c..0000000000 --- a/spring-security-login-and-registration-frontend/src/main/webapp/META-INF/MANIFEST.MF +++ /dev/null @@ -1,3 +0,0 @@ -Manifest-Version: 1.0 -Class-Path: - diff --git a/spring-security-login-and-registration-frontend/src/main/webapp/WEB-INF/mvc-servlet.xml b/spring-security-login-and-registration-frontend/src/main/webapp/WEB-INF/mvc-servlet.xml deleted file mode 100644 index 7862ca24c0..0000000000 --- a/spring-security-login-and-registration-frontend/src/main/webapp/WEB-INF/mvc-servlet.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - \ No newline at end of file diff --git a/spring-security-login-and-registration-frontend/src/main/webapp/WEB-INF/view/admin.jsp b/spring-security-login-and-registration-frontend/src/main/webapp/WEB-INF/view/admin.jsp deleted file mode 100644 index d94c80bd25..0000000000 --- a/spring-security-login-and-registration-frontend/src/main/webapp/WEB-INF/view/admin.jsp +++ /dev/null @@ -1,34 +0,0 @@ -<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> -<%@ taglib prefix="sec" - uri="http://www.springframework.org/security/tags"%> -<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%> - - - - - - - - - - - "> - - - "> - - - - - - - - - - - - - - - - diff --git a/spring-security-login-and-registration-frontend/src/main/webapp/WEB-INF/view/badUser.jsp b/spring-security-login-and-registration-frontend/src/main/webapp/WEB-INF/view/badUser.jsp deleted file mode 100644 index 6d15b87d88..0000000000 --- a/spring-security-login-and-registration-frontend/src/main/webapp/WEB-INF/view/badUser.jsp +++ /dev/null @@ -1,54 +0,0 @@ -<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> -<%@ taglib prefix="sec" - uri="http://www.springframework.org/security/tags"%> -<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%> -<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%> - -<%@ page session="true"%> - - - - - - - - - ${param.message} - - -"> - - - -${label.form.resendRegistrationToken} - - - - - - - - - - diff --git a/spring-security-login-and-registration-frontend/src/main/webapp/WEB-INF/view/console.jsp b/spring-security-login-and-registration-frontend/src/main/webapp/WEB-INF/view/console.jsp deleted file mode 100644 index b993fc4a94..0000000000 --- a/spring-security-login-and-registration-frontend/src/main/webapp/WEB-INF/view/console.jsp +++ /dev/null @@ -1,36 +0,0 @@ -<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> -<%@ taglib prefix="sec" - uri="http://www.springframework.org/security/tags"%> -<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%> - - - - - - - - - "> - - - "> - - - - - - This is the landing page for the admin - - This text is only visible to a user - - - - This text is only visible to an admin - - - - "> - - - - \ No newline at end of file diff --git a/spring-security-login-and-registration-frontend/src/main/webapp/WEB-INF/view/emailError.jsp b/spring-security-login-and-registration-frontend/src/main/webapp/WEB-INF/view/emailError.jsp deleted file mode 100644 index ea3b5fac88..0000000000 --- a/spring-security-login-and-registration-frontend/src/main/webapp/WEB-INF/view/emailError.jsp +++ /dev/null @@ -1,17 +0,0 @@ -<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> -<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%> - - - - - - - - - - - - - - - diff --git a/spring-security-login-and-registration-frontend/src/main/webapp/WEB-INF/view/expiredAccount.jsp b/spring-security-login-and-registration-frontend/src/main/webapp/WEB-INF/view/expiredAccount.jsp deleted file mode 100644 index 8f00b64acc..0000000000 --- a/spring-security-login-and-registration-frontend/src/main/webapp/WEB-INF/view/expiredAccount.jsp +++ /dev/null @@ -1,24 +0,0 @@ -<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> -<%@ taglib prefix="sec" - uri="http://www.springframework.org/security/tags"%> -<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%> -<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%> - -<%@ page session="true"%> - - - - - - - - - - - - -"> - - - diff --git a/spring-security-login-and-registration-frontend/src/main/webapp/WEB-INF/view/forgetPassword.jsp b/spring-security-login-and-registration-frontend/src/main/webapp/WEB-INF/view/forgetPassword.jsp deleted file mode 100644 index 5b8f7c0cd4..0000000000 --- a/spring-security-login-and-registration-frontend/src/main/webapp/WEB-INF/view/forgetPassword.jsp +++ /dev/null @@ -1,56 +0,0 @@ - -<%@ page contentType="text/html;charset=UTF-8" language="java"%> -<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> -<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%> -<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%> -<%@ taglib prefix="sec" - uri="http://www.springframework.org/security/tags"%> -<%@ page session="false"%> - - - - - - - - - - - - - - - - - -"> - -"> - - - - - - - - \ No newline at end of file diff --git a/spring-security-login-and-registration-frontend/src/main/webapp/WEB-INF/view/home.jsp b/spring-security-login-and-registration-frontend/src/main/webapp/WEB-INF/view/home.jsp deleted file mode 100644 index 7ef1fb60ec..0000000000 --- a/spring-security-login-and-registration-frontend/src/main/webapp/WEB-INF/view/home.jsp +++ /dev/null @@ -1,28 +0,0 @@ -<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> -<%@ page session="true"%> -<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%> - - - - - - - - - - - - - - "> - - - - - - - - - - - diff --git a/spring-security-login-and-registration-frontend/src/main/webapp/WEB-INF/view/homepage.jsp b/spring-security-login-and-registration-frontend/src/main/webapp/WEB-INF/view/homepage.jsp deleted file mode 100644 index 327606745b..0000000000 --- a/spring-security-login-and-registration-frontend/src/main/webapp/WEB-INF/view/homepage.jsp +++ /dev/null @@ -1,38 +0,0 @@ -<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> -<%@ taglib prefix="sec" - uri="http://www.springframework.org/security/tags"%> -<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%> -<%@ page session="true"%> - - - - - - - - - - "> - - - "> - - - - - - - - - - - - - - - - ${param.user} - "> - - - \ No newline at end of file diff --git a/spring-security-login-and-registration-frontend/src/main/webapp/WEB-INF/view/invalidSession.jsp b/spring-security-login-and-registration-frontend/src/main/webapp/WEB-INF/view/invalidSession.jsp deleted file mode 100644 index 107e9d3032..0000000000 --- a/spring-security-login-and-registration-frontend/src/main/webapp/WEB-INF/view/invalidSession.jsp +++ /dev/null @@ -1,18 +0,0 @@ -<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> -<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%> - - - - - - - - - - - "> - - - - diff --git a/spring-security-login-and-registration-frontend/src/main/webapp/WEB-INF/view/login.jsp b/spring-security-login-and-registration-frontend/src/main/webapp/WEB-INF/view/login.jsp deleted file mode 100644 index 6767de5c5e..0000000000 --- a/spring-security-login-and-registration-frontend/src/main/webapp/WEB-INF/view/login.jsp +++ /dev/null @@ -1,109 +0,0 @@ -<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> -<%@ taglib prefix="sec" - uri="http://www.springframework.org/security/tags"%> -<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%> -<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%> - -<%@ page session="true"%> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -${param.message} - - - - - - - - - - | - - - - - - - - - - - - /> - - - Current Locale : ${pageContext.response.locale} - "> - - "> - - - - - \ No newline at end of file diff --git a/spring-security-login-and-registration-frontend/src/main/webapp/WEB-INF/view/logout.jsp b/spring-security-login-and-registration-frontend/src/main/webapp/WEB-INF/view/logout.jsp deleted file mode 100644 index 9862ef4c78..0000000000 --- a/spring-security-login-and-registration-frontend/src/main/webapp/WEB-INF/view/logout.jsp +++ /dev/null @@ -1,31 +0,0 @@ -<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> -<%@ taglib prefix="sec" - uri="http://www.springframework.org/security/tags"%> -<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%> - - - - - - - - - - - - - - - - - - - - - - "> - - - - \ No newline at end of file diff --git a/spring-security-login-and-registration-frontend/src/main/webapp/WEB-INF/view/registration.jsp b/spring-security-login-and-registration-frontend/src/main/webapp/WEB-INF/view/registration.jsp deleted file mode 100644 index 9b39761516..0000000000 --- a/spring-security-login-and-registration-frontend/src/main/webapp/WEB-INF/view/registration.jsp +++ /dev/null @@ -1,95 +0,0 @@ - -<%@ page contentType="text/html;charset=UTF-8" language="java"%> -<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> -<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%> -<%@ page session="false"%> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - "> - - - - - - - - \ No newline at end of file diff --git a/spring-security-login-and-registration-frontend/src/main/webapp/WEB-INF/view/regitrationConfirm.jsp b/spring-security-login-and-registration-frontend/src/main/webapp/WEB-INF/view/regitrationConfirm.jsp deleted file mode 100644 index c2bda675ec..0000000000 --- a/spring-security-login-and-registration-frontend/src/main/webapp/WEB-INF/view/regitrationConfirm.jsp +++ /dev/null @@ -1,23 +0,0 @@ -<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> -<%@ taglib prefix="sec" - uri="http://www.springframework.org/security/tags"%> -<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%> -<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%> - -<%@ page session="true"%> - - - - - - - - - - - - - "> - - - \ No newline at end of file diff --git a/spring-security-login-and-registration-frontend/src/main/webapp/WEB-INF/view/successRegister.jsp b/spring-security-login-and-registration-frontend/src/main/webapp/WEB-INF/view/successRegister.jsp deleted file mode 100644 index 4982da1621..0000000000 --- a/spring-security-login-and-registration-frontend/src/main/webapp/WEB-INF/view/successRegister.jsp +++ /dev/null @@ -1,25 +0,0 @@ -<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> -<%@ taglib prefix="sec" - uri="http://www.springframework.org/security/tags"%> -<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%> -<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%> - -<%@ page session="true"%> - - - - -" rel="stylesheet"> - - - - - - - - - "> - - - \ No newline at end of file diff --git a/spring-security-login-and-registration-frontend/src/main/webapp/WEB-INF/view/updatePassword.jsp b/spring-security-login-and-registration-frontend/src/main/webapp/WEB-INF/view/updatePassword.jsp deleted file mode 100644 index abb5b516c8..0000000000 --- a/spring-security-login-and-registration-frontend/src/main/webapp/WEB-INF/view/updatePassword.jsp +++ /dev/null @@ -1,60 +0,0 @@ - -<%@ page contentType="text/html;charset=UTF-8" language="java"%> -<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> -<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%> -<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%> -<%@ taglib prefix="sec" - uri="http://www.springframework.org/security/tags"%> -<%@ page session="false"%> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/spring-security-login-and-registration-frontend/src/main/webapp/WEB-INF/web.xml b/spring-security-login-and-registration-frontend/src/main/webapp/WEB-INF/web.xml deleted file mode 100644 index ed3d1b3ce7..0000000000 --- a/spring-security-login-and-registration-frontend/src/main/webapp/WEB-INF/web.xml +++ /dev/null @@ -1,51 +0,0 @@ - - - - - contextClass - org.springframework.web.context.support.AnnotationConfigWebApplicationContext - - - contextConfigLocation - org.baeldung.spring - - - - org.springframework.web.context.ContextLoaderListener - - - - org.springframework.web.context.request.RequestContextListener - - - - mvc - org.springframework.web.servlet.DispatcherServlet - 1 - - - mvc - / - - - - springSecurityFilterChain - org.springframework.web.filter.DelegatingFilterProxy - - - springSecurityFilterChain - /* - - - localizationFilter - org.springframework.web.filter.RequestContextFilter - - - localizationFilter - /* - - - \ No newline at end of file