Commit c7e765a3 by Antonio Rueda

Revisión y pequeños cambios en controlador REST

parent d77a464b
...@@ -7,8 +7,8 @@ ...@@ -7,8 +7,8 @@
<packaging>jar</packaging> <packaging>jar</packaging>
<properties> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>16</maven.compiler.source> <maven.compiler.source>18</maven.compiler.source>
<maven.compiler.target>16</maven.compiler.target> <maven.compiler.target>18</maven.compiler.target>
</properties> </properties>
<parent> <parent>
......
...@@ -113,7 +113,7 @@ public class Cliente implements Serializable { ...@@ -113,7 +113,7 @@ public class Cliente implements Serializable {
} }
/** /**
* Compara la clave con la del cliente, codificándola en Md5 * Compara la clave con la del cliente, codificándola con el algoritmo establecido
* @param clave * @param clave
* @return * @return
*/ */
......
...@@ -22,7 +22,6 @@ import java.time.LocalDateTime; ...@@ -22,7 +22,6 @@ import java.time.LocalDateTime;
import java.time.format.DateTimeParseException; import java.time.format.DateTimeParseException;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
import java.util.stream.Collectors;
import javax.validation.ConstraintViolationException; import javax.validation.ConstraintViolationException;
import javax.validation.constraints.Positive; import javax.validation.constraints.Positive;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -73,12 +72,6 @@ public class ControladorREST { ...@@ -73,12 +72,6 @@ public class ControladorREST {
} }
} }
// Just for testing
@GetMapping("/clientes/hola")
String hola() {
return "Hola";
}
/** Login de clientes (temporal hasta incluir autenticación mediante Spring Security */ /** Login de clientes (temporal hasta incluir autenticación mediante Spring Security */
@GetMapping("/clientes/{dni}") @GetMapping("/clientes/{dni}")
ResponseEntity<DTOCliente> verCliente(@PathVariable String dni) { ResponseEntity<DTOCliente> verCliente(@PathVariable String dni) {
...@@ -105,7 +98,7 @@ public class ControladorREST { ...@@ -105,7 +98,7 @@ public class ControladorREST {
@ResponseStatus(HttpStatus.OK) @ResponseStatus(HttpStatus.OK)
List<DTOTarjeta> verTarjetas(@PathVariable String dni) { List<DTOTarjeta> verTarjetas(@PathVariable String dni) {
return servicios.verTarjetas(dni).stream() return servicios.verTarjetas(dni).stream()
.map(t -> new DTOTarjeta(t)).collect(Collectors.toList()); .map(t -> new DTOTarjeta(t)).toList();
} }
/** Obtener una tarjeta concreta */ /** Obtener una tarjeta concreta */
...@@ -130,7 +123,7 @@ public class ControladorREST { ...@@ -130,7 +123,7 @@ public class ControladorREST {
@ResponseStatus(HttpStatus.OK) @ResponseStatus(HttpStatus.OK)
List<DTOCuenta> verCuentas(@PathVariable String dni) { List<DTOCuenta> verCuentas(@PathVariable String dni) {
return servicios.verCuentas(dni).stream() return servicios.verCuentas(dni).stream()
.map(c -> new DTOCuenta(c)).collect(Collectors.toList()); .map(c -> new DTOCuenta(c)).toList();
} }
/** Obtener una cuenta concreta */ /** Obtener una cuenta concreta */
...@@ -204,6 +197,6 @@ public class ControladorREST { ...@@ -204,6 +197,6 @@ public class ControladorREST {
.skip((pag - 1) * num) .skip((pag - 1) * num)
.limit(num) .limit(num)
.map(m -> DTOMovimiento.dtoMovimiento(m)) .map(m -> DTOMovimiento.dtoMovimiento(m))
.collect(Collectors.toList())); .toList());
} }
} }
...@@ -26,6 +26,7 @@ public class ServicioDatosCliente implements UserDetailsService { ...@@ -26,6 +26,7 @@ public class ServicioDatosCliente implements UserDetailsService {
@Autowired @Autowired
ServicioUjaCoin servicioUjaCoin; ServicioUjaCoin servicioUjaCoin;
/*
PasswordEncoder encoder; PasswordEncoder encoder;
public ServicioDatosCliente() { public ServicioDatosCliente() {
...@@ -35,6 +36,7 @@ public class ServicioDatosCliente implements UserDetailsService { ...@@ -35,6 +36,7 @@ public class ServicioDatosCliente implements UserDetailsService {
PasswordEncoder getEncoder() { PasswordEncoder getEncoder() {
return encoder; return encoder;
} }
*/
@Override @Override
public UserDetails loadUserByUsername(String dni) throws UsernameNotFoundException { public UserDetails loadUserByUsername(String dni) throws UsernameNotFoundException {
......
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
package es.ujaen.dae.ujacoin.seguridad; package es.ujaen.dae.ujacoin.seguridad;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.CacheManager;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpMethod; import org.springframework.http.HttpMethod;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
...@@ -47,7 +46,7 @@ public class ServicioSeguridadUjaCoin extends WebSecurityConfigurerAdapter { ...@@ -47,7 +46,7 @@ public class ServicioSeguridadUjaCoin extends WebSecurityConfigurerAdapter {
// Activar seguridad HTTP Basic // Activar seguridad HTTP Basic
httpSecurity.httpBasic(); httpSecurity.httpBasic();
//httpSecurity.authorizeRequests().antMatchers("/ujacoin/**").permitAll(); // httpSecurity.authorizeRequests().antMatchers("/ujacoin/**").permitAll();
// Definir protección por URL // Definir protección por URL
httpSecurity.authorizeRequests().antMatchers(HttpMethod.POST, "/ujacoin/clientes").permitAll(); httpSecurity.authorizeRequests().antMatchers(HttpMethod.POST, "/ujacoin/clientes").permitAll();
......
## Fichero de configuración para UjaCoin ## Fichero de configuración para UjaCoin
## MySQL local ## MySQL local
# spring.datasource.url: jdbc:mysql://localhost:33060/ujacoin spring.datasource.url: jdbc:mysql://localhost:33060/ujacoin
spring.datasource.username: ujacoin spring.datasource.username: ujacoin
spring.datasource.password: secret spring.datasource.password: secret
## H2 embedded ## H2 file
spring.datasource.url: jdbc:h2:file:~/data/ujacoin;MODE=MYSQL;DATABASE_TO_LOWER=TRUE;DB_CLOSE_DELAY=-1 #spring.datasource.url: jdbc:h2:file:~/data/ujacoin;MODE=MYSQL;DATABASE_TO_LOWER=TRUE;DB_CLOSE_DELAY=-1
spring.jpa.properties.javax.persistence.schema-generation.database.action: drop-and-create
spring.jpa.properties.javax.persistence.schema-generation.database.action: none
spring.data.jpa.repositories.bootstrap-mode: default spring.data.jpa.repositories.bootstrap-mode: default
spring.jpa.open-in-view: false spring.jpa.open-in-view: false
spring.cache.type: NONE
#spring.cache.type: NONE
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment