Search in sources :

Example 1 with GoogleAuthenticatorAccount

use of org.apereo.cas.adaptors.gauth.repository.credentials.GoogleAuthenticatorAccount in project cas by apereo.

the class JpaGoogleAuthenticatorTokenCredentialRepository method save.

@Override
public void save(final String userName, final String secretKey, final int validationCode, final List<Integer> scratchCodes) {
    final GoogleAuthenticatorAccount r = new GoogleAuthenticatorAccount(userName, secretKey, validationCode, scratchCodes);
    this.entityManager.merge(r);
}
Also used : GoogleAuthenticatorAccount(org.apereo.cas.adaptors.gauth.repository.credentials.GoogleAuthenticatorAccount)

Example 2 with GoogleAuthenticatorAccount

use of org.apereo.cas.adaptors.gauth.repository.credentials.GoogleAuthenticatorAccount in project cas by apereo.

the class MongoDbGoogleAuthenticatorTokenCredentialRepository method save.

@Override
public void save(final String userName, final String secretKey, final int validationCode, final List<Integer> scratchCodes) {
    final GoogleAuthenticatorAccount account = new GoogleAuthenticatorAccount(userName, secretKey, validationCode, scratchCodes);
    this.mongoTemplate.save(account, this.collectionName);
}
Also used : GoogleAuthenticatorAccount(org.apereo.cas.adaptors.gauth.repository.credentials.GoogleAuthenticatorAccount)

Example 3 with GoogleAuthenticatorAccount

use of org.apereo.cas.adaptors.gauth.repository.credentials.GoogleAuthenticatorAccount in project cas by apereo.

the class MongoDbGoogleAuthenticatorTokenCredentialRepository method getSecret.

@Override
public String getSecret(final String username) {
    try {
        final Query query = new Query();
        query.addCriteria(Criteria.where("username").is(username));
        final GoogleAuthenticatorAccount r = this.mongoTemplate.findOne(query, GoogleAuthenticatorAccount.class, this.collectionName);
        if (r != null) {
            return r.getSecretKey();
        }
    } catch (final NoResultException e) {
        LOGGER.debug("No record could be found for google authenticator id [{}]", username);
    }
    return null;
}
Also used : GoogleAuthenticatorAccount(org.apereo.cas.adaptors.gauth.repository.credentials.GoogleAuthenticatorAccount) Query(org.springframework.data.mongodb.core.query.Query) NoResultException(javax.persistence.NoResultException)

Aggregations

GoogleAuthenticatorAccount (org.apereo.cas.adaptors.gauth.repository.credentials.GoogleAuthenticatorAccount)3 NoResultException (javax.persistence.NoResultException)1 Query (org.springframework.data.mongodb.core.query.Query)1