Search in sources :

Example 1 with VXAuthSession

use of org.apache.ranger.view.VXAuthSession in project ranger by apache.

the class SessionMgr method getAuthSessionBySessionId.

public VXAuthSession getAuthSessionBySessionId(String authSessionId) {
    if (stringUtil.isEmpty(authSessionId)) {
        throw restErrorUtil.createRESTException("Please provide the auth session id.", MessageEnums.INVALID_INPUT_DATA);
    }
    XXAuthSession xXAuthSession = daoManager.getXXAuthSession().getAuthSessionBySessionId(authSessionId);
    if (xXAuthSession == null) {
        throw restErrorUtil.createRESTException("Please provide a valid " + "session id.", MessageEnums.INVALID_INPUT_DATA);
    }
    VXAuthSession vXAuthSession = authSessionService.populateViewBean(xXAuthSession);
    return vXAuthSession;
}
Also used : VXAuthSession(org.apache.ranger.view.VXAuthSession) XXAuthSession(org.apache.ranger.entity.XXAuthSession)

Example 2 with VXAuthSession

use of org.apache.ranger.view.VXAuthSession in project ranger by apache.

the class TestXUserREST method createVXAuthSession.

private VXAuthSession createVXAuthSession() {
    VXAuthSession testVXAuthSession = new VXAuthSession();
    testVXAuthSession.setAuthProvider(1);
    testVXAuthSession.setAuthStatus(1);
    testVXAuthSession.setAuthTime(new Date());
    testVXAuthSession.setCityName("Mumbai");
    testVXAuthSession.setCountryName("India");
    testVXAuthSession.setCreateDate(new Date());
    testVXAuthSession.setDeviceType(1);
    testVXAuthSession.setEmailAddress("email@EXAMPLE.COM");
    testVXAuthSession.setFamilyScreenName("testfamilyScreenName");
    testVXAuthSession.setFirstName("testAuthSessionName");
    testVXAuthSession.setId(id);
    testVXAuthSession.setLoginId("Admin");
    testVXAuthSession.setOwner("Admin");
    testVXAuthSession.setPublicScreenName("Admin");
    testVXAuthSession.setUpdatedBy("Admin");
    testVXAuthSession.setUpdateDate(new Date());
    testVXAuthSession.setUserId(id);
    testVXAuthSession.setStateName("Maharashtra");
    return testVXAuthSession;
}
Also used : VXAuthSession(org.apache.ranger.view.VXAuthSession) Date(java.util.Date)

Example 3 with VXAuthSession

use of org.apache.ranger.view.VXAuthSession in project ranger by apache.

the class AuthSessionService method search.

/**
 * @param searchCriteria
 * @return
 */
public VXAuthSessionList search(SearchCriteria searchCriteria) {
    VXAuthSessionList returnList = new VXAuthSessionList();
    List<VXAuthSession> viewList = new ArrayList<VXAuthSession>();
    List<XXAuthSession> resultList = searchResources(searchCriteria, AUTH_SESSION_SEARCH_FLDS, AUTH_SESSION_SORT_FLDS, returnList);
    // Iterate over the result list and create the return list
    for (XXAuthSession gjObj : resultList) {
        VXAuthSession viewObj = populateViewBean(gjObj);
        viewList.add(viewObj);
    }
    returnList.setVXAuthSessions(viewList);
    return returnList;
}
Also used : VXAuthSession(org.apache.ranger.view.VXAuthSession) ArrayList(java.util.ArrayList) VXAuthSessionList(org.apache.ranger.view.VXAuthSessionList) XXAuthSession(org.apache.ranger.entity.XXAuthSession)

Example 4 with VXAuthSession

use of org.apache.ranger.view.VXAuthSession in project ranger by apache.

the class TestXUserREST method test75getAuthSession.

@Test
public void test75getAuthSession() {
    String authSessionId = "testauthSessionId";
    VXAuthSession testVXAuthSession = createVXAuthSession();
    HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
    Mockito.when(request.getParameter("extSessionId")).thenReturn(authSessionId);
    Mockito.when(sessionMgr.getAuthSessionBySessionId(authSessionId)).thenReturn(testVXAuthSession);
    VXAuthSession retVXAuthSession = xUserRest.getAuthSession(request);
    Mockito.verify(sessionMgr).getAuthSessionBySessionId(authSessionId);
    Mockito.verify(request).getParameter("extSessionId");
    assertEquals(testVXAuthSession.getId(), retVXAuthSession.getId());
    assertEquals(testVXAuthSession.getClass(), retVXAuthSession.getClass());
    assertNotNull(retVXAuthSession);
}
Also used : VXAuthSession(org.apache.ranger.view.VXAuthSession) HttpServletRequest(javax.servlet.http.HttpServletRequest) VXString(org.apache.ranger.view.VXString) Test(org.junit.Test)

Example 5 with VXAuthSession

use of org.apache.ranger.view.VXAuthSession in project ranger by apache.

the class TestXUserREST method test74getAuthSessions.

@SuppressWarnings("unchecked")
@Test
public void test74getAuthSessions() {
    HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
    SearchCriteria testSearchCriteria = createsearchCriteria();
    Mockito.when(searchUtil.extractCommonCriterias((HttpServletRequest) Mockito.any(), (List<SortField>) Mockito.any())).thenReturn(testSearchCriteria);
    Mockito.when(searchUtil.extractLong(request, testSearchCriteria, "id", "Auth Session Id")).thenReturn(1L);
    Mockito.when(searchUtil.extractLong(request, testSearchCriteria, "userId", "User Id")).thenReturn(1L);
    Mockito.when(searchUtil.extractInt(request, testSearchCriteria, "authStatus", "Auth Status")).thenReturn(1);
    Mockito.when(searchUtil.extractInt(request, testSearchCriteria, "deviceType", "Device Type")).thenReturn(1);
    Mockito.when(searchUtil.extractString(request, testSearchCriteria, "firstName", "User First Name", StringUtil.VALIDATION_NAME)).thenReturn("");
    Mockito.when(searchUtil.extractString(request, testSearchCriteria, "lastName", "User Last Name", StringUtil.VALIDATION_NAME)).thenReturn("");
    Mockito.when(searchUtil.extractString(request, testSearchCriteria, "requestUserAgent", "User Agent", StringUtil.VALIDATION_TEXT)).thenReturn("");
    Mockito.when(searchUtil.extractString(request, testSearchCriteria, "requestIP", "Request IP Address", StringUtil.VALIDATION_IP_ADDRESS)).thenReturn("");
    Mockito.when(searchUtil.extractString(request, testSearchCriteria, "loginId", "Login ID", StringUtil.VALIDATION_TEXT)).thenReturn("");
    VXAuthSessionList testVXAuthSessionList = new VXAuthSessionList();
    testVXAuthSessionList.setTotalCount(1);
    testVXAuthSessionList.setStartIndex(1);
    VXAuthSession testVXAuthSession = createVXAuthSession();
    List<VXAuthSession> testvXAuthSessions = new ArrayList<VXAuthSession>();
    testvXAuthSessions.add(testVXAuthSession);
    testVXAuthSessionList.setVXAuthSessions(testvXAuthSessions);
    Mockito.when(sessionMgr.searchAuthSessions(testSearchCriteria)).thenReturn(testVXAuthSessionList);
    VXAuthSessionList outputvXGroupList = xUserRest.getAuthSessions(request);
    Mockito.verify(sessionMgr).searchAuthSessions(testSearchCriteria);
    Mockito.verify(searchUtil).extractCommonCriterias((HttpServletRequest) Mockito.any(), (List<SortField>) Mockito.any());
    Mockito.verify(searchUtil).extractLong(request, testSearchCriteria, "id", "Auth Session Id");
    Mockito.verify(searchUtil).extractLong(request, testSearchCriteria, "userId", "User Id");
    Mockito.verify(searchUtil).extractInt(request, testSearchCriteria, "authStatus", "Auth Status");
    Mockito.verify(searchUtil).extractInt(request, testSearchCriteria, "authType", "Login Type");
    Mockito.verify(searchUtil).extractInt(request, testSearchCriteria, "deviceType", "Device Type");
    Mockito.verify(searchUtil).extractString(request, testSearchCriteria, "firstName", "User First Name", StringUtil.VALIDATION_NAME);
    Mockito.verify(searchUtil).extractString(request, testSearchCriteria, "lastName", "User Last Name", StringUtil.VALIDATION_NAME);
    Mockito.verify(searchUtil).extractString(request, testSearchCriteria, "requestUserAgent", "User Agent", StringUtil.VALIDATION_TEXT);
    Mockito.verify(searchUtil).extractString(request, testSearchCriteria, "requestIP", "Request IP Address", StringUtil.VALIDATION_IP_ADDRESS);
    Mockito.verify(searchUtil).extractString(request, testSearchCriteria, "loginId", "Login ID", StringUtil.VALIDATION_TEXT);
    Mockito.verify(searchUtil).extractDate(request, testSearchCriteria, "startDate", "Start Date", null);
    Mockito.verify(searchUtil).extractDate(request, testSearchCriteria, "endDate", "End Date", null);
    assertNotNull(outputvXGroupList);
    assertEquals(outputvXGroupList.getStartIndex(), testVXAuthSessionList.getStartIndex());
    assertEquals(outputvXGroupList.getTotalCount(), testVXAuthSessionList.getTotalCount());
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) VXAuthSession(org.apache.ranger.view.VXAuthSession) ArrayList(java.util.ArrayList) SortField(org.apache.ranger.common.SortField) VXAuthSessionList(org.apache.ranger.view.VXAuthSessionList) SearchCriteria(org.apache.ranger.common.SearchCriteria) Test(org.junit.Test)

Aggregations

VXAuthSession (org.apache.ranger.view.VXAuthSession)5 ArrayList (java.util.ArrayList)2 HttpServletRequest (javax.servlet.http.HttpServletRequest)2 XXAuthSession (org.apache.ranger.entity.XXAuthSession)2 VXAuthSessionList (org.apache.ranger.view.VXAuthSessionList)2 Test (org.junit.Test)2 Date (java.util.Date)1 SearchCriteria (org.apache.ranger.common.SearchCriteria)1 SortField (org.apache.ranger.common.SortField)1 VXString (org.apache.ranger.view.VXString)1