use of com.peterphi.std.guice.restclient.jaxb.webquery.WebQuery in project stdlib by petergeneric.
the class OAuthSessionDaoImpl method exchangeCodeForToken.
@Transactional
public OAuthSessionEntity exchangeCodeForToken(final OAuthServiceEntity service, final String authorisationCode) {
final OAuthSessionEntity session = uniqueResult(new WebQuery().eq("authorisationCode", authorisationCode).isNull("token").eq("alive", true).eq("context.service.id", service.getId()));
if (session == null)
return null;
session.setToken(SimpleId.alphanumeric("tok-", 36));
session.setAuthorisationCode(null);
update(session);
return session;
}
use of com.peterphi.std.guice.restclient.jaxb.webquery.WebQuery in project stdlib by petergeneric.
the class OAuthSessionDaoImpl method exchangeRefreshTokenForNewToken.
@Transactional
public OAuthSessionEntity exchangeRefreshTokenForNewToken(final OAuthServiceEntity service, final String refreshToken, final DateTime newExpires) {
final OAuthSessionEntity session = uniqueResult(new WebQuery().eq("id", refreshToken).isNotNull("token").eq("alive", true).eq("context.service.id", service.getId()));
if (session == null)
return null;
session.setToken(SimpleId.alphanumeric("tok-", 36));
session.setExpires(newExpires);
update(session);
return session;
}
use of com.peterphi.std.guice.restclient.jaxb.webquery.WebQuery in project stdlib by petergeneric.
the class UserDaoImpl method loginBySessionReconnectKey.
@Transactional
public UserEntity loginBySessionReconnectKey(String key) {
final UserEntity account = uniqueResult(new WebQuery().eq("local", true).eq("sessionReconnectKey", key));
if (account != null) {
log.info("Allowed login by session reconnect key for user: " + account.getEmail());
account.setLastLogin(new DateTime());
update(account);
}
return account;
}
use of com.peterphi.std.guice.restclient.jaxb.webquery.WebQuery in project stdlib by petergeneric.
the class RoleUIServiceImpl method getRoles.
@Override
@Transactional(readOnly = true)
public String getRoles(UriInfo query) {
ConstrainedResultSet<RoleEntity> resultset = dao.findByUriQuery(new WebQuery().orderAsc("id").decode(query));
TemplateCall call = templater.template("roles");
call.set("resultset", resultset);
call.set("roles", resultset.getList());
call.set("nonce", nonceStore.getValue(NONCE_USE));
return call.process();
}
use of com.peterphi.std.guice.restclient.jaxb.webquery.WebQuery in project stdlib by petergeneric.
the class WebQueryTest method testEncodeResultStable.
@Test
public void testEncodeResultStable() {
WebQuery query = new WebQuery().orderDesc("id").orderAsc("name").orderAsc("name2").limit(99).computeSize(true).or(g -> g.eq("id", 1).contains("id", "some_value")).eq("name", "x");
assertEquals("{_compute_size=[true], _fetch=[entity], _order=[id desc, name asc, name2 asc], _limit=[99], name=[x], id=[1, _f_contains_some_value]}", query.encode().toString());
}
Aggregations