Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
SAE4.A02.1
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
Package registry
Model registry
Operate
Environments
Terraform modules
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
Maxime Gosselin
SAE4.A02.1
Commits
ea7f76e5
Commit
ea7f76e5
authored
1 month ago
by
Florine Lefebvre
Browse files
Options
Downloads
Patches
Plain Diff
protection xss nom d'utilisateur + contrainte chiffre ou lettres entre 3 et 24 carac
parent
e39232c8
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
WEB-INF/src/controleur/Authent.java
+8
-1
8 additions, 1 deletion
WEB-INF/src/controleur/Authent.java
WEB-INF/vue/signin.jsp
+1
-1
1 addition, 1 deletion
WEB-INF/vue/signin.jsp
with
9 additions
and
2 deletions
WEB-INF/src/controleur/Authent.java
+
8
−
1
View file @
ea7f76e5
...
...
@@ -4,6 +4,9 @@ import java.io.IOException;
import
java.security.MessageDigest
;
import
java.security.NoSuchAlgorithmException
;
import
org.apache.commons.text.StringEscapeUtils
;
import
org.apache.commons.text.translate.CharSequenceTranslator
;
import
jakarta.servlet.ServletException
;
import
jakarta.servlet.annotation.WebServlet
;
import
jakarta.servlet.http.HttpServlet
;
...
...
@@ -20,6 +23,9 @@ public class Authent extends HttpServlet {
String
action
=
req
.
getParameter
(
"action"
);
String
username
=
req
.
getParameter
(
"username"
);
String
password
=
req
.
getParameter
(
"password"
);
CharSequenceTranslator
cst
=
StringEscapeUtils
.
ESCAPE_HTML4
;
if
(
username
==
null
||
password
==
null
){
req
.
setAttribute
(
"error"
,
"Vous ne pouvez pas avoir un pseudo ou mot de passe vide !"
);
req
.
getRequestDispatcher
(
"/WEB-INF/vue/error.jsp"
).
forward
(
req
,
resp
);
...
...
@@ -27,6 +33,7 @@ public class Authent extends HttpServlet {
}
String
hashedPassword
;
username
=
username
.
toLowerCase
();
username
=
cst
.
translate
(
username
);
MessageDigest
md
;
this
.
getServletContext
();
...
...
@@ -69,7 +76,7 @@ public class Authent extends HttpServlet {
resp
.
sendRedirect
(
"navigation?page=accueil"
);
return
;
}
catch
(
Exception
e
)
{
req
.
setAttribute
(
"error"
,
"Nom d'utilisateur déjà pris"
);
req
.
setAttribute
(
"error"
,
"
Pseudonyme invalide /
Nom d'utilisateur déjà pris"
);
vue
=
"WEB-INF/vue/signin.jsp"
;
}
break
;
...
...
This diff is collapsed.
Click to expand it.
WEB-INF/vue/signin.jsp
+
1
−
1
View file @
ea7f76e5
...
...
@@ -30,7 +30,7 @@
<div>
<div
class=
"mt-2 mb-3"
>
<p
class=
"mb-1"
>
Pseudonyme
</p>
<input
class=
"form-control"
name=
"username"
type=
"text"
placeholder=
"pmathieu"
maxlength=
"24"
required
>
<input
class=
"form-control"
name=
"username"
type=
"text"
placeholder=
"pmathieu"
maxlength=
"24"
pattern=
"\w{3,24}"
required
>
</div>
<div
class=
"mb-3"
>
<p
class=
"mb-1"
>
Mot de passe
</p>
...
...
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