mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
fix deployment
This commit is contained in:
@@ -1,9 +1,26 @@
|
||||
package com.commafeed.frontend.rest;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import javax.ws.rs.ApplicationPath;
|
||||
import javax.ws.rs.core.Application;
|
||||
|
||||
import com.commafeed.frontend.rest.resources.EntriesREST;
|
||||
import com.commafeed.frontend.rest.resources.SettingsREST;
|
||||
import com.commafeed.frontend.rest.resources.SubscriptionsREST;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
@ApplicationPath("/rest")
|
||||
public class RESTApplication extends Application {
|
||||
|
||||
@Override
|
||||
public Set<Class<?>> getClasses() {
|
||||
Set<Class<?>> set = Sets.newHashSet();
|
||||
set.add(JSONMessageBodyReaderWriter.class);
|
||||
|
||||
set.add(SubscriptionsREST.class);
|
||||
set.add(EntriesREST.class);
|
||||
set.add(SettingsREST.class);
|
||||
return set;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.WebApplicationException;
|
||||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.Response.Status;
|
||||
|
||||
import org.apache.wicket.ThreadContext;
|
||||
@@ -102,7 +103,9 @@ public abstract class AbstractREST {
|
||||
public Object checkSecurity(InvocationContext context) throws Exception {
|
||||
User user = getUser();
|
||||
if (user == null) {
|
||||
throw new WebApplicationException(Status.UNAUTHORIZED);
|
||||
throw new WebApplicationException(Response
|
||||
.status(Status.UNAUTHORIZED)
|
||||
.entity("You need to be authenticated to do this.").build());
|
||||
}
|
||||
|
||||
boolean allowed = false;
|
||||
@@ -118,7 +121,8 @@ public abstract class AbstractREST {
|
||||
SecurityCheck.class));
|
||||
}
|
||||
if (!allowed) {
|
||||
throw new WebApplicationException(Status.FORBIDDEN);
|
||||
throw new WebApplicationException(Response.status(Status.FORBIDDEN)
|
||||
.entity("You are not authorized to do this.").build());
|
||||
}
|
||||
|
||||
return context.proceed();
|
||||
|
||||
Reference in New Issue
Block a user