/*
 * 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;

import javax.ws.rs.core.SecurityContext;

public class BaseResource {

    @javax.ws.rs.core.Context
    private SecurityContext securityContext;

    protected long getUserId() {
        UserPrincipal principal = (UserPrincipal) securityContext.getUserPrincipal();
        if (principal != null) {
            return principal.getUserId();
        }
        return 0;
    }

}

@@ -14,16 +14,23 @@
 ht 2015 
+- 2016 
 Anton Ta
@@ -651,16 +651,122 @@
 r.api;%0A%0A
+import javax.annotation.security.PermitAll;%0Aimport javax.ws.rs.OPTIONS;%0Aimport javax.ws.rs.core.Response;%0A
 import j
@@ -1133,10 +1133,122 @@
 %0A    %7D%0A%0A
+    @PermitAll%0A    @OPTIONS%0A    public Response options() %7B%0A        return Response.noContent().build();%0A    %7D%0A%0A
 %7D%0A

Implement OPTIONS verb API handler