author | František Kučera <franta-hg@frantovo.cz> |
Sun, 20 Jun 2010 14:46:47 +0200 | |
changeset 145 | 0efefbf5f8b6 |
parent 55 | 079a3221355d |
permissions | -rw-r--r-- |
franta-hg@51 | 1 |
package cz.frantovo.nekurak.web; |
franta-hg@51 | 2 |
|
franta-hg@55 | 3 |
import cz.frantovo.nekurak.dto.PozadavekNaRegistraciUzivatele; |
franta-hg@52 | 4 |
import cz.frantovo.nekurak.util.Hash; |
franta-hg@52 | 5 |
import java.util.logging.Level; |
franta-hg@52 | 6 |
import java.util.logging.Logger; |
franta-hg@51 | 7 |
|
franta-hg@51 | 8 |
/** |
franta-hg@51 | 9 |
* Pomocná třída obalujícího uživatele a token (kvůli CSRF) |
franta-hg@51 | 10 |
* @author fiki |
franta-hg@51 | 11 |
*/ |
franta-hg@51 | 12 |
public class UzivatelPredRegistraci { |
franta-hg@51 | 13 |
|
franta-hg@145 | 14 |
private static final Logger log = Logger.getLogger(UzivatelPredRegistraci.class.getSimpleName()); |
franta-hg@145 | 15 |
private PozadavekNaRegistraciUzivatele uzivatel; |
franta-hg@145 | 16 |
private final String token = generujToken(); |
franta-hg@51 | 17 |
|
franta-hg@145 | 18 |
public PozadavekNaRegistraciUzivatele getUzivatel() { |
franta-hg@145 | 19 |
return uzivatel; |
franta-hg@145 | 20 |
} |
franta-hg@51 | 21 |
|
franta-hg@145 | 22 |
public void setUzivatel(PozadavekNaRegistraciUzivatele uzivatel) { |
franta-hg@145 | 23 |
this.uzivatel = uzivatel; |
franta-hg@145 | 24 |
} |
franta-hg@51 | 25 |
|
franta-hg@145 | 26 |
public String getToken() { |
franta-hg@145 | 27 |
return token; |
franta-hg@145 | 28 |
} |
franta-hg@51 | 29 |
|
franta-hg@145 | 30 |
/** |
franta-hg@145 | 31 |
* @return náhodný token |
franta-hg@145 | 32 |
*/ |
franta-hg@145 | 33 |
private static String generujToken() { |
franta-hg@145 | 34 |
try { |
franta-hg@145 | 35 |
return Hash.hashuj(String.valueOf(Math.random())); |
franta-hg@145 | 36 |
} catch (Exception e) { |
franta-hg@145 | 37 |
log.log(Level.SEVERE, "Chyba při generování háhodného tokenu", e); |
franta-hg@145 | 38 |
/** Nemělo by nikdy nastat :-) */ |
franta-hg@145 | 39 |
return "nbusr123"; |
franta-hg@145 | 40 |
} |
franta-hg@52 | 41 |
} |
franta-hg@51 | 42 |
} |