aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2015-12-01 10:48:14 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2015-12-01 10:48:14 +1300
commit416ea87605b13f329430fbbb6a4aa1c002086514 (patch)
tree16f693c9cec8df8967f12fe987387a81282064a2 /src/org/traccar
parented7e73b5af4e4e84f3abd2dde73626f90de911bb (diff)
downloadtraccar-server-416ea87605b13f329430fbbb6a4aa1c002086514.tar.gz
traccar-server-416ea87605b13f329430fbbb6a4aa1c002086514.tar.bz2
traccar-server-416ea87605b13f329430fbbb6a4aa1c002086514.zip
Rename CORS response filter
Diffstat (limited to 'src/org/traccar')
-rw-r--r--src/org/traccar/api/CORSResponseFilter.java3
-rw-r--r--src/org/traccar/api/SecurityRequestFilter.java6
-rw-r--r--src/org/traccar/web/WebServer.java4
3 files changed, 5 insertions, 8 deletions
diff --git a/src/org/traccar/api/CORSResponseFilter.java b/src/org/traccar/api/CORSResponseFilter.java
index 89b49fc84..8aab5ad68 100644
--- a/src/org/traccar/api/CORSResponseFilter.java
+++ b/src/org/traccar/api/CORSResponseFilter.java
@@ -20,7 +20,7 @@ import javax.ws.rs.container.ContainerRequestContext;
import javax.ws.rs.container.ContainerResponseContext;
import javax.ws.rs.container.ContainerResponseFilter;
-public class CORSResponseFilter implements ContainerResponseFilter {
+public class CorsResponseFilter implements ContainerResponseFilter {
public static final String ACCESS_CONTROL_ALLOW_ORIGIN_KEY = "Access-Control-Allow-Origin";
public static final String ACCESS_CONTROL_ALLOW_ORIGIN_VALUE = "*";
@@ -49,4 +49,5 @@ public class CORSResponseFilter implements ContainerResponseFilter {
response.getHeaders().add(ACCESS_CONTROL_ALLOW_METHODS_KEY, ACCESS_CONTROL_ALLOW_METHODS_VALUE);
}
}
+
}
diff --git a/src/org/traccar/api/SecurityRequestFilter.java b/src/org/traccar/api/SecurityRequestFilter.java
index e52df661b..8dbd2bbb0 100644
--- a/src/org/traccar/api/SecurityRequestFilter.java
+++ b/src/org/traccar/api/SecurityRequestFilter.java
@@ -35,18 +35,15 @@ public class SecurityRequestFilter implements ContainerRequestFilter {
public void filter(ContainerRequestContext requestContext) {
Method method = resourceInfo.getResourceMethod();
- //@PermitAll
if (method.isAnnotationPresent(PermitAll.class)) {
return;
}
- //@DenyAll
if (method.isAnnotationPresent(DenyAll.class)) {
requestContext.abortWith(ResponseBuilder.forbidden());
return;
}
- //AuthorizationBasic
UserPrincipal userPrincipal = AuthorizationBasic.getUserPrincipal(requestContext);
if (userPrincipal == null
|| userPrincipal.getName() == null
@@ -56,7 +53,6 @@ public class SecurityRequestFilter implements ContainerRequestFilter {
return;
}
- //@RolesAllowed
if (method.isAnnotationPresent(RolesAllowed.class)) {
RolesAllowed rolesAnnotation = method.getAnnotation(RolesAllowed.class);
Set<String> roles = new HashSet<>(Arrays.asList(rolesAnnotation.value()));
@@ -66,7 +62,6 @@ public class SecurityRequestFilter implements ContainerRequestFilter {
}
}
- //SecurityContext
requestContext.setSecurityContext(new SecurityContextApi(userPrincipal));
}
@@ -77,4 +72,5 @@ public class SecurityRequestFilter implements ContainerRequestFilter {
private boolean isAuthorizedUser(UserPrincipal userPrincipal, Set<String> roles) {
return AuthorizationBasic.isAuthorizedUser(userPrincipal, roles);
}
+
}
diff --git a/src/org/traccar/web/WebServer.java b/src/org/traccar/web/WebServer.java
index 675f4d489..5ea31b079 100644
--- a/src/org/traccar/web/WebServer.java
+++ b/src/org/traccar/web/WebServer.java
@@ -27,7 +27,7 @@ import org.eclipse.jetty.webapp.WebAppContext;
import org.glassfish.jersey.server.ResourceConfig;
import org.glassfish.jersey.servlet.ServletContainer;
import org.traccar.Config;
-import org.traccar.api.CORSResponseFilter;
+import org.traccar.api.CorsResponseFilter;
import org.traccar.api.SecurityRequestFilter;
import org.traccar.helper.Log;
@@ -134,7 +134,7 @@ public class WebServer {
ResourceConfig resourceConfig = new ResourceConfig();
resourceConfig.packages("org.traccar.api");
resourceConfig.register(SecurityRequestFilter.class);
- resourceConfig.register(CORSResponseFilter.class);
+ resourceConfig.register(CorsResponseFilter.class);
ServletContextHandler servletHandler = new ServletContextHandler(ServletContextHandler.NO_SESSIONS);
ServletHolder servletHolder = new ServletHolder(new ServletContainer(resourceConfig));
servletHandler.addServlet(servletHolder, "/rest/*");