This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.awt.*; | |
public class Main { | |
public static void main(String[] args) throws InterruptedException, AWTException { | |
//It takes the argument args[0] as the timeInMiliseconds for moving the cursor | |
var timeInMiliSecondsForMoveCursor = Integer.parseInt(args[0]); | |
CursorMoverFunctionality.moveCursor(timeInMiliSecondsForMoveCursor); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.awt.*; | |
import java.util.Random; | |
public class CursorMoverFunctionality { | |
//Max position of mouse on screen for X axis | |
private static final Integer MAX_SCREEN_X = 150; | |
//Max position of mouse on screen for Y axis | |
private static final Integer MAX_SCREEN_Y = 150; | |
public static void moveCursor(Integer timeInMiliseconds) throws AWTException, InterruptedException { | |
Robot robot = new Robot(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package utils; | |
import java.io.*; | |
import java.security.*; | |
import java.security.cert.CertificateFactory; | |
import java.security.cert.X509Certificate; | |
import java.util.logging.Level; | |
import java.util.logging.Logger; | |
public class JksCreator { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import utils.JksCreator; | |
import java.io.IOException; | |
import java.security.GeneralSecurityException; | |
public class Main { | |
public static void main(String[] args) throws GeneralSecurityException, IOException { | |
JksCreator.generateJKS("src/main/resources/medium.crt"); //Recibe la ruta de donde se ubique el certificado a cargar | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package utils; | |
public enum Estatus { | |
JKS_GENERADO("JKS generado satisfactoriamente"), | |
JKS_ERROR("Error al generar JKS"); | |
private String mensaje; | |
Estatus(String mensaje) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void generateJKS(String certPath) throws GeneralSecurityException, IOException { | |
KeyStore ks = createEmptyKeyStore(); | |
var cert = loadCertificate(new FileInputStream(certPath));//Carga el certificado de la ruta especificada, puede cargarse más de uno | |
ks.setCertificateEntry("mi-cer-1", cert);//Agrega el certificado al keystore creado y se le asigna un alias, puede agregarse más de uno | |
try (FileOutputStream fos = new FileOutputStream("certificado.jks")) { //Asigna nombre al archivo generado, este contendrá los certificados cargados y agregados | |
ks.store(fos, "".toCharArray()); //Genera el archivo jks y asigna una contraseña | |
LOGGER.log(Level.INFO, Estatus.JKS_GENERADO.getMensaje()); | |
}catch (Exception e){ | |
LOGGER.log(Level.SEVERE, Estatus.JKS_ERROR.getMensaje()); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static X509Certificate loadCertificate(InputStream publicCertIn) throws GeneralSecurityException { | |
CertificateFactory factory = CertificateFactory.getInstance("X.509"); | |
return (X509Certificate)factory.generateCertificate(publicCertIn); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Directivo extends Persona{ | |
private String cargo; | |
private String anosEnClub; | |
//Constructor, setters, getters | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// En java la palabra reservada extends permite que una clase herede de otra, Jugador hereda de Persona | |
public class Jugador extends Persona { | |
private String posicion; | |
private int tirosAlArco; | |
private boolean esTitular; | |
private String numeroPlayera; | |
private int golesAnotados; | |
private int pasesRealizados; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//En java la palabra reservada abstract indica que es una clase base | |
public abstract class Persona { | |
protected String nombre; | |
protected String apellido; | |
protected int edad; | |
protected float estatura; | |
protected String nacionalidad; | |
//Constructor, settters, getters... |
NewerOlder