Skip to content

Commit 7223ede

Browse files
committed
fix code example
1 parent 624a1bd commit 7223ede

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

developer-tools/java-debugging/Eclipse-README.md

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,13 +154,28 @@ Try to log into the application. Look at the value for password in the Eclipse v
154154

155155
In this MVC application the UserController uses the findByLogin method in the UserServiceImpl class which uses the findByUsername method to retrieve the information from the database. It then checks to see if the password from the form matches the user password. Since the password from the login form is not scrambled using ROT13, it does not match the user password and you cannot log into the application.
156156

157-
To fix this, apply ROT13 to the password by adding
157+
To fix this, apply ROT13 to the password by adding an import near the top of the file
158158

159159
```
160160
import com.docker.UserSignup.util.Rot13
161+
```
162+
163+
and replace the contents of `findByLogin` with
161164

162-
String passwd = Rot13.rot13(password);
163165
```
166+
public boolean findByLogin(String userName, String password) {
167+
User usr = userRepository.findByUserName(userName);
168+
169+
String passwd = Rot13.rot13(password);
170+
171+
if(usr != null && usr.getPassword().equals(passwd)) {
172+
return true;
173+
}
174+
175+
return false;
176+
}
177+
```
178+
164179
![](images/eclipse_debug_UserServiceImpl_code.png)
165180

166181
Set a breakpoint in UserServiceImpl on the findByLogin method. Log in again and look at the values for the breakpoint. The 'passwd' variable is `z0ol` which matches the password for the user moby.

0 commit comments

Comments
 (0)