Skip to content

Commit

Permalink
Test creado
Browse files Browse the repository at this point in the history
  • Loading branch information
rafriofra committed Feb 2, 2017
1 parent 7d0ceed commit eece3a1
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/main/java/main/java/Authority.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,6 @@ public interface Authority {
//Desencripta el texto con la clave privada de la votación cuya id se pasa como parámetro en Local.
String decryptLocal(String idVote,String cipherText, Integer token) throws BadPaddingException, UnsupportedEncodingException, Exception;


//Recibe la id de la votación, crea las claves y las guarda en BD.
boolean defensaLocal(String id, Integer token);
}
39 changes: 39 additions & 0 deletions src/main/java/main/java/AuthorityImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,46 @@ public static String Desencriptar(String textoEncriptado) throws Exception{
}
return base64EncryptedString;
}

public boolean defensaLocal(String id, Integer token) {
boolean res;
BigInteger secretKey;
String publicKey;
String encodedPublicKey;
res = false;

if(TokenLocal.checkToken(new Integer(id), token)){
try{

TokenLocal.createToken(new Integer(id));

CryptoEngine cryptoEngine = new CryptoEngine(id);
cryptoEngine.generateKeyPair();

secretKey = cryptoEngine.getKeyPair().getSecretKey();
publicKey = cryptoEngine.getKeyPair().getPublicKey().getX()+"++++"+cryptoEngine.getKeyPair().getPublicKey().getY();


//Cambiar metodo de autenticacion
encodedPublicKey = new String(Base64.encodeBase64(publicKey.getBytes()));


//Usar base de datos local
LocalDataBaseManager rdbm=new LocalDataBaseManager();

if (rdbm.postKeys(id, encodedPublicKey, secretKey.toString())){
res = true;
}

}catch(Exception e){
e.printStackTrace();
}
}else{
throw new VerificationException("El token no coincide");
}

return res;
}



Expand Down

0 comments on commit eece3a1

Please sign in to comment.