Search in sources :

Example 16 with SearchCriteria

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);
}
Also used : SearchCriteria(org.apache.ranger.common.SearchCriteria) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Example 17 with 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);
}
Also used : SearchCriteria(org.apache.ranger.common.SearchCriteria) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Example 18 with 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;
}
Also used : HashMap(java.util.HashMap) SearchFilter(org.apache.ranger.plugin.util.SearchFilter) VXAccessAuditList(org.apache.ranger.view.VXAccessAuditList) SearchCriteria(org.apache.ranger.common.SearchCriteria) VXMetricServiceCount(org.apache.ranger.view.VXMetricServiceCount) RangerServiceDef(org.apache.ranger.plugin.model.RangerServiceDef)

Example 19 with SearchCriteria

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;
}
Also used : VXUserList(org.apache.ranger.view.VXUserList) SearchCriteria(org.apache.ranger.common.SearchCriteria)

Example 20 with SearchCriteria

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);
}
Also used : XXServiceDef(org.apache.ranger.entity.XXServiceDef) SearchCriteria(org.apache.ranger.common.SearchCriteria) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Aggregations

SearchCriteria (org.apache.ranger.common.SearchCriteria)61 Test (org.junit.Test)29 SortField (org.apache.ranger.common.SortField)27 ArrayList (java.util.ArrayList)22 HttpServletRequest (javax.servlet.http.HttpServletRequest)20 GET (javax.ws.rs.GET)13 Path (javax.ws.rs.Path)12 Produces (javax.ws.rs.Produces)12 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)12 VXLong (org.apache.ranger.view.VXLong)10 Date (java.util.Date)9 DateUtil (org.apache.ranger.common.DateUtil)6 HashMap (java.util.HashMap)4 XXPortalUser (org.apache.ranger.entity.XXPortalUser)4 RangerPolicy (org.apache.ranger.plugin.model.RangerPolicy)4 RangerPolicyItem (org.apache.ranger.plugin.model.RangerPolicy.RangerPolicyItem)4 VXPermMap (org.apache.ranger.view.VXPermMap)4 VXUserList (org.apache.ranger.view.VXUserList)4 List (java.util.List)3 XXServiceDef (org.apache.ranger.entity.XXServiceDef)3