package senhafortev2;
import com.senhaforte.classes.ChallengeRetorno;
import com.senhaforte.classes.Grupo;
import com.senhaforte.classes.Usuario;
import com.senhaforte.security.Challenge;
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 BrunoRicardo
*/
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 < 10; i++){
AuthenticationStressUnit authenticationStressUnit = new AuthenticationStressUnit();
authenticationStressUnit.test();
}
}
public void test() {
//Cria novo desafio ou busca já criado
Grupo g = Grupo.BuscaGrupo("-", "-");
Usuario usuario = Usuario.buscaUsuario(g, "dcuentas");
Usuario.DesbloquearUsuario(g, usuario, 101);
ChallengeRetorno ret = Challenge.GeraChallenge(g, "dcuentas");
System.
out.
println("Desafio a partir de cartão Nº " + ret.
getSerial_grid());
for (String des
: ret.
getDesafio()) {
}
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);
String resposta
= Challenge.
RespostaChallenge(resposta1, resposta2, resposta3, usuario
);
System.
out.
println("probando : " + resposta1
+ resposta2
+ resposta3
+ " - " + resposta
);
}
char[] validCoords = getValidCoords(Usuario.RetornaGrid(usuario.getCartaoGrid()), ret.getDesafio());
String resposta
= Challenge.
RespostaChallenge(validCoords
[0], validCoords
[1], validCoords
[2], usuario
);
System.
out.
println("probando : " + validCoords
[0] + validCoords
[1] + validCoords
[2] + " - " + 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;
}
}