http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/413fcb68/security-admin/src/main/java/org/apache/ranger/common/XACommonEnums.java ---------------------------------------------------------------------- diff --git a/security-admin/src/main/java/org/apache/ranger/common/XACommonEnums.java b/security-admin/src/main/java/org/apache/ranger/common/XACommonEnums.java new file mode 100644 index 0000000..bc5d809 --- /dev/null +++ b/security-admin/src/main/java/org/apache/ranger/common/XACommonEnums.java @@ -0,0 +1,1444 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.ranger.common; + +/** + * + */ + +import java.util.*; + +import org.apache.ranger.common.*; + +public class XACommonEnums { + + /*************************************************************** + * Enum values for ActiveStatus + **************************************************************/ + /** + * STATUS_DISABLED is an element of enum ActiveStatus. Its value is "STATUS_DISABLED". + */ + public static final int STATUS_DISABLED = 0; + /** + * STATUS_ENABLED is an element of enum ActiveStatus. Its value is "STATUS_ENABLED". + */ + public static final int STATUS_ENABLED = 1; + /** + * STATUS_DELETED is an element of enum ActiveStatus. Its value is "STATUS_DELETED". + */ + public static final int STATUS_DELETED = 2; + + /** + * Max value for enum ActiveStatus_MAX + */ + public static final int ActiveStatus_MAX = 2; + + + /*************************************************************** + * Enum values for ActivationStatus + **************************************************************/ + /** + * ACT_STATUS_DISABLED is an element of enum ActivationStatus. Its value is "ACT_STATUS_DISABLED". + */ + public static final int ACT_STATUS_DISABLED = 0; + /** + * ACT_STATUS_ACTIVE is an element of enum ActivationStatus. Its value is "ACT_STATUS_ACTIVE". + */ + public static final int ACT_STATUS_ACTIVE = 1; + /** + * ACT_STATUS_PENDING_APPROVAL is an element of enum ActivationStatus. Its value is "ACT_STATUS_PENDING_APPROVAL". + */ + public static final int ACT_STATUS_PENDING_APPROVAL = 2; + /** + * ACT_STATUS_PENDING_ACTIVATION is an element of enum ActivationStatus. Its value is "ACT_STATUS_PENDING_ACTIVATION". + */ + public static final int ACT_STATUS_PENDING_ACTIVATION = 3; + /** + * ACT_STATUS_REJECTED is an element of enum ActivationStatus. Its value is "ACT_STATUS_REJECTED". + */ + public static final int ACT_STATUS_REJECTED = 4; + /** + * ACT_STATUS_DEACTIVATED is an element of enum ActivationStatus. Its value is "ACT_STATUS_DEACTIVATED". + */ + public static final int ACT_STATUS_DEACTIVATED = 5; + /** + * ACT_STATUS_PRE_REGISTRATION is an element of enum ActivationStatus. Its value is "ACT_STATUS_PRE_REGISTRATION". + */ + public static final int ACT_STATUS_PRE_REGISTRATION = 6; + /** + * ACT_STATUS_NO_LOGIN is an element of enum ActivationStatus. Its value is "ACT_STATUS_NO_LOGIN". + */ + public static final int ACT_STATUS_NO_LOGIN = 7; + + /** + * Max value for enum ActivationStatus_MAX + */ + public static final int ActivationStatus_MAX = 7; + + + /*************************************************************** + * Enum values for BooleanValue + **************************************************************/ + /** + * BOOL_NONE is an element of enum BooleanValue. Its value is "BOOL_NONE". + */ + public static final int BOOL_NONE = 0; + /** + * BOOL_TRUE is an element of enum BooleanValue. Its value is "BOOL_TRUE". + */ + public static final int BOOL_TRUE = 1; + /** + * BOOL_FALSE is an element of enum BooleanValue. Its value is "BOOL_FALSE". + */ + public static final int BOOL_FALSE = 2; + + /** + * Max value for enum BooleanValue_MAX + */ + public static final int BooleanValue_MAX = 2; + + + /*************************************************************** + * Enum values for DataType + **************************************************************/ + /** + * DATA_TYPE_UNKNOWN is an element of enum DataType. Its value is "DATA_TYPE_UNKNOWN". + */ + public static final int DATA_TYPE_UNKNOWN = 0; + /** + * DATA_TYPE_INTEGER is an element of enum DataType. Its value is "DATA_TYPE_INTEGER". + */ + public static final int DATA_TYPE_INTEGER = 1; + /** + * DATA_TYPE_DOUBLE is an element of enum DataType. Its value is "DATA_TYPE_DOUBLE". + */ + public static final int DATA_TYPE_DOUBLE = 2; + /** + * DATA_TYPE_STRING is an element of enum DataType. Its value is "DATA_TYPE_STRING". + */ + public static final int DATA_TYPE_STRING = 3; + /** + * DATA_TYPE_BOOLEAN is an element of enum DataType. Its value is "DATA_TYPE_BOOLEAN". + */ + public static final int DATA_TYPE_BOOLEAN = 4; + /** + * DATA_TYPE_DATE is an element of enum DataType. Its value is "DATA_TYPE_DATE". + */ + public static final int DATA_TYPE_DATE = 5; + /** + * DATA_TYPE_STRING_ENUM is an element of enum DataType. Its value is "DATA_TYPE_STRING_ENUM". + */ + public static final int DATA_TYPE_STRING_ENUM = 6; + /** + * DATA_TYPE_LONG is an element of enum DataType. Its value is "DATA_TYPE_LONG". + */ + public static final int DATA_TYPE_LONG = 7; + /** + * DATA_TYPE_INTEGER_ENUM is an element of enum DataType. Its value is "DATA_TYPE_INTEGER_ENUM". + */ + public static final int DATA_TYPE_INTEGER_ENUM = 8; + + /** + * Max value for enum DataType_MAX + */ + public static final int DataType_MAX = 8; + + + /*************************************************************** + * Enum values for DeviceType + **************************************************************/ + /** + * DEVICE_UNKNOWN is an element of enum DeviceType. Its value is "DEVICE_UNKNOWN". + */ + public static final int DEVICE_UNKNOWN = 0; + /** + * DEVICE_BROWSER is an element of enum DeviceType. Its value is "DEVICE_BROWSER". + */ + public static final int DEVICE_BROWSER = 1; + /** + * DEVICE_IPHONE is an element of enum DeviceType. Its value is "DEVICE_IPHONE". + */ + public static final int DEVICE_IPHONE = 2; + /** + * DEVICE_IPAD is an element of enum DeviceType. Its value is "DEVICE_IPAD". + */ + public static final int DEVICE_IPAD = 3; + /** + * DEVICE_IPOD is an element of enum DeviceType. Its value is "DEVICE_IPOD". + */ + public static final int DEVICE_IPOD = 4; + /** + * DEVICE_ANDROID is an element of enum DeviceType. Its value is "DEVICE_ANDROID". + */ + public static final int DEVICE_ANDROID = 5; + + /** + * Max value for enum DeviceType_MAX + */ + public static final int DeviceType_MAX = 5; + + + /*************************************************************** + * Enum values for DiffLevel + **************************************************************/ + /** + * DIFF_UNKNOWN is an element of enum DiffLevel. Its value is "DIFF_UNKNOWN". + */ + public static final int DIFF_UNKNOWN = 0; + /** + * DIFF_LOW is an element of enum DiffLevel. Its value is "DIFF_LOW". + */ + public static final int DIFF_LOW = 1; + /** + * DIFF_MEDIUM is an element of enum DiffLevel. Its value is "DIFF_MEDIUM". + */ + public static final int DIFF_MEDIUM = 2; + /** + * DIFF_HIGH is an element of enum DiffLevel. Its value is "DIFF_HIGH". + */ + public static final int DIFF_HIGH = 3; + + /** + * Max value for enum DiffLevel_MAX + */ + public static final int DiffLevel_MAX = 3; + + + /*************************************************************** + * Enum values for FileType + **************************************************************/ + /** + * FILE_FILE is an element of enum FileType. Its value is "FILE_FILE". + */ + public static final int FILE_FILE = 0; + /** + * FILE_DIR is an element of enum FileType. Its value is "FILE_DIR". + */ + public static final int FILE_DIR = 1; + + /** + * Max value for enum FileType_MAX + */ + public static final int FileType_MAX = 1; + + + /*************************************************************** + * Enum values for FreqType + **************************************************************/ + /** + * FREQ_NONE is an element of enum FreqType. Its value is "FREQ_NONE". + */ + public static final int FREQ_NONE = 0; + /** + * FREQ_MANUAL is an element of enum FreqType. Its value is "FREQ_MANUAL". + */ + public static final int FREQ_MANUAL = 1; + /** + * FREQ_HOURLY is an element of enum FreqType. Its value is "FREQ_HOURLY". + */ + public static final int FREQ_HOURLY = 2; + /** + * FREQ_DAILY is an element of enum FreqType. Its value is "FREQ_DAILY". + */ + public static final int FREQ_DAILY = 3; + /** + * FREQ_WEEKLY is an element of enum FreqType. Its value is "FREQ_WEEKLY". + */ + public static final int FREQ_WEEKLY = 4; + /** + * FREQ_BI_WEEKLY is an element of enum FreqType. Its value is "FREQ_BI_WEEKLY". + */ + public static final int FREQ_BI_WEEKLY = 5; + /** + * FREQ_MONTHLY is an element of enum FreqType. Its value is "FREQ_MONTHLY". + */ + public static final int FREQ_MONTHLY = 6; + + /** + * Max value for enum FreqType_MAX + */ + public static final int FreqType_MAX = 6; + + + /*************************************************************** + * Enum values for MimeType + **************************************************************/ + /** + * MIME_UNKNOWN is an element of enum MimeType. Its value is "MIME_UNKNOWN". + */ + public static final int MIME_UNKNOWN = 0; + /** + * MIME_TEXT is an element of enum MimeType. Its value is "MIME_TEXT". + */ + public static final int MIME_TEXT = 1; + /** + * MIME_HTML is an element of enum MimeType. Its value is "MIME_HTML". + */ + public static final int MIME_HTML = 2; + /** + * MIME_PNG is an element of enum MimeType. Its value is "MIME_PNG". + */ + public static final int MIME_PNG = 3; + /** + * MIME_JPEG is an element of enum MimeType. Its value is "MIME_JPEG". + */ + public static final int MIME_JPEG = 4; + + /** + * Max value for enum MimeType_MAX + */ + public static final int MimeType_MAX = 4; + + + /*************************************************************** + * Enum values for NumberFormat + **************************************************************/ + /** + * NUM_FORMAT_NONE is an element of enum NumberFormat. Its value is "NUM_FORMAT_NONE". + */ + public static final int NUM_FORMAT_NONE = 0; + /** + * NUM_FORMAT_NUMERIC is an element of enum NumberFormat. Its value is "NUM_FORMAT_NUMERIC". + */ + public static final int NUM_FORMAT_NUMERIC = 1; + /** + * NUM_FORMAT_ALPHA is an element of enum NumberFormat. Its value is "NUM_FORMAT_ALPHA". + */ + public static final int NUM_FORMAT_ALPHA = 2; + /** + * NUM_FORMAT_ROMAN is an element of enum NumberFormat. Its value is "NUM_FORMAT_ROMAN". + */ + public static final int NUM_FORMAT_ROMAN = 3; + + /** + * Max value for enum NumberFormat_MAX + */ + public static final int NumberFormat_MAX = 3; + + + /*************************************************************** + * Enum values for ObjectStatus + **************************************************************/ + /** + * OBJ_STATUS_ACTIVE is an element of enum ObjectStatus. Its value is "OBJ_STATUS_ACTIVE". + */ + public static final int OBJ_STATUS_ACTIVE = 0; + /** + * OBJ_STATUS_DELETED is an element of enum ObjectStatus. Its value is "OBJ_STATUS_DELETED". + */ + public static final int OBJ_STATUS_DELETED = 1; + /** + * OBJ_STATUS_ARCHIVED is an element of enum ObjectStatus. Its value is "OBJ_STATUS_ARCHIVED". + */ + public static final int OBJ_STATUS_ARCHIVED = 2; + + /** + * Max value for enum ObjectStatus_MAX + */ + public static final int ObjectStatus_MAX = 2; + + + /*************************************************************** + * Enum values for PasswordResetStatus + **************************************************************/ + /** + * PWD_RESET_ACTIVE is an element of enum PasswordResetStatus. Its value is "PWD_RESET_ACTIVE". + */ + public static final int PWD_RESET_ACTIVE = 0; + /** + * PWD_RESET_USED is an element of enum PasswordResetStatus. Its value is "PWD_RESET_USED". + */ + public static final int PWD_RESET_USED = 1; + /** + * PWD_RESET_EXPIRED is an element of enum PasswordResetStatus. Its value is "PWD_RESET_EXPIRED". + */ + public static final int PWD_RESET_EXPIRED = 2; + /** + * PWD_RESET_DISABLED is an element of enum PasswordResetStatus. Its value is "PWD_RESET_DISABLED". + */ + public static final int PWD_RESET_DISABLED = 3; + + /** + * Max value for enum PasswordResetStatus_MAX + */ + public static final int PasswordResetStatus_MAX = 3; + + + /*************************************************************** + * Enum values for PriorityType + **************************************************************/ + /** + * PRIORITY_NORMAL is an element of enum PriorityType. Its value is "PRIORITY_NORMAL". + */ + public static final int PRIORITY_NORMAL = 0; + /** + * PRIORITY_LOW is an element of enum PriorityType. Its value is "PRIORITY_LOW". + */ + public static final int PRIORITY_LOW = 1; + /** + * PRIORITY_MEDIUM is an element of enum PriorityType. Its value is "PRIORITY_MEDIUM". + */ + public static final int PRIORITY_MEDIUM = 2; + /** + * PRIORITY_HIGH is an element of enum PriorityType. Its value is "PRIORITY_HIGH". + */ + public static final int PRIORITY_HIGH = 3; + + /** + * Max value for enum PriorityType_MAX + */ + public static final int PriorityType_MAX = 3; + + + /*************************************************************** + * Enum values for ProgressStatus + **************************************************************/ + /** + * PROGRESS_PENDING is an element of enum ProgressStatus. Its value is "PROGRESS_PENDING". + */ + public static final int PROGRESS_PENDING = 0; + /** + * PROGRESS_IN_PROGRESS is an element of enum ProgressStatus. Its value is "PROGRESS_IN_PROGRESS". + */ + public static final int PROGRESS_IN_PROGRESS = 1; + /** + * PROGRESS_COMPLETE is an element of enum ProgressStatus. Its value is "PROGRESS_COMPLETE". + */ + public static final int PROGRESS_COMPLETE = 2; + /** + * PROGRESS_ABORTED is an element of enum ProgressStatus. Its value is "PROGRESS_ABORTED". + */ + public static final int PROGRESS_ABORTED = 3; + /** + * PROGRESS_FAILED is an element of enum ProgressStatus. Its value is "PROGRESS_FAILED". + */ + public static final int PROGRESS_FAILED = 4; + + /** + * Max value for enum ProgressStatus_MAX + */ + public static final int ProgressStatus_MAX = 4; + + + /*************************************************************** + * Enum values for RelationType + **************************************************************/ + /** + * REL_NONE is an element of enum RelationType. Its value is "REL_NONE". + */ + public static final int REL_NONE = 0; + /** + * REL_SELF is an element of enum RelationType. Its value is "REL_SELF". + */ + public static final int REL_SELF = 1; + + /** + * Max value for enum RelationType_MAX + */ + public static final int RelationType_MAX = 1; + + + /*************************************************************** + * Enum values for UserSource + **************************************************************/ + /** + * USER_APP is an element of enum UserSource. Its value is "USER_APP". + */ + public static final int USER_APP = 0; + public static final int USER_EXTERNAL = 1; + public static final int USER_AD= 2; + public static final int USER_LDAP = 3; + public static final int USER_UNIX = 4; + public static final int USER_REPO = 5; + + public static final int GROUP_INTERNAL = 0; + public static final int GROUP_EXTERNAL = 1; + public static final int GROUP_AD= 2; + public static final int GROUP_LDAP = 3; + public static final int GROUP_UNIX = 4; + public static final int GROUP_REPO = 5; + /** + * USER_GOOGLE is an element of enum UserSource. Its value is "USER_GOOGLE". + */ + //public static final int USER_GOOGLE = 1; + /** + * USER_FB is an element of enum UserSource. Its value is "USER_FB". + */ + //public static final int USER_FB = 2; + + /** + * Max value for enum UserSource_MAX + */ + public static final int UserSource_MAX = 5; + + + /*************************************************************** + * Enum values for AssetType + **************************************************************/ + /** + * ASSET_UNKNOWN is an element of enum AssetType. Its value is "ASSET_UNKNOWN". + */ + public static final int ASSET_UNKNOWN = 0; + /** + * ASSET_HDFS is an element of enum AssetType. Its value is "ASSET_HDFS". + */ + public static final int ASSET_HDFS = 1; + /** + * ASSET_HBASE is an element of enum AssetType. Its value is "ASSET_HBASE". + */ + public static final int ASSET_HBASE = 2; + /** + * ASSET_HIVE is an element of enum AssetType. Its value is "ASSET_HIVE". + */ + public static final int ASSET_HIVE = 3; + /** + * ASSET_HIVE is an element of enum AssetType. Its value is "ASSET_HIVE". + */ + public static final int ASSET_AGENT = 4; + /** + * ASSET_HIVE is an element of enum AssetType. Its value is "ASSET_HIVE". + */ + public static final int ASSET_KNOX = 5; + /** + * ASSET_HIVE is an element of enum AssetType. Its value is "ASSET_HIVE". + */ + public static final int ASSET_STORM = 6; + + /** + * Max value for enum AssetType_MAX + */ + public static final int AssetType_MAX = 6; + + + /*************************************************************** + * Enum values for AccessResult + **************************************************************/ + /** + * ACCESS_RESULT_DENIED is an element of enum AccessResult. Its value is "ACCESS_RESULT_DENIED". + */ + public static final int ACCESS_RESULT_DENIED = 0; + /** + * ACCESS_RESULT_ALLOWED is an element of enum AccessResult. Its value is "ACCESS_RESULT_ALLOWED". + */ + public static final int ACCESS_RESULT_ALLOWED = 1; + + /** + * Max value for enum AccessResult_MAX + */ + public static final int AccessResult_MAX = 1; + + + /*************************************************************** + * Enum values for PolicyType + **************************************************************/ + /** + * POLICY_INCLUSION is an element of enum PolicyType. Its value is "POLICY_INCLUSION". + */ + public static final int POLICY_INCLUSION = 0; + /** + * POLICY_EXCLUSION is an element of enum PolicyType. Its value is "POLICY_EXCLUSION". + */ + public static final int POLICY_EXCLUSION = 1; + + /** + * Max value for enum PolicyType_MAX + */ + public static final int PolicyType_MAX = 1; + + + /*************************************************************** + * Enum values for XAAuditType + **************************************************************/ + /** + * XA_AUDIT_TYPE_UNKNOWN is an element of enum XAAuditType. Its value is "XA_AUDIT_TYPE_UNKNOWN". + */ + public static final int XA_AUDIT_TYPE_UNKNOWN = 0; + /** + * XA_AUDIT_TYPE_ALL is an element of enum XAAuditType. Its value is "XA_AUDIT_TYPE_ALL". + */ + public static final int XA_AUDIT_TYPE_ALL = 1; + /** + * XA_AUDIT_TYPE_READ is an element of enum XAAuditType. Its value is "XA_AUDIT_TYPE_READ". + */ + public static final int XA_AUDIT_TYPE_READ = 2; + /** + * XA_AUDIT_TYPE_WRITE is an element of enum XAAuditType. Its value is "XA_AUDIT_TYPE_WRITE". + */ + public static final int XA_AUDIT_TYPE_WRITE = 3; + /** + * XA_AUDIT_TYPE_CREATE is an element of enum XAAuditType. Its value is "XA_AUDIT_TYPE_CREATE". + */ + public static final int XA_AUDIT_TYPE_CREATE = 4; + /** + * XA_AUDIT_TYPE_DELETE is an element of enum XAAuditType. Its value is "XA_AUDIT_TYPE_DELETE". + */ + public static final int XA_AUDIT_TYPE_DELETE = 5; + /** + * XA_AUDIT_TYPE_LOGIN is an element of enum XAAuditType. Its value is "XA_AUDIT_TYPE_LOGIN". + */ + public static final int XA_AUDIT_TYPE_LOGIN = 6; + + /** + * Max value for enum XAAuditType_MAX + */ + public static final int XAAuditType_MAX = 6; + + + /*************************************************************** + * Enum values for ResourceType + **************************************************************/ + /** + * RESOURCE_UNKNOWN is an element of enum ResourceType. Its value is "RESOURCE_UNKNOWN". + */ + public static final int RESOURCE_UNKNOWN = 0; + /** + * RESOURCE_PATH is an element of enum ResourceType. Its value is "RESOURCE_PATH". + */ + public static final int RESOURCE_PATH = 1; + /** + * RESOURCE_DB is an element of enum ResourceType. Its value is "RESOURCE_DB". + */ + public static final int RESOURCE_DB = 2; + /** + * RESOURCE_TABLE is an element of enum ResourceType. Its value is "RESOURCE_TABLE". + */ + public static final int RESOURCE_TABLE = 3; + /** + * RESOURCE_COL_FAM is an element of enum ResourceType. Its value is "RESOURCE_COL_FAM". + */ + public static final int RESOURCE_COL_FAM = 4; + /** + * RESOURCE_COLUMN is an element of enum ResourceType. Its value is "RESOURCE_COLUMN". + */ + public static final int RESOURCE_COLUMN = 5; + /** + * RESOURCE_VIEW is an element of enum ResourceType. Its value is "RESOURCE_VIEW". + */ + public static final int RESOURCE_VIEW = 6; + /** + * RESOURCE_UDF is an element of enum ResourceType. Its value is "RESOURCE_UDF". + */ + public static final int RESOURCE_UDF = 7; + /** + * RESOURCE_VIEW_COL is an element of enum ResourceType. Its value is "RESOURCE_VIEW_COL". + */ + public static final int RESOURCE_VIEW_COL = 8; + + /** + * Max value for enum ResourceType_MAX + */ + public static final int ResourceType_MAX = 8; + + + /*************************************************************** + * Enum values for XAGroupType + **************************************************************/ + /** + * XA_GROUP_UNKNOWN is an element of enum XAGroupType. Its value is "XA_GROUP_UNKNOWN". + */ + public static final int XA_GROUP_UNKNOWN = 0; + /** + * XA_GROUP_USER is an element of enum XAGroupType. Its value is "XA_GROUP_USER". + */ + public static final int XA_GROUP_USER = 1; + /** + * XA_GROUP_GROUP is an element of enum XAGroupType. Its value is "XA_GROUP_GROUP". + */ + public static final int XA_GROUP_GROUP = 2; + /** + * XA_GROUP_ROLE is an element of enum XAGroupType. Its value is "XA_GROUP_ROLE". + */ + public static final int XA_GROUP_ROLE = 3; + + /** + * Max value for enum XAGroupType_MAX + */ + public static final int XAGroupType_MAX = 3; + + + /*************************************************************** + * Enum values for XAPermForType + **************************************************************/ + /** + * XA_PERM_FOR_UNKNOWN is an element of enum XAPermForType. Its value is "XA_PERM_FOR_UNKNOWN". + */ + public static final int XA_PERM_FOR_UNKNOWN = 0; + /** + * XA_PERM_FOR_USER is an element of enum XAPermForType. Its value is "XA_PERM_FOR_USER". + */ + public static final int XA_PERM_FOR_USER = 1; + /** + * XA_PERM_FOR_GROUP is an element of enum XAPermForType. Its value is "XA_PERM_FOR_GROUP". + */ + public static final int XA_PERM_FOR_GROUP = 2; + + /** + * Max value for enum XAPermForType_MAX + */ + public static final int XAPermForType_MAX = 2; + + + /*************************************************************** + * Enum values for XAPermType + **************************************************************/ + /** + * XA_PERM_TYPE_UNKNOWN is an element of enum XAPermType. Its value is "XA_PERM_TYPE_UNKNOWN". + */ + public static final int XA_PERM_TYPE_UNKNOWN = 0; + /** + * XA_PERM_TYPE_RESET is an element of enum XAPermType. Its value is "XA_PERM_TYPE_RESET". + */ + public static final int XA_PERM_TYPE_RESET = 1; + /** + * XA_PERM_TYPE_READ is an element of enum XAPermType. Its value is "XA_PERM_TYPE_READ". + */ + public static final int XA_PERM_TYPE_READ = 2; + /** + * XA_PERM_TYPE_WRITE is an element of enum XAPermType. Its value is "XA_PERM_TYPE_WRITE". + */ + public static final int XA_PERM_TYPE_WRITE = 3; + /** + * XA_PERM_TYPE_CREATE is an element of enum XAPermType. Its value is "XA_PERM_TYPE_CREATE". + */ + public static final int XA_PERM_TYPE_CREATE = 4; + /** + * XA_PERM_TYPE_DELETE is an element of enum XAPermType. Its value is "XA_PERM_TYPE_DELETE". + */ + public static final int XA_PERM_TYPE_DELETE = 5; + /** + * XA_PERM_TYPE_ADMIN is an element of enum XAPermType. Its value is "XA_PERM_TYPE_ADMIN". + */ + public static final int XA_PERM_TYPE_ADMIN = 6; + /** + * XA_PERM_TYPE_OBFUSCATE is an element of enum XAPermType. Its value is "XA_PERM_TYPE_OBFUSCATE". + */ + public static final int XA_PERM_TYPE_OBFUSCATE = 7; + /** + * XA_PERM_TYPE_MASK is an element of enum XAPermType. Its value is "XA_PERM_TYPE_MASK". + */ + public static final int XA_PERM_TYPE_MASK = 8; + /** + * XA_PERM_TYPE_EXECUTE is an element of enum XAPermType. Its value is "XA_PERM_TYPE_EXECUTE". + */ + public static final int XA_PERM_TYPE_EXECUTE = 9; + /** + * XA_PERM_TYPE_SELECT is an element of enum XAPermType. Its value is "XA_PERM_TYPE_SELECT". + */ + public static final int XA_PERM_TYPE_SELECT = 10; + /** + * XA_PERM_TYPE_UPDATE is an element of enum XAPermType. Its value is "XA_PERM_TYPE_UPDATE". + */ + public static final int XA_PERM_TYPE_UPDATE = 11; + /** + * XA_PERM_TYPE_DROP is an element of enum XAPermType. Its value is "XA_PERM_TYPE_DROP". + */ + public static final int XA_PERM_TYPE_DROP = 12; + /** + * XA_PERM_TYPE_ALTER is an element of enum XAPermType. Its value is "XA_PERM_TYPE_ALTER". + */ + public static final int XA_PERM_TYPE_ALTER = 13; + /** + * XA_PERM_TYPE_INDEX is an element of enum XAPermType. Its value is "XA_PERM_TYPE_INDEX". + */ + public static final int XA_PERM_TYPE_INDEX = 14; + /** + * XA_PERM_TYPE_LOCK is an element of enum XAPermType. Its value is "XA_PERM_TYPE_LOCK". + */ + public static final int XA_PERM_TYPE_LOCK = 15; + /** + * XA_PERM_TYPE_ALL is an element of enum XAPermType. Its value is "XA_PERM_TYPE_ALL". + */ + public static final int XA_PERM_TYPE_ALL = 16; + + /** + * XA_PERM_TYPE_ALL is an element of enum XAPermType. Its value is "XA_PERM_TYPE_ALLOW". + */ + public static final int XA_PERM_TYPE_ALLOW = 17; + + /** + * Max value for enum XAPermType_MAX + */ + public static final int XAPermType_MAX = 17; + + + /*************************************************************** + * Enum values for ClassTypes + **************************************************************/ + /** + * CLASS_TYPE_NONE is an element of enum ClassTypes. Its value is "CLASS_TYPE_NONE". + */ + public static final int CLASS_TYPE_NONE = 0; + /** + * CLASS_TYPE_MESSAGE is an element of enum ClassTypes. Its value is "CLASS_TYPE_MESSAGE". + */ + public static final int CLASS_TYPE_MESSAGE = 1; + /** + * CLASS_TYPE_USER_PROFILE is an element of enum ClassTypes. Its value is "CLASS_TYPE_USER_PROFILE". + */ + public static final int CLASS_TYPE_USER_PROFILE = 2; + /** + * CLASS_TYPE_AUTH_SESS is an element of enum ClassTypes. Its value is "CLASS_TYPE_AUTH_SESS". + */ + public static final int CLASS_TYPE_AUTH_SESS = 3; + /** + * CLASS_TYPE_DATA_OBJECT is an element of enum ClassTypes. Its value is "CLASS_TYPE_DATA_OBJECT". + */ + public static final int CLASS_TYPE_DATA_OBJECT = 4; + /** + * CLASS_TYPE_NAMEVALUE is an element of enum ClassTypes. Its value is "CLASS_TYPE_NAMEVALUE". + */ + public static final int CLASS_TYPE_NAMEVALUE = 5; + /** + * CLASS_TYPE_LONG is an element of enum ClassTypes. Its value is "CLASS_TYPE_LONG". + */ + public static final int CLASS_TYPE_LONG = 6; + /** + * CLASS_TYPE_PASSWORD_CHANGE is an element of enum ClassTypes. Its value is "CLASS_TYPE_PASSWORD_CHANGE". + */ + public static final int CLASS_TYPE_PASSWORD_CHANGE = 7; + /** + * CLASS_TYPE_STRING is an element of enum ClassTypes. Its value is "CLASS_TYPE_STRING". + */ + public static final int CLASS_TYPE_STRING = 8; + /** + * CLASS_TYPE_ENUM is an element of enum ClassTypes. Its value is "CLASS_TYPE_ENUM". + */ + public static final int CLASS_TYPE_ENUM = 9; + /** + * CLASS_TYPE_ENUM_ELEMENT is an element of enum ClassTypes. Its value is "CLASS_TYPE_ENUM_ELEMENT". + */ + public static final int CLASS_TYPE_ENUM_ELEMENT = 10; + /** + * CLASS_TYPE_RESPONSE is an element of enum ClassTypes. Its value is "CLASS_TYPE_RESPONSE". + */ + public static final int CLASS_TYPE_RESPONSE = 11; + /** + * CLASS_TYPE_XA_ASSET is an element of enum ClassTypes. Its value is "CLASS_TYPE_XA_ASSET". + */ + public static final int CLASS_TYPE_XA_ASSET = 1000; + /** + * CLASS_TYPE_XA_RESOURCE is an element of enum ClassTypes. Its value is "CLASS_TYPE_XA_RESOURCE". + */ + public static final int CLASS_TYPE_XA_RESOURCE = 1001; + /** + * CLASS_TYPE_XA_GROUP is an element of enum ClassTypes. Its value is "CLASS_TYPE_XA_GROUP". + */ + public static final int CLASS_TYPE_XA_GROUP = 1002; + /** + * CLASS_TYPE_XA_USER is an element of enum ClassTypes. Its value is "CLASS_TYPE_XA_USER". + */ + public static final int CLASS_TYPE_XA_USER = 1003; + /** + * CLASS_TYPE_XA_GROUP_USER is an element of enum ClassTypes. Its value is "CLASS_TYPE_XA_GROUP_USER". + */ + public static final int CLASS_TYPE_XA_GROUP_USER = 1004; + /** + * CLASS_TYPE_XA_GROUP_GROUP is an element of enum ClassTypes. Its value is "CLASS_TYPE_XA_GROUP_GROUP". + */ + public static final int CLASS_TYPE_XA_GROUP_GROUP = 1005; + /** + * CLASS_TYPE_XA_PERM_MAP is an element of enum ClassTypes. Its value is "CLASS_TYPE_XA_PERM_MAP". + */ + public static final int CLASS_TYPE_XA_PERM_MAP = 1006; + /** + * CLASS_TYPE_XA_AUDIT_MAP is an element of enum ClassTypes. Its value is "CLASS_TYPE_XA_AUDIT_MAP". + */ + public static final int CLASS_TYPE_XA_AUDIT_MAP = 1007; + /** + * CLASS_TYPE_XA_CRED_STORE is an element of enum ClassTypes. Its value is "CLASS_TYPE_XA_CRED_STORE". + */ + public static final int CLASS_TYPE_XA_CRED_STORE = 1008; + /** + * CLASS_TYPE_XA_POLICY_EXPORT_AUDIT is an element of enum ClassTypes. Its value is "CLASS_TYPE_XA_POLICY_EXPORT_AUDIT". + */ + public static final int CLASS_TYPE_XA_POLICY_EXPORT_AUDIT = 1009; + /** + * CLASS_TYPE_TRX_LOG is an element of enum ClassTypes. Its value is "CLASS_TYPE_TRX_LOG". + */ + public static final int CLASS_TYPE_TRX_LOG = 1010; + /** + * CLASS_TYPE_XA_ACCESS_AUDIT is an element of enum ClassTypes. Its value is "CLASS_TYPE_XA_ACCESS_AUDIT". + */ + public static final int CLASS_TYPE_XA_ACCESS_AUDIT = 1011; + /** + * CLASS_TYPE_XA_TRANSACTION_LOG_ATTRIBUTE is an element of enum ClassTypes. Its value is "CLASS_TYPE_XA_TRANSACTION_LOG_ATTRIBUTE". + */ + public static final int CLASS_TYPE_XA_TRANSACTION_LOG_ATTRIBUTE = 1012; + + /** + * Max value for enum ClassTypes_MAX + */ + public static final int ClassTypes_MAX = 1012; + + + + static public String getLabelFor_ActiveStatus( int elementValue ) { + if( elementValue == 0 ) { + return "Disabled"; //STATUS_DISABLED + } + if( elementValue == 1 ) { + return "Enabled"; //STATUS_ENABLED + } + if( elementValue == 2 ) { + return "Deleted"; //STATUS_DELETED + } + return null; + } + + static public String getLabelFor_ActivationStatus( int elementValue ) { + if( elementValue == 0 ) { + return "Disabled"; //ACT_STATUS_DISABLED + } + if( elementValue == 1 ) { + return "Active"; //ACT_STATUS_ACTIVE + } + if( elementValue == 2 ) { + return "Pending Approval"; //ACT_STATUS_PENDING_APPROVAL + } + if( elementValue == 3 ) { + return "Pending Activation"; //ACT_STATUS_PENDING_ACTIVATION + } + if( elementValue == 4 ) { + return "Rejected"; //ACT_STATUS_REJECTED + } + if( elementValue == 5 ) { + return "Deactivated"; //ACT_STATUS_DEACTIVATED + } + if( elementValue == 6 ) { + return "Registration Pending"; //ACT_STATUS_PRE_REGISTRATION + } + if( elementValue == 7 ) { + return "No login privilege"; //ACT_STATUS_NO_LOGIN + } + return null; + } + + static public String getLabelFor_BooleanValue( int elementValue ) { + if( elementValue == 0 ) { + return "None"; //BOOL_NONE + } + if( elementValue == 1 ) { + return "True"; //BOOL_TRUE + } + if( elementValue == 2 ) { + return "False"; //BOOL_FALSE + } + return null; + } + + static public String getLabelFor_DataType( int elementValue ) { + if( elementValue == 0 ) { + return "Unknown"; //DATA_TYPE_UNKNOWN + } + if( elementValue == 1 ) { + return "Integer"; //DATA_TYPE_INTEGER + } + if( elementValue == 2 ) { + return "Double"; //DATA_TYPE_DOUBLE + } + if( elementValue == 3 ) { + return "String"; //DATA_TYPE_STRING + } + if( elementValue == 4 ) { + return "Boolean"; //DATA_TYPE_BOOLEAN + } + if( elementValue == 5 ) { + return "Date"; //DATA_TYPE_DATE + } + if( elementValue == 6 ) { + return "String enumeration"; //DATA_TYPE_STRING_ENUM + } + if( elementValue == 7 ) { + return "Long"; //DATA_TYPE_LONG + } + if( elementValue == 8 ) { + return "Integer enumeration"; //DATA_TYPE_INTEGER_ENUM + } + return null; + } + + static public String getLabelFor_DeviceType( int elementValue ) { + if( elementValue == 0 ) { + return "Unknown"; //DEVICE_UNKNOWN + } + if( elementValue == 1 ) { + return "Browser"; //DEVICE_BROWSER + } + if( elementValue == 2 ) { + return "iPhone"; //DEVICE_IPHONE + } + if( elementValue == 3 ) { + return "iPad"; //DEVICE_IPAD + } + if( elementValue == 4 ) { + return "iPod"; //DEVICE_IPOD + } + if( elementValue == 5 ) { + return "Android"; //DEVICE_ANDROID + } + return null; + } + + static public String getLabelFor_DiffLevel( int elementValue ) { + if( elementValue == 0 ) { + return "Unknown"; //DIFF_UNKNOWN + } + if( elementValue == 1 ) { + return "Low"; //DIFF_LOW + } + if( elementValue == 2 ) { + return "Medium"; //DIFF_MEDIUM + } + if( elementValue == 3 ) { + return "High"; //DIFF_HIGH + } + return null; + } + + static public String getLabelFor_FileType( int elementValue ) { + if( elementValue == 0 ) { + return "File"; //FILE_FILE + } + if( elementValue == 1 ) { + return "Directory"; //FILE_DIR + } + return null; + } + + static public String getLabelFor_FreqType( int elementValue ) { + if( elementValue == 0 ) { + return "None"; //FREQ_NONE + } + if( elementValue == 1 ) { + return "Manual"; //FREQ_MANUAL + } + if( elementValue == 2 ) { + return "Hourly"; //FREQ_HOURLY + } + if( elementValue == 3 ) { + return "Daily"; //FREQ_DAILY + } + if( elementValue == 4 ) { + return "Weekly"; //FREQ_WEEKLY + } + if( elementValue == 5 ) { + return "Bi Weekly"; //FREQ_BI_WEEKLY + } + if( elementValue == 6 ) { + return "Monthly"; //FREQ_MONTHLY + } + return null; + } + + static public String getLabelFor_MimeType( int elementValue ) { + if( elementValue == 0 ) { + return "Unknown"; //MIME_UNKNOWN + } + if( elementValue == 1 ) { + return "Text"; //MIME_TEXT + } + if( elementValue == 2 ) { + return "Html"; //MIME_HTML + } + if( elementValue == 3 ) { + return "png"; //MIME_PNG + } + if( elementValue == 4 ) { + return "jpeg"; //MIME_JPEG + } + return null; + } + + static public String getLabelFor_NumberFormat( int elementValue ) { + if( elementValue == 0 ) { + return "None"; //NUM_FORMAT_NONE + } + if( elementValue == 1 ) { + return "Numeric"; //NUM_FORMAT_NUMERIC + } + if( elementValue == 2 ) { + return "Alphabhet"; //NUM_FORMAT_ALPHA + } + if( elementValue == 3 ) { + return "Roman"; //NUM_FORMAT_ROMAN + } + return null; + } + + static public String getLabelFor_ObjectStatus( int elementValue ) { + if( elementValue == 0 ) { + return "Active"; //OBJ_STATUS_ACTIVE + } + if( elementValue == 1 ) { + return "Deleted"; //OBJ_STATUS_DELETED + } + if( elementValue == 2 ) { + return "Archived"; //OBJ_STATUS_ARCHIVED + } + return null; + } + + static public String getLabelFor_PasswordResetStatus( int elementValue ) { + if( elementValue == 0 ) { + return "Active"; //PWD_RESET_ACTIVE + } + if( elementValue == 1 ) { + return "Used"; //PWD_RESET_USED + } + if( elementValue == 2 ) { + return "Expired"; //PWD_RESET_EXPIRED + } + if( elementValue == 3 ) { + return "Disabled"; //PWD_RESET_DISABLED + } + return null; + } + + static public String getLabelFor_PriorityType( int elementValue ) { + if( elementValue == 0 ) { + return "Normal"; //PRIORITY_NORMAL + } + if( elementValue == 1 ) { + return "Low"; //PRIORITY_LOW + } + if( elementValue == 2 ) { + return "Medium"; //PRIORITY_MEDIUM + } + if( elementValue == 3 ) { + return "High"; //PRIORITY_HIGH + } + return null; + } + + static public String getLabelFor_ProgressStatus( int elementValue ) { + if( elementValue == 0 ) { + return "Pending"; //PROGRESS_PENDING + } + if( elementValue == 1 ) { + return "In Progress"; //PROGRESS_IN_PROGRESS + } + if( elementValue == 2 ) { + return "Complete"; //PROGRESS_COMPLETE + } + if( elementValue == 3 ) { + return "Aborted"; //PROGRESS_ABORTED + } + if( elementValue == 4 ) { + return "Failed"; //PROGRESS_FAILED + } + return null; + } + + static public String getLabelFor_RelationType( int elementValue ) { + if( elementValue == 0 ) { + return "None"; //REL_NONE + } + if( elementValue == 1 ) { + return "Self"; //REL_SELF + } + return null; + } + + static public String getLabelFor_UserSource( int elementValue ) { + if( elementValue == 0 ) { + return "Application"; //USER_APP + } + if( elementValue == 1 ) { + return "External"; //USER_EXTERNAL + } + /*if( elementValue == 1 ) { + return "Google"; //USER_GOOGLE + } + if( elementValue == 2 ) { + return "FaceBook"; //USER_FB + }*/ + return null; + } + + static public String getLabelFor_AssetType( int elementValue ) { + if( elementValue == 0 ) { + return "Unknown"; //ASSET_UNKNOWN + } + if( elementValue == 1 ) { + return "HDFS"; //ASSET_HDFS + } + if( elementValue == 2 ) { + return "HBase"; //ASSET_HBASE + } + if( elementValue == 3 ) { + return "Hive"; //ASSET_HIVE + } + if( elementValue == 4 ) { + return "Agent"; //ASSET_HIVE + } + if( elementValue == 5 ) { + return "Knox"; //ASSET_HIVE + } + if( elementValue == 6 ) { + return "Storm"; //ASSET_HIVE + } + return null; + } + + static public String getLabelFor_AccessResult( int elementValue ) { + if( elementValue == 0 ) { + return "Denied"; //ACCESS_RESULT_DENIED + } + if( elementValue == 1 ) { + return "Allowed"; //ACCESS_RESULT_ALLOWED + } + return null; + } + + static public String getLabelFor_PolicyType( int elementValue ) { + if( elementValue == 0 ) { + return "Inclusion"; //POLICY_INCLUSION + } + if( elementValue == 1 ) { + return "Exclusion"; //POLICY_EXCLUSION + } + return null; + } + + static public String getLabelFor_XAAuditType( int elementValue ) { + if( elementValue == 0 ) { + return "Unknown"; //XA_AUDIT_TYPE_UNKNOWN + } + if( elementValue == 1 ) { + return "All"; //XA_AUDIT_TYPE_ALL + } + if( elementValue == 2 ) { + return "Read"; //XA_AUDIT_TYPE_READ + } + if( elementValue == 3 ) { + return "Write"; //XA_AUDIT_TYPE_WRITE + } + if( elementValue == 4 ) { + return "Create"; //XA_AUDIT_TYPE_CREATE + } + if( elementValue == 5 ) { + return "Delete"; //XA_AUDIT_TYPE_DELETE + } + if( elementValue == 6 ) { + return "Login"; //XA_AUDIT_TYPE_LOGIN + } + return null; + } + + static public String getLabelFor_ResourceType( int elementValue ) { + if( elementValue == 0 ) { + return "Unknown"; //RESOURCE_UNKNOWN + } + if( elementValue == 1 ) { + return "Path"; //RESOURCE_PATH + } + if( elementValue == 2 ) { + return "Database"; //RESOURCE_DB + } + if( elementValue == 3 ) { + return "Table"; //RESOURCE_TABLE + } + if( elementValue == 4 ) { + return "Column Family"; //RESOURCE_COL_FAM + } + if( elementValue == 5 ) { + return "Column"; //RESOURCE_COLUMN + } + if( elementValue == 6 ) { + return "VIEW"; //RESOURCE_VIEW + } + if( elementValue == 7 ) { + return "UDF"; //RESOURCE_UDF + } + if( elementValue == 8 ) { + return "View Column"; //RESOURCE_VIEW_COL + } + return null; + } + + static public String getLabelFor_XAGroupType( int elementValue ) { + if( elementValue == 0 ) { + return "Unknown"; //XA_GROUP_UNKNOWN + } + if( elementValue == 1 ) { + return "User"; //XA_GROUP_USER + } + if( elementValue == 2 ) { + return "Group"; //XA_GROUP_GROUP + } + if( elementValue == 3 ) { + return "Role"; //XA_GROUP_ROLE + } + return null; + } + + static public String getLabelFor_XAPermForType( int elementValue ) { + if( elementValue == 0 ) { + return "Unknown"; //XA_PERM_FOR_UNKNOWN + } + if( elementValue == 1 ) { + return "Permission for Users"; //XA_PERM_FOR_USER + } + if( elementValue == 2 ) { + return "Permission for Groups"; //XA_PERM_FOR_GROUP + } + return null; + } + + static public String getLabelFor_XAPermType( int elementValue ) { + if( elementValue == 0 ) { + return "Unknown"; //XA_PERM_TYPE_UNKNOWN + } + if( elementValue == 1 ) { + return "Reset"; //XA_PERM_TYPE_RESET + } + if( elementValue == 2 ) { + return "Read"; //XA_PERM_TYPE_READ + } + if( elementValue == 3 ) { + return "Write"; //XA_PERM_TYPE_WRITE + } + if( elementValue == 4 ) { + return "Create"; //XA_PERM_TYPE_CREATE + } + if( elementValue == 5 ) { + return "Delete"; //XA_PERM_TYPE_DELETE + } + if( elementValue == 6 ) { + return "Admin"; //XA_PERM_TYPE_ADMIN + } + if( elementValue == 7 ) { + return "Obfuscate"; //XA_PERM_TYPE_OBFUSCATE + } + if( elementValue == 8 ) { + return "Mask"; //XA_PERM_TYPE_MASK + } + if( elementValue == 9 ) { + return "Execute"; //XA_PERM_TYPE_EXECUTE + } + if( elementValue == 10 ) { + return "Select"; //XA_PERM_TYPE_SELECT + } + if( elementValue == 11 ) { + return "Update"; //XA_PERM_TYPE_UPDATE + } + if( elementValue == 12 ) { + return "Drop"; //XA_PERM_TYPE_DROP + } + if( elementValue == 13 ) { + return "Alter"; //XA_PERM_TYPE_ALTER + } + if( elementValue == 14 ) { + return "Index"; //XA_PERM_TYPE_INDEX + } + if( elementValue == 15 ) { + return "Lock"; //XA_PERM_TYPE_LOCK + } + if( elementValue == 16 ) { + return "All"; //XA_PERM_TYPE_ALL + } + if( elementValue == 17 ) { + return "Allow"; //XA_PERM_TYPE_ALLOW + } + return null; + } + + static public String getLabelFor_ClassTypes( int elementValue ) { + if( elementValue == 0 ) { + return "None"; //CLASS_TYPE_NONE + } + if( elementValue == 1 ) { + return "Message"; //CLASS_TYPE_MESSAGE + } + if( elementValue == 2 ) { + return "User Profile"; //CLASS_TYPE_USER_PROFILE + } + if( elementValue == 3 ) { + return "Authentication Session"; //CLASS_TYPE_AUTH_SESS + } + if( elementValue == 4 ) { + return null; //CLASS_TYPE_DATA_OBJECT + } + if( elementValue == 5 ) { + return null; //CLASS_TYPE_NAMEVALUE + } + if( elementValue == 6 ) { + return null; //CLASS_TYPE_LONG + } + if( elementValue == 7 ) { + return null; //CLASS_TYPE_PASSWORD_CHANGE + } + if( elementValue == 8 ) { + return null; //CLASS_TYPE_STRING + } + if( elementValue == 9 ) { + return null; //CLASS_TYPE_ENUM + } + if( elementValue == 10 ) { + return null; //CLASS_TYPE_ENUM_ELEMENT + } + if( elementValue == 11 ) { + return "Response"; //CLASS_TYPE_RESPONSE + } + if( elementValue == 1000 ) { + return "Asset"; //CLASS_TYPE_XA_ASSET + } + if( elementValue == 1001 ) { + return "Resource"; //CLASS_TYPE_XA_RESOURCE + } + if( elementValue == 1002 ) { + return "XA Group"; //CLASS_TYPE_XA_GROUP + } + if( elementValue == 1003 ) { + return "XA User"; //CLASS_TYPE_XA_USER + } + if( elementValue == 1004 ) { + return "XA Group of Users"; //CLASS_TYPE_XA_GROUP_USER + } + if( elementValue == 1005 ) { + return "XA Group of groups"; //CLASS_TYPE_XA_GROUP_GROUP + } + if( elementValue == 1006 ) { + return "XA permissions for resource"; //CLASS_TYPE_XA_PERM_MAP + } + if( elementValue == 1007 ) { + return "XA audits for resource"; //CLASS_TYPE_XA_AUDIT_MAP + } + if( elementValue == 1008 ) { + return "XA credential store"; //CLASS_TYPE_XA_CRED_STORE + } + if( elementValue == 1009 ) { + return "XA Policy Export Audit"; //CLASS_TYPE_XA_POLICY_EXPORT_AUDIT + } + if( elementValue == 1010 ) { + return "Transaction log"; //CLASS_TYPE_TRX_LOG + } + if( elementValue == 1011 ) { + return "Access Audit"; //CLASS_TYPE_XA_ACCESS_AUDIT + } + if( elementValue == 1012 ) { + return "Transaction log attribute"; //CLASS_TYPE_XA_TRANSACTION_LOG_ATTRIBUTE + } + return null; + } + + +} +
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/413fcb68/security-admin/src/main/java/org/apache/ranger/common/XAConfigUtil.java ---------------------------------------------------------------------- diff --git a/security-admin/src/main/java/org/apache/ranger/common/XAConfigUtil.java b/security-admin/src/main/java/org/apache/ranger/common/XAConfigUtil.java new file mode 100644 index 0000000..e50fb20 --- /dev/null +++ b/security-admin/src/main/java/org/apache/ranger/common/XAConfigUtil.java @@ -0,0 +1,91 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.ranger.common; + +import org.apache.log4j.Logger; +import org.apache.ranger.common.PropertiesUtil; +import org.springframework.stereotype.Component; + +/** + * + * + */ +@Component +public class XAConfigUtil { + static Logger logger = Logger.getLogger(XAConfigUtil.class); + + String webappRootURL; + int defaultMaxRows = 250; + String[] roles; + boolean accessFilterEnabled = true; + boolean isModerationEnabled = false; + boolean isUserPrefEnabled = false; + + public XAConfigUtil() { + webappRootURL = PropertiesUtil + .getProperty("xa.webapp.url.root"); + if (webappRootURL == null || webappRootURL.trim().length() == 0) { + logger.error("webapp URL is not set. Please xa.webapp.url.root property"); + } + + defaultMaxRows = PropertiesUtil.getIntProperty( + "xa.db.maxrows.default", defaultMaxRows); + + roles = PropertiesUtil + .getPropertyStringList("xa.users.roles.list"); + + accessFilterEnabled = PropertiesUtil.getBooleanProperty( + "xa.db.access.filter.enable", true); + + isModerationEnabled = PropertiesUtil.getBooleanProperty( + "xa.moderation.enabled", isModerationEnabled); + isUserPrefEnabled = PropertiesUtil.getBooleanProperty( + "xa.userpref.enabled", isUserPrefEnabled); + } + + /** + * @return the defaultMaxRows + */ + public int getDefaultMaxRows() { + return defaultMaxRows; + } + + /** + * @return the roles + */ + public String[] getRoles() { + return roles; + } + + /** + * @return the accessFilterEnabled + */ + public boolean isAccessFilterEnabled() { + return accessFilterEnabled; + } + + /** + * @return the webAppRootURL + */ + public String getWebAppRootURL() { + return webappRootURL; + } + +} http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/413fcb68/security-admin/src/main/java/org/apache/ranger/common/XAConstants.java ---------------------------------------------------------------------- diff --git a/security-admin/src/main/java/org/apache/ranger/common/XAConstants.java b/security-admin/src/main/java/org/apache/ranger/common/XAConstants.java new file mode 100644 index 0000000..5dbebb8 --- /dev/null +++ b/security-admin/src/main/java/org/apache/ranger/common/XAConstants.java @@ -0,0 +1,169 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.ranger.common; + +public class XAConstants extends XACommonEnums { + + // Default Roles + public final static String ROLE_SYS_ADMIN = "ROLE_SYS_ADMIN"; + public final static String ROLE_ADMIN = "ROLE_ADMIN"; + public final static String ROLE_INTEGRATOR = "ROLE_INTEGRATOR"; + public final static String ROLE_DATA_ANALYST = "ROLE_DATA_ANALYST"; + public final static String ROLE_BIZ_MGR = "ROLE_BIZ_MGR"; + + public final static String ROLE_USER = "ROLE_USER"; + public final static String ROLE_ANON = "ROLE_ANON"; + public final static String ROLE_OTHER = "ROLE_OTHER"; + public final static String GROUP_PUBLIC = "public"; + // Action constants + public final static String ACTION_EDIT = "edit"; + public final static String ACTION_CHANGE = "change"; + public final static String ACTION_DELETE = "delete"; + public final static String ACTION_MARK_SPAM = "mark_spam"; + public final static String ACTION_RATE = "rate"; + public final static String ACTION_SELECT = "select"; + public final static String ACTION_UNSELECT = "unselect"; + public final static String ACTION_HIDE = "hide"; + public final static String ACTION_UNHIDE = "unhide"; + public final static String ACTION_SHARE = "share"; + public final static String ACTION_UNSHARE = "unshare"; + public final static String ACTION_BOOKMARK = "bookmark"; + public final static String ACTION_UNBOOKMARK = "unbookmark"; + + // Sendgrid email API constants + public static final String SENDGRID_API_USER = "api_user"; + public static final String SENDGRID_API_KEY = "api_key"; + public static final String SENDGRID_TO = "to"; + public static final String SENDGRID_TO_NAME = "toname"; + public static final String SENDGRID_SUBJECT = "subject"; + public static final String SENDGRID_TEXT = "text"; + public static final String SENDGRID_HTML = "html"; + public static final String SENDGRID_FROM_EMAIL = "from"; + public static final String SENDGRID_FROM_NAME = "fromname"; + public static final String SENDGRID_BCC = "bcc"; + public static final String SENDGRID_CC = "cc"; + public static final String SENDGRID_REPLY_TO = "replyto"; + + // User create validation errors + public enum ValidationUserProfile { + + NO_EMAIL_ADDR("xa.validation.userprofile.no_email_addr", + "Email address not provided"), INVALID_EMAIL_ADDR( + "xa.validation.userprofile.userprofile.invalid_email_addr", + "Invalid email address"), NO_FIRST_NAME( + "xa.validation.userprofile.userprofile.no_first_name", + "First name not provided"), INVALID_FIRST_NAME( + "xa.validation.userprofile.invalid_first_name", + "Invalid first name"), NO_LAST_NAME( + "xa.validation.userprofile.noemailaddr", + "Email address not provided"), INVALID_LAST_NAME( + "xa.validation.userprofile.noemailaddr", + "Email address not provided"), NO_PUBLIC_SCREEN_NAME( + "xa.validation.userprofile.noemailaddr", + "Email address not provided"), INVALID_PUBLIC_SCREEN_NAME( + "xa.validation.userprofile.noemailaddr", + "Email address not provided"); + + String rbKey; + String message; + + ValidationUserProfile(String rbKey, String message) { + this.rbKey = rbKey; + this.message = message; + } + }; + + // these constants will be used in setting GjResponse object. + + public final static String USER_PENDING_APPROVAL_MSG = "User is yet not reviewed by Administrator. Please contact at <number>."; + public final static int USER_PENDING_APPROVAL_STATUS_CODE = 0; + + public final static String USER_APPROVAL_MSG = "User is approved"; + public final static int USER_APPROVAL_STATUS_CODE = 1; + + public final static String USER_REJECTION_MSG = "User is rejected"; + public final static int USER_REJECTION_STATUS_CODE = 1; + + public final static String USER_STATUS_ALREADY_CHANGED_MSG = "Can not change user status. it is either already activated/approved/rejected"; + public final static int USER_STATUS_ALREADY_CHANGED_STATUS_CODE = 0; + + public final static String USER_ALREADY_ACTIVATED_MSG = "Your account is already activated. If you have forgotten your password, then from the login page, select 'Forgot Password'"; + public final static int USER_ALREADY_ACTIVATED_STATUS_CODE = 0; + + public final static String USER_STATUS_NOT_ACTIVE_MSG = "User is not in active status. Please activate your account first."; + public final static int USER_STATUS_NOT_ACTIVE_STATUS_CODE = 0; + + public final static String INVALID_EMAIL_ADDRESS_MSG = "Invalid email address"; + public final static int INVALID_EMAIL_ADDRESS_STATUS_CODE = 0; + + public final static String WRONG_ACTIVATION_CODE_MSG = "Wrong activation code"; + public final static int WRONG_ACTIVATION_CODE_STATUS_CODE = 0; + + public final static String VALID_EMAIL_ADDRESS_MSG = "Valid email address"; + public final static int VALID_EMAIL_ADDRESS_STATUS_CODE = 1; + + public final static String NO_ACTIVATION_RECORD_FOR_USER_ERR_MSG = "No activation record found for user:"; + public final static String NO_ACTIVATION_ENTRY = "activation entry not found"; + + public final static String VALIDATION_INVALID_DATA_DESC = "Invalid value for"; + public final static int VALIDATION_INVALID_DATA_CODE = 0; + public static final String GROUP_MODERATORS = "GROUP_MODERATORS"; + + // public final static String EMAIL_WELCOME_MSG = + // "Welcome to iSchoolCircle"; + // public final static String EMAIL_LINK_WELCOME_MSG = + // "Welcome to iSchoolCircle ! Please verify your account by clicking on the link below: "; + // public static final String EMAIL_EDIT_REJECTED_MSG = + // "Your changes not approved for public sharing."; + // public static final String EMAIL_APPROVAL_NEEDED_MSG = + // "New objects pending approval"; + // public static final String EMAIL_PWD_RESET_CODE_MSG = + // "iSchoolCircle - Password Reset"; + + public final static String PWD_RESET_FAILED_MSG = "Invalid password reset request"; + + public final static String INVALID_NEW_PASSWORD_MSG = "Invalid new password"; + public static final String EMAIL_NEW_FEEDBACK_RECEIVED = "New feedback from"; + public static final int INITIAL_DOCUMENT_VERSION = 1; + + public static final int EMAIL_TYPE_ACCOUNT_CREATE = 0; + public static final int EMAIL_TYPE_USER_CREATE = 1; + public static final int EMAIL_TYPE_USER_ACCT_ADD = 2; + public static final int EMAIL_TYPE_DOCUMENT_CREATE = 3; + public static final int EMAIL_TYPE_DISCUSSION_CREATE = 4; + public static final int EMAIL_TYPE_NOTE_CREATE = 5; + public static final int EMAIL_TYPE_TASK_CREATE = 6; + public static final int EMAIL_TYPE_USER_PASSWORD = 7; + public static final int EMAIL_TYPE_USER_ACTIVATION = 8; + public static final int EMAIL_TYPE_USER_ROLE_UPDATED = 9; + public static final int EMAIL_TYPE_USER_GRP_ADD = 10; + + public static enum RBAC_PERM { + ALLOW_NONE, + ALLOW_READ, + ALLOW_WRITE, + ALLOW_DELETE + } + +} http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/413fcb68/security-admin/src/main/java/org/apache/ranger/common/XAJAXBContextResolver.java ---------------------------------------------------------------------- diff --git a/security-admin/src/main/java/org/apache/ranger/common/XAJAXBContextResolver.java b/security-admin/src/main/java/org/apache/ranger/common/XAJAXBContextResolver.java new file mode 100644 index 0000000..87a7924 --- /dev/null +++ b/security-admin/src/main/java/org/apache/ranger/common/XAJAXBContextResolver.java @@ -0,0 +1,73 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.ranger.common; + +import javax.ws.rs.ext.ContextResolver; +import javax.ws.rs.ext.Provider; +import javax.xml.bind.JAXBContext; + +import org.apache.ranger.common.*; + +import com.sun.jersey.api.json.JSONConfiguration; +import com.sun.jersey.api.json.JSONJAXBContext; + +/** + * + * + */ +@Provider +public class XAJAXBContextResolver implements ContextResolver<JAXBContext> { + + private JAXBContext context; + private Class<?>[] types = { + org.apache.ranger.view.VXAuthSessionList.class, + org.apache.ranger.view.VXResponse.class, + org.apache.ranger.view.VXStringList.class, + org.apache.ranger.view.VXPortalUserList.class, + org.apache.ranger.view.VXAssetList.class, + org.apache.ranger.view.VXResourceList.class, + org.apache.ranger.view.VXCredentialStoreList.class, + org.apache.ranger.view.VXGroupList.class, + org.apache.ranger.view.VXUserList.class, + org.apache.ranger.view.VXGroupUserList.class, + org.apache.ranger.view.VXGroupGroupList.class, + org.apache.ranger.view.VXPermMapList.class, + org.apache.ranger.view.VXAuditMapList.class, + org.apache.ranger.view.VXPolicyExportAuditList.class, + org.apache.ranger.view.VXAccessAuditList.class + }; + + public XAJAXBContextResolver() throws Exception { + JSONConfiguration config = JSONConfiguration.natural().build(); + context = new JSONJAXBContext(config, types); + } + + @Override + public JAXBContext getContext(Class<?> objectType) { + // return context; + for (Class<?> type : types) { + if (type.getName().equals(objectType.getName())) { + return context; + } + } + return null; + } +} + http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/413fcb68/security-admin/src/main/java/org/apache/ranger/common/XASearchUtil.java ---------------------------------------------------------------------- diff --git a/security-admin/src/main/java/org/apache/ranger/common/XASearchUtil.java b/security-admin/src/main/java/org/apache/ranger/common/XASearchUtil.java new file mode 100644 index 0000000..ff1f1a4 --- /dev/null +++ b/security-admin/src/main/java/org/apache/ranger/common/XASearchUtil.java @@ -0,0 +1,78 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.ranger.common; + +import java.util.List; + +import javax.persistence.EntityManager; +import javax.persistence.Query; + +import org.apache.log4j.Logger; +import org.apache.ranger.common.SearchCriteria; +import org.apache.ranger.common.SearchField; +import org.apache.ranger.common.SearchUtil; +import org.apache.ranger.db.XADaoManager; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +@Component +public class XASearchUtil extends SearchUtil { + final static Logger logger = Logger.getLogger(XASearchUtil.class); + /* + @Override + public Query createSearchQuery(EntityManager em, String queryStr, String sortClause, + SearchCriteria searchCriteria, List<SearchField> searchFields, + int objectClassType, boolean hasAttributes, boolean isCountQuery){ + + // [1] Build where clause + StringBuilder queryClause = buildWhereClause(searchCriteria, + searchFields); + + // [2] Add domain-object-security clause if needed + // if (objectClassType != -1 + // && !ContextUtil.getCurrentUserSession().isUserAdmin()) { + // addDomainObjectSecuirtyClause(queryClause, hasAttributes); + // } + + // [2] Add order by clause + addOrderByClause(queryClause, sortClause); + + // [3] Create Query Object + Query query = em.createQuery( + queryStr + queryClause); + + // [4] Resolve query parameters with values + resolveQueryParams(query, searchCriteria, searchFields); + + // [5] Resolve domain-object-security parameters + // if (objectClassType != -1 && + // !securityHandler.hasModeratorPermission()) { + // resolveDomainObjectSecuirtyParams(query, objectClassType); + // } + + if (!isCountQuery) { + query.setFirstResult(searchCriteria.getStartIndex()); + updateQueryPageSize(query, searchCriteria); + } + + return query; + } + */ +} http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/413fcb68/security-admin/src/main/java/org/apache/ranger/common/annotation/XAAnnotationClassName.java ---------------------------------------------------------------------- diff --git a/security-admin/src/main/java/org/apache/ranger/common/annotation/XAAnnotationClassName.java b/security-admin/src/main/java/org/apache/ranger/common/annotation/XAAnnotationClassName.java new file mode 100644 index 0000000..dcc357d --- /dev/null +++ b/security-admin/src/main/java/org/apache/ranger/common/annotation/XAAnnotationClassName.java @@ -0,0 +1,32 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.ranger.common.annotation; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + + +@Retention(RetentionPolicy.RUNTIME) +public @interface XAAnnotationClassName { + public Class class_name(); +} http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/413fcb68/security-admin/src/main/java/org/apache/ranger/common/annotation/XAAnnotationJSMgrName.java ---------------------------------------------------------------------- diff --git a/security-admin/src/main/java/org/apache/ranger/common/annotation/XAAnnotationJSMgrName.java b/security-admin/src/main/java/org/apache/ranger/common/annotation/XAAnnotationJSMgrName.java new file mode 100644 index 0000000..cf21848 --- /dev/null +++ b/security-admin/src/main/java/org/apache/ranger/common/annotation/XAAnnotationJSMgrName.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.ranger.common.annotation; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +/** + * + * + */ +@Retention(RetentionPolicy.RUNTIME) +public @interface XAAnnotationJSMgrName { + public String value(); +} http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/413fcb68/security-admin/src/main/java/org/apache/ranger/common/annotation/XAAnnotationRestAPI.java ---------------------------------------------------------------------- diff --git a/security-admin/src/main/java/org/apache/ranger/common/annotation/XAAnnotationRestAPI.java b/security-admin/src/main/java/org/apache/ranger/common/annotation/XAAnnotationRestAPI.java new file mode 100644 index 0000000..3dc62bb --- /dev/null +++ b/security-admin/src/main/java/org/apache/ranger/common/annotation/XAAnnotationRestAPI.java @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.ranger.common.annotation; + +import java.lang.annotation.*; + +/** + * Annotating the REST APIs + * + */ +@Retention(RetentionPolicy.RUNTIME) +public @interface XAAnnotationRestAPI { + public String api_name() default ""; + public boolean updates_generic_objects() default false; + public String updates_classes() default ""; +} http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/413fcb68/security-admin/src/main/java/org/apache/ranger/common/db/BaseDao.java ---------------------------------------------------------------------- diff --git a/security-admin/src/main/java/org/apache/ranger/common/db/BaseDao.java b/security-admin/src/main/java/org/apache/ranger/common/db/BaseDao.java new file mode 100644 index 0000000..bebe956 --- /dev/null +++ b/security-admin/src/main/java/org/apache/ranger/common/db/BaseDao.java @@ -0,0 +1,215 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.ranger.common.db; + + + +import java.lang.reflect.ParameterizedType; +import java.lang.reflect.Type; +import java.util.ArrayList; +import java.util.List; + +import javax.persistence.EntityManager; +import javax.persistence.NoResultException; +import javax.persistence.Query; +import javax.persistence.TypedQuery; + +import org.apache.log4j.Logger; +import org.apache.ranger.common.ContextUtil; +import org.apache.ranger.db.XADaoManager; +import org.apache.ranger.db.XADaoManagerBase; +import org.apache.ranger.entity.XXDBBase; + +public abstract class BaseDao<T> { + static final Logger logger = Logger.getLogger(BaseDao.class); + + protected XADaoManager daoManager; + + EntityManager em; + + protected Class<T> tClass; + + public BaseDao(XADaoManagerBase daoManager) { + this.daoManager = (XADaoManager) daoManager; + this.init(daoManager.getEntityManager()); + } + + public BaseDao(XADaoManagerBase daoManager, String persistenceContextUnit) { + this.daoManager = (XADaoManager) daoManager; + + EntityManager em = this.daoManager.getEntityManager(persistenceContextUnit); + + this.init(em); + } + + @SuppressWarnings("unchecked") + private void init(EntityManager em) { + this.em = em; + + ParameterizedType genericSuperclass = (ParameterizedType) getClass() + .getGenericSuperclass(); + + Type type = genericSuperclass.getActualTypeArguments()[0]; + + if (type instanceof ParameterizedType) { + this.tClass = (Class<T>) ((ParameterizedType) type).getRawType(); + } else { + this.tClass = (Class<T>) type; + } + } + + public EntityManager getEntityManager() { + return this.em; + } + + public T create(T obj) { + T ret = null; + + em.persist(obj); + em.flush(); + + ret = obj; + return ret; + } + + public T update(T obj) { + em.merge(obj); + em.flush(); + return obj; + } + + public boolean remove(Long id) { + return remove(getById(id)); + } + + public boolean remove(T obj) { + if (obj == null) { + return true; + } + + em.remove(obj); + em.flush(); + + return true; + } + + public T getById(Long id) { + if (id == null) { + return null; + } + T ret = null; + try { + ret = em.find(tClass, id); + } catch (NoResultException e) { + return null; + } + return ret; + } + + public List<T> findByNamedQuery(String namedQuery, String paramName, + Object refId) { + List<T> ret = new ArrayList<T>(); + + if (namedQuery == null) { + return ret; + } + try { + TypedQuery<T> qry = em.createNamedQuery(namedQuery, tClass); + qry.setParameter(paramName, refId); + ret = qry.getResultList(); + } catch (NoResultException e) { + // ignore + } + return ret; + } + + public List<T> findByParentId(Long parentId) { + String namedQuery = tClass.getSimpleName() + ".findByParentId"; + return findByNamedQuery(namedQuery, "parentId", parentId); + } + + + public List<T> executeQueryInSecurityContext(Class<T> clazz, Query query) { + return executeQueryInSecurityContext(clazz, query, true); + } + + @SuppressWarnings("unchecked") + public List<T> executeQueryInSecurityContext(Class<T> clazz, Query query, + boolean userPrefFilter) { + // boolean filterEnabled = false; + List<T> rtrnList = null; + try { + // filterEnabled = enableVisiblityFilters(clazz, userPrefFilter); + + rtrnList = query.getResultList(); + } finally { + // if (filterEnabled) { + // disableVisiblityFilters(clazz); + // } + + } + + return rtrnList; + } + + /** + * @param clazz + * @param query + * @param b + * @return + */ + private Long executeCountQueryInSecurityContext(Class<T> clazz, + Query query, boolean userPrefFilter) { + // boolean filterEnabled = false; + Long rtrnObj = null; + try { + // filterEnabled = enableVisiblityFilters(clazz, userPrefFilter); + rtrnObj = (Long) query.getSingleResult(); + } finally { + // if (filterEnabled) { + // disableVisiblityFilters(clazz); + // } + } + + return rtrnObj; + } + + public Long executeCountQueryInSecurityContext(Class<T> clazz, Query query) { + return executeCountQueryInSecurityContext(clazz, query, true); + } + + public List<T> getAll() { + List<T> ret = null; + TypedQuery<T> qry = em.createQuery( + "SELECT t FROM " + tClass.getSimpleName() + " t", tClass); + ret = qry.getResultList(); + return ret; + } + + public Long getAllCount() { + Long ret = null; + TypedQuery<Long> qry = em.createQuery( + "SELECT count(t) FROM " + tClass.getSimpleName() + " t", + Long.class); + ret = qry.getSingleResult(); + return ret; + } + +} http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/413fcb68/security-admin/src/main/java/org/apache/ranger/common/db/JPABeanCallbacks.java ---------------------------------------------------------------------- diff --git a/security-admin/src/main/java/org/apache/ranger/common/db/JPABeanCallbacks.java b/security-admin/src/main/java/org/apache/ranger/common/db/JPABeanCallbacks.java new file mode 100644 index 0000000..c5176ba --- /dev/null +++ b/security-admin/src/main/java/org/apache/ranger/common/db/JPABeanCallbacks.java @@ -0,0 +1,103 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.ranger.common.db; + +import javax.persistence.PrePersist; +import javax.persistence.PreUpdate; + +import org.apache.log4j.Logger; +import org.apache.ranger.common.DateUtil; +import org.apache.ranger.common.UserSessionBase; +import org.apache.ranger.entity.XXDBBase; +import org.apache.ranger.security.context.XAContextHolder; +import org.apache.ranger.security.context.XASecurityContext; + +public class JPABeanCallbacks { + static final Logger logger = Logger.getLogger(JPABeanCallbacks.class); + + @PrePersist + void onPrePersist(Object o) { + try { + if (o != null && o instanceof XXDBBase) { + XXDBBase entity = (XXDBBase) o; + + entity.setUpdateTime(DateUtil.getUTCDate()); + + XASecurityContext context = XAContextHolder + .getSecurityContext(); + if (context != null) { + UserSessionBase userSession = context.getUserSession(); + if (userSession != null) { + entity.setAddedByUserId(userSession.getUserId()); + entity.setUpdatedByUserId(userSession + .getUserId()); + } + } else { + if (logger.isDebugEnabled()) { + logger.debug( + "Security context not found for this request. obj=" + + o, new Throwable()); + } + } + } + } catch (Throwable t) { + logger.error(t); + } + + } + + // @PostPersist + // void onPostPersist(Object o) { + // if (o != null && o instanceof MBase) { + // MBase entity = (MBase) o; + // if (logger.isDebugEnabled()) { + // logger.debug("DBChange.create:class=" + o.getClass().getName() + // + entity.getId()); + // } + // + // } + // } + + // @PostLoad void onPostLoad(Object o) {} + + @PreUpdate + void onPreUpdate(Object o) { + try { + if (o != null && o instanceof XXDBBase) { + XXDBBase entity = (XXDBBase) o; + entity.setUpdateTime(DateUtil.getUTCDate()); + } + } catch (Throwable t) { + logger.error(t); + } + + } + + // @PostUpdate + // void onPostUpdate(Object o) { + // } + + // @PreRemove void onPreRemove(Object o) {} + + // @PostRemove + // void onPostRemove(Object o) { + // } + +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/413fcb68/security-admin/src/main/java/org/apache/ranger/common/view/VEnum.java ---------------------------------------------------------------------- diff --git a/security-admin/src/main/java/org/apache/ranger/common/view/VEnum.java b/security-admin/src/main/java/org/apache/ranger/common/view/VEnum.java new file mode 100644 index 0000000..9f31390 --- /dev/null +++ b/security-admin/src/main/java/org/apache/ranger/common/view/VEnum.java @@ -0,0 +1,107 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.ranger.common.view; + +import java.util.List; + +import javax.xml.bind.annotation.XmlRootElement; + +import org.apache.ranger.common.XACommonEnums; + + +@XmlRootElement +public class VEnum extends ViewBaseBean implements java.io.Serializable { + private static final long serialVersionUID = 1L; + + /** + * Name of the enum + */ + protected String enumName; + /** + * List of elements for this enum + */ + protected List<VEnumElement> elementList; + + /** + * Default constructor. This will set all the attributes to default value. + */ + public VEnum() { + } + + /** + * This method sets the value to the member attribute <b>enumName</b>. You + * cannot set null to the attribute. + * + * @param enumName + * Value to set member attribute <b>enumName</b> + */ + public void setEnumName(String enumName) { + this.enumName = enumName; + } + + /** + * Returns the value for the member attribute <b>enumName</b> + * + * @return String - value of member attribute <b>enumName</b>. + */ + public String getEnumName() { + return this.enumName; + } + + /** + * This method sets the value to the member attribute <b>elementList</b>. + * You cannot set null to the attribute. + * + * @param elementList + * Value to set member attribute <b>elementList</b> + */ + public void setElementList(List<VEnumElement> elementList) { + this.elementList = elementList; + } + + /** + * Returns the value for the member attribute <b>elementList</b> + * + * @return List<VEnumElement> - value of member attribute + * <b>elementList</b>. + */ + public List<VEnumElement> getElementList() { + return this.elementList; + } + + @Override + public int getMyClassType() { + return XACommonEnums.CLASS_TYPE_ENUM; + } + + /** + * This return the bean content in string format + * + * @return formatedStr + */ + public String toString() { + String str = "VEnum={"; + str += super.toString(); + str += "enumName={" + enumName + "} "; + str += "elementList={" + elementList + "} "; + str += "}"; + return str; + } +} http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/413fcb68/security-admin/src/main/java/org/apache/ranger/common/view/VEnumElement.java ---------------------------------------------------------------------- diff --git a/security-admin/src/main/java/org/apache/ranger/common/view/VEnumElement.java b/security-admin/src/main/java/org/apache/ranger/common/view/VEnumElement.java new file mode 100644 index 0000000..15f890d --- /dev/null +++ b/security-admin/src/main/java/org/apache/ranger/common/view/VEnumElement.java @@ -0,0 +1,166 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.ranger.common.view; + +import javax.xml.bind.annotation.XmlRootElement; + +import org.apache.ranger.common.XACommonEnums; + +@XmlRootElement +public class VEnumElement extends ViewBaseBean implements java.io.Serializable { + private static final long serialVersionUID = 1L; + + + /** + * Name of the element + */ + protected String elementName; + /** + * Name of the enum + */ + protected String enumName; + /** + * Value of the element + */ + protected int elementValue; + /** + * Label for the element + */ + protected String elementLabel; + /** + * Resource bundle key + */ + protected String rbKey; + + /** + * Default constructor. This will set all the attributes to default value. + */ + public VEnumElement ( ) { + } + + /** + * This method sets the value to the member attribute <b>elementName</b>. + * You cannot set null to the attribute. + * @param elementName Value to set member attribute <b>elementName</b> + */ + public void setElementName( String elementName ) { + this.elementName = elementName; + } + + + + /** + * @return the elementName + */ + public String getElementName() { + return elementName; + } + + /** + * @return the enumName + */ + public String getEnumName() { + return enumName; + } + + /** + * @return the rbKey + */ + public String getRbKey() { + return rbKey; + } + + /** + * This method sets the value to the member attribute <b>enumName</b>. + * You cannot set null to the attribute. + * @param enumName Value to set member attribute <b>enumName</b> + */ + public void setEnumName( String enumName ) { + this.enumName = enumName; + } + + + + /** + * This method sets the value to the member attribute <b>elementValue</b>. + * You cannot set null to the attribute. + * @param elementValue Value to set member attribute <b>elementValue</b> + */ + public void setElementValue( int elementValue ) { + this.elementValue = elementValue; + } + + /** + * Returns the value for the member attribute <b>elementValue</b> + * @return int - value of member attribute <b>elementValue</b>. + */ + public int getElementValue( ) { + return this.elementValue; + } + + /** + * This method sets the value to the member attribute <b>elementLabel</b>. + * You cannot set null to the attribute. + * @param elementLabel Value to set member attribute <b>elementLabel</b> + */ + public void setElementLabel( String elementLabel ) { + this.elementLabel = elementLabel; + } + + /** + * Returns the value for the member attribute <b>elementLabel</b> + * @return String - value of member attribute <b>elementLabel</b>. + */ + public String getElementLabel( ) { + return this.elementLabel; + } + + /** + * This method sets the value to the member attribute <b>rbKey</b>. + * You cannot set null to the attribute. + * @param rbKey Value to set member attribute <b>rbKey</b> + */ + public void setRbKey( String rbKey ) { + this.rbKey = rbKey; + } + + + + @Override + public int getMyClassType( ) { + return XACommonEnums.CLASS_TYPE_ENUM_ELEMENT; + } + + /** + * This return the bean content in string format + * @return formatedStr + */ + public String toString( ) { + String str = "VEnumElement={"; + str += super.toString(); + str += "elementName={" + elementName + "} "; + str += "enumName={" + enumName + "} "; + str += "elementValue={" + elementValue + "} "; + str += "elementLabel={" + elementLabel + "} "; + str += "rbKey={" + rbKey + "} "; + str += "}"; + return str; + } +}
