diff --git a/Frontend Angular 4/src/app/shared/config.ts b/Frontend Angular 4/src/app/shared/config.ts index c2a30b6e43e9f3ca572557f8b19f651a2e4b6e3d..462abf8a46f37749da048f5299f3f18e032ef735 100755 --- a/Frontend Angular 4/src/app/shared/config.ts +++ b/Frontend Angular 4/src/app/shared/config.ts @@ -29,11 +29,19 @@ // export const GHCI_URL = 'wss://matefun.math.psico.edu.uy/endpoint'; // fing -export const SERVER = 'https://www.fing.edu.uy/proyectos/matefun'; -export const GHCI_URL = 'wss://matefun.fing.edu.uy/proyectos/matefun/endpoint'; +//export const SERVER = 'https://www.fing.edu.uy/proyectos/matefun'; +//export const GHCI_URL = 'wss://www.fing.edu.uy/proyectos/matefun/endpoint'; + +// fing-pru +//export const SERVER = 'https://localhost:9443/proyectos/matefun'; +//export const GHCI_URL = 'wss://localhost:9443/proyectos/matefun/endpoint'; //diego docker -// export const SERVER = 'http://localhost:8080'; -// export const GHCI_URL = 'ws://localhost:8080/endpoint'; +export const SERVER = 'http://localhost:8080'; +export const GHCI_URL = 'ws://localhost:8080/endpoint'; + +//local proyectos/matefun +//export const SERVER = 'http://localhost:9990'; +//export const GHCI_URL = 'ws://localhost:9990/endpoint'; diff --git a/Servidor JEE/WebContent/WEB-INF/jboss-web.xml b/Servidor JEE/WebContent/WEB-INF/jboss-web.xml index c55c387855c87b634a8066da89ae976e3d0787e7..f26e15753a34084fe11e6ba98f955e08d56f89ad 100644 --- a/Servidor JEE/WebContent/WEB-INF/jboss-web.xml +++ b/Servidor JEE/WebContent/WEB-INF/jboss-web.xml @@ -1,3 +1,3 @@ <jboss-web> <context-root>/</context-root> -</jboss-web> \ No newline at end of file +</jboss-web> diff --git a/Servidor JEE/WebContent/index.html b/Servidor JEE/WebContent/index.html index e2f639ff4992da579f867a10906b762e1c063eff..9260a74c99a1a9b981b2c932dcf3265c3682c829 100644 --- a/Servidor JEE/WebContent/index.html +++ b/Servidor JEE/WebContent/index.html @@ -1,4 +1,4 @@ -<!doctype html><html><head><meta charset="utf-8"><title>Proyecto MateFun</title><base href="/proyectos/matefun/"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" type="image/x-icon" href="favicon.ico"><!-- despues lo saco de aca --><!-- <link rel="stylesheet" type="text/css" href="node_modules/codemirror/addon/hint/show-hint.css"> --><script src="https://code.jquery.com/jquery-3.1.1.slim.min.js" integrity="sha384-A7FZj7v+d/sdmMqp/nOQwliLvUsJfDHW+k9Omg/a/EheAdgtzNs3hpfag6Ed950n" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.4.0/js/tether.min.js" integrity="sha384-DztdAPBWPRXSA/3eYEEUWrWCy7G5KFbe8fFjk5JAIxUYHKkDx6Qin1DkWx51bBrb" crossorigin="anonymous"></script><script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/js/bootstrap.min.js" integrity="sha384-vBWWzlZJ8ea9aCX4pEW3rVHjgjt7zpkNpZk+02D9phzyeVkE+jo0ieGizqPLForn" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js" crossorigin="anonymous"></script><!-- +<!doctype html><html><head><meta charset="utf-8"><title>Proyecto MateFun</title><base href="/"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" type="image/x-icon" href="favicon.ico"><!-- despues lo saco de aca --><!-- <link rel="stylesheet" type="text/css" href="node_modules/codemirror/addon/hint/show-hint.css"> --><script src="https://code.jquery.com/jquery-3.1.1.slim.min.js" integrity="sha384-A7FZj7v+d/sdmMqp/nOQwliLvUsJfDHW+k9Omg/a/EheAdgtzNs3hpfag6Ed950n" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.4.0/js/tether.min.js" integrity="sha384-DztdAPBWPRXSA/3eYEEUWrWCy7G5KFbe8fFjk5JAIxUYHKkDx6Qin1DkWx51bBrb" crossorigin="anonymous"></script><script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/js/bootstrap.min.js" integrity="sha384-vBWWzlZJ8ea9aCX4pEW3rVHjgjt7zpkNpZk+02D9phzyeVkE+jo0ieGizqPLForn" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js" crossorigin="anonymous"></script><!-- <script src="https://wzrd.in/standalone/function-plot@1.18.1" crossorigin="anonymous"></script> - --><link href="styles.1dc6715c59e708068692.bundle.css" rel="stylesheet"/></head><body><app-root><div class="loading"><div class="loading-bar"></div><div class="loading-bar"></div><div class="loading-bar"></div><div class="loading-bar"></div><div class="loading-bar"></div></div></app-root><script type="text/javascript" src="inline.7971b8aed44589acdfb7.bundle.js"></script><script type="text/javascript" src="polyfills.d50ac7c762e2eb4097d9.bundle.js"></script><script type="text/javascript" src="scripts.d01654a9119059a68b2b.bundle.js"></script><script type="text/javascript" src="vendor.d3c1758890cc7548bc7b.bundle.js"></script><script type="text/javascript" src="main.94941e96a5bd65bdeb71.bundle.js"></script></body></html> \ No newline at end of file + --><link href="styles.1dc6715c59e708068692.bundle.css" rel="stylesheet"/></head><body><app-root><div class="loading"><div class="loading-bar"></div><div class="loading-bar"></div><div class="loading-bar"></div><div class="loading-bar"></div><div class="loading-bar"></div></div></app-root><script type="text/javascript" src="inline.427fe152dbac388e02e1.bundle.js"></script><script type="text/javascript" src="polyfills.d50ac7c762e2eb4097d9.bundle.js"></script><script type="text/javascript" src="scripts.d01654a9119059a68b2b.bundle.js"></script><script type="text/javascript" src="vendor.d3c1758890cc7548bc7b.bundle.js"></script><script type="text/javascript" src="main.94941e96a5bd65bdeb71.bundle.js"></script></body></html> \ No newline at end of file diff --git a/Servidor JEE/src/main/java/edu/proygrado/ejb/CommandsBean.java b/Servidor JEE/src/main/java/edu/proygrado/ejb/CommandsBean.java index ae467daf346c41c7450fae9b6afc8886666a72f9..0cde2b1583cfe7a65a3bab1f95b79c8e3ba97c2a 100644 --- a/Servidor JEE/src/main/java/edu/proygrado/ejb/CommandsBean.java +++ b/Servidor JEE/src/main/java/edu/proygrado/ejb/CommandsBean.java @@ -190,8 +190,9 @@ public class CommandsBean { } public void restartProcess(String cedula, String token, Session session) throws InterruptedException { - try { - if(!loginEJB.validarSesion(token)){ + System.out.println("restartProcess"); + try { + if(!loginEJB.validarSesion(token)){ session.close(new CloseReason(CloseCodes.VIOLATED_POLICY,"Sin permisos")); System.out.print("Web socket finalizado"); return; @@ -265,10 +266,10 @@ public class CommandsBean { } this.standardConsoleThread = outputStandardConsoleThread(); this.errorConsoleThread = outputErrorConsoleThread(); - this.latch.await(); + this.latch.await(); } catch (IOException ex) { Logger.getLogger(CommandsBean.class.getName()).log(Level.SEVERE, null, ex); - } + } } public void eliminarRecursos(String cedula, String token){ diff --git a/Servidor JEE/src/main/java/edu/proygrado/ejb/LoginEJB.java b/Servidor JEE/src/main/java/edu/proygrado/ejb/LoginEJB.java index 16e8ea92e7015fd9139d9f474ba24cac1eec289c..5d9a201ce4caa35b683eaa0487fdc5cbbdc5f599 100644 --- a/Servidor JEE/src/main/java/edu/proygrado/ejb/LoginEJB.java +++ b/Servidor JEE/src/main/java/edu/proygrado/ejb/LoginEJB.java @@ -29,6 +29,8 @@ import javax.transaction.UserTransaction; import javax.ws.rs.client.ClientBuilder; import javax.ws.rs.core.GenericType; + + import edu.proygrado.dto.MoodleCourseDTO; import edu.proygrado.dto.MoodleCoursesInfoDTO; import edu.proygrado.dto.MoodleRoleDTO; @@ -55,6 +57,8 @@ import edu.proygrado.modelo.Usuario; */ @Stateless @TransactionManagement(value=TransactionManagementType.BEAN) + + public class LoginEJB { @Inject @@ -116,9 +120,16 @@ public class LoginEJB { List<Sesion> sesiones = em.createQuery("select s from Sesion s where s.timestamp < :horaExpiracion", Sesion.class) .setParameter("horaExpiracion", horaExpiracion) .getResultList(); + try{ + userTransaction.begin(); for(Sesion sesion:sesiones){ em.remove(sesion); } + userTransaction.commit(); + } + catch(Exception e) { + System.out.println("Error borrando sesiones expiradas"); + } } public UsuarioDTO login(String cedula, String password) throws MatefunException { @@ -292,8 +303,9 @@ public class LoginEJB { } private String getTokenMoodle(String username, String password) throws MatefunException { - javax.ws.rs.client.ClientBuilder cb = ClientBuilder.newBuilder(); + + javax.ws.rs.client.ClientBuilder cb = ClientBuilder.newBuilder(); javax.ws.rs.client.Client c = cb.build(); String url = getMoodleAPIEndpoint() + "/login/token.php"; diff --git a/Servidor JEE/src/main/java/edu/proygrado/matefun/CORSFilter.java b/Servidor JEE/src/main/java/edu/proygrado/matefun/CORSFilter.java index 734a73de578061e300e61a27843da23b27077e60..9d915e8fb2e57bc4b76996947a33efb96df4320f 100644 --- a/Servidor JEE/src/main/java/edu/proygrado/matefun/CORSFilter.java +++ b/Servidor JEE/src/main/java/edu/proygrado/matefun/CORSFilter.java @@ -29,4 +29,4 @@ public class CORSFilter implements ContainerResponseFilter { cres.getHeaders().add("Access-Control-Max-Age", "1209600"); } -} \ No newline at end of file +} diff --git a/addUsers.sh b/addUsers.sh new file mode 100644 index 0000000000000000000000000000000000000000..64a5d511a1349d4399dbb5921ae27a67898e7379 --- /dev/null +++ b/addUsers.sh @@ -0,0 +1,29 @@ +#! /bin/bash + +#todas las filas tienen que terminar con enter +INPUT=users.csv + +SERVER=https://www.fing.edu.uy/proyectos/matefun/servicios +ROLE=docente #alumno + +token=$(curl --header "Content-Type: application/json" \ + --request POST \ + --data '{"cedula":"invitado","password":"invitado"}' \ + "$SERVER/login" | \ + python3 -c "import sys, json; print(json.load(sys.stdin)['token'])") + +while IFS=, read -r user name surname code; do + echo "user: $user" + hcode=$(echo -n "$code" | sha1sum | awk '{print $1}') + echo "pass: $hcode" + echo "token: $token" + data='{ "rol": "'$ROLE'","cedula": "'$user'", "nombre": "'$name'","apellido": "'$surname'","password": "'$hcode'","configuracion": { "themeEditor": "dracula","fontSizeEditor": 12,"argumentoI": true,"argumentoF": true},"gruposAsignados": [],"archivos": []}' + echo $data + curl -H "Content-Type: application/json" -H "Authorization: Bearer $token" \ + --request POST \ + --data "$data" \ + "$SERVER/usuario/$ROLE/restore" + +done < $INPUT + + diff --git a/generate-war.sh b/generate-war.sh index bc5cb83618dbc3973eb942b565afc77d8dd98d27..3e2875082c5ba24c9257404640d3b431fc1a7817 100644 --- a/generate-war.sh +++ b/generate-war.sh @@ -1,5 +1,5 @@ cd Frontend\ Angular\ 4/ -ng build --prod --base-href /proyectos/matefun/ +ng build --prod #--base-href /proyectos/matefun/ cd .. cp -R Frontend\ Angular\ 4/dist/* Servidor\ JEE/WebContent/ cd Servidor\ JEE/