/*
 * Copyright 2019 Rundeck, Inc. (http://rundeck.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.rundeck.core.auth;

import com.dtolabs.rundeck.core.authorization.AuthorizationUtil;

import java.util.Collections;
import java.util.Map;

public class AuthConstants {

    public static final String ACTION_CREATE = "create";
    public static final String ACTION_READ = "read";
    public static final String ACTION_VIEW = "view";
    public static final String ACTION_UPDATE = "update";
    public static final String ACTION_DELETE = "delete";
    public static final String ACTION_RUN = "run";
    public static final String ACTION_KILL = "kill";
    public static final String ACTION_ADMIN = "admin";
    public static final String ACTION_GENERATE_USER_TOKEN = "generate_user_token";
    public static final String ACTION_GENERATE_SERVICE_TOKEN = "generate_service_token";
    public static final String ACTION_REFRESH = "refresh";
    public static final String ACTION_RUNAS = "runAs";
    public static final String ACTION_KILLAS = "killAs";
    public static final String ACTION_CONFIGURE = "configure";
    public static final String ACTION_IMPORT = "import";
    public static final String ACTION_EXPORT = "export";
    public static final String ACTION_INSTALL = "install";
    public static final String ACTION_UNINSTALL = "uninstall";
    public static final String ACTION_DELETE_EXECUTION = "delete_execution";
    public static final String ACTION_ENABLE_EXECUTIONS = "enable_executions";
    public static final String ACTION_DISABLE_EXECUTIONS = "disable_executions";
    public static final String ACTION_TOGGLE_SCHEDULE = "toggle_schedule";
    public static final String ACTION_TOGGLE_EXECUTION = "toggle_execution";
    public static final String ACTION_SCM_UPDATE="scm_update";
    public static final String ACTION_SCM_CREATE="scm_create";
    public static final String ACTION_SCM_DELETE="scm_delete";
    public static final String ACTION_SCM_IMPORT = "scm_import";
    public static final String ACTION_SCM_EXPORT = "scm_export";
    public static final String ACTION_PROMOTE = "promote";
    public static final String ACTION_POST = "post";

    public static final String VIEW_HISTORY = "view_history";

    public static final String TYPE_SYSTEM = "system";
    public static final String TYPE_SYSTEM_ACL = "system_acl";
    public static final String TYPE_NODE = "node";
    public static final String TYPE_JOB = "job";
    public static final String TYPE_APITOKEN = "apitoken";
    public static final String TYPE_ADHOC = "adhoc";
    public static final String TYPE_PROJECT = "project";
    public static final String TYPE_PROJECT_ACL = "project_acl";
    public static final String TYPE_PLUGIN = "plugin";
    public static final String TYPE_EVENT = "event";
    public static final String TYPE_USER = "user";
    public static final String TYPE_STORAGE = "storage";
    public static final String TYPE_WEBHOOK = "webhook";

    private static Map<String, String> resType(String type) {
        return Collections.unmodifiableMap(AuthorizationUtil.resourceType(type));
    }

    public static final Map<String, String> RESOURCE_TYPE_SYSTEM = resType(TYPE_SYSTEM);
    public static final Map<String, String> RESOURCE_TYPE_SYSTEM_ACL = resType(TYPE_SYSTEM_ACL);
    public static final Map<String, String> RESOURCE_TYPE_NODE = resType(TYPE_NODE);
    public static final Map<String, String> RESOURCE_TYPE_JOB = resType(TYPE_JOB);
    public static final Map<String, String> RESOURCE_TYPE_EVENT = resType(TYPE_EVENT);
    public static final Map<String, String> RESOURCE_TYPE_WEBHOOK = resType(TYPE_WEBHOOK);
    public static final Map<String, String> RESOURCE_ADHOC = Collections.unmodifiableMap(AuthorizationUtil
            .resource(TYPE_ADHOC));
}

@@ -791,16 +791,79 @@
 tants %7B%0A
+    public static final String CTX_APPLICATION = %22application%22;
 %0A    pub
@@ -1287,24 +1287,150 @@
  = %22admin%22;%0A
+    public static final String ACTION_OPS_ADMIN = %22ops_admin%22;%0A    public static final String ACTION_APP_ADMIN = %22app_admin%22;%0A
     public s
@@ -3672,28 +3672,86 @@
 k%22;%0A
-%0A
     p
-rivate
+ublic static final String TYPE_RESOURCE = %22resource%22;%0A%0A    public
  static 
 Map%3C
@@ -3746,16 +3746,22 @@
  static 
+final 
 Map%3CStri
@@ -3776,74 +3776,261 @@
 ng%3E 
-resType(String type) %7B%0A        return Collections.unmodifiableMap(
+RESOURCE_TYPE_SYSTEM = AuthorizationUtil.resourceType(TYPE_SYSTEM);%0A    public static final Map%3CString, String%3E RESOURCE_TYPE_SYSTEM_ACL = AuthorizationUtil.resourceType(TYPE_SYSTEM_ACL);%0A    public static final Map%3CString, String%3E RESOURCE_TYPE_NODE = 
 Auth
@@ -4060,22 +4060,19 @@
 ype(
-type));%0A    %7D%0A
+TYPE_NODE);
 %0A   
@@ -4130,20 +4130,40 @@
 YPE_
-SYSTEM = res
+JOB = AuthorizationUtil.resource
 Type
@@ -4160,38 +4160,35 @@
 sourceType(TYPE_
-SYSTEM
+JOB
 );%0A    public st
@@ -4236,44 +4236,57 @@
 YPE_
-SYSTEM_ACL = resType(TYPE_SYSTEM_ACL
+EVENT = AuthorizationUtil.resourceType(TYPE_EVENT
 );%0A 
@@ -4346,18 +4346,44 @@
 YPE_
-NODE = res
+WEBHOOK = AuthorizationUtil.resource
 Type
@@ -4380,36 +4380,39 @@
 sourceType(TYPE_
-NODE
+WEBHOOK
 );%0A    public st
@@ -4460,17 +4460,43 @@
 YPE_
-JOB = res
+PLUGIN = AuthorizationUtil.resource
 Type
@@ -4493,35 +4493,38 @@
 sourceType(TYPE_
-JOB
+PLUGIN
 );%0A    public st
@@ -4572,19 +4572,41 @@
 YPE_
-EVENT = res
+USER = AuthorizationUtil.resource
 Type
@@ -4603,37 +4603,36 @@
 sourceType(TYPE_
-EVENT
+USER
 );%0A    public st
@@ -4680,21 +4680,45 @@
 YPE_
-WEBHOOK = res
+APITOKEN = AuthorizationUtil.resource
 Type
@@ -4715,39 +4715,40 @@
 sourceType(TYPE_
-WEBHOOK
+APITOKEN
 );%0A    public st

Add app_admin/ops_admin, added resource type definitions