use of com.peterphi.usermanager.db.entity.OAuthServiceEntity in project stdlib by petergeneric.
the class ServiceUIServiceImpl method get.
@Override
@Transactional(readOnly = true)
public String get(final String id) {
final OAuthServiceEntity entity = dao.getById(id);
if (entity == null)
throw new IllegalArgumentException("No such service with client_id: " + id);
final TemplateCall call = templater.template("service");
call.set("nonce", nonceStore.getValue(NONCE_USE));
call.set("entity", entity);
call.set("localEndpoint", localEndpoint);
return call.process();
}
use of com.peterphi.usermanager.db.entity.OAuthServiceEntity in project stdlib by petergeneric.
the class ServiceUIServiceImpl method setEndpoints.
@Override
@Transactional
public Response setEndpoints(final String nonce, final String id, final String endpoints) {
nonceStore.validate(NONCE_USE, nonce);
final OAuthServiceEntity entity = dao.getById(id);
if (entity == null)
throw new IllegalArgumentException("No such service with client_id: " + id);
else if (!entity.isEnabled())
throw new IllegalArgumentException("Cannot set endpoints on disabled service: " + id);
else if (entity.getOwner().getId() != userProvider.get().getId() && !userProvider.get().isAdmin())
throw new IllegalArgumentException("Only the owner or an admin can change endpoints of a service!");
entity.setEndpoints(endpoints);
dao.update(entity);
return Response.seeOther(URI.create("/service/" + id)).build();
}
Aggregations