|
aerogear-security 1.3.1 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface TokenService
IdentityManagement allows to manage a Token.
| Method Summary | |
|---|---|
void |
destroy(String id)
Destroys the Token. |
String |
generate(String email)
Method to generate the Token. |
boolean |
isValid(String id)
Checks the validity of the Token based on the identifier passed as parameter. |
| Method Detail |
|---|
void destroy(String id)
try {
Token token = em.find(Token.class, id);
em.remove(token);
em.flush();
} catch (Exception e) {
e.printStackTrace();
}
id - id of the Token used to retrieve the Token.boolean isValid(String id)
Token token = null;
try {
token = em.createQuery("SELECT t FROM Token t WHERE t.id = :id", Token.class)
.setParameter("id", id)
.getSingleResult();
} catch (NoResultException e) {
//Do nothing because we don't want to give any clue to an attacker
}
return (token != null && !expirationTime.isExpired(token.getExpiration()));
id - is the token provided for password reset.
String generate(String email)
if (userExists(email)) {
String secret = Configuration.getSecret();
//Secret is the secret_key included into config.properties file
Hmac hmac = new Hmac(secret);
//Persists the temporary token
token = save(hmac.digest());
return token;
}
email - to be checked. E-mail must be provided to validate if it exists into the database
|
aerogear-security 1.3.1 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||