Commit db223fe8 authored by Marcos Viera's avatar Marcos Viera
Browse files

script agregar usuarios

parent a62ec3b9
...@@ -29,11 +29,19 @@ ...@@ -29,11 +29,19 @@
// export const GHCI_URL = 'wss://matefun.math.psico.edu.uy/endpoint'; // export const GHCI_URL = 'wss://matefun.math.psico.edu.uy/endpoint';
// fing // fing
export const SERVER = 'https://www.fing.edu.uy/proyectos/matefun'; //export const SERVER = 'https://www.fing.edu.uy/proyectos/matefun';
export const GHCI_URL = 'wss://matefun.fing.edu.uy/proyectos/matefun/endpoint'; //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 //diego docker
// export const SERVER = 'http://localhost:8080'; export const SERVER = 'http://localhost:8080';
// export const GHCI_URL = 'ws://localhost:8080/endpoint'; 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';
<jboss-web> <jboss-web>
<context-root>/</context-root> <context-root>/</context-root>
</jboss-web> </jboss-web>
\ No newline at end of file
<!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> <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> --><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 \ No newline at end of file
...@@ -190,8 +190,9 @@ public class CommandsBean { ...@@ -190,8 +190,9 @@ public class CommandsBean {
} }
public void restartProcess(String cedula, String token, Session session) throws InterruptedException { public void restartProcess(String cedula, String token, Session session) throws InterruptedException {
try { System.out.println("restartProcess");
if(!loginEJB.validarSesion(token)){ try {
if(!loginEJB.validarSesion(token)){
session.close(new CloseReason(CloseCodes.VIOLATED_POLICY,"Sin permisos")); session.close(new CloseReason(CloseCodes.VIOLATED_POLICY,"Sin permisos"));
System.out.print("Web socket finalizado"); System.out.print("Web socket finalizado");
return; return;
...@@ -265,10 +266,10 @@ public class CommandsBean { ...@@ -265,10 +266,10 @@ public class CommandsBean {
} }
this.standardConsoleThread = outputStandardConsoleThread(); this.standardConsoleThread = outputStandardConsoleThread();
this.errorConsoleThread = outputErrorConsoleThread(); this.errorConsoleThread = outputErrorConsoleThread();
this.latch.await(); this.latch.await();
} catch (IOException ex) { } catch (IOException ex) {
Logger.getLogger(CommandsBean.class.getName()).log(Level.SEVERE, null, ex); Logger.getLogger(CommandsBean.class.getName()).log(Level.SEVERE, null, ex);
} }
} }
public void eliminarRecursos(String cedula, String token){ public void eliminarRecursos(String cedula, String token){
......
...@@ -29,6 +29,8 @@ import javax.transaction.UserTransaction; ...@@ -29,6 +29,8 @@ import javax.transaction.UserTransaction;
import javax.ws.rs.client.ClientBuilder; import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.core.GenericType; import javax.ws.rs.core.GenericType;
import edu.proygrado.dto.MoodleCourseDTO; import edu.proygrado.dto.MoodleCourseDTO;
import edu.proygrado.dto.MoodleCoursesInfoDTO; import edu.proygrado.dto.MoodleCoursesInfoDTO;
import edu.proygrado.dto.MoodleRoleDTO; import edu.proygrado.dto.MoodleRoleDTO;
...@@ -55,6 +57,8 @@ import edu.proygrado.modelo.Usuario; ...@@ -55,6 +57,8 @@ import edu.proygrado.modelo.Usuario;
*/ */
@Stateless @Stateless
@TransactionManagement(value=TransactionManagementType.BEAN) @TransactionManagement(value=TransactionManagementType.BEAN)
public class LoginEJB { public class LoginEJB {
@Inject @Inject
...@@ -116,9 +120,16 @@ public class LoginEJB { ...@@ -116,9 +120,16 @@ public class LoginEJB {
List<Sesion> sesiones = em.createQuery("select s from Sesion s where s.timestamp < :horaExpiracion", Sesion.class) List<Sesion> sesiones = em.createQuery("select s from Sesion s where s.timestamp < :horaExpiracion", Sesion.class)
.setParameter("horaExpiracion", horaExpiracion) .setParameter("horaExpiracion", horaExpiracion)
.getResultList(); .getResultList();
try{
userTransaction.begin();
for(Sesion sesion:sesiones){ for(Sesion sesion:sesiones){
em.remove(sesion); em.remove(sesion);
} }
userTransaction.commit();
}
catch(Exception e) {
System.out.println("Error borrando sesiones expiradas");
}
} }
public UsuarioDTO login(String cedula, String password) throws MatefunException { public UsuarioDTO login(String cedula, String password) throws MatefunException {
...@@ -292,8 +303,9 @@ public class LoginEJB { ...@@ -292,8 +303,9 @@ public class LoginEJB {
} }
private String getTokenMoodle(String username, String password) throws MatefunException { 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(); javax.ws.rs.client.Client c = cb.build();
String url = getMoodleAPIEndpoint() + "/login/token.php"; String url = getMoodleAPIEndpoint() + "/login/token.php";
......
...@@ -29,4 +29,4 @@ public class CORSFilter implements ContainerResponseFilter { ...@@ -29,4 +29,4 @@ public class CORSFilter implements ContainerResponseFilter {
cres.getHeaders().add("Access-Control-Max-Age", "1209600"); cres.getHeaders().add("Access-Control-Max-Age", "1209600");
} }
} }
\ No newline at end of file
#! /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
cd Frontend\ Angular\ 4/ cd Frontend\ Angular\ 4/
ng build --prod --base-href /proyectos/matefun/ ng build --prod #--base-href /proyectos/matefun/
cd .. cd ..
cp -R Frontend\ Angular\ 4/dist/* Servidor\ JEE/WebContent/ cp -R Frontend\ Angular\ 4/dist/* Servidor\ JEE/WebContent/
cd Servidor\ JEE/ cd Servidor\ JEE/
......
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 to comment