use of org.springframework.data.mongodb.core.query.Query in project cas by apereo.
the class MongoDbTicketRegistry method deleteAll.
@Override
public long deleteAll() {
final Query query = new Query(Criteria.where(TicketHolder.FIELD_NAME_ID).regex(".+"));
final long count = this.mongoTemplate.count(query, this.collectionName);
mongoTemplate.remove(query, this.collectionName);
return count;
}
use of org.springframework.data.mongodb.core.query.Query in project cas by apereo.
the class MongoDbYubiKeyAccountRegistry method getAccount.
@Override
public Optional<YubiKeyAccount> getAccount(final String uid) {
final Query query = new Query();
query.addCriteria(Criteria.where("username").is(uid));
final YubiKeyAccount account = this.mongoTemplate.findOne(query, YubiKeyAccount.class, this.collectionName);
if (account != null) {
return Optional.of(new YubiKeyAccount(account.getId(), getCipherExecutor().decode(account.getPublicId()), account.getUsername()));
}
return Optional.empty();
}
use of org.springframework.data.mongodb.core.query.Query in project cas by apereo.
the class GoogleAuthenticatorMongoDbTokenRepository method get.
@Override
public GoogleAuthenticatorToken get(final String uid, final Integer otp) {
try {
final Query query = new Query();
query.addCriteria(Criteria.where("userId").is(uid).and("token").is(otp));
final GoogleAuthenticatorToken r = this.mongoTemplate.findOne(query, GoogleAuthenticatorToken.class, this.collectionName);
return r;
} catch (final NoResultException e) {
LOGGER.debug("No record could be found for google authenticator id [{}]", uid);
}
return null;
}
use of org.springframework.data.mongodb.core.query.Query in project cas by apereo.
the class MongoDbGoogleAuthenticatorTokenCredentialRepository method get.
@Override
public OneTimeTokenAccount get(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 decode(r);
}
} catch (final NoResultException e) {
LOGGER.debug("No record could be found for google authenticator id [{}]", username);
}
return null;
}
use of org.springframework.data.mongodb.core.query.Query in project commons-dao by reportportal.
the class LaunchRepositoryCustomImpl method findIdsByFilter.
@Override
public List<Launch> findIdsByFilter(Filter filter, int limit) {
Query query = QueryBuilder.newBuilder().with(filter).with(limit).build();
query.fields().include(ID_REFERENCE);
return mongoTemplate.find(query, Launch.class);
}
Aggregations