Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
B
BackEnd-V2
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Joel Andres Molina Velez
BackEnd-V2
Commits
b05aed6b
Commit
b05aed6b
authored
Jul 21, 2023
by
Joel Andres Molina Velez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Se corrigen warnings
parent
debb86f7
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
4 additions
and
94 deletions
+4
-94
build.gradle
build.gradle
+1
-8
JwtAuthenticationFilter.java
...vilidad/MovilidadWS/Security/JwtAuthenticationFilter.java
+0
-44
JwtUserDetailsService.java
...movilidad/MovilidadWS/Security/JwtUserDetailsService.java
+3
-3
JwtUtils.java
.../ec/edu/espe/movilidad/MovilidadWS/Security/JwtUtils.java
+0
-39
No files found.
build.gradle
View file @
b05aed6b
...
...
@@ -22,26 +22,19 @@ dependencies {
implementation
'org.springframework.boot:spring-boot-starter-data-jpa'
// Dependencia para la integración de JPA en Spring Boot
implementation
'org.springframework.boot:spring-boot-starter-validation'
// Dependencia para la validación de datos en Spring Boot
implementation
'org.springframework.boot:spring-boot-starter-web'
// Dependencia para crear aplicaciones web con Spring Boot
implementation
'org.springframework.boot:spring-boot-starter-websocket'
//
implementation 'org.springframework.boot:spring-boot-starter-websocket'
implementation
'org.springframework.boot:spring-boot-starter-mail'
implementation
'org.json:json:20210307'
//implementation 'commons-fileupload:commons-fileupload:1.4' // Dependencia para el manejo de archivos en Java
implementation
'com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.12.5'
// Dependencia para el formato XML en Jackson
implementation
'commons-io:commons-io:2.11.0'
implementation
'org.javassist:javassist:3.27.0-GA'
// Dependencia para la manipulación de bytecode en Java
implementation
'org.mapstruct:mapstruct:1.4.2.Final'
implementation
'org.modelmapper:modelmapper:3.0.0'
// Dependencia para la generación de mappers en Java
implementation
'org.springframework.boot:spring-boot-starter-security'
// seguridad de Apis
implementation
'io.jsonwebtoken:jjwt-api:0.11.2'
implementation
'io.jsonwebtoken:jjwt-impl:0.11.2'
implementation
'io.jsonwebtoken:jjwt-jackson:0.11.2'
//
implementation
'org.springframework.boot:spring-boot-starter-oauth2-resource-server'
// Hibernate Oracle Dialect
//implementation 'org.hibernate.dialect:hibernate-oraclendialect:5.6.3.Final'
annotationProcessor
'org.mapstruct:mapstruct-processor:1.4.2.Final'
// Procesador de anotaciones para MapStruct
compileOnly
'org.projectlombok:lombok'
// Dependencia para generar automáticamente código repetitivo en Java
runtimeOnly
'com.oracle.database.jdbc:ojdbc8'
// Dependencia para el controlador JDBC de Oracle
...
...
src/main/java/ec/edu/espe/movilidad/MovilidadWS/Security/JwtAuthenticationFilter.java
View file @
b05aed6b
...
...
@@ -60,49 +60,5 @@ public class JwtAuthenticationFilter extends OncePerRequestFilter {
filterChain
.
doFilter
(
request
,
response
);
}
/*
private UsernamePasswordAuthenticationToken getAuthentication(String token) {
try {
if (tokenEsValido(token)) {
UserDetails userDetails = getUserDetailsFromToken(token);
UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken(userDetails, null, null);
loggerToken.info("Token válido obtenido en el backend: {}", token);
return authenticationToken;
}
} catch (Exception e) {
}
return null;
}
private boolean tokenEsValido(String token) {
loggerToken.info("token de validación: {}", token);
UserDetails userDetails = getUserDetailsFromToken(token);
boolean isValid = JwtUtils.validateToken(token, userDetails);
loggerToken.info("Resultado de la validación del token: {}", isValid);
return isValid;
}
private UserDetails getUserDetailsFromToken(String token) {
try {
loggerToken.info("Extrayendo detalles del usuario del token: {}", token);
Claims claims = Jwts.parserBuilder()
.setSigningKey(SECRET_KEY)
.build()
.parseClaimsJws(token)
.getBody();
String username = claims.getSubject();
//return new CustomUserDetails(username, "", null);
return new CustomUserDetails(null);
} catch (Exception e) {
}
return null;
}
*/
}
src/main/java/ec/edu/espe/movilidad/MovilidadWS/Security/JwtUserDetailsService.java
View file @
b05aed6b
...
...
@@ -21,12 +21,12 @@ public class JwtUserDetailsService implements UserDetailsService {
private
final
DaoUzyTUsuario
userRepository
;
@Autowired
UzyTPerfilMapper
perfilMapper
;
private
final
UzyTPerfilMapper
perfilMapper
;
@Autowired
public
JwtUserDetailsService
(
DaoUzyTUsuario
userRepository
)
{
public
JwtUserDetailsService
(
DaoUzyTUsuario
userRepository
,
UzyTPerfilMapper
perfilMapper
)
{
this
.
userRepository
=
userRepository
;
this
.
perfilMapper
=
perfilMapper
;
}
@Override
...
...
src/main/java/ec/edu/espe/movilidad/MovilidadWS/Security/JwtUtils.java
deleted
100644 → 0
View file @
debb86f7
package
ec
.
edu
.
espe
.
movilidad
.
MovilidadWS
.
Security
;
import
io.jsonwebtoken.Jwts
;
import
org.springframework.security.core.userdetails.UserDetails
;
import
org.springframework.stereotype.Component
;
import
java.util.Date
;
@Component
public
class
JwtUtils
{
public
static
boolean
validateToken
(
String
token
,
UserDetails
userDetails
)
{
if
(
token
==
null
)
{
System
.
out
.
println
(
"Token nullo: "
+
token
);
return
false
;
}
String
username
=
extractUsername
(
token
);
System
.
out
.
println
(
"Token: "
+
token
);
return
username
.
equals
(
userDetails
.
getUsername
())
&&
!
isTokenExpired
(
token
);
}
public
static
String
extractUsername
(
String
token
)
{
return
Jwts
.
parserBuilder
()
.
build
()
.
parseClaimsJws
(
token
)
.
getBody
()
.
getSubject
();
}
public
static
boolean
isTokenExpired
(
String
token
)
{
return
Jwts
.
parserBuilder
()
.
build
()
.
parseClaimsJws
(
token
)
.
getBody
()
.
getExpiration
()
.
before
(
new
Date
());
}
}
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