...
 
Commits (4)
  • Administrator's avatar
    Makes SQL scripts compatible with MySQL 8 · 6c30abb1
    Administrator authored
    Minor changes have been done in the SQL scripts to make them
    compatible with MySQL 8. The main change is the way that the user is
    created.
    6c30abb1
  • Administrator's avatar
    Fixes DB authentication error for MySQL 8.0.4+ · be787b89
    Administrator authored
    The default authentication plugin for MySQL has been changed from
    mysql_native_password to caching_sha2_password in version 8.0.4. This
    causes that an access failure for the user created in the database
    scripts when trying to login from Tomcat.
    
    This commit changes the MySQL database scripts to maintain the
    compatibility between Tomcat and MySQL in versions 8.0.4+.
    be787b89
  • Administrator's avatar
    Simplifies the configuration of the AuthorizationFilter · 1850f97d
    Administrator authored
    The AuthorizationFilter is used by the test to simulate the HTTP basic
    authentication. It was initially programmed to just allow access to the
    "people" path.
    
    This commit modifies this filter so that now it is easier to include
    more paths accessible by the administrator.
    1850f97d
  • Administrator's avatar
    Updates project for the new course · 86fff9ac
    Administrator authored
    Some minor changes have been done to update the project and adapt it
    to some depencencies updates.
    86fff9ac
...@@ -15,3 +15,6 @@ WebContent ...@@ -15,3 +15,6 @@ WebContent
# Testing # Testing
/servers /servers
C:\\nppdf32Log\\debuglog.txt C:\\nppdf32Log\\debuglog.txt
# Angular
src/main/angular
...@@ -5,6 +5,16 @@ Aplicación y arquitectura de ejemplo para la asignatura Desarrollo Ágil de ...@@ -5,6 +5,16 @@ Aplicación y arquitectura de ejemplo para la asignatura Desarrollo Ágil de
Aplicaciones del Grado en Ingeniería Informática de la Escuela Superior de Aplicaciones del Grado en Ingeniería Informática de la Escuela Superior de
Ingeniería Informática de la Universidad de Vigo. Ingeniería Informática de la Universidad de Vigo.
## Dependencias
Este proyecto está diseñado para ser desarrollado en un entorno con:
* Maven 3
* Java 8
* MySQL 5.7.6+ o 8+
Además, se recomienda emplear la última versión de Eclipse IDE for Enterprise
Java Developers.
## Ejecución con Maven ## Ejecución con Maven
La configuración de Maven ha sido preparada para permitir varios tipos de La configuración de Maven ha sido preparada para permitir varios tipos de
ejecución. ejecución.
...@@ -60,9 +70,9 @@ El comando para lanzar esta construcción es: ...@@ -60,9 +70,9 @@ El comando para lanzar esta construcción es:
### Construcción con tests de unidad, integración y aceptación ### Construcción con tests de unidad, integración y aceptación
Esta construcción es similar a la previa, añadiendo las **pruebas de Esta construcción es similar a la previa, añadiendo las
aceptación**, que comprueban que las fucionalidades de la aplicación están **pruebas de aceptación**, que comprueban que las fucionalidades de la aplicación
correctamente implementadas. están correctamente implementadas.
En estas pruebas se descarga y arranca el un servidor Tomcat 8 en el que se En estas pruebas se descarga y arranca el un servidor Tomcat 8 en el que se
despliega la aplicación configurada para utilizar una base de datos HSQL. Las despliega la aplicación configurada para utilizar una base de datos HSQL. Las
......
DROP DATABASE IF EXISTS `daaexample`;
CREATE DATABASE `daaexample`; CREATE DATABASE `daaexample`;
CREATE TABLE `daaexample`.`people` ( CREATE TABLE `daaexample`.`people` (
...@@ -5,16 +6,17 @@ CREATE TABLE `daaexample`.`people` ( ...@@ -5,16 +6,17 @@ CREATE TABLE `daaexample`.`people` (
`name` varchar(50) NOT NULL, `name` varchar(50) NOT NULL,
`surname` varchar(100) NOT NULL, `surname` varchar(100) NOT NULL,
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
CREATE TABLE `daaexample`.`users` ( CREATE TABLE `daaexample`.`users` (
`login` varchar(100) NOT NULL, `login` varchar(100) NOT NULL,
`password` varchar(64) NOT NULL, `password` varchar(64) NOT NULL,
`role` varchar(10) NOT NULL, `role` varchar(10) NOT NULL,
PRIMARY KEY (`login`) PRIMARY KEY (`login`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
GRANT ALL ON `daaexample`.* TO 'daa'@'localhost' IDENTIFIED BY 'daa'; CREATE USER IF NOT EXISTS 'daa'@'localhost' IDENTIFIED WITH mysql_native_password BY 'daa';
GRANT ALL ON `daaexample`.* TO 'daa'@'localhost';
INSERT INTO `daaexample`.`people` (`id`,`name`,`surname`) VALUES (0,'Antón','Pérez'); INSERT INTO `daaexample`.`people` (`id`,`name`,`surname`) VALUES (0,'Antón','Pérez');
INSERT INTO `daaexample`.`people` (`id`,`name`,`surname`) VALUES (0,'Manuel','Martínez'); INSERT INTO `daaexample`.`people` (`id`,`name`,`surname`) VALUES (0,'Manuel','Martínez');
......
DROP DATABASE IF EXISTS `daaexample`;
CREATE DATABASE `daaexample`; CREATE DATABASE `daaexample`;
CREATE TABLE `daaexample`.`people` ( CREATE TABLE `daaexample`.`people` (
...@@ -5,13 +6,14 @@ CREATE TABLE `daaexample`.`people` ( ...@@ -5,13 +6,14 @@ CREATE TABLE `daaexample`.`people` (
`name` varchar(50) NOT NULL, `name` varchar(50) NOT NULL,
`surname` varchar(100) NOT NULL, `surname` varchar(100) NOT NULL,
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
CREATE TABLE `daaexample`.`users` ( CREATE TABLE `daaexample`.`users` (
`login` varchar(100) NOT NULL, `login` varchar(100) NOT NULL,
`password` varchar(64) NOT NULL, `password` varchar(64) NOT NULL,
`role` varchar(10) NOT NULL, `role` varchar(10) NOT NULL,
PRIMARY KEY (`login`) PRIMARY KEY (`login`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
GRANT ALL ON `daaexample`.* TO 'daa'@'localhost' IDENTIFIED BY 'daa'; CREATE USER IF NOT EXISTS 'daa'@'localhost' IDENTIFIED WITH mysql_native_password BY 'daa';
GRANT ALL ON `daaexample`.* TO 'daa'@'localhost';
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>es.uvigo.esei.daa</groupId> <groupId>es.uvigo.esei.daa</groupId>
<artifactId>example</artifactId> <artifactId>example-full-tests</artifactId>
<packaging>war</packaging> <packaging>war</packaging>
<version>0.1.13</version> <version>0.1.19</version>
<name>DAA Example</name> <name>DAA Example</name>
<licenses> <licenses>
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
<slf4j-jdk14.version>1.7.21</slf4j-jdk14.version> <slf4j-jdk14.version>1.7.21</slf4j-jdk14.version>
<!-- Tests dependencies --> <!-- Tests dependencies -->
<junit.version>4.12</junit.version> <junit.version>4.13.2</junit.version>
<java-hamcrest.version>2.0.0.0</java-hamcrest.version> <java-hamcrest.version>2.0.0.0</java-hamcrest.version>
<easymock.version>3.5.1</easymock.version> <easymock.version>3.5.1</easymock.version>
<selenium-java.version>3.141.59</selenium-java.version> <selenium-java.version>3.141.59</selenium-java.version>
...@@ -44,11 +44,12 @@ ...@@ -44,11 +44,12 @@
<spring-test-dbunit.version>1.3.0</spring-test-dbunit.version> <spring-test-dbunit.version>1.3.0</spring-test-dbunit.version>
<hsqldb.version>2.3.3</hsqldb.version> <hsqldb.version>2.3.3</hsqldb.version>
<mysql.version>5.1.45</mysql.version> <mysql.version>5.1.45</mysql.version>
<geckodriver.version>v0.24.0</geckodriver.version> <geckodriver.version>v0.29.0</geckodriver.version>
<equalsverifier.version>2.4.2</equalsverifier.version> <equalsverifier.version>2.4.2</equalsverifier.version>
<!-- Plugins --> <!-- Plugins -->
<maven-failsafe-plugin.version>2.20.1</maven-failsafe-plugin.version> <maven-failsafe-plugin.version>2.20.1</maven-failsafe-plugin.version>
<maven-jxr-plugin.version>3.0.0</maven-jxr-plugin.version>
<maven-surefire-plugin.version>2.20.1</maven-surefire-plugin.version> <maven-surefire-plugin.version>2.20.1</maven-surefire-plugin.version>
<maven-surefire-report-plugin.version>2.20.1</maven-surefire-report-plugin.version> <maven-surefire-report-plugin.version>2.20.1</maven-surefire-report-plugin.version>
<maven-war-plugin.version>3.2.0</maven-war-plugin.version> <maven-war-plugin.version>3.2.0</maven-war-plugin.version>
...@@ -184,6 +185,16 @@ ...@@ -184,6 +185,16 @@
</dependency> </dependency>
</dependencies> </dependencies>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jxr-plugin</artifactId>
<version>${maven-jxr-plugin.version}</version>
</plugin>
</plugins>
</reporting>
<build> <build>
<finalName>DAAExample</finalName> <finalName>DAAExample</finalName>
...@@ -571,7 +582,7 @@ ...@@ -571,7 +582,7 @@
<cargo.datasource.datasource.h2> <cargo.datasource.datasource.h2>
cargo.datasource.jndi=jdbc/daaexample| cargo.datasource.jndi=jdbc/daaexample|
cargo.datasource.driver=com.mysql.jdbc.Driver| cargo.datasource.driver=com.mysql.jdbc.Driver|
cargo.datasource.url=jdbc:mysql://localhost/daaexample| cargo.datasource.url=jdbc:mysql://localhost/daaexample?useSSL=false|
cargo.datasource.username=daa| cargo.datasource.username=daa|
cargo.datasource.password=daa| cargo.datasource.password=daa|
cargo.datasource.maxActive=8| cargo.datasource.maxActive=8|
......
...@@ -12,7 +12,7 @@ import static es.uvigo.esei.daa.dataset.PeopleDataset.peopleWithout; ...@@ -12,7 +12,7 @@ import static es.uvigo.esei.daa.dataset.PeopleDataset.peopleWithout;
import static es.uvigo.esei.daa.matchers.IsEqualToPerson.containsPeopleInAnyOrder; import static es.uvigo.esei.daa.matchers.IsEqualToPerson.containsPeopleInAnyOrder;
import static es.uvigo.esei.daa.matchers.IsEqualToPerson.equalsToPerson; import static es.uvigo.esei.daa.matchers.IsEqualToPerson.equalsToPerson;
import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat; import static org.hamcrest.MatcherAssert.assertThat;
import javax.sql.DataSource; import javax.sql.DataSource;
......
...@@ -14,7 +14,7 @@ import static org.easymock.EasyMock.expect; ...@@ -14,7 +14,7 @@ import static org.easymock.EasyMock.expect;
import static org.easymock.EasyMock.reset; import static org.easymock.EasyMock.reset;
import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat; import static org.hamcrest.MatcherAssert.assertThat;
import java.sql.SQLException; import java.sql.SQLException;
......
...@@ -2,7 +2,7 @@ package es.uvigo.esei.daa.entities; ...@@ -2,7 +2,7 @@ package es.uvigo.esei.daa.entities;
import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat; import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import org.junit.Test; import org.junit.Test;
......
...@@ -2,6 +2,7 @@ package es.uvigo.esei.daa.filters; ...@@ -2,6 +2,7 @@ package es.uvigo.esei.daa.filters;
import java.io.IOException; import java.io.IOException;
import java.security.Principal; import java.security.Principal;
import java.util.Arrays;
import java.util.Base64; import java.util.Base64;
import java.util.List; import java.util.List;
...@@ -29,6 +30,9 @@ import es.uvigo.esei.daa.entities.User; ...@@ -29,6 +30,9 @@ import es.uvigo.esei.daa.entities.User;
@Provider @Provider
@Priority(Priorities.AUTHENTICATION) @Priority(Priorities.AUTHENTICATION)
public class AuthorizationFilter implements ContainerRequestFilter { public class AuthorizationFilter implements ContainerRequestFilter {
// Add here the list of REST paths that an administrator can access.
private final static List<String> ADMIN_PATHS = Arrays.asList("people");
private final UsersDAO dao; private final UsersDAO dao;
public AuthorizationFilter() { public AuthorizationFilter() {
...@@ -54,7 +58,7 @@ public class AuthorizationFilter implements ContainerRequestFilter { ...@@ -54,7 +58,7 @@ public class AuthorizationFilter implements ContainerRequestFilter {
if (this.dao.checkLogin(userPass[0], userPass[1])) { if (this.dao.checkLogin(userPass[0], userPass[1])) {
final User user = this.dao.get(userPass[0]); final User user = this.dao.get(userPass[0]);
if (isPeoplePath(requestContext) && !user.getRole().equals("ADMIN")) { if (isAdminPath(requestContext) && !user.getRole().equals("ADMIN")) {
requestContext.abortWith(createResponse()); requestContext.abortWith(createResponse());
} else { } else {
requestContext.setSecurityContext(new UserSecurityContext(user)); requestContext.setSecurityContext(new UserSecurityContext(user));
...@@ -71,9 +75,15 @@ public class AuthorizationFilter implements ContainerRequestFilter { ...@@ -71,9 +75,15 @@ public class AuthorizationFilter implements ContainerRequestFilter {
} }
} }
private static boolean isPeoplePath(ContainerRequestContext context) { private static boolean isAdminPath(ContainerRequestContext context) {
final List<PathSegment> pathSegments = context.getUriInfo().getPathSegments(); final List<PathSegment> pathSegments = context.getUriInfo().getPathSegments();
return !pathSegments.isEmpty() && pathSegments.get(0).getPath().equals("people");
if (pathSegments.isEmpty()) {
return false;
} else {
final String path = pathSegments.get(0).getPath();
return ADMIN_PATHS.contains(path);
}
} }
private static Response createResponse() { private static Response createResponse() {
......
...@@ -18,7 +18,7 @@ import static es.uvigo.esei.daa.matchers.IsEqualToPerson.equalsToPerson; ...@@ -18,7 +18,7 @@ import static es.uvigo.esei.daa.matchers.IsEqualToPerson.equalsToPerson;
import static javax.ws.rs.client.Entity.entity; import static javax.ws.rs.client.Entity.entity;
import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat; import static org.hamcrest.MatcherAssert.assertThat;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;
......
...@@ -22,7 +22,7 @@ import static org.easymock.EasyMock.replay; ...@@ -22,7 +22,7 @@ import static org.easymock.EasyMock.replay;
import static org.easymock.EasyMock.verify; import static org.easymock.EasyMock.verify;
import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat; import static org.hamcrest.MatcherAssert.assertThat;
import java.util.List; import java.util.List;
......
...@@ -8,7 +8,7 @@ import static es.uvigo.esei.daa.matchers.HasHttpStatus.hasOkStatus; ...@@ -8,7 +8,7 @@ import static es.uvigo.esei.daa.matchers.HasHttpStatus.hasOkStatus;
import static es.uvigo.esei.daa.matchers.HasHttpStatus.hasUnauthorized; import static es.uvigo.esei.daa.matchers.HasHttpStatus.hasUnauthorized;
import static es.uvigo.esei.daa.matchers.IsEqualToUser.equalsToUser; import static es.uvigo.esei.daa.matchers.IsEqualToUser.equalsToUser;
import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat; import static org.hamcrest.MatcherAssert.assertThat;
import java.io.IOException; import java.io.IOException;
......
...@@ -10,7 +10,7 @@ import static es.uvigo.esei.daa.matchers.IsEqualToPerson.containsPeopleInAnyOrde ...@@ -10,7 +10,7 @@ import static es.uvigo.esei.daa.matchers.IsEqualToPerson.containsPeopleInAnyOrde
import static es.uvigo.esei.daa.matchers.IsEqualToPerson.equalsToPerson; import static es.uvigo.esei.daa.matchers.IsEqualToPerson.equalsToPerson;
import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThat; import static org.hamcrest.MatcherAssert.assertThat;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
......
...@@ -138,7 +138,7 @@ ...@@ -138,7 +138,7 @@
<Realm className="org.apache.catalina.realm.JDBCRealm" <Realm className="org.apache.catalina.realm.JDBCRealm"
driverName="com.mysql.jdbc.Driver" driverName="com.mysql.jdbc.Driver"
connectionURL="jdbc:mysql://localhost/daaexample" connectionURL="jdbc:mysql://localhost/daaexample?useSSL=false"
connectionName="daa" connectionName="daa"
connectionPassword="daa" connectionPassword="daa"
userTable="users" userNameCol="login" userCredCol="password" userTable="users" userNameCol="login" userCredCol="password"
......