Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
devops-workshop
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Stian Andersen Negård
devops-workshop
Commits
08c24514
Commit
08c24514
authored
5 years ago
by
Stian Andersen Negård
Browse files
Options
Downloads
Patches
Plain Diff
Added salting method
parent
418abcbd
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#72220
passed
5 years ago
Stage: test
Stage: deploy
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/java/dao/UserDAO.java
+5
-1
5 additions, 1 deletion
src/main/java/dao/UserDAO.java
src/test/java/UserDAOTest.java
+9
-0
9 additions, 0 deletions
src/test/java/UserDAOTest.java
with
14 additions
and
1 deletion
src/main/java/dao/UserDAO.java
+
5
−
1
View file @
08c24514
...
...
@@ -183,7 +183,11 @@ public class UserDAO {
* @return a random salt
*/
public
byte
[]
generateSalt
()
{
return
null
;
SecureRandom
random
=
new
SecureRandom
();
byte
bytes
[]
=
new
byte
[
16
];
bytes
=
random
.
nextBytes
(
bytes
);
return
bytes
;
}
/**
...
...
This diff is collapsed.
Click to expand it.
src/test/java/UserDAOTest.java
+
9
−
0
View file @
08c24514
...
...
@@ -194,4 +194,13 @@ public class UserDAOTest extends JerseyTest {
assertEquals
(
expectedUsername
,
actualUsername
);
assertNotEquals
(
beforeNewUser
,
afterNewUser
);
}
@Test
public
void
testSalt
()
{
String
password
=
"passord"
;
byte
salted1
[]
=
userDAO
.
generateSalt
(
password
);
byte
salted2
[]
=
userDAO
.
generateSalt
(
password
);
assertNotEquals
(
salted1
,
salted2
);
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment