Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
DemoRest
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Percy Quispe Huarcaya
DemoRest
Commits
de2ba4b5
Commit
de2ba4b5
authored
Apr 23, 2018
by
Percy Quispe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Correciones
parent
95cd8819
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
6 deletions
+19
-6
RequestFilter.java
src/java/demojsoncrud/servlets/RequestFilter.java
+19
-6
No files found.
src/java/demojsoncrud/servlets/RequestFilter.java
View file @
de2ba4b5
...
@@ -47,14 +47,26 @@ public class RequestFilter implements Filter, ServletContextListener {
...
@@ -47,14 +47,26 @@ public class RequestFilter implements Filter, ServletContextListener {
String
js
=
request
.
getContextPath
()
+
"/js"
;
String
js
=
request
.
getContextPath
()
+
"/js"
;
String
url
=
String
.
valueOf
(
request
.
getRequestURL
());
String
url
=
String
.
valueOf
(
request
.
getRequestURL
());
if
(
url
.
contains
(
login
)
||
url
.
contains
(
plantilla
)
||
url
.
contains
(
js
)||
url
.
contains
(
"index.jsp"
)||
url
.
contains
(
"main.jsp"
)
if
(
url
.
contains
(
login
)
||
url
.
contains
(
plantilla
)
||
url
.
contains
(
js
)||
url
.
contains
(
"index.jsp"
)||
url
.
contains
(
"main.jsp"
))
{
||
url
.
contains
(
BASE
))
{
chain
.
doFilter
(
request
,
response
);
chain
.
doFilter
(
request
,
response
);
}
else
{
}
else
{
String
auth
=
request
.
getHeader
(
"Authorization"
);
JSONObject
valid
=
null
;
String
auth
=
""
;
if
(
url
.
contains
(
".jsp"
)){
auth
=
request
.
getHeader
(
"Cookie"
);
if
(
auth
.
contains
(
"Bearer"
)){
String
[]
parts
=
auth
.
split
(
";"
);
String
authorization
=
parts
[
0
];
parts
=
authorization
.
split
(
"%20"
);
auth
=
"Bearer "
+
parts
[
1
];
System
.
out
.
println
(
auth
);
}
}
else
{
auth
=
request
.
getHeader
(
"Authorization"
);
}
PostRequest
postRequest
=
new
PostRequest
(
urlRequested
);
PostRequest
postRequest
=
new
PostRequest
(
urlRequested
);
respuesta
=
postRequest
.
getRespueta
(
auth
);
respuesta
=
postRequest
.
getRespueta
(
auth
);
JSONObject
valid
=
new
JSONObject
(
respuesta
);
valid
=
new
JSONObject
(
respuesta
);
if
(
valid
.
getBoolean
(
"status"
))
{
if
(
valid
.
getBoolean
(
"status"
))
{
JSONObject
menu
=
new
JSONObject
(
valid
.
getString
(
"menu"
));
//Obtiene el menu
JSONObject
menu
=
new
JSONObject
(
valid
.
getString
(
"menu"
));
//Obtiene el menu
JSONArray
views
=
new
JSONArray
(
menu
.
get
(
"vistas"
).
toString
());
//Obtiene las vistas disponibles del usuario
JSONArray
views
=
new
JSONArray
(
menu
.
get
(
"vistas"
).
toString
());
//Obtiene las vistas disponibles del usuario
...
@@ -62,12 +74,13 @@ public class RequestFilter implements Filter, ServletContextListener {
...
@@ -62,12 +74,13 @@ public class RequestFilter implements Filter, ServletContextListener {
String
ruta
=
request
.
getRequestURI
();
String
ruta
=
request
.
getRequestURI
();
int
indice
=
obtenerIndex
(
ruta
);
int
indice
=
obtenerIndex
(
ruta
);
String
rutaJsp
=
ruta
.
substring
(
indice
,
ruta
.
length
());
String
rutaJsp
=
ruta
.
substring
(
indice
,
ruta
.
length
());
if
(
url
.
contains
(
".jsp"
)){
boolean
acceso
=
false
;
boolean
acceso
=
false
;
for
(
Object
vista
:
views
){
for
(
Object
vista
:
views
){
System
.
out
.
println
(
"Vista : "
+
vista
+
"rutaJSP : "
+
rutaJsp
);
System
.
out
.
println
(
"Vista : "
+
vista
+
"rutaJSP : "
+
rutaJsp
);
if
(
vista
.
toString
().
equalsIgnoreCase
(
rutaJsp
)){
if
(
vista
.
toString
().
equalsIgnoreCase
(
rutaJsp
)){
acceso
=
true
;
acceso
=
true
;
break
;
}
}
}
}
if
(!
acceso
){
if
(!
acceso
){
...
@@ -77,7 +90,7 @@ public class RequestFilter implements Filter, ServletContextListener {
...
@@ -77,7 +90,7 @@ public class RequestFilter implements Filter, ServletContextListener {
builder
=
Response
.
status
(
Response
.
Status
.
UNAUTHORIZED
).
entity
(
response
);
builder
=
Response
.
status
(
Response
.
Status
.
UNAUTHORIZED
).
entity
(
response
);
throw
new
WebApplicationException
(
builder
.
build
());
throw
new
WebApplicationException
(
builder
.
build
());
}
}
}
// List<String> views = (List<String>) ;
// List<String> views = (List<String>) ;
chain
.
doFilter
(
request
,
response
);
chain
.
doFilter
(
request
,
response
);
}
else
{
}
else
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment