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
2f1dd810
Commit
2f1dd810
authored
Jul 12, 2023
by
Joel Andres Molina Velez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Se modifica la autenticación del usuario logeado
parent
4f5b5638
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
78 additions
and
0 deletions
+78
-0
DtoUserLogeado.java
...ec/edu/espe/movilidad/MovilidadWS/Dto/DtoUserLogeado.java
+3
-0
UzyTavActivProgMapper.java
...idadWS/Mapper/Components_Class/UzyTavActivProgMapper.java
+56
-0
JwtUserDetailsService.java
...movilidad/MovilidadWS/Security/JwtUserDetailsService.java
+2
-0
SecurityConfig.java
...u/espe/movilidad/MovilidadWS/Security/SecurityConfig.java
+17
-0
No files found.
src/main/java/ec/edu/espe/movilidad/MovilidadWS/Dto/DtoUserLogeado.java
View file @
2f1dd810
...
...
@@ -3,6 +3,7 @@ package ec.edu.espe.movilidad.MovilidadWS.Dto;
import
lombok.Data
;
@Data
public
class
DtoUserLogeado
{
private
Long
uzytusuario_id
;
...
...
@@ -15,4 +16,6 @@ public class DtoUserLogeado {
private
String
uzytusuario_telefono_fijo
;
private
String
uzytusuario_telefono_celular
;
private
String
spriden_id
;
private
String
uzytusuario_campus
;
private
String
uzytusuario_departamento
;
}
src/main/java/ec/edu/espe/movilidad/MovilidadWS/Mapper/Components_Class/UzyTavActivProgMapper.java
0 → 100644
View file @
2f1dd810
package
ec
.
edu
.
espe
.
movilidad
.
MovilidadWS
.
Mapper
.
Components_Class
;
import
ec.edu.espe.movilidad.MovilidadWS.Dto.DtoUzyTavActivProg
;
import
ec.edu.espe.movilidad.MovilidadWS.Model.ModelUzyTavActivProg
;
import
ec.edu.espe.movilidad.MovilidadWS.Model.ModelUzyTavPrograma_V
;
import
ec.edu.espe.movilidad.MovilidadWS.Model.ModelUzyTavProyec
;
import
org.modelmapper.ModelMapper
;
import
org.springframework.stereotype.Component
;
import
javax.persistence.EntityManager
;
import
java.util.List
;
import
java.util.stream.Collectors
;
@Component
public
class
UzyTavActivProgMapper
{
private
final
EntityManager
entityManager
;
private
final
ModelMapper
modelMapper
;
public
UzyTavActivProgMapper
(
ModelMapper
modelMapper
,
EntityManager
entityManager
)
{
this
.
modelMapper
=
modelMapper
;
this
.
entityManager
=
entityManager
;
}
public
DtoUzyTavActivProg
entityToDto
(
ModelUzyTavActivProg
entity
)
{
return
modelMapper
.
map
(
entity
,
DtoUzyTavActivProg
.
class
);
}
public
ModelUzyTavActivProg
dtoToEntity
(
DtoUzyTavActivProg
dto
)
{
ModelUzyTavActivProg
entity
=
modelMapper
.
map
(
dto
,
ModelUzyTavActivProg
.
class
);
Long
proyectoID
=
dto
.
getUZYTAVPROYEC_ID
();
Long
programaID
=
dto
.
getUZYTAVPROGRAMA_V_ID
();
if
(
proyectoID
!=
null
){
ModelUzyTavProyec
proyec
=
entityManager
.
find
(
ModelUzyTavProyec
.
class
,
proyectoID
);
entity
.
setUzytavproyec
(
proyec
);
}
if
(
programaID
!=
null
){
ModelUzyTavPrograma_V
programa
=
entityManager
.
find
(
ModelUzyTavPrograma_V
.
class
,
programaID
);
entity
.
setUzytavprograma_v
(
programa
);
}
return
entity
;
}
public
List
<
DtoUzyTavActivProg
>
entitiesToDtos
(
List
<
ModelUzyTavActivProg
>
entities
)
{
return
entities
.
stream
()
.
map
(
this
::
entityToDto
)
.
collect
(
Collectors
.
toList
());
}
}
src/main/java/ec/edu/espe/movilidad/MovilidadWS/Security/JwtUserDetailsService.java
View file @
2f1dd810
...
...
@@ -50,6 +50,8 @@ public class JwtUserDetailsService implements UserDetailsService {
userInfo
.
setUzytusuario_telefono_celular
(
user
.
getUzytusuario_telefono_celular
());
userInfo
.
setUzytusuario_telefono_fijo
(
user
.
getUzytusuario_telefono_fijo
());
userInfo
.
setSpriden_id
(
user
.
getSpriden_id
());
userInfo
.
setUzytusuario_campus
(
user
.
getUzytusuario_campus
());
userInfo
.
setUzytusuario_departamento
(
user
.
getUzytusuario_departamento
());
return
userInfo
;
}
...
...
src/main/java/ec/edu/espe/movilidad/MovilidadWS/Security/SecurityConfig.java
View file @
2f1dd810
...
...
@@ -8,6 +8,9 @@ import org.springframework.security.config.http.SessionCreationPolicy;
import
org.springframework.security.web.SecurityFilterChain
;
import
org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter
;
import
org.springframework.web.cors.CorsConfiguration
;
import
org.springframework.web.cors.CorsConfigurationSource
;
import
org.springframework.web.cors.UrlBasedCorsConfigurationSource
;
@Configuration
...
...
@@ -24,6 +27,8 @@ public class SecurityConfig {
http
.
csrf
()
.
disable
()
.
cors
()
.
and
()
.
exceptionHandling
()
.
and
()
.
httpBasic
().
authenticationEntryPoint
(
jwtEntryPoint
)
...
...
@@ -46,5 +51,17 @@ public class SecurityConfig {
return
new
JwtAuthenticationFilter
();
}
@Bean
public
CorsConfigurationSource
corsConfigurationSource
()
{
CorsConfiguration
configuration
=
new
CorsConfiguration
();
configuration
.
addAllowedOrigin
(
"http://localhost:4200"
);
configuration
.
addAllowedMethod
(
"*"
);
configuration
.
addAllowedHeader
(
"*"
);
UrlBasedCorsConfigurationSource
source
=
new
UrlBasedCorsConfigurationSource
();
source
.
registerCorsConfiguration
(
"/**"
,
configuration
);
return
source
;
}
}
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