use of org.apache.ranger.common.SearchCriteria in project ranger by apache.
the class UserREST method searchUsers.
/**
* Implements the traditional search functionalities for UserProfile
*
* @param request
* @return
*/
@GET
@Produces({ "application/xml", "application/json" })
@PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.SEARCH_USERS + "\")")
public VXPortalUserList searchUsers(@Context HttpServletRequest request) {
SearchCriteria searchCriteria = searchUtil.extractCommonCriterias(request, SORT_FIELDS);
// userId
searchUtil.extractLong(request, searchCriteria, "userId", "User Id");
// loginId
searchUtil.extractString(request, searchCriteria, "loginId", "Login Id", null);
// emailAddress
searchUtil.extractString(request, searchCriteria, "emailAddress", "Email Address", null);
// firstName
searchUtil.extractString(request, searchCriteria, "firstName", "First Name", StringUtil.VALIDATION_NAME);
// lastName
searchUtil.extractString(request, searchCriteria, "lastName", "Last Name", StringUtil.VALIDATION_NAME);
// status
searchUtil.extractEnum(request, searchCriteria, "status", "Status", "statusList", RangerConstants.ActivationStatus_MAX);
// publicScreenName
searchUtil.extractString(request, searchCriteria, "publicScreenName", "Public Screen Name", StringUtil.VALIDATION_NAME);
// roles
searchUtil.extractStringList(request, searchCriteria, "role", "Role", "roleList", configUtil.getRoles(), StringUtil.VALIDATION_NAME);
return userManager.searchUsers(searchCriteria);
}
use of org.apache.ranger.common.SearchCriteria in project ranger by apache.
the class XUserREST method getXGroupUsers.
@GET
@Path("/{groupId}/users")
@Produces({ "application/xml", "application/json" })
@PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.GET_X_GROUP_USERS + "\")")
public VXUserList getXGroupUsers(@Context HttpServletRequest request, @PathParam("groupId") Long id) {
SearchCriteria searchCriteria = searchUtil.extractCommonCriterias(request, xGroupUserService.sortFields);
searchCriteria.addParam("xGroupId", id);
return xUserMgr.getXGroupUsers(searchCriteria);
}
use of org.apache.ranger.common.SearchCriteria in project ranger by apache.
the class MetricUtil method getAuditsCount.
private VXMetricServiceCount getAuditsCount(int accessResult, Date startDate, Date endDate) throws Exception {
long totalCountOfAudits = 0;
SearchFilter filter = new SearchFilter();
filter.setStartIndex(0);
Map<String, Long> servicesRepoType = new HashMap<String, Long>();
VXMetricServiceCount vXMetricServiceCount = new VXMetricServiceCount();
PList<RangerServiceDef> paginatedSvcDefs = svcStore.getPaginatedServiceDefs(filter);
Iterable<RangerServiceDef> repoTypeGet = paginatedSvcDefs.getList();
for (Object repo : repoTypeGet) {
RangerServiceDef rangerServiceDefObj = (RangerServiceDef) repo;
long id = rangerServiceDefObj.getId();
String serviceRepoName = rangerServiceDefObj.getName();
SearchCriteria searchCriteriaWithType = new SearchCriteria();
searchCriteriaWithType.getParamList().put("repoType", id);
searchCriteriaWithType.getParamList().put("accessResult", accessResult);
searchCriteriaWithType.addParam("startDate", startDate);
searchCriteriaWithType.addParam("endDate", endDate);
VXAccessAuditList vXAccessAuditListwithType = assetMgr.getAccessLogs(searchCriteriaWithType);
long toltalCountOfRepo = vXAccessAuditListwithType.getTotalCount();
if (toltalCountOfRepo != 0) {
servicesRepoType.put(serviceRepoName, toltalCountOfRepo);
totalCountOfAudits += toltalCountOfRepo;
}
}
vXMetricServiceCount.setServiceBasedCountList(servicesRepoType);
vXMetricServiceCount.setTotalCount(totalCountOfAudits);
return vXMetricServiceCount;
}
use of org.apache.ranger.common.SearchCriteria in project ranger by apache.
the class MetricUtil method getUserCountBasedOnUserRole.
private Long getUserCountBasedOnUserRole(@SuppressWarnings("rawtypes") List userRoleList) {
SearchCriteria searchCriteria = new SearchCriteria();
searchCriteria.setStartIndex(0);
searchCriteria.setMaxRows(100);
searchCriteria.setGetCount(true);
searchCriteria.setSortType("asc");
searchCriteria.addParam("userRoleList", userRoleList);
VXUserList VXUserListKeyAdmin = xUserMgr.searchXUsers(searchCriteria);
long userCount = VXUserListKeyAdmin.getTotalCount();
return userCount;
}
use of org.apache.ranger.common.SearchCriteria in project ranger by apache.
the class AssetREST method getAccessLogs.
@GET
@Path("/accessAudit")
@Produces({ "application/xml", "application/json" })
@PreAuthorize("@rangerPreAuthSecurityHandler.isAPIAccessible(\"" + RangerAPIList.GET_ACCESS_LOGS + "\")")
public VXAccessAuditList getAccessLogs(@Context HttpServletRequest request) {
SearchCriteria searchCriteria = searchUtil.extractCommonCriterias(request, xAccessAuditService.sortFields);
searchUtil.extractString(request, searchCriteria, "accessType", "Access Type", StringUtil.VALIDATION_TEXT);
searchUtil.extractString(request, searchCriteria, "aclEnforcer", "Access Type", StringUtil.VALIDATION_TEXT);
searchUtil.extractString(request, searchCriteria, "agentId", "Access Type", StringUtil.VALIDATION_TEXT);
searchUtil.extractString(request, searchCriteria, "repoName", "Access Type", StringUtil.VALIDATION_TEXT);
searchUtil.extractString(request, searchCriteria, "sessionId", "Access Type", StringUtil.VALIDATION_TEXT);
searchUtil.extractString(request, searchCriteria, "requestUser", "Access Type", StringUtil.VALIDATION_TEXT);
searchUtil.extractString(request, searchCriteria, "requestData", "Access Type", StringUtil.VALIDATION_TEXT);
searchUtil.extractString(request, searchCriteria, "resourcePath", "Access Type", StringUtil.VALIDATION_TEXT);
searchUtil.extractString(request, searchCriteria, "clientIP", "Client IP", StringUtil.VALIDATION_TEXT);
searchUtil.extractString(request, searchCriteria, "resourceType", "Resource Type", StringUtil.VALIDATION_TEXT);
searchUtil.extractInt(request, searchCriteria, "auditType", "Audit Type");
searchUtil.extractInt(request, searchCriteria, "accessResult", "Result");
searchUtil.extractInt(request, searchCriteria, "assetId", "Audit Type");
searchUtil.extractLong(request, searchCriteria, "policyId", "Audit Type");
searchUtil.extractInt(request, searchCriteria, "repoType", "Service Type");
searchUtil.extractDate(request, searchCriteria, "startDate", "Start Date", "MM/dd/yyyy");
searchUtil.extractDate(request, searchCriteria, "endDate", "End Date", "MM/dd/yyyy");
searchUtil.extractString(request, searchCriteria, "tags", "tags", null);
searchUtil.extractString(request, searchCriteria, "cluster", "Cluster Name", StringUtil.VALIDATION_TEXT);
boolean isKeyAdmin = msBizUtil.isKeyAdmin();
boolean isAuditKeyAdmin = msBizUtil.isAuditKeyAdmin();
XXServiceDef xxServiceDef = daoManager.getXXServiceDef().findByName(EmbeddedServiceDefsUtil.EMBEDDED_SERVICEDEF_KMS_NAME);
if (isKeyAdmin && xxServiceDef != null || isAuditKeyAdmin && xxServiceDef != null) {
searchCriteria.getParamList().put("repoType", xxServiceDef.getId());
}
return assetMgr.getAccessLogs(searchCriteria);
}
Aggregations