// Path: src/java/rocks/teammolise/myunimol/webapp/configuration/ConfigurationManager.java
// public class ConfigurationManager implements ConfigurationManagerInterface{  
// 	private File file;
// 	
// 	public ConfigurationManager(String pFilename) {
// 		this.file = new File(pFilename);
// 	}
//     
//     public Properties loadProperties() throws IOException {
//         
//         Properties properties = new Properties();
// 
//         /**
//          * Carico il file config.properties in un File con il suo absolute path **TO FIX**
//          */
// 
//         FileInputStream input = new FileInputStream(file);
//         
//         properties.load(input);
//         
//         input.close();
//         
//         return properties;
//     }
//    
//     @Override
//     public String getWebAppURL() throws IOException {
//  
//       String URL = loadProperties().getProperty("URL");
//         
//       return URL;  
//     }
// 
//     @Override
//     public String getWebServicesRoot() throws IOException {
//        
//       String root = loadProperties().getProperty("root");
//              
//       return root;       
//     }
// 
//     @Override
//     public String getToken() throws IOException {
//              
//         String token = loadProperties().getProperty("token");
//               
//         return token;        
//     }
//     
//     @Override
//     public boolean isAllowed(String pUsername) throws IOException {
//     	String betatest = loadProperties().getProperty("betatest");
//     	
//     	if (!betatest.equals("true"))
//     		return true;
//     	
//     	String allowedsStringList = loadProperties().getProperty("allowed");
//     	String[] alloweds = allowedsStringList.split(";");
//     	for (String allowed : alloweds) {
//     		if (pUsername.equals(allowed))
//     			return true;
//     	}
//     	
//     	return false;
//     }
//     
//     public boolean checkAdminPassword(String pPassword) {
//     	try {
//     		String adminPassword = loadProperties().getProperty("admin");
//     		return pPassword.equals(adminPassword);
//     	} catch (IOException e) {
//     		return false;
//     	}
//     }
// 
// 	@Override
// 	public void allowUser(String pUsername) throws IOException {
// 		Properties properties = loadProperties();
// 		
// 		properties.put("allowed", properties.get("allowed") + ";" + pUsername);
// 		
// 		FileOutputStream stream = new FileOutputStream(this.file);
// 		
// 		properties.store(stream, "");
// 		
// 		stream.close();
// 	}
// 
// 	@Override
// 	public String showConfig() {
// 		try {
// 			return new String(Files.readAllBytes(this.file.toPath()), StandardCharsets.UTF_8);
// 		} catch (IOException e) {
// 			return "???";
// 		}
// 	}
// 
// 	@Override
// 	public String getMongoDbUri() throws IOException {
// 		String mdburi = loadProperties().getProperty("mongodburi");
// 		return mdburi;
// 	}
// }
// 
// Path: src/java/rocks/teammolise/myunimol/webapp/configuration/ConfigurationManagerHandler.java
// public class ConfigurationManagerHandler {
// 	
// 	private static String filename;
//     
//     public static ConfigurationManager getInstance(){
//        
//         ConfigurationManager confManager = new ConfigurationManager(filename);
//               
//         return confManager;        
//     }
//     
//     public static void setConfigurationFilename(String pFilename) {
//     	filename = pFilename;
//     }
// }


import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import rocks.teammolise.myunimol.webapp.configuration.ConfigurationManager;
import rocks.teammolise.myunimol.webapp.configuration.ConfigurationManagerHandler;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package rocks.teammolise.myunimol.stubs;


/**
 *
 * @author Silvio
 */
@WebServlet(name = "enrollExam", urlPatterns = {"/enrollExam"})
public class EnrollExamStub extends HttpServlet {

    /**
     * Processes requests for both HTTP <code>GET</code> and <code>POST</code>
     * methods.
     *
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        
        
        response.setContentType("text/html;charset=UTF-8");
        PrintWriter out = response.getWriter();
       
        String enrollID = "19#10010#3130517#1579806#2011#10019#9998#2011#2#2";
        
        String token = request.getParameter("token");
        String reqEnrollId = request.getParameter("id");

// Path: src/java/rocks/teammolise/myunimol/webapp/configuration/ConfigurationManager.java
// public class ConfigurationManager implements ConfigurationManagerInterface{  
// 	private File file;
// 	
// 	public ConfigurationManager(String pFilename) {
// 		this.file = new File(pFilename);
// 	}
//     
//     public Properties loadProperties() throws IOException {
//         
//         Properties properties = new Properties();
// 
//         /**
//          * Carico il file config.properties in un File con il suo absolute path **TO FIX**
//          */
// 
//         FileInputStream input = new FileInputStream(file);
//         
//         properties.load(input);
//         
//         input.close();
//         
//         return properties;
//     }
//    
//     @Override
//     public String getWebAppURL() throws IOException {
//  
//       String URL = loadProperties().getProperty("URL");
//         
//       return URL;  
//     }
// 
//     @Override
//     public String getWebServicesRoot() throws IOException {
//        
//       String root = loadProperties().getProperty("root");
//              
//       return root;       
//     }
// 
//     @Override
//     public String getToken() throws IOException {
//              
//         String token = loadProperties().getProperty("token");
//               
//         return token;        
//     }
//     
//     @Override
//     public boolean isAllowed(String pUsername) throws IOException {
//     	String betatest = loadProperties().getProperty("betatest");
//     	
//     	if (!betatest.equals("true"))
//     		return true;
//     	
//     	String allowedsStringList = loadProperties().getProperty("allowed");
//     	String[] alloweds = allowedsStringList.split(";");
//     	for (String allowed : alloweds) {
//     		if (pUsername.equals(allowed))
//     			return true;
//     	}
//     	
//     	return false;
//     }
//     
//     public boolean checkAdminPassword(String pPassword) {
//     	try {
//     		String adminPassword = loadProperties().getProperty("admin");
//     		return pPassword.equals(adminPassword);
//     	} catch (IOException e) {
//     		return false;
//     	}
//     }
// 
// 	@Override
// 	public void allowUser(String pUsername) throws IOException {
// 		Properties properties = loadProperties();
// 		
// 		properties.put("allowed", properties.get("allowed") + ";" + pUsername);
// 		
// 		FileOutputStream stream = new FileOutputStream(this.file);
// 		
// 		properties.store(stream, "");
// 		
// 		stream.close();
// 	}
// 
// 	@Override
// 	public String showConfig() {
// 		try {
// 			return new String(Files.readAllBytes(this.file.toPath()), StandardCharsets.UTF_8);
// 		} catch (IOException e) {
// 			return "???";
// 		}
// 	}
// 
// 	@Override
// 	public String getMongoDbUri() throws IOException {
// 		String mdburi = loadProperties().getProperty("mongodburi");
// 		return mdburi;
// 	}
// }
// 
// Path: src/java/rocks/teammolise/myunimol/webapp/configuration/ConfigurationManagerHandler.java
// public class ConfigurationManagerHandler {
// 	
// 	private static String filename;
//     
//     public static ConfigurationManager getInstance(){
//        
//         ConfigurationManager confManager = new ConfigurationManager(filename);
//               
//         return confManager;        
//     }
//     
//     public static void setConfigurationFilename(String pFilename) {
//     	filename = pFilename;
//     }
// }


// Path: src/java/rocks/teammolise/myunimol/stubs/EnrollExamStub.java
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import rocks.teammolise.myunimol.webapp.configuration.ConfigurationManager;
import rocks.teammolise.myunimol.webapp.configuration.ConfigurationManagerHandler;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package rocks.teammolise.myunimol.stubs;


/**
 *
 * @author Silvio
 */
@WebServlet(name = "enrollExam", urlPatterns = {"/enrollExam"})
public class EnrollExamStub extends HttpServlet {

    /**
     * Processes requests for both HTTP <code>GET</code> and <code>POST</code>
     * methods.
     *
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        
        
        response.setContentType("text/html;charset=UTF-8");
        PrintWriter out = response.getWriter();
       
        String enrollID = "19#10010#3130517#1579806#2011#10019#9998#2011#2#2";
        
        String token = request.getParameter("token");
        String reqEnrollId = request.getParameter("id");

        String realToken = ConfigurationManagerHandler.getInstance().getToken();
