You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ranger.apache.org by ma...@apache.org on 2014/12/12 02:29:46 UTC
[03/51] [partial] incubator-ranger git commit: RANGER-194: Rename
packages from xasecure to apache ranger
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/413fcb68/security-admin/src/main/java/org/apache/ranger/common/view/VList.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/common/view/VList.java b/security-admin/src/main/java/org/apache/ranger/common/view/VList.java
new file mode 100644
index 0000000..177e7fd
--- /dev/null
+++ b/security-admin/src/main/java/org/apache/ranger/common/view/VList.java
@@ -0,0 +1,189 @@
+/*
+ * 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
+public abstract class VList extends ViewBaseBean implements
+ java.io.Serializable {
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Start index for the result
+ */
+ protected int startIndex;
+ /**
+ * Page size used for the result
+ */
+ protected int pageSize;
+ /**
+ * Total records in the database for the given search conditions
+ */
+ protected long totalCount;
+ /**
+ * Number of rows returned for the search condition
+ */
+ protected int resultSize;
+ /**
+ * Sort type. Either desc or asc
+ */
+ protected String sortType;
+ /**
+ * Comma seperated list of the fields for sorting
+ */
+ protected String sortBy;
+
+ protected long queryTimeMS = System.currentTimeMillis();
+
+ /**
+ * Default constructor. This will set all the attributes to default value.
+ */
+ public VList() {
+ }
+
+ /**
+ * Initialize with existing list
+ *
+ * @param size
+ */
+ public VList(@SuppressWarnings("rawtypes") List objectList) {
+ int size = 0;
+ if (objectList != null) {
+ size = objectList.size();
+ }
+
+ startIndex = 0;
+ pageSize = size;
+ totalCount = size;
+ resultSize = size;
+ sortType = null;
+ sortBy = null;
+ }
+
+ abstract public int getListSize();
+
+ abstract public List<?> getList();
+
+ /**
+ * This method sets the value to the member attribute <b>startIndex</b>. You
+ * cannot set null to the attribute.
+ *
+ * @param startIndex
+ * Value to set member attribute <b>startIndex</b>
+ */
+ public void setStartIndex(int startIndex) {
+ this.startIndex = startIndex;
+ }
+
+
+ /**
+ * This method sets the value to the member attribute <b>pageSize</b>. You
+ * cannot set null to the attribute.
+ *
+ * @param pageSize
+ * Value to set member attribute <b>pageSize</b>
+ */
+ public void setPageSize(int pageSize) {
+ this.pageSize = pageSize;
+ }
+
+
+ /**
+ * This method sets the value to the member attribute <b>totalCount</b>. You
+ * cannot set null to the attribute.
+ *
+ * @param totalCount
+ * Value to set member attribute <b>totalCount</b>
+ */
+ public void setTotalCount(long totalCount) {
+ this.totalCount = totalCount;
+ }
+
+
+
+ /**
+ * This method sets the value to the member attribute <b>resultSize</b>. You
+ * cannot set null to the attribute.
+ *
+ * @param resultSize
+ * Value to set member attribute <b>resultSize</b>
+ */
+ public void setResultSize(int resultSize) {
+ this.resultSize = resultSize;
+ }
+
+ /**
+ * Returns the value for the member attribute <b>resultSize</b>
+ *
+ * @return int - value of member attribute <b>resultSize</b>.
+ */
+ public int getResultSize() {
+ return getListSize();
+ }
+
+ /**
+ * This method sets the value to the member attribute <b>sortType</b>. You
+ * cannot set null to the attribute.
+ *
+ * @param sortType
+ * Value to set member attribute <b>sortType</b>
+ */
+ public void setSortType(String sortType) {
+ this.sortType = sortType;
+ }
+
+
+
+ /**
+ * This method sets the value to the member attribute <b>sortBy</b>. You
+ * cannot set null to the attribute.
+ *
+ * @param sortBy
+ * Value to set member attribute <b>sortBy</b>
+ */
+ public void setSortBy(String sortBy) {
+ this.sortBy = sortBy;
+ }
+
+
+
+
+
+
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString() {
+ return "VList [startIndex=" + startIndex + ", pageSize="
+ + pageSize + ", totalCount=" + totalCount
+ + ", resultSize=" + resultSize + ", sortType="
+ + sortType + ", sortBy=" + sortBy + ", queryTimeMS="
+ + queryTimeMS + "]";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/413fcb68/security-admin/src/main/java/org/apache/ranger/common/view/VTrxLogAttr.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/common/view/VTrxLogAttr.java b/security-admin/src/main/java/org/apache/ranger/common/view/VTrxLogAttr.java
new file mode 100644
index 0000000..2974e7d
--- /dev/null
+++ b/security-admin/src/main/java/org/apache/ranger/common/view/VTrxLogAttr.java
@@ -0,0 +1,83 @@
+/*
+ * 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.io.Serializable;
+
+import javax.xml.bind.annotation.XmlRootElement;
+
+import org.apache.ranger.common.AppConstants;
+import org.apache.ranger.common.XACommonEnums;
+import org.apache.ranger.common.view.ViewBaseBean;
+
+@XmlRootElement
+public class VTrxLogAttr extends ViewBaseBean implements Serializable{
+ private static final long serialVersionUID = 1L;
+
+ protected String attribName;
+ protected String attribUserFriendlyName;
+ protected boolean isEnum;
+
+ public VTrxLogAttr(){}
+
+ public VTrxLogAttr(String attribName, String attribUserFriendlyName,
+ boolean isEnum) {
+ super();
+ this.attribName = attribName;
+ this.attribUserFriendlyName = attribUserFriendlyName;
+ this.isEnum = isEnum;
+ }
+
+
+
+
+ /**
+ * @return the attribUserFriendlyName
+ */
+ public String getAttribUserFriendlyName() {
+ return attribUserFriendlyName;
+ }
+
+
+ /**
+ * @return the isEnum
+ */
+ public boolean isEnum() {
+ return isEnum;
+ }
+
+
+
+ @Override
+ public int getMyClassType( ) {
+ return AppConstants.CLASS_TYPE_XA_TRANSACTION_LOG_ATTRIBUTE;
+ }
+
+ @Override
+ public String toString(){
+ String str = "VTrxLogAttr={";
+ str += super.toString();
+ str += "attribName={" + attribName + "} ";
+ str += "attribUserFriendlyName={" + attribUserFriendlyName + "} ";
+ str += "isEnum={" + isEnum + "} ";
+ 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/ViewBaseBean.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/common/view/ViewBaseBean.java b/security-admin/src/main/java/org/apache/ranger/common/view/ViewBaseBean.java
new file mode 100644
index 0000000..b820120
--- /dev/null
+++ b/security-admin/src/main/java/org/apache/ranger/common/view/ViewBaseBean.java
@@ -0,0 +1,56 @@
+/*
+ * 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.XmlTransient;
+
+import org.apache.ranger.common.XACommonEnums;
+import org.apache.ranger.entity.XXDBBase;
+import org.codehaus.jackson.annotate.JsonIgnore;
+
+public class ViewBaseBean implements java.io.Serializable {
+ private static final long serialVersionUID = 1L;
+
+ @JsonIgnore
+ private XXDBBase mObj = null;
+
+ /**
+ * @return the gjObj
+ */
+ @XmlTransient
+ @JsonIgnore
+ public XXDBBase getMObj() {
+ return mObj;
+ }
+
+ /**
+ * @param gjObj
+ * the gjObj to set
+ */
+ public void setMObj(XXDBBase gjObj) {
+ this.mObj = gjObj;
+ }
+
+ @XmlTransient
+ @JsonIgnore
+ public int getMyClassType() {
+ return XACommonEnums.CLASS_TYPE_NONE;
+ }
+}
\ 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/credentialapi/CredentialReader.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/credentialapi/CredentialReader.java b/security-admin/src/main/java/org/apache/ranger/credentialapi/CredentialReader.java
new file mode 100644
index 0000000..920c12d
--- /dev/null
+++ b/security-admin/src/main/java/org/apache/ranger/credentialapi/CredentialReader.java
@@ -0,0 +1,87 @@
+/*
+ * 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.credentialapi;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.security.alias.CredentialProvider;
+import org.apache.hadoop.security.alias.CredentialProviderFactory;
+import org.apache.hadoop.security.alias.JavaKeyStoreProvider;
+
+public class CredentialReader {
+
+ public static String getDecryptedString(String CrendentialProviderPath,String alias) {
+ String credential=null;
+ try{
+ if(CrendentialProviderPath==null || alias==null){
+ return null;
+ }
+ char[] pass = null;
+ Configuration conf = new Configuration();
+ String crendentialProviderPrefix=JavaKeyStoreProvider.SCHEME_NAME + "://file";
+ crendentialProviderPrefix=crendentialProviderPrefix.toLowerCase();
+ CrendentialProviderPath=CrendentialProviderPath.trim();
+ alias=alias.trim();
+ if(CrendentialProviderPath.toLowerCase().startsWith(crendentialProviderPrefix)){
+ conf.set(CredentialProviderFactory.CREDENTIAL_PROVIDER_PATH,
+ //UserProvider.SCHEME_NAME + ":///," +
+ CrendentialProviderPath);
+ }else{
+ if(CrendentialProviderPath.startsWith("/")){
+ conf.set(CredentialProviderFactory.CREDENTIAL_PROVIDER_PATH,
+ //UserProvider.SCHEME_NAME + ":///," +
+ JavaKeyStoreProvider.SCHEME_NAME + "://file" + CrendentialProviderPath);
+ }else{
+ conf.set(CredentialProviderFactory.CREDENTIAL_PROVIDER_PATH,
+ //UserProvider.SCHEME_NAME + ":///," +
+ JavaKeyStoreProvider.SCHEME_NAME + "://file/" + CrendentialProviderPath);
+ }
+ }
+ List<CredentialProvider> providers = CredentialProviderFactory.getProviders(conf);
+ List<String> aliasesList=new ArrayList<String>();
+ CredentialProvider.CredentialEntry credEntry=null;
+ for(CredentialProvider provider: providers) {
+ //System.out.println("Credential Provider :" + provider);
+ aliasesList=provider.getAliases();
+ if(aliasesList!=null && aliasesList.contains(alias.toLowerCase())){
+ credEntry=null;
+ credEntry= provider.getCredentialEntry(alias);
+ pass = credEntry.getCredential();
+ if(pass!=null && pass.length>0){
+ credential=String.valueOf(pass);
+ break;
+ }
+ }
+ }
+ }catch(Exception ex){
+ ex.printStackTrace();
+ credential=null;
+ }
+ return credential;
+ }
+
+ /*
+ public static void main(String args[]) throws Exception{
+ String keystoreFile =new String("/tmp/mykey3.jceks");
+ String password=CredentialReader.getDecryptedString(keystoreFile, "mykey3");
+ System.out.println(password);
+ }*/
+}
\ 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/db/XADaoManager.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/db/XADaoManager.java b/security-admin/src/main/java/org/apache/ranger/db/XADaoManager.java
new file mode 100644
index 0000000..64f2148
--- /dev/null
+++ b/security-admin/src/main/java/org/apache/ranger/db/XADaoManager.java
@@ -0,0 +1,77 @@
+/*
+ * 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.db;
+
+
+
+import javax.persistence.*;
+
+import org.apache.log4j.Logger;
+import org.apache.ranger.common.*;
+import org.apache.ranger.common.db.BaseDao;
+import org.springframework.stereotype.Component;
+import org.springframework.beans.factory.annotation.Autowired;
+
+@Component
+public class XADaoManager extends XADaoManagerBase {
+ final static Logger logger = Logger.getLogger(XADaoManager.class);
+
+ @PersistenceContext(unitName = "defaultPU")
+ private EntityManager em;
+
+ @PersistenceContext(unitName = "loggingPU")
+ private EntityManager loggingEM;
+
+ @Autowired
+ StringUtil stringUtil;
+
+ @Override
+ public EntityManager getEntityManager() {
+ return em;
+ }
+
+ public EntityManager getEntityManager(String persistenceContextUnit) {
+ logger.error("XADaoManager.getEntityManager(" + persistenceContextUnit + ")");
+ if (persistenceContextUnit.equalsIgnoreCase("loggingPU")) {
+ return loggingEM;
+ }
+ return getEntityManager();
+ }
+
+
+ /**
+ * @return the stringUtil
+ */
+ public StringUtil getStringUtil() {
+ return stringUtil;
+ }
+
+ /*
+ * (non-Javadoc)
+ */
+ @Override
+ public BaseDao<?> getDaoForClassType(int classType) {
+ if (classType == XAConstants.CLASS_TYPE_NONE) {
+ return null;
+ }
+ return super.getDaoForClassType(classType);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/413fcb68/security-admin/src/main/java/org/apache/ranger/db/XADaoManagerBase.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/db/XADaoManagerBase.java b/security-admin/src/main/java/org/apache/ranger/db/XADaoManagerBase.java
new file mode 100644
index 0000000..e908447
--- /dev/null
+++ b/security-admin/src/main/java/org/apache/ranger/db/XADaoManagerBase.java
@@ -0,0 +1,216 @@
+/*
+ * 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.db;
+
+/**
+ *
+ */
+
+import javax.persistence.*;
+
+import java.util.*;
+
+import org.apache.log4j.Logger;
+import org.apache.ranger.common.*;
+import org.apache.ranger.common.db.*;
+import org.apache.ranger.entity.*;
+import org.springframework.stereotype.Component;
+import org.springframework.beans.factory.annotation.Autowired;
+
+
+public abstract class XADaoManagerBase {
+ final static Logger logger = Logger.getLogger(XADaoManagerBase.class);
+
+ @Autowired
+ protected RESTErrorUtil restErrorUtil;
+ abstract public EntityManager getEntityManager();
+
+ public XADaoManagerBase() {
+ }
+
+ public BaseDao<?> getDaoForClassType(int classType) {
+ if (classType == AppConstants.CLASS_TYPE_AUTH_SESS) {
+ return getXXAuthSession();
+ }
+ if (classType == AppConstants.CLASS_TYPE_USER_PROFILE) {
+ return getXXPortalUser();
+ }
+ if (classType == AppConstants.CLASS_TYPE_XA_ASSET) {
+ return getXXAsset();
+ }
+ if (classType == AppConstants.CLASS_TYPE_XA_RESOURCE) {
+ return getXXResource();
+ }
+ if (classType == AppConstants.CLASS_TYPE_XA_CRED_STORE) {
+ return getXXCredentialStore();
+ }
+ if (classType == AppConstants.CLASS_TYPE_XA_GROUP) {
+ return getXXGroup();
+ }
+ if (classType == AppConstants.CLASS_TYPE_XA_USER) {
+ return getXXUser();
+ }
+ if (classType == AppConstants.CLASS_TYPE_XA_GROUP_USER) {
+ return getXXGroupUser();
+ }
+ if (classType == AppConstants.CLASS_TYPE_XA_GROUP_GROUP) {
+ return getXXGroupGroup();
+ }
+ if (classType == AppConstants.CLASS_TYPE_XA_PERM_MAP) {
+ return getXXPermMap();
+ }
+ if (classType == AppConstants.CLASS_TYPE_XA_AUDIT_MAP) {
+ return getXXAuditMap();
+ }
+ if (classType == AppConstants.CLASS_TYPE_XA_POLICY_EXPORT_AUDIT) {
+ return getXXPolicyExportAudit();
+ }
+ if (classType == AppConstants.CLASS_TYPE_TRX_LOG) {
+ return getXXTrxLog();
+ }
+ if (classType == AppConstants.CLASS_TYPE_XA_ACCESS_AUDIT) {
+ return getXXAccessAudit();
+ }
+
+ logger.error("No DaoManager found for classType=" + classType, new Throwable());
+ return null;
+ }
+
+ public BaseDao<?> getDaoForClassName(String className) {
+ if (className.equals("XXDBBase")) {
+ return getXXDBBase();
+ }
+ if (className.equals("XXAuthSession")) {
+ return getXXAuthSession();
+ }
+ if (className.equals("XXPortalUser")) {
+ return getXXPortalUser();
+ }
+ if (className.equals("XXPortalUserRole")) {
+ return getXXPortalUserRole();
+ }
+ if (className.equals("XXAsset")) {
+ return getXXAsset();
+ }
+ if (className.equals("XXResource")) {
+ return getXXResource();
+ }
+ if (className.equals("XXCredentialStore")) {
+ return getXXCredentialStore();
+ }
+ if (className.equals("XXGroup")) {
+ return getXXGroup();
+ }
+ if (className.equals("XXUser")) {
+ return getXXUser();
+ }
+ if (className.equals("XXGroupUser")) {
+ return getXXGroupUser();
+ }
+ if (className.equals("XXGroupGroup")) {
+ return getXXGroupGroup();
+ }
+ if (className.equals("XXPermMap")) {
+ return getXXPermMap();
+ }
+ if (className.equals("XXAuditMap")) {
+ return getXXAuditMap();
+ }
+ if (className.equals("XXPolicyExportAudit")) {
+ return getXXPolicyExportAudit();
+ }
+ if (className.equals("XXTrxLog")) {
+ return getXXTrxLog();
+ }
+ if (className.equals("XXAccessAudit")) {
+ return getXXAccessAudit();
+ }
+
+ logger.error("No DaoManager found for className=" + className, new Throwable());
+ return null;
+ }
+
+ public XXDBBaseDao getXXDBBase() {
+ return new XXDBBaseDao(this);
+ }
+
+ public XXAuthSessionDao getXXAuthSession() {
+ return new XXAuthSessionDao(this);
+ }
+
+ public XXPortalUserDao getXXPortalUser() {
+ return new XXPortalUserDao(this);
+ }
+
+ public XXPortalUserRoleDao getXXPortalUserRole() {
+ return new XXPortalUserRoleDao(this);
+ }
+
+ public XXAssetDao getXXAsset() {
+ return new XXAssetDao(this);
+ }
+
+ public XXResourceDao getXXResource() {
+ return new XXResourceDao(this);
+ }
+
+ public XXCredentialStoreDao getXXCredentialStore() {
+ return new XXCredentialStoreDao(this);
+ }
+
+ public XXGroupDao getXXGroup() {
+ return new XXGroupDao(this);
+ }
+
+ public XXUserDao getXXUser() {
+ return new XXUserDao(this);
+ }
+
+ public XXGroupUserDao getXXGroupUser() {
+ return new XXGroupUserDao(this);
+ }
+
+ public XXGroupGroupDao getXXGroupGroup() {
+ return new XXGroupGroupDao(this);
+ }
+
+ public XXPermMapDao getXXPermMap() {
+ return new XXPermMapDao(this);
+ }
+
+ public XXAuditMapDao getXXAuditMap() {
+ return new XXAuditMapDao(this);
+ }
+
+ public XXPolicyExportAuditDao getXXPolicyExportAudit() {
+ return new XXPolicyExportAuditDao(this);
+ }
+
+ public XXTrxLogDao getXXTrxLog() {
+ return new XXTrxLogDao(this);
+ }
+
+ public XXAccessAuditDao getXXAccessAudit() {
+ return new XXAccessAuditDao(this);
+ }
+
+
+}
+
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/413fcb68/security-admin/src/main/java/org/apache/ranger/db/XXAccessAuditDao.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/db/XXAccessAuditDao.java b/security-admin/src/main/java/org/apache/ranger/db/XXAccessAuditDao.java
new file mode 100644
index 0000000..614cea9
--- /dev/null
+++ b/security-admin/src/main/java/org/apache/ranger/db/XXAccessAuditDao.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.db;
+
+import org.apache.ranger.common.*;
+import org.apache.ranger.common.db.*;
+import org.apache.ranger.entity.*;
+
+public class XXAccessAuditDao extends BaseDao<XXAccessAudit> {
+
+ public XXAccessAuditDao( XADaoManagerBase daoManager ) {
+ super(daoManager, "loggingPU");
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/413fcb68/security-admin/src/main/java/org/apache/ranger/db/XXAssetDao.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/db/XXAssetDao.java b/security-admin/src/main/java/org/apache/ranger/db/XXAssetDao.java
new file mode 100644
index 0000000..08a1d2a
--- /dev/null
+++ b/security-admin/src/main/java/org/apache/ranger/db/XXAssetDao.java
@@ -0,0 +1,54 @@
+/*
+ * 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.db;
+
+import javax.persistence.NoResultException;
+
+import org.apache.log4j.Logger;
+import org.apache.ranger.common.XACommonEnums;
+import org.apache.ranger.common.db.*;
+import org.apache.ranger.entity.XXAsset;
+
+public class XXAssetDao extends BaseDao<XXAsset> {
+ static final Logger logger = Logger.getLogger(XXAssetDao.class);
+
+ public XXAssetDao( XADaoManagerBase daoManager ) {
+ super(daoManager);
+ }
+
+ public XXAsset findByAssetName(String name){
+ if (daoManager.getStringUtil().isEmpty(name)) {
+ logger.debug("name is empty");
+ return null;
+ }
+ try {
+ return getEntityManager()
+ .createNamedQuery("XXAsset.findByAssetName", XXAsset.class)
+ .setParameter("name", name.trim())
+ .setParameter("status",XACommonEnums.STATUS_DELETED)
+ .getSingleResult();
+ } catch (NoResultException e) {
+ // ignore
+ }
+ return null;
+ }
+
+}
+
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/413fcb68/security-admin/src/main/java/org/apache/ranger/db/XXAuditMapDao.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/db/XXAuditMapDao.java b/security-admin/src/main/java/org/apache/ranger/db/XXAuditMapDao.java
new file mode 100644
index 0000000..2b1a95f
--- /dev/null
+++ b/security-admin/src/main/java/org/apache/ranger/db/XXAuditMapDao.java
@@ -0,0 +1,57 @@
+/*
+ * 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.db;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.persistence.NoResultException;
+
+import org.apache.log4j.Logger;
+import org.apache.ranger.common.*;
+import org.apache.ranger.common.db.*;
+import org.apache.ranger.entity.*;
+
+public class XXAuditMapDao extends BaseDao<XXAuditMap> {
+ static final Logger logger = Logger.getLogger(XXAssetDao.class);
+
+ public XXAuditMapDao( XADaoManagerBase daoManager ) {
+ super(daoManager);
+ }
+
+ public List<XXAuditMap> findByResourceId(Long resourceId) {
+ if (resourceId != null) {
+ try {
+ return getEntityManager()
+ .createNamedQuery("XXAuditMap.findByResourceId", XXAuditMap.class)
+ .setParameter("resourceId", resourceId)
+ .getResultList();
+ } catch (NoResultException e) {
+ logger.debug(e.getMessage());
+ }
+ } else {
+ logger.debug("ResourceId not provided.");
+ return new ArrayList<XXAuditMap>();
+ }
+ return new ArrayList<XXAuditMap>();
+ }
+
+}
+
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/413fcb68/security-admin/src/main/java/org/apache/ranger/db/XXAuthSessionDao.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/db/XXAuthSessionDao.java b/security-admin/src/main/java/org/apache/ranger/db/XXAuthSessionDao.java
new file mode 100644
index 0000000..4e592f4
--- /dev/null
+++ b/security-admin/src/main/java/org/apache/ranger/db/XXAuthSessionDao.java
@@ -0,0 +1,53 @@
+/*
+ * 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.db;
+
+import java.util.List;
+
+import javax.persistence.NoResultException;
+
+import org.apache.ranger.common.db.BaseDao;
+import org.apache.ranger.entity.XXAuthSession;
+
+public class XXAuthSessionDao extends BaseDao<XXAuthSession> {
+
+ public XXAuthSessionDao( XADaoManagerBase daoManager ) {
+ super(daoManager);
+ }
+
+ @SuppressWarnings("unchecked")
+ public List<Object[]> getUserLoggedIn(){
+ return getEntityManager()
+ .createNamedQuery("XXAuthSession.getUserLoggedIn")
+ .getResultList();
+ }
+
+ public XXAuthSession getAuthSessionBySessionId(String sessionId){
+ try{
+ return (XXAuthSession) getEntityManager()
+ .createNamedQuery("XXAuthSession.getAuthSessionBySessionId")
+ .setParameter("sessionId", sessionId)
+ .getSingleResult();
+ } catch(NoResultException ignoreNoResultFound) {
+ return null;
+ }
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/413fcb68/security-admin/src/main/java/org/apache/ranger/db/XXCredentialStoreDao.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/db/XXCredentialStoreDao.java b/security-admin/src/main/java/org/apache/ranger/db/XXCredentialStoreDao.java
new file mode 100644
index 0000000..1ed278e
--- /dev/null
+++ b/security-admin/src/main/java/org/apache/ranger/db/XXCredentialStoreDao.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.db;
+
+import org.apache.ranger.common.*;
+import org.apache.ranger.common.db.*;
+import org.apache.ranger.entity.*;
+
+public class XXCredentialStoreDao extends BaseDao<XXCredentialStore> {
+
+ public XXCredentialStoreDao( XADaoManagerBase daoManager ) {
+ super(daoManager);
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/413fcb68/security-admin/src/main/java/org/apache/ranger/db/XXDBBaseDao.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/db/XXDBBaseDao.java b/security-admin/src/main/java/org/apache/ranger/db/XXDBBaseDao.java
new file mode 100644
index 0000000..3913f3d
--- /dev/null
+++ b/security-admin/src/main/java/org/apache/ranger/db/XXDBBaseDao.java
@@ -0,0 +1,31 @@
+/*
+ * 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.db;
+
+import org.apache.ranger.common.db.BaseDao;
+import org.apache.ranger.entity.*;
+
+public class XXDBBaseDao extends BaseDao<XXDBBase> {
+
+ public XXDBBaseDao( XADaoManagerBase daoManager ) {
+ super(daoManager);
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/413fcb68/security-admin/src/main/java/org/apache/ranger/db/XXGroupDao.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/db/XXGroupDao.java b/security-admin/src/main/java/org/apache/ranger/db/XXGroupDao.java
new file mode 100644
index 0000000..e0b7735
--- /dev/null
+++ b/security-admin/src/main/java/org/apache/ranger/db/XXGroupDao.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.db;
+
+
+import java.util.ArrayList;
+import java.util.List;
+
+
+
+
+import org.apache.ranger.common.*;
+import org.apache.ranger.common.db.*;
+import org.apache.ranger.entity.*;
+
+public class XXGroupDao extends BaseDao<XXGroup> {
+
+ public XXGroupDao(XADaoManagerBase daoManager) {
+ super(daoManager);
+ }
+
+ @SuppressWarnings("unchecked")
+ public List<XXGroup> findByUserId(Long userId) {
+ if (userId == null) {
+ return new ArrayList<XXGroup>();
+ }
+
+ List<XXGroup> groupList = (List<XXGroup>) getEntityManager()
+ .createNamedQuery("XXGroup.findByUserId")
+ .setParameter("userId", userId).getResultList();
+
+ if (groupList == null) {
+ groupList = new ArrayList<XXGroup>();
+ }
+
+ return groupList;
+ }
+
+ @SuppressWarnings("unchecked")
+ public XXGroup findByGroupName(String groupName) {
+ if (groupName == null) {
+ return null;
+ }
+ try {
+
+ return (XXGroup) getEntityManager()
+ .createNamedQuery("XXGroup.findByGroupName")
+ .setParameter("name", groupName)
+ .getSingleResult();
+ } catch (Exception e) {
+
+ }
+ return null;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/413fcb68/security-admin/src/main/java/org/apache/ranger/db/XXGroupGroupDao.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/db/XXGroupGroupDao.java b/security-admin/src/main/java/org/apache/ranger/db/XXGroupGroupDao.java
new file mode 100644
index 0000000..5b831a2
--- /dev/null
+++ b/security-admin/src/main/java/org/apache/ranger/db/XXGroupGroupDao.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.db;
+
+import org.apache.ranger.common.*;
+import org.apache.ranger.common.db.*;
+import org.apache.ranger.entity.*;
+
+public class XXGroupGroupDao extends BaseDao<XXGroupGroup> {
+
+ public XXGroupGroupDao( XADaoManagerBase daoManager ) {
+ super(daoManager);
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/413fcb68/security-admin/src/main/java/org/apache/ranger/db/XXGroupUserDao.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/db/XXGroupUserDao.java b/security-admin/src/main/java/org/apache/ranger/db/XXGroupUserDao.java
new file mode 100644
index 0000000..8b27c7f
--- /dev/null
+++ b/security-admin/src/main/java/org/apache/ranger/db/XXGroupUserDao.java
@@ -0,0 +1,64 @@
+/*
+ * 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.db;
+
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.persistence.NoResultException;
+
+import org.apache.log4j.Logger;
+import org.apache.ranger.common.*;
+import org.apache.ranger.common.db.*;
+import org.apache.ranger.entity.*;
+
+public class XXGroupUserDao extends BaseDao<XXGroupUser> {
+ static final Logger logger = Logger.getLogger(XXGroupUserDao.class);
+
+ public XXGroupUserDao(XADaoManagerBase daoManager) {
+ super(daoManager);
+ }
+
+ public void deleteByGroupIdAndUserId(Long groupId, Long userId) {
+ getEntityManager()
+ .createNamedQuery("XXGroupUser.deleteByGroupIdAndUserId")
+ .setParameter("userId", userId)
+ .setParameter("parentGroupId", groupId).executeUpdate();
+
+ }
+
+ public List<XXGroupUser> findByUserId(Long userId) {
+ if (userId != null) {
+ try {
+ return getEntityManager()
+ .createNamedQuery("XXGroupUser.findByUserId", XXGroupUser.class)
+ .setParameter("userId", userId)
+ .getResultList();
+ } catch (NoResultException e) {
+ logger.debug(e.getMessage());
+ }
+ } else {
+ logger.debug("ResourceId not provided.");
+ return new ArrayList<XXGroupUser>();
+ }
+ return null;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/413fcb68/security-admin/src/main/java/org/apache/ranger/db/XXPermMapDao.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/db/XXPermMapDao.java b/security-admin/src/main/java/org/apache/ranger/db/XXPermMapDao.java
new file mode 100644
index 0000000..659b9be
--- /dev/null
+++ b/security-admin/src/main/java/org/apache/ranger/db/XXPermMapDao.java
@@ -0,0 +1,56 @@
+/*
+ * 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.db;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.persistence.NoResultException;
+
+import org.apache.log4j.Logger;
+import org.apache.ranger.common.*;
+import org.apache.ranger.common.db.*;
+import org.apache.ranger.entity.*;
+
+public class XXPermMapDao extends BaseDao<XXPermMap> {
+ static final Logger logger = Logger.getLogger(XXResourceDao.class);
+
+ public XXPermMapDao( XADaoManagerBase daoManager ) {
+ super(daoManager);
+ }
+
+ public List<XXPermMap> findByResourceId(Long resourceId) {
+ if (resourceId != null) {
+ try {
+ return getEntityManager()
+ .createNamedQuery("XXPermMap.findByResourceId", XXPermMap.class)
+ .setParameter("resourceId", resourceId)
+ .getResultList();
+ } catch (NoResultException e) {
+ logger.debug(e.getMessage());
+ }
+ } else {
+ logger.debug("ResourceId not provided.");
+ return new ArrayList<XXPermMap>();
+ }
+ return null;
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/413fcb68/security-admin/src/main/java/org/apache/ranger/db/XXPolicyExportAuditDao.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/db/XXPolicyExportAuditDao.java b/security-admin/src/main/java/org/apache/ranger/db/XXPolicyExportAuditDao.java
new file mode 100644
index 0000000..9ac89b7
--- /dev/null
+++ b/security-admin/src/main/java/org/apache/ranger/db/XXPolicyExportAuditDao.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.db;
+
+import org.apache.ranger.common.*;
+import org.apache.ranger.common.db.*;
+import org.apache.ranger.entity.*;
+
+public class XXPolicyExportAuditDao extends BaseDao<XXPolicyExportAudit> {
+
+ public XXPolicyExportAuditDao( XADaoManagerBase daoManager ) {
+ super(daoManager);
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/413fcb68/security-admin/src/main/java/org/apache/ranger/db/XXPortalUserDao.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/db/XXPortalUserDao.java b/security-admin/src/main/java/org/apache/ranger/db/XXPortalUserDao.java
new file mode 100644
index 0000000..ac11431
--- /dev/null
+++ b/security-admin/src/main/java/org/apache/ranger/db/XXPortalUserDao.java
@@ -0,0 +1,79 @@
+/*
+ * 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.db;
+
+
+import java.util.List;
+
+import org.apache.ranger.common.db.*;
+import org.apache.ranger.entity.XXPortalUser;
+
+public class XXPortalUserDao extends BaseDao<XXPortalUser> {
+
+ public XXPortalUserDao(XADaoManagerBase daoManager) {
+ super(daoManager);
+ }
+
+ public XXPortalUser findByLoginId(String loginId) {
+ if (daoManager.getStringUtil().isEmpty(loginId)) {
+ return null;
+ }
+
+ @SuppressWarnings("rawtypes")
+ List resultList = getEntityManager()
+ .createNamedQuery("XXPortalUser.findByLoginId")
+ .setParameter("loginId", loginId).getResultList();
+ if (resultList.size() != 0) {
+ return (XXPortalUser) resultList.get(0);
+ }
+ return null;
+ }
+
+ public XXPortalUser findByEmailAddress(String emailAddress) {
+ if (daoManager.getStringUtil().isEmpty(emailAddress)) {
+ return null;
+ }
+
+ @SuppressWarnings("rawtypes")
+ List resultList = getEntityManager()
+ .createNamedQuery("XXPortalUser.findByEmailAddress")
+ .setParameter("emailAddress", emailAddress)
+ .getResultList();
+ if (resultList.size() != 0) {
+ return (XXPortalUser) resultList.get(0);
+ }
+ return null;
+ }
+
+ @SuppressWarnings("unchecked")
+ public List<XXPortalUser> findByRole(String userRole) {
+ return getEntityManager().createNamedQuery("XXPortalUser.findByRole")
+ .setParameter("userRole", userRole.toUpperCase())
+ .getResultList();
+ }
+
+ @SuppressWarnings("unchecked")
+ public List<Object[]> getUserAddedReport(){
+ return getEntityManager()
+ .createNamedQuery("XXPortalUser.getUserAddedReport")
+ .getResultList();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/413fcb68/security-admin/src/main/java/org/apache/ranger/db/XXPortalUserRoleDao.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/db/XXPortalUserRoleDao.java b/security-admin/src/main/java/org/apache/ranger/db/XXPortalUserRoleDao.java
new file mode 100644
index 0000000..cf41d59
--- /dev/null
+++ b/security-admin/src/main/java/org/apache/ranger/db/XXPortalUserRoleDao.java
@@ -0,0 +1,59 @@
+/*
+ * 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.db;
+
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.persistence.NoResultException;
+
+import org.apache.ranger.common.db.*;
+import org.apache.ranger.entity.XXPortalUserRole;
+
+public class XXPortalUserRoleDao extends BaseDao<XXPortalUserRole> {
+
+ public XXPortalUserRoleDao(XADaoManagerBase daoManager) {
+ super(daoManager);
+ }
+
+ @SuppressWarnings("unchecked")
+ public List<XXPortalUserRole> findByUserId(Long userId) {
+ if (userId == null) {
+ return new ArrayList<XXPortalUserRole>();
+ }
+ return getEntityManager().createNamedQuery("XXPortalUserRole.findByUserId")
+ .setParameter("userId", userId).getResultList();
+ }
+
+ public XXPortalUserRole findByRoleUserId(Long userId, String role) {
+ if(userId == null || role == null || role.isEmpty()){
+ return null;
+ }
+ try{
+ return (XXPortalUserRole)getEntityManager().createNamedQuery("XXPortalUserRole.findByRoleUserId")
+ .setParameter("userId", userId)
+ .setParameter("userRole", role).getSingleResult();
+ } catch(NoResultException e){
+ //doNothing;
+ }
+ return null;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/413fcb68/security-admin/src/main/java/org/apache/ranger/db/XXResourceDao.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/db/XXResourceDao.java b/security-admin/src/main/java/org/apache/ranger/db/XXResourceDao.java
new file mode 100644
index 0000000..0aa3f75
--- /dev/null
+++ b/security-admin/src/main/java/org/apache/ranger/db/XXResourceDao.java
@@ -0,0 +1,273 @@
+/*
+ * 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.db;
+
+
+import java.util.Date;
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.persistence.NoResultException;
+
+import org.apache.log4j.Logger;
+import org.apache.ranger.common.db.*;
+import org.apache.ranger.entity.XXResource;
+
+public class XXResourceDao extends BaseDao<XXResource> {
+ static final Logger logger = Logger.getLogger(XXResourceDao.class);
+
+ public XXResourceDao(XADaoManagerBase daoManager) {
+ super(daoManager);
+ }
+
+ public XXResource findByResourceName(String name) {
+ if (daoManager.getStringUtil().isEmpty(name)) {
+ logger.debug("name is empty");
+ return null;
+ }
+ try {
+ return getEntityManager()
+ .createNamedQuery("XXResource.findByResourceName",
+ XXResource.class).setParameter("name", name.trim())
+ .getSingleResult();
+ } catch (NoResultException e) {
+ // ignore
+ }
+ return null;
+ }
+
+ public List<XXResource> findUpdatedResourcesByAssetId(
+ Long assetId, Date lastUpdated) {
+ if (assetId != null) {
+ try {
+ return getEntityManager()
+ .createNamedQuery("XXResource.findUpdatedResourcesByAssetId",
+ XXResource.class)
+ .setParameter("assetId", assetId)
+ .setParameter("lastUpdated", lastUpdated)
+ .getResultList();
+ } catch (NoResultException e) {
+ logger.debug(e.getMessage());
+ }
+ } else {
+ logger.debug("AssetId not provided.");
+ return new ArrayList<XXResource>();
+ }
+ return null;
+ }
+
+ public List<XXResource> findByAssetId(Long assetId) {
+ List<XXResource> xResourceList = null;
+ if (assetId != null) {
+ try {
+ xResourceList = getEntityManager()
+ .createNamedQuery("XXResource.findByAssetId", XXResource.class)
+ .setParameter("assetId", assetId)
+ .getResultList();
+ } catch (NoResultException e) {
+ // ignore
+ logger.debug(e.getMessage());
+ }
+ if(xResourceList == null) {
+ xResourceList = new ArrayList<XXResource>();
+ }
+ } else {
+ logger.debug("AssetId not provided.");
+ xResourceList = new ArrayList<XXResource>();
+ }
+ return xResourceList;
+ }
+
+ public List<XXResource> findByAssetType(Integer assetType) {
+ List<XXResource> xResourceList = null;
+ if (assetType != null) {
+ try {
+ xResourceList = getEntityManager()
+ .createNamedQuery("XXResource.findByAssetType", XXResource.class)
+ .setParameter("assetType", assetType)
+ .getResultList();
+ } catch (NoResultException e) {
+ // ignore
+ logger.debug(e.getMessage());
+ }
+ if(xResourceList == null) {
+ xResourceList = new ArrayList<XXResource>();
+ }
+ } else {
+ logger.debug("AssetType not provided.");
+ xResourceList = new ArrayList<XXResource>();
+ }
+ return xResourceList;
+ }
+
+ public Timestamp getMaxUpdateTimeForAssetName(String assetName) {
+ if (assetName == null) {
+ return null;
+ }
+ try {
+ Date date=(Date)getEntityManager()
+ .createNamedQuery("XXResource.getMaxUpdateTimeForAssetName")
+ .setParameter("assetName", assetName)
+ .getSingleResult();
+ if(date!=null){
+ Timestamp timestamp=new Timestamp(date.getTime());
+ return timestamp;
+ }else{
+ return null;
+ }
+ } catch (NoResultException e) {
+ // ignore
+ }
+ return null;
+ }
+
+ public List<XXResource> findUpdatedResourcesByAssetName(
+ String assetName, Date lastUpdated) {
+ if (assetName != null) {
+ try {
+ return getEntityManager()
+ .createNamedQuery(
+ "XXResource.findUpdatedResourcesByAssetName",
+ XXResource.class)
+ .setParameter("assetName", assetName)
+ .setParameter("lastUpdated", lastUpdated)
+ .getResultList();
+ } catch (NoResultException e) {
+ logger.debug(e.getMessage());
+ }
+ } else {
+ logger.debug("Asset name not provided.");
+ return new ArrayList<XXResource>();
+ }
+ return null;
+ }
+
+ public List<XXResource> findByResourceNameAndAssetIdAndRecursiveFlag(
+ String name,Long assetId,int isRecursive ) {
+ if (daoManager.getStringUtil().isEmpty(name)) {
+ logger.debug("name is empty");
+ return null;
+ }
+ if (assetId==null) {
+ logger.debug("assetId is null");
+ return null;
+ }
+ try {
+ String resourceName = name.trim();
+ resourceName = "%"+resourceName+"%";
+ return getEntityManager()
+ .createNamedQuery(
+ "XXResource.findByResourceNameAndAssetIdAndRecursiveFlag",
+ XXResource.class).setParameter("name", resourceName)
+ .setParameter("assetId", assetId)
+ .setParameter("isRecursive", isRecursive)
+ .getResultList();
+ } catch (NoResultException e) {
+ // ignore
+ }
+ return null;
+ }
+
+ public List<XXResource> findByResourceNameAndAssetIdAndResourceType(String name,Long assetId,int resourceType) {
+ if (daoManager.getStringUtil().isEmpty(name)) {
+ logger.debug("name is empty");
+ return null;
+ }
+ if (assetId==null) {
+ logger.debug("assetId is null");
+ return null;
+ }
+ try {
+ String resourceName = name.trim();
+ resourceName = "%"+resourceName+"%";
+ return getEntityManager()
+ .createNamedQuery(
+ "XXResource.findByResourceNameAndAssetIdAndResourceType",
+ XXResource.class).setParameter("name", resourceName)
+ .setParameter("assetId", assetId)
+ .setParameter("resourceType", resourceType)
+ .getResultList();
+ } catch (NoResultException e) {
+ // ignore
+ }
+ return null;
+ }
+
+ @SuppressWarnings("unchecked")
+ public List<XXResource> findByAssetIdAndResourceTypes(Long assetId,
+ List<Integer> resourceType) {
+ if (assetId == null) {
+ logger.debug("assetId is null");
+ return null;
+ }
+ try {
+ StringBuffer query = new StringBuffer(
+ "SELECT obj FROM XXResource obj WHERE obj.assetId="
+ + assetId);
+ String whereClause = makeWhereCaluseForResourceType(resourceType);
+ if (!whereClause.trim().isEmpty()) {
+ query.append(" and ( " + whereClause + " )");
+ }
+ return getEntityManager().createQuery(query.toString())
+ .getResultList();
+ } catch (NoResultException e) {
+ // ignore
+ }
+ return null;
+ }
+
+ private String makeWhereCaluseForResourceType(List<Integer> resourceTypes) {
+ StringBuffer whereClause = new StringBuffer();
+ if (resourceTypes != null && resourceTypes.size() != 0) {
+
+ for (int i = 0; i < resourceTypes.size() - 1; i++) {
+ whereClause.append("obj.resourceType=" + resourceTypes.get(i)
+ + " OR ");
+ }
+ whereClause.append("obj.resourceType="
+ + resourceTypes.get(resourceTypes.size() - 1));
+ }
+ return whereClause.toString();
+ }
+
+ public List<XXResource> findByAssetIdAndResourceStatus(Long assetId, int resourceStatus) {
+ List<XXResource> xResourceList = null;
+ if (assetId != null) {
+ try {
+ xResourceList = getEntityManager()
+ .createNamedQuery("XXResource.findByAssetIdAndResourceStatus", XXResource.class)
+ .setParameter("assetId", assetId)
+ .setParameter("resourceStatus", resourceStatus)
+ .getResultList();
+ } catch (NoResultException e) {
+ // ignore
+ logger.debug(e.getMessage());
+ }
+ if(xResourceList == null) {
+ xResourceList = new ArrayList<XXResource>();
+ }
+ } else {
+ logger.debug("AssetId not provided.");
+ xResourceList = new ArrayList<XXResource>();
+ }
+ return xResourceList;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/413fcb68/security-admin/src/main/java/org/apache/ranger/db/XXTrxLogDao.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/db/XXTrxLogDao.java b/security-admin/src/main/java/org/apache/ranger/db/XXTrxLogDao.java
new file mode 100644
index 0000000..e5729fa
--- /dev/null
+++ b/security-admin/src/main/java/org/apache/ranger/db/XXTrxLogDao.java
@@ -0,0 +1,56 @@
+/*
+ * 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.db;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.persistence.NoResultException;
+
+import org.apache.log4j.Logger;
+import org.apache.ranger.common.db.*;
+import org.apache.ranger.entity.XXTrxLog;
+
+public class XXTrxLogDao extends BaseDao<XXTrxLog> {
+ private static Logger logger = Logger.getLogger(XXTrxLogDao.class);
+
+ public XXTrxLogDao( XADaoManagerBase daoManager ) {
+ super(daoManager);
+ }
+
+ public List<XXTrxLog> findByTransactionId(String transactionId){
+ if(transactionId == null){
+ return null;
+ }
+
+ List<XXTrxLog> xTrxLogList = new ArrayList<XXTrxLog>();
+ try {
+ xTrxLogList = getEntityManager()
+ .createNamedQuery("XXTrxLog.findByTrxId", XXTrxLog.class)
+ .setParameter("transactionId", transactionId)
+ .getResultList();
+ } catch (NoResultException e) {
+ logger.debug(e.getMessage());
+ }
+
+ return xTrxLogList;
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/413fcb68/security-admin/src/main/java/org/apache/ranger/db/XXUserDao.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/db/XXUserDao.java b/security-admin/src/main/java/org/apache/ranger/db/XXUserDao.java
new file mode 100644
index 0000000..4d2cec4
--- /dev/null
+++ b/security-admin/src/main/java/org/apache/ranger/db/XXUserDao.java
@@ -0,0 +1,51 @@
+/*
+ * 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.db;
+
+
+import javax.persistence.NoResultException;
+
+import org.apache.log4j.Logger;
+import org.apache.ranger.common.db.*;
+import org.apache.ranger.entity.XXUser;
+
+public class XXUserDao extends BaseDao<XXUser> {
+ static final Logger logger = Logger.getLogger(XXResourceDao.class);
+
+ public XXUserDao(XADaoManagerBase daoManager) {
+ super(daoManager);
+ }
+
+ public XXUser findByUserName(String name) {
+ if (daoManager.getStringUtil().isEmpty(name)) {
+ logger.debug("name is empty");
+ return null;
+ }
+ try {
+ return getEntityManager()
+ .createNamedQuery("XXUser.findByUserName", XXUser.class)
+ .setParameter("name", name.trim())
+ .getSingleResult();
+ } catch (NoResultException e) {
+ // ignore
+ }
+ return null;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/413fcb68/security-admin/src/main/java/org/apache/ranger/entity/XXAccessAudit.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/entity/XXAccessAudit.java b/security-admin/src/main/java/org/apache/ranger/entity/XXAccessAudit.java
new file mode 100644
index 0000000..1e8f6e7
--- /dev/null
+++ b/security-admin/src/main/java/org/apache/ranger/entity/XXAccessAudit.java
@@ -0,0 +1,653 @@
+/*
+ * 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.entity;
+
+/**
+ * Access Audit
+ *
+ */
+
+import java.util.*;
+
+import javax.persistence.*;
+import javax.xml.bind.annotation.*;
+
+import org.apache.ranger.common.*;
+import org.apache.ranger.entity.*;
+
+
+@Entity
+@Table(name="xa_access_audit")
+@XmlRootElement
+public class XXAccessAudit extends XXDBBase implements java.io.Serializable {
+ private static final long serialVersionUID = 1L;
+
+ @Id
+ @SequenceGenerator(name="XA_ACCESS_AUDIT_SEQ",sequenceName="XA_ACCESS_AUDIT_SEQ",allocationSize=1)
+ @GeneratedValue(strategy=GenerationType.AUTO,generator="XA_ACCESS_AUDIT_SEQ")
+ @Column(name="ID")
+ protected Long id;
+
+ @Override
+ public void setId(Long id) {
+ this.id=id;
+ }
+ @Override
+ public Long getId() {
+ return id;
+ }
+ /**
+ * Repository Type
+ * <ul>
+ * <li>This attribute is of type enum CommonEnums::AssetType
+ * </ul>
+ *
+ */
+ @Column(name="AUDIT_TYPE" , nullable=false )
+ protected int auditType = AppConstants.ASSET_UNKNOWN;
+
+ /**
+ * Access Result
+ * <ul>
+ * <li>This attribute is of type enum CommonEnums::AccessResult
+ * </ul>
+ *
+ */
+ @Column(name="ACCESS_RESULT" )
+ protected int accessResult = XAConstants.ACCESS_RESULT_DENIED;
+
+ /**
+ * Access Type
+ * <ul>
+ * <li>The maximum length for this attribute is <b>255</b>.
+ * </ul>
+ *
+ */
+ @Column(name="ACCESS_TYPE" , length=255)
+ protected String accessType;
+
+ /**
+ * Acl Enforcer
+ * <ul>
+ * <li>The maximum length for this attribute is <b>255</b>.
+ * </ul>
+ *
+ */
+ @Column(name="ACL_ENFORCER" , length=255)
+ protected String aclEnforcer;
+
+ /**
+ * Agent Id
+ * <ul>
+ * <li>The maximum length for this attribute is <b>255</b>.
+ * </ul>
+ *
+ */
+ @Column(name="AGENT_ID" , length=255)
+ protected String agentId;
+
+ /**
+ * Client Ip
+ * <ul>
+ * <li>The maximum length for this attribute is <b>255</b>.
+ * </ul>
+ *
+ */
+ @Column(name="CLIENT_IP" , length=255)
+ protected String clientIP;
+
+ /**
+ * Client Type
+ * <ul>
+ * <li>The maximum length for this attribute is <b>255</b>.
+ * </ul>
+ *
+ */
+ @Column(name="CLIENT_TYPE" , length=255)
+ protected String clientType;
+
+ /**
+ * Policy Id
+ * <ul>
+ * </ul>
+ *
+ */
+ @Column(name="POLICY_ID" )
+ protected long policyId;
+
+ /**
+ * Repository Name
+ * <ul>
+ * <li>The maximum length for this attribute is <b>255</b>.
+ * </ul>
+ *
+ */
+ @Column(name="REPO_NAME" , length=255)
+ protected String repoName;
+
+ /**
+ * Repository Type
+ * <ul>
+ * </ul>
+ *
+ */
+ @Column(name="REPO_TYPE" )
+ protected int repoType;
+
+ /**
+ * Reason of result
+ * <ul>
+ * <li>The maximum length for this attribute is <b>255</b>.
+ * </ul>
+ *
+ */
+ @Column(name="RESULT_REASON" , length=255)
+ protected String resultReason;
+
+ /**
+ * Session Id
+ * <ul>
+ * <li>The maximum length for this attribute is <b>255</b>.
+ * </ul>
+ *
+ */
+ @Column(name="SESSION_ID" , length=255)
+ protected String sessionId;
+
+ /**
+ * Event Time
+ * <ul>
+ * </ul>
+ *
+ */
+ @Temporal(TemporalType.TIMESTAMP)
+ @Column(name="EVENT_TIME" )
+ protected Date eventTime = DateUtil.getUTCDate();
+
+ /**
+ * Requesting User
+ * <ul>
+ * <li>The maximum length for this attribute is <b>255</b>.
+ * </ul>
+ *
+ */
+ @Column(name="REQUEST_USER" , length=255)
+ protected String requestUser;
+
+ /**
+ * Action
+ * <ul>
+ * <li>The maximum length for this attribute is <b>2000</b>.
+ * </ul>
+ *
+ */
+ @Column(name="ACTION" , length=2000)
+ protected String action;
+
+ /**
+ * Requesting Data
+ * <ul>
+ * <li>The maximum length for this attribute is <b>2000</b>.
+ * </ul>
+ *
+ */
+ @Column(name="REQUEST_DATA" , length=2000)
+ protected String requestData;
+
+ /**
+ * Resource Path
+ * <ul>
+ * <li>The maximum length for this attribute is <b>2000</b>.
+ * </ul>
+ *
+ */
+ @Column(name="RESOURCE_PATH" , length=2000)
+ protected String resourcePath;
+
+ /**
+ * Resource Type
+ * <ul>
+ * <li>The maximum length for this attribute is <b>255</b>.
+ * </ul>
+ *
+ */
+ @Column(name="RESOURCE_TYPE" , length=255)
+ protected String resourceType;
+
+ /**
+ * Default constructor. This will set all the attributes to default value.
+ */
+ public XXAccessAudit ( ) {
+ auditType = AppConstants.ASSET_UNKNOWN;
+ accessResult = XAConstants.ACCESS_RESULT_DENIED;
+ }
+
+ @Override
+ public int getMyClassType( ) {
+ return AppConstants.CLASS_TYPE_XA_ACCESS_AUDIT;
+ }
+
+ /**
+ * This method sets the value to the member attribute <b>auditType</b>.
+ * You cannot set null to the attribute.
+ * @param auditType Value to set member attribute <b>auditType</b>
+ */
+ public void setAuditType( int auditType ) {
+ this.auditType = auditType;
+ }
+
+ /**
+ * Returns the value for the member attribute <b>auditType</b>
+ * @return int - value of member attribute <b>auditType</b>.
+ */
+ public int getAuditType( ) {
+ return this.auditType;
+ }
+
+ /**
+ * This method sets the value to the member attribute <b>accessResult</b>.
+ * You cannot set null to the attribute.
+ * @param accessResult Value to set member attribute <b>accessResult</b>
+ */
+ public void setAccessResult( int accessResult ) {
+ this.accessResult = accessResult;
+ }
+
+ /**
+ * Returns the value for the member attribute <b>accessResult</b>
+ * @return int - value of member attribute <b>accessResult</b>.
+ */
+ public int getAccessResult( ) {
+ return this.accessResult;
+ }
+
+ /**
+ * This method sets the value to the member attribute <b>accessType</b>.
+ * You cannot set null to the attribute.
+ * @param accessType Value to set member attribute <b>accessType</b>
+ */
+ public void setAccessType( String accessType ) {
+ this.accessType = accessType;
+ }
+
+ /**
+ * Returns the value for the member attribute <b>accessType</b>
+ * @return String - value of member attribute <b>accessType</b>.
+ */
+ public String getAccessType( ) {
+ return this.accessType;
+ }
+
+ /**
+ * This method sets the value to the member attribute <b>aclEnforcer</b>.
+ * You cannot set null to the attribute.
+ * @param aclEnforcer Value to set member attribute <b>aclEnforcer</b>
+ */
+ public void setAclEnforcer( String aclEnforcer ) {
+ this.aclEnforcer = aclEnforcer;
+ }
+
+ /**
+ * Returns the value for the member attribute <b>aclEnforcer</b>
+ * @return String - value of member attribute <b>aclEnforcer</b>.
+ */
+ public String getAclEnforcer( ) {
+ return this.aclEnforcer;
+ }
+
+ /**
+ * This method sets the value to the member attribute <b>agentId</b>.
+ * You cannot set null to the attribute.
+ * @param agentId Value to set member attribute <b>agentId</b>
+ */
+ public void setAgentId( String agentId ) {
+ this.agentId = agentId;
+ }
+
+ /**
+ * Returns the value for the member attribute <b>agentId</b>
+ * @return String - value of member attribute <b>agentId</b>.
+ */
+ public String getAgentId( ) {
+ return this.agentId;
+ }
+
+ /**
+ * This method sets the value to the member attribute <b>clientIP</b>.
+ * You cannot set null to the attribute.
+ * @param clientIP Value to set member attribute <b>clientIP</b>
+ */
+ public void setClientIP( String clientIP ) {
+ this.clientIP = clientIP;
+ }
+
+ /**
+ * Returns the value for the member attribute <b>clientIP</b>
+ * @return String - value of member attribute <b>clientIP</b>.
+ */
+ public String getClientIP( ) {
+ return this.clientIP;
+ }
+
+ /**
+ * This method sets the value to the member attribute <b>clientType</b>.
+ * You cannot set null to the attribute.
+ * @param clientType Value to set member attribute <b>clientType</b>
+ */
+ public void setClientType( String clientType ) {
+ this.clientType = clientType;
+ }
+
+ /**
+ * Returns the value for the member attribute <b>clientType</b>
+ * @return String - value of member attribute <b>clientType</b>.
+ */
+ public String getClientType( ) {
+ return this.clientType;
+ }
+
+ /**
+ * This method sets the value to the member attribute <b>policyId</b>.
+ * You cannot set null to the attribute.
+ * @param policyId Value to set member attribute <b>policyId</b>
+ */
+ public void setPolicyId( long policyId ) {
+ this.policyId = policyId;
+ }
+
+ /**
+ * Returns the value for the member attribute <b>policyId</b>
+ * @return long - value of member attribute <b>policyId</b>.
+ */
+ public long getPolicyId( ) {
+ return this.policyId;
+ }
+
+ /**
+ * This method sets the value to the member attribute <b>repoName</b>.
+ * You cannot set null to the attribute.
+ * @param repoName Value to set member attribute <b>repoName</b>
+ */
+ public void setRepoName( String repoName ) {
+ this.repoName = repoName;
+ }
+
+ /**
+ * Returns the value for the member attribute <b>repoName</b>
+ * @return String - value of member attribute <b>repoName</b>.
+ */
+ public String getRepoName( ) {
+ return this.repoName;
+ }
+
+ /**
+ * This method sets the value to the member attribute <b>repoType</b>.
+ * You cannot set null to the attribute.
+ * @param repoType Value to set member attribute <b>repoType</b>
+ */
+ public void setRepoType( int repoType ) {
+ this.repoType = repoType;
+ }
+
+ /**
+ * Returns the value for the member attribute <b>repoType</b>
+ * @return int - value of member attribute <b>repoType</b>.
+ */
+ public int getRepoType( ) {
+ return this.repoType;
+ }
+
+ /**
+ * This method sets the value to the member attribute <b>resultReason</b>.
+ * You cannot set null to the attribute.
+ * @param resultReason Value to set member attribute <b>resultReason</b>
+ */
+ public void setResultReason( String resultReason ) {
+ this.resultReason = resultReason;
+ }
+
+ /**
+ * Returns the value for the member attribute <b>resultReason</b>
+ * @return String - value of member attribute <b>resultReason</b>.
+ */
+ public String getResultReason( ) {
+ return this.resultReason;
+ }
+
+ /**
+ * This method sets the value to the member attribute <b>sessionId</b>.
+ * You cannot set null to the attribute.
+ * @param sessionId Value to set member attribute <b>sessionId</b>
+ */
+ public void setSessionId( String sessionId ) {
+ this.sessionId = sessionId;
+ }
+
+ /**
+ * Returns the value for the member attribute <b>sessionId</b>
+ * @return String - value of member attribute <b>sessionId</b>.
+ */
+ public String getSessionId( ) {
+ return this.sessionId;
+ }
+
+ /**
+ * This method sets the value to the member attribute <b>eventTime</b>.
+ * You cannot set null to the attribute.
+ * @param eventTime Value to set member attribute <b>eventTime</b>
+ */
+ public void setEventTime( Date eventTime ) {
+ this.eventTime = eventTime;
+ }
+
+ /**
+ * Returns the value for the member attribute <b>eventTime</b>
+ * @return Date - value of member attribute <b>eventTime</b>.
+ */
+ public Date getEventTime( ) {
+ return this.eventTime;
+ }
+
+ /**
+ * This method sets the value to the member attribute <b>requestUser</b>.
+ * You cannot set null to the attribute.
+ * @param requestUser Value to set member attribute <b>requestUser</b>
+ */
+ public void setRequestUser( String requestUser ) {
+ this.requestUser = requestUser;
+ }
+
+ /**
+ * Returns the value for the member attribute <b>requestUser</b>
+ * @return String - value of member attribute <b>requestUser</b>.
+ */
+ public String getRequestUser( ) {
+ return this.requestUser;
+ }
+
+ /**
+ * This method sets the value to the member attribute <b>action</b>.
+ * You cannot set null to the attribute.
+ * @param action Value to set member attribute <b>action</b>
+ */
+ public void setAction( String action ) {
+ this.action = action;
+ }
+
+ /**
+ * Returns the value for the member attribute <b>action</b>
+ * @return String - value of member attribute <b>action</b>.
+ */
+ public String getAction( ) {
+ return this.action;
+ }
+
+ /**
+ * This method sets the value to the member attribute <b>requestData</b>.
+ * You cannot set null to the attribute.
+ * @param requestData Value to set member attribute <b>requestData</b>
+ */
+ public void setRequestData( String requestData ) {
+ this.requestData = requestData;
+ }
+
+ /**
+ * Returns the value for the member attribute <b>requestData</b>
+ * @return String - value of member attribute <b>requestData</b>.
+ */
+ public String getRequestData( ) {
+ return this.requestData;
+ }
+
+ /**
+ * This method sets the value to the member attribute <b>resourcePath</b>.
+ * You cannot set null to the attribute.
+ * @param resourcePath Value to set member attribute <b>resourcePath</b>
+ */
+ public void setResourcePath( String resourcePath ) {
+ this.resourcePath = resourcePath;
+ }
+
+ /**
+ * Returns the value for the member attribute <b>resourcePath</b>
+ * @return String - value of member attribute <b>resourcePath</b>.
+ */
+ public String getResourcePath( ) {
+ return this.resourcePath;
+ }
+
+ /**
+ * This method sets the value to the member attribute <b>resourceType</b>.
+ * You cannot set null to the attribute.
+ * @param resourceType Value to set member attribute <b>resourceType</b>
+ */
+ public void setResourceType( String resourceType ) {
+ this.resourceType = resourceType;
+ }
+
+ /**
+ * Returns the value for the member attribute <b>resourceType</b>
+ * @return String - value of member attribute <b>resourceType</b>.
+ */
+ public String getResourceType( ) {
+ return this.resourceType;
+ }
+
+ /**
+ * This return the bean content in string format
+ * @return formatedStr
+ */
+ @Override
+ public String toString( ) {
+ String str = "XXAccessAudit={";
+ str += super.toString();
+ str += "auditType={" + auditType + "} ";
+ str += "accessResult={" + accessResult + "} ";
+ str += "accessType={" + accessType + "} ";
+ str += "aclEnforcer={" + aclEnforcer + "} ";
+ str += "agentId={" + agentId + "} ";
+ str += "clientIP={" + clientIP + "} ";
+ str += "clientType={" + clientType + "} ";
+ str += "policyId={" + policyId + "} ";
+ str += "repoName={" + repoName + "} ";
+ str += "repoType={" + repoType + "} ";
+ str += "resultReason={" + resultReason + "} ";
+ str += "sessionId={" + sessionId + "} ";
+ str += "eventTime={" + eventTime + "} ";
+ str += "requestUser={" + requestUser + "} ";
+ str += "action={" + action + "} ";
+ str += "requestData={" + requestData + "} ";
+ str += "resourcePath={" + resourcePath + "} ";
+ str += "resourceType={" + resourceType + "} ";
+ str += "}";
+ return str;
+ }
+
+ /**
+ * Checks for all attributes except referenced db objects
+ * @return true if all attributes match
+ */
+ @Override
+ public boolean equals( Object obj) {
+ if ( !super.equals(obj) ) {
+ return false;
+ }
+ XXAccessAudit other = (XXAccessAudit) obj;
+ if( this.auditType != other.auditType ) return false;
+ if( this.accessResult != other.accessResult ) return false;
+ if ((this.accessType == null && other.accessType != null) || (this.accessType != null && !this.accessType.equals(other.accessType))) {
+ return false;
+ }
+ if ((this.aclEnforcer == null && other.aclEnforcer != null) || (this.aclEnforcer != null && !this.aclEnforcer.equals(other.aclEnforcer))) {
+ return false;
+ }
+ if ((this.agentId == null && other.agentId != null) || (this.agentId != null && !this.agentId.equals(other.agentId))) {
+ return false;
+ }
+ if ((this.clientIP == null && other.clientIP != null) || (this.clientIP != null && !this.clientIP.equals(other.clientIP))) {
+ return false;
+ }
+ if ((this.clientType == null && other.clientType != null) || (this.clientType != null && !this.clientType.equals(other.clientType))) {
+ return false;
+ }
+ if( this.policyId != other.policyId ) return false;
+ if ((this.repoName == null && other.repoName != null) || (this.repoName != null && !this.repoName.equals(other.repoName))) {
+ return false;
+ }
+ if( this.repoType != other.repoType ) return false;
+ if ((this.resultReason == null && other.resultReason != null) || (this.resultReason != null && !this.resultReason.equals(other.resultReason))) {
+ return false;
+ }
+ if ((this.sessionId == null && other.sessionId != null) || (this.sessionId != null && !this.sessionId.equals(other.sessionId))) {
+ return false;
+ }
+ if ((this.eventTime == null && other.eventTime != null) || (this.eventTime != null && !this.eventTime.equals(other.eventTime))) {
+ return false;
+ }
+ if ((this.requestUser == null && other.requestUser != null) || (this.requestUser != null && !this.requestUser.equals(other.requestUser))) {
+ return false;
+ }
+ if ((this.action == null && other.action != null) || (this.action != null && !this.action.equals(other.action))) {
+ return false;
+ }
+ if ((this.requestData == null && other.requestData != null) || (this.requestData != null && !this.requestData.equals(other.requestData))) {
+ return false;
+ }
+ if ((this.resourcePath == null && other.resourcePath != null) || (this.resourcePath != null && !this.resourcePath.equals(other.resourcePath))) {
+ return false;
+ }
+ if ((this.resourceType == null && other.resourceType != null) || (this.resourceType != null && !this.resourceType.equals(other.resourceType))) {
+ return false;
+ }
+ return true;
+ }
+ public static String getEnumName(String fieldName ) {
+ if( fieldName.equals("auditType") ) {
+ return "CommonEnums.AssetType";
+ }
+ if( fieldName.equals("accessResult") ) {
+ return "CommonEnums.AccessResult";
+ }
+ //Later TODO
+ //return super.getEnumName(fieldName);
+ return null;
+ }
+
+}