Skip to content

Commit ea227f8

Browse files
author
eugenp
committed
formatting work and session fix
1 parent 73a63d0 commit ea227f8

32 files changed

Lines changed: 215 additions & 149 deletions

‎spring-security-login-and-registration/src/main/java/org/baeldung/persistence/dao/PasswordResetTokenRepository.java‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66

77
public interface PasswordResetTokenRepository extends JpaRepository<PasswordResetToken, Long> {
88

9-
public PasswordResetToken findByToken(String token);
9+
PasswordResetToken findByToken(String token);
10+
11+
PasswordResetToken findByUser(User user);
1012

11-
public PasswordResetToken findByUser(User user);
1213
}

‎spring-security-login-and-registration/src/main/java/org/baeldung/persistence/dao/PrivilegeRepository.java‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44
import org.springframework.data.jpa.repository.JpaRepository;
55

66
public interface PrivilegeRepository extends JpaRepository<Privilege, Long> {
7-
public Privilege findByName(String name);
87

9-
public void delete(Privilege privilege);
8+
Privilege findByName(String name);
9+
10+
@Override
11+
void delete(Privilege privilege);
12+
1013
}

‎spring-security-login-and-registration/src/main/java/org/baeldung/persistence/dao/RoleRepository.java‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44
import org.springframework.data.jpa.repository.JpaRepository;
55

66
public interface RoleRepository extends JpaRepository<Role, Long> {
7-
public Role findByName(String name);
87

9-
public void delete(Role role);
8+
Role findByName(String name);
9+
10+
@Override
11+
void delete(Role role);
12+
1013
}
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
package org.baeldung.persistence.dao;
22

3-
import org.springframework.data.jpa.repository.JpaRepository;
43
import org.baeldung.persistence.model.User;
4+
import org.springframework.data.jpa.repository.JpaRepository;
55

66
public interface UserRepository extends JpaRepository<User, Long> {
7-
public User findByEmail(String email);
7+
User findByEmail(String email);
88

9-
public void delete(User user);
9+
@Override
10+
void delete(User user);
1011

1112
}

‎spring-security-login-and-registration/src/main/java/org/baeldung/persistence/dao/VerificationTokenRepository.java‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66

77
public interface VerificationTokenRepository extends JpaRepository<VerificationToken, Long> {
88

9-
public VerificationToken findByToken(String token);
9+
VerificationToken findByToken(String token);
10+
11+
VerificationToken findByUser(User user);
1012

11-
public VerificationToken findByUser(User user);
1213
}

‎spring-security-login-and-registration/src/main/java/org/baeldung/persistence/model/PasswordResetToken.java‎

Lines changed: 30 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -32,53 +32,55 @@ public PasswordResetToken() {
3232
super();
3333
}
3434

35-
public PasswordResetToken(String token) {
35+
public PasswordResetToken(final String token) {
3636
super();
3737

3838
this.token = token;
3939
this.expiryDate = calculateExpiryDate(EXPIRATION);
4040
}
4141

42-
public PasswordResetToken(String token, User user) {
42+
public PasswordResetToken(final String token, final User user) {
4343
super();
4444

4545
this.token = token;
4646
this.user = user;
4747
this.expiryDate = calculateExpiryDate(EXPIRATION);
4848
}
4949

50+
//
51+
5052
public String getToken() {
5153
return token;
5254
}
5355

54-
public void setToken(String token) {
56+
public void setToken(final String token) {
5557
this.token = token;
5658
}
5759

5860
public User getUser() {
5961
return user;
6062
}
6163

62-
public void setUser(User user) {
64+
public void setUser(final User user) {
6365
this.user = user;
6466
}
6567

6668
public Date getExpiryDate() {
6769
return expiryDate;
6870
}
6971

70-
public void setExpiryDate(Date expiryDate) {
72+
public void setExpiryDate(final Date expiryDate) {
7173
this.expiryDate = expiryDate;
7274
}
7375

74-
private Date calculateExpiryDate(int expiryTimeInMinutes) {
75-
Calendar cal = Calendar.getInstance();
76+
private Date calculateExpiryDate(final int expiryTimeInMinutes) {
77+
final Calendar cal = Calendar.getInstance();
7678
cal.setTimeInMillis(new Date().getTime());
7779
cal.add(Calendar.MINUTE, expiryTimeInMinutes);
7880
return new Date(cal.getTime().getTime());
7981
}
8082

81-
public void updateToken(String token) {
83+
public void updateToken(final String token) {
8284
this.token = token;
8385
this.expiryDate = calculateExpiryDate(EXPIRATION);
8486
}
@@ -96,29 +98,38 @@ public int hashCode() {
9698
}
9799

98100
@Override
99-
public boolean equals(Object obj) {
100-
if (this == obj)
101+
public boolean equals(final Object obj) {
102+
if (this == obj) {
101103
return true;
102-
if (obj == null)
104+
}
105+
if (obj == null) {
103106
return false;
104-
if (getClass() != obj.getClass())
107+
}
108+
if (getClass() != obj.getClass()) {
105109
return false;
106-
PasswordResetToken other = (PasswordResetToken) obj;
110+
}
111+
final PasswordResetToken other = (PasswordResetToken) obj;
107112
if (expiryDate == null) {
108-
if (other.expiryDate != null)
113+
if (other.expiryDate != null) {
109114
return false;
110-
} else if (!expiryDate.equals(other.expiryDate))
115+
}
116+
} else if (!expiryDate.equals(other.expiryDate)) {
111117
return false;
118+
}
112119
if (token == null) {
113-
if (other.token != null)
120+
if (other.token != null) {
114121
return false;
115-
} else if (!token.equals(other.token))
122+
}
123+
} else if (!token.equals(other.token)) {
116124
return false;
125+
}
117126
if (user == null) {
118-
if (other.user != null)
127+
if (other.user != null) {
119128
return false;
120-
} else if (!user.equals(other.user))
129+
}
130+
} else if (!user.equals(other.user)) {
121131
return false;
132+
}
122133
return true;
123134
}
124135

‎spring-security-login-and-registration/src/main/java/org/baeldung/persistence/model/Privilege.java‎

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
@Entity
1212
public class Privilege {
13+
1314
@Id
1415
@GeneratedValue(strategy = GenerationType.AUTO)
1516
private Long id;
@@ -23,32 +24,34 @@ public Privilege() {
2324
super();
2425
}
2526

26-
public Privilege(String name) {
27+
public Privilege(final String name) {
2728
super();
2829
this.name = name;
2930
}
3031

32+
//
33+
3134
public Long getId() {
3235
return id;
3336
}
3437

35-
public void setId(Long id) {
38+
public void setId(final Long id) {
3639
this.id = id;
3740
}
3841

3942
public String getName() {
4043
return name;
4144
}
4245

43-
public void setName(String name) {
46+
public void setName(final String name) {
4447
this.name = name;
4548
}
4649

4750
public Collection<Role> getRoles() {
4851
return roles;
4952
}
5053

51-
public void setRoles(Collection<Role> roles) {
54+
public void setRoles(final Collection<Role> roles) {
5255
this.roles = roles;
5356
}
5457

@@ -62,15 +65,19 @@ public int hashCode() {
6265

6366
@Override
6467
public boolean equals(final Object obj) {
65-
if (this == obj)
68+
if (this == obj) {
6669
return true;
67-
if (obj == null)
70+
}
71+
if (obj == null) {
6872
return false;
69-
if (getClass() != obj.getClass())
73+
}
74+
if (getClass() != obj.getClass()) {
7075
return false;
76+
}
7177
final Privilege privilege = (Privilege) obj;
72-
if (!privilege.equals(privilege.name))
78+
if (!privilege.equals(privilege.name)) {
7379
return false;
80+
}
7481
return true;
7582
}
7683

‎spring-security-login-and-registration/src/main/java/org/baeldung/persistence/model/Role.java‎

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
import javax.persistence.GeneratedValue;
77
import javax.persistence.GenerationType;
88
import javax.persistence.Id;
9+
import javax.persistence.JoinColumn;
910
import javax.persistence.JoinTable;
1011
import javax.persistence.ManyToMany;
11-
import javax.persistence.JoinColumn;
1212

1313
@Entity
1414
public class Role {
@@ -30,40 +30,42 @@ public Role() {
3030
super();
3131
}
3232

33-
public Role(String name) {
33+
public Role(final String name) {
3434
super();
3535
this.name = name;
3636
}
3737

38+
//
39+
3840
public Long getId() {
3941
return id;
4042
}
4143

42-
public void setId(Long id) {
44+
public void setId(final Long id) {
4345
this.id = id;
4446
}
4547

4648
public String getName() {
4749
return name;
4850
}
4951

50-
public void setName(String name) {
52+
public void setName(final String name) {
5153
this.name = name;
5254
}
5355

5456
public Collection<User> getUsers() {
5557
return users;
5658
}
5759

58-
public void setUsers(Collection<User> users) {
60+
public void setUsers(final Collection<User> users) {
5961
this.users = users;
6062
}
6163

6264
public Collection<Privilege> getPrivileges() {
6365
return privileges;
6466
}
6567

66-
public void setPrivileges(Collection<Privilege> privileges) {
68+
public void setPrivileges(final Collection<Privilege> privileges) {
6769
this.privileges = privileges;
6870
}
6971

@@ -77,15 +79,19 @@ public int hashCode() {
7779

7880
@Override
7981
public boolean equals(final Object obj) {
80-
if (this == obj)
82+
if (this == obj) {
8183
return true;
82-
if (obj == null)
84+
}
85+
if (obj == null) {
8386
return false;
84-
if (getClass() != obj.getClass())
87+
}
88+
if (getClass() != obj.getClass()) {
8589
return false;
90+
}
8691
final Role role = (Role) obj;
87-
if (!role.equals(role.name))
92+
if (!role.equals(role.name)) {
8893
return false;
94+
}
8995
return true;
9096
}
9197

0 commit comments

Comments
 (0)