package senhafortev2;
import com.senhaforte.classes.ChallengeRetorno;
import com.senhaforte.classes.DBc;
import com.senhaforte.classes.Grupo;
import com.senhaforte.classes.Usuario;
import com.senhaforte.security.Challenge;
import javax.persistence.EntityManager;
import org.apache.commons.lang3.RandomStringUtils;
/*
* 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.
*/
/**
*
* @author BrunoRicardox
*/
public class AuthenticationStressUnit {
public static int UPPER_A_INT_VALUE = 65;
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
for (int i = 0; i < 2; i++) {
AuthenticationStressUnit authenticationStressUnit = new AuthenticationStressUnit();
authenticationStressUnit.test();
}
}
public void test() {
//Cria novo desafio ou busca já criado
Grupo g = Grupo.BuscaGrupo("NotSelADM", "VdJRYHFK");
Usuario usuario = Usuario.buscaUsuario(g, "dcuentas");
Usuario.DesbloquearUsuario(g, usuario, 11);
usuario = Usuario.buscaUsuario(g, "dcuentas");
ChallengeRetorno ret = Challenge.GeraChallenge(g, "dcuentas");
System.out.println("Desafio a partir de cartão Nº " + ret.getSerial_grid());
for (String des : ret.getDesafio()) {
System.out.println(des);
}
exemplo_usuario.printCartao(usuario.getCartaoGrid());
for (int i = 0; i < 10; i++) {
char resposta1 = RandomStringUtils.random(1, "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890").charAt(0);
char resposta2 = RandomStringUtils.random(1, "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890").charAt(0);
char resposta3 = RandomStringUtils.random(1, "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890").charAt(0);
System.out.print("probando : " + resposta1 + resposta2 + resposta3);
String resposta = Challenge.RespostaChallenge(resposta1, resposta2, resposta3, usuario);
System.out.println(" - " + resposta);
}
usuario = Usuario.buscaUsuario(g, "dcuentas");
char[] validCoords = getValidCoords(Usuario.RetornaGrid(usuario.getCartaoGrid()), ret.getDesafio());
System.out.print("probando : " + validCoords[0] + validCoords[1] + validCoords[2]);
String resposta = Challenge.RespostaChallenge(validCoords[0], validCoords[1], validCoords[2], usuario);
System.out.println(" - " + resposta);
}
public char[] getValidCoords(char[][] grid, String[] challengeArray) {
char[] validCoords = new char[3];
int validCoordsArrayIndex = 0;
for (String challenge : challengeArray) {
char coord1 = challenge.charAt(0);
char coord2 = challenge.charAt(2);
int numericXCoord = (int) coord2 - UPPER_A_INT_VALUE;
int numericYCoord = Character.getNumericValue(coord1) - 1;
validCoords[validCoordsArrayIndex] = grid[numericYCoord][numericXCoord];
validCoordsArrayIndex++;
}
return validCoords;
}
}