aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/org/traccar/api/resource/SOSResource.java40
-rw-r--r--src/org/traccar/web/CommandServlet.java12
-rw-r--r--src/org/traccar/web/WebServer.java3
3 files changed, 4 insertions, 51 deletions
diff --git a/src/org/traccar/api/resource/SOSResource.java b/src/org/traccar/api/resource/SOSResource.java
deleted file mode 100644
index 9c25132ee..000000000
--- a/src/org/traccar/api/resource/SOSResource.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright 2015 Anton Tananaev (anton.tananaev@gmail.com)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.traccar.api.resource;
-
-import org.traccar.Context;
-import org.traccar.api.BaseResource;
-import org.traccar.database.ActiveDevice;
-import org.traccar.model.Command;
-
-import javax.ws.rs.*;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-
-@Path("sos")
-@Produces(MediaType.APPLICATION_JSON)
-@Consumes(MediaType.APPLICATION_JSON)
-public class SOSResource extends BaseResource {
-
- @POST
- public Response add(Command entity) {
- Context.getPermissionsManager().checkDevice(getUserId(), entity.getDeviceId());
- ActiveDevice device = Context.getConnectionManager().getActiveDevice(entity.getDeviceId());
- device.write(entity.getType());
- return Response.ok(entity).build();
- }
-
-}
diff --git a/src/org/traccar/web/CommandServlet.java b/src/org/traccar/web/CommandServlet.java
index 7febb7f42..ff8c85542 100644
--- a/src/org/traccar/web/CommandServlet.java
+++ b/src/org/traccar/web/CommandServlet.java
@@ -22,7 +22,6 @@ import javax.servlet.http.HttpServletResponse;
import org.traccar.Context;
import org.traccar.database.ActiveDevice;
import org.traccar.model.Command;
-import org.traccar.model.User;
public class CommandServlet extends BaseServlet {
@@ -60,13 +59,8 @@ public class CommandServlet extends BaseServlet {
JsonObject json = Json.createReader(req.getReader()).readObject();
long deviceId = json.getJsonNumber("deviceId").longValue();
String command = json.getString("command");
- String username = json.getString("email");
- String password = json.getString("password");
- boolean success = false;
- if(username.equals("admin") && password.equals("VGY&7ujm")) {
- getActiveDevice(deviceId).write(command);
- success = true;
- }
- sendResponse(resp.getWriter(), success);
+ Context.getPermissionsManager().checkDevice(getUserId(req), deviceId);
+ getActiveDevice(deviceId).write(command);
+ sendResponse(resp.getWriter(), true);
}
}
diff --git a/src/org/traccar/web/WebServer.java b/src/org/traccar/web/WebServer.java
index f18e80182..7c842b2d2 100644
--- a/src/org/traccar/web/WebServer.java
+++ b/src/org/traccar/web/WebServer.java
@@ -134,8 +134,7 @@ public class WebServer {
resourceConfig.register(SecurityRequestFilter.class);
resourceConfig.register(CorsResponseFilter.class);
resourceConfig.registerClasses(ServerResource.class, SessionResource.class, CommandResource.class,
- PermissionResource.class, DeviceResource.class, UserResource.class, PositionResource.class,
- /*sos*/SOSResource.class);
+ PermissionResource.class, DeviceResource.class, UserResource.class, PositionResource.class);
servletHandler.addServlet(new ServletHolder(new ServletContainer(resourceConfig)), "/*");
handlers.addHandler(servletHandler);