@PermitAll public String getPermitAll() { return permitAll; }
@Path("/config") @PermitAll public static class ConfigResource { @GET @Produces(MediaType.APPLICATION_JSON) public Map<String,Object> getConfig( ) { Map<String, Object> map = new HashMap<>(); for (NameValuePair pair : DrillOnYarnConfig.instance().getPairs()) { map.put(pair.getName(), pair.getValue()); } return map; } }
/** * DoY provides a link to YARN to display the AM UI. YARN wants to display the * linked page in a frame, which does not play well with the DoY UI. To avoid * this, we give YARN a link to this redirect page which does nothing other * than to redirect the browser to the (full) DoY main UI. */ @Path("/redirect") @PermitAll public static class RedirectPage { @GET @Produces(MediaType.TEXT_HTML) public Viewable getRoot() { Map<String, String> map = new HashMap<>(); String baseUrl = DoYUtil.unwrapAmUrl(dispatcher.getTrackingUrl()); map.put("amLink", baseUrl); map.put("clusterName", config.getString(DrillOnYarnConfig.APP_NAME)); return new Viewable("/drill-am/redirect.ftl", map); } }
@GET @Path("permitAll") @PermitAll public RestrictedEntity permitAll() { return RestrictedEntity.instance(); }
@PermitAll public void permitAllMethod() { } }
@PermitAll String jsr250PermitAll();
@GET @PermitAll @Path("guest") public String showSecret(@Auth User user) { return String.format("Hey there, %s. You know the secret! %d", user.getName(), user.getId()); }
@Path("/resize/{quantity}") @PermitAll public static class ResizeResource { @PathParam(value = "quantity") String quantity; @DefaultValue( "" ) @QueryParam( "key" ) String key; @POST @Produces(MediaType.APPLICATION_JSON) public Map<String,String> postResize( ) { ResizeRequest request = new ResizeRequest(key, quantity); if (request.error != null) { return request.error; } int curSize = dispatcher.getController().getTargetCount(); dispatcher.getController().resizeTo(request.n); return successResponse("Resizing from " + curSize + " to " + request.n); } }
/** * Stop the cluster. Uses a key to validate the request. The value of the key is * set in the Drill-on-YARN configuration file. The purpose is simply to prevent * accidental cluster shutdown when experimenting with the REST API; this is * not meant to be a security mechanism. */ @Path("/stop") @PermitAll public static class StopResource { @DefaultValue( "" ) @QueryParam( "key" ) String key; @POST @Produces(MediaType.APPLICATION_JSON) public Map<String,String> postStop( ) { Map<String, String> error = checkKey(key); if (error != null) { return error; } dispatcher.getController().shutDown(); return successResponse("Shutting down"); } }
@PermitAll @GET public String showSecret(@Auth User user) { return String.format("Hey there, %s. You know the secret! %d", user.getName(), user.getId()); }
@Path("/grow/{quantity}") @PermitAll public static class GrowResource { @PathParam(value = "quantity") @DefaultValue( "1" ) String quantity; @DefaultValue( "" ) @QueryParam( "key" ) String key; @POST @Produces(MediaType.APPLICATION_JSON) public Map<String,String> postResize( ) { ResizeRequest request = new ResizeRequest(key, quantity); if (request.error != null) { return request.error; } int curSize = dispatcher.getController().getTargetCount(); int newSize = curSize + request.n; dispatcher.getController().resizeTo(newSize); return successResponse("Growing by " + request.n + " to " + newSize); } }
@Path("/shrink/{quantity}") @PermitAll public static class ShrinkResource { @PathParam(value = "quantity") @DefaultValue( "1" ) String quantity; @DefaultValue( "" ) @QueryParam( "key" ) String key; @POST @Produces(MediaType.APPLICATION_JSON) public Map<String,String> postResize( ) { ResizeRequest request = new ResizeRequest(key, quantity); if (request.error != null) { return request.error; } int curSize = dispatcher.getController().getTargetCount(); int newSize = Math.max(curSize - request.n, 0); dispatcher.getController().resizeTo(newSize); return successResponse("Shrinking by " + request.n + " to " + newSize); } }
@PermitAll @GET public Server get() throws SQLException { return Context.getPermissionsManager().getServer(); }
@PermitAll public static class LogInLogOutPages { @Inject
@PermitAll public class Jsr250BusinessServiceImpl implements BusinessService {
@PermitAll @POST public User add( @FormParam("email") String email, @FormParam("password") String password) throws SQLException { User user = Context.getPermissionsManager().login(email, password); if (user != null) { request.getSession().setAttribute(USER_ID_KEY, user.getId()); LogAction.login(user.getId()); return user; } else { throw new WebApplicationException(Response.status(Response.Status.UNAUTHORIZED).build()); } }
@PermitAll public class ProtectedEJB {
@PermitAll @GET public User get(@QueryParam("token") String token) throws SQLException, UnsupportedEncodingException {
@PermitAll public interface BusinessService extends Serializable {
@Override @PermitAll @POST public Response add(User entity) throws SQLException { if (!Context.getPermissionsManager().getUserAdmin(getUserId())) { Context.getPermissionsManager().checkUserUpdate(getUserId(), new User(), entity); if (Context.getPermissionsManager().getUserManager(getUserId())) { Context.getPermissionsManager().checkUserLimit(getUserId()); } else { Context.getPermissionsManager().checkRegistration(getUserId()); entity.setDeviceLimit(Context.getConfig().getInteger("users.defaultDeviceLimit", -1)); int expirationDays = Context.getConfig().getInteger("users.defaultExpirationDays"); if (expirationDays > 0) { entity.setExpirationTime( new Date(System.currentTimeMillis() + (long) expirationDays * 24 * 3600 * 1000)); } } } Context.getUsersManager().addItem(entity); LogAction.create(getUserId(), entity); if (Context.getPermissionsManager().getUserManager(getUserId())) { Context.getDataManager().linkObject(User.class, getUserId(), ManagedUser.class, entity.getId(), true); LogAction.link(getUserId(), User.class, getUserId(), ManagedUser.class, entity.getId()); } Context.getUsersManager().refreshUserItems(); return Response.ok(entity).build(); }