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
7918d928
Commit
7918d928
authored
Apr 23, 2018
by
Percy Quispe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
correcciones
parent
de2ba4b5
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
19 deletions
+35
-19
RequestFilter.java
src/java/demojsoncrud/servlets/RequestFilter.java
+8
-19
GeneralUtils.java
src/java/demojsoncrud/utilities/GeneralUtils.java
+27
-0
No files found.
src/java/demojsoncrud/servlets/RequestFilter.java
View file @
7918d928
package
demojsoncrud
.
servlets
;
import
demojsoncrud.utilities.GeneralUtils
;
import
demojsoncrud.utilities.PostRequest
;
import
java.io.IOException
;
import
java.io.PrintWriter
;
...
...
@@ -72,7 +73,7 @@ public class RequestFilter implements Filter, ServletContextListener {
JSONArray
views
=
new
JSONArray
(
menu
.
get
(
"vistas"
).
toString
());
//Obtiene las vistas disponibles del usuario
List
<
Object
>
salida
=
views
.
toList
();
String
ruta
=
request
.
getRequestURI
();
int
indice
=
obtenerIndex
(
ruta
);
int
indice
=
GeneralUtils
.
obtenerIndex
(
ruta
);
String
rutaJsp
=
ruta
.
substring
(
indice
,
ruta
.
length
());
if
(
url
.
contains
(
".jsp"
)){
boolean
acceso
=
false
;
...
...
@@ -85,8 +86,7 @@ public class RequestFilter implements Filter, ServletContextListener {
}
if
(!
acceso
){
Response
.
ResponseBuilder
builder
=
null
;
response
.
setStatus
(
HttpServletResponse
.
SC_UNAUTHORIZED
);
response
.
sendError
(
401
);
sendError
(
response
);
builder
=
Response
.
status
(
Response
.
Status
.
UNAUTHORIZED
).
entity
(
response
);
throw
new
WebApplicationException
(
builder
.
build
());
}
...
...
@@ -94,28 +94,17 @@ public class RequestFilter implements Filter, ServletContextListener {
// List<String> views = (List<String>) ;
chain
.
doFilter
(
request
,
response
);
}
else
{
response
.
setStatus
(
HttpServletResponse
.
SC_UNAUTHORIZED
);
response
.
sendError
(
401
);
sendError
(
response
);
}
}
}
else
{
response
.
setStatus
(
HttpServletResponse
.
SC_UNAUTHORIZED
);
response
.
sendError
(
401
);
}
}
private
int
obtenerIndex
(
String
ruta
){
char
[]
c
=
ruta
.
toCharArray
();
int
salida
=
0
;
for
(
int
i
=
c
.
length
-
1
;
i
>=
0
;
i
--)
{
String
help
=
c
[
i
]+
""
;
if
(!
help
.
equals
(
"/"
)){
salida
=
i
;
}
else
{
break
;
sendError
(
response
);
}
}
return
salida
;
private
void
sendError
(
HttpServletResponse
response
)
throws
IOException
{
response
.
setStatus
(
HttpServletResponse
.
SC_UNAUTHORIZED
);
response
.
sendError
(
401
);
}
@Override
public
void
destroy
()
{
...
...
src/java/demojsoncrud/utilities/GeneralUtils.java
0 → 100644
View file @
7918d928
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package
demojsoncrud
.
utilities
;
/**
*
* @author sistem08user
*/
public
class
GeneralUtils
{
public
static
int
obtenerIndex
(
String
ruta
){
char
[]
c
=
ruta
.
toCharArray
();
int
salida
=
0
;
for
(
int
i
=
c
.
length
-
1
;
i
>=
0
;
i
--)
{
String
help
=
c
[
i
]+
""
;
if
(!
help
.
equals
(
"/"
)){
salida
=
i
;
}
else
{
break
;
}
}
return
salida
;
}
}
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