Search in sources :

Example 1 with SessionID

use of com.iplanet.dpro.session.SessionID in project OpenAM by OpenRock.

the class SessionPLLSender method sendPLLRequest.

/**
     * Returns a Session Response object based on the XML document received from
     * remote Session Server. This is in response to a request that we send to
     * the session server.
     *
     * @param svcurl The URL of the Session Service.
     * @param sreq The Session Request XML document.
     * @return a Vector of responses from the remote server
     * @exception com.iplanet.dpro.session.SessionException if there was an error in sending the XML
     *            document or if the response has multiple components.
     */
public SessionResponse sendPLLRequest(URL svcurl, SessionRequest sreq) throws SessionException {
    try {
        String cookies = sessionCookies.getCookieName() + "=" + sreq.getSessionID();
        if (!SystemProperties.isServerMode()) {
            SessionID sessionID = new SessionID(sreq.getSessionID());
            cookies = cookies + ";" + sessionCookies.getLBCookie(sessionID);
        }
        final Request req = new Request(sreq.toXMLString());
        final RequestSet set = new RequestSet(SESSION_SERVICE);
        set.addRequest(req);
        final Vector responses = PLLClient.send(svcurl, cookies, set);
        if (responses.size() != 1) {
            throw new SessionException(SessionBundle.rbName, "unexpectedResponse", null);
        }
        final Response res = (Response) responses.elementAt(0);
        return SessionResponse.parseXML(res.getContent());
    } catch (Exception e) {
        throw new SessionException(e);
    }
}
Also used : Response(com.iplanet.services.comm.share.Response) SessionResponse(com.iplanet.dpro.session.share.SessionResponse) RequestSet(com.iplanet.services.comm.share.RequestSet) SessionRequest(com.iplanet.dpro.session.share.SessionRequest) Request(com.iplanet.services.comm.share.Request) SessionException(com.iplanet.dpro.session.SessionException) SessionID(com.iplanet.dpro.session.SessionID) Vector(java.util.Vector) SessionException(com.iplanet.dpro.session.SessionException)

Example 2 with SessionID

use of com.iplanet.dpro.session.SessionID in project OpenAM by OpenRock.

the class CTSOperationsTest method shouldOnlyDeleteTokenRemotelyDuringDestroy.

@Test
public void shouldOnlyDeleteTokenRemotelyDuringDestroy() throws Exception {
    // Given
    SessionID mockSessionID = mock(SessionID.class);
    given(mockSession.getID()).willReturn(mockSessionID);
    given(mockSessionService.checkSessionLocal(mockSessionID)).willReturn(false);
    // When
    ctsOperations.destroy(mockRequester, mockSession);
    // Then
    verify(mockRemote).destroy(mockRequester, mockSession);
}
Also used : SessionID(com.iplanet.dpro.session.SessionID) Test(org.testng.annotations.Test)

Example 3 with SessionID

use of com.iplanet.dpro.session.SessionID in project OpenAM by OpenRock.

the class CTSOperationsTest method setUp.

@BeforeMethod
public void setUp() throws Exception {
    mockRequester = mock(Session.class);
    mockSession = mock(Session.class);
    mockCTS = mock(CTSPersistentStore.class);
    mockAdapter = mock(SessionAdapter.class);
    mockIdFactory = mock(TokenIdFactory.class);
    mockInfoFactory = mock(SessionInfoFactory.class);
    mockSessionService = mock(SessionService.class);
    mockRemote = mock(RemoteOperations.class);
    SessionID mockSessionID = mock(SessionID.class);
    given(mockSession.getID()).willReturn(mockSessionID);
    given(mockIdFactory.toSessionTokenId(any(SessionID.class))).willReturn("TEST");
    ctsOperations = new CTSOperations(mockCTS, mockAdapter, mockIdFactory, mockInfoFactory, mockSessionService, mockRemote, mock(Debug.class));
}
Also used : CTSPersistentStore(org.forgerock.openam.cts.CTSPersistentStore) SessionInfoFactory(com.iplanet.dpro.session.utils.SessionInfoFactory) SessionService(com.iplanet.dpro.session.service.SessionService) TokenIdFactory(org.forgerock.openam.cts.api.tokens.TokenIdFactory) SessionAdapter(org.forgerock.openam.cts.adapters.SessionAdapter) SessionID(com.iplanet.dpro.session.SessionID) Session(com.iplanet.dpro.session.Session) InternalSession(com.iplanet.dpro.session.service.InternalSession) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 4 with SessionID

use of com.iplanet.dpro.session.SessionID in project OpenAM by OpenRock.

the class CTSOperationsTest method shouldCallRemoteSetPropertyDuringSetProperty.

@Test
public void shouldCallRemoteSetPropertyDuringSetProperty() throws SessionException {
    // Given
    SessionID mockSessionID = mock(SessionID.class);
    given(mockSession.getID()).willReturn(mockSessionID);
    // When / Then Throw
    ctsOperations.setProperty(mockSession, "a", "b");
    verify(mockRemote).setProperty(mockSession, "a", "b");
}
Also used : SessionID(com.iplanet.dpro.session.SessionID) Test(org.testng.annotations.Test)

Example 5 with SessionID

use of com.iplanet.dpro.session.SessionID in project OpenAM by OpenRock.

the class DefaultSessionActivatorTest method shouldDestroyAuthSession.

@Test
public void shouldDestroyAuthSession() throws Exception {
    // Given
    final SessionID authSessionID = new SessionID();
    given(mockAuthSession.getID()).willReturn(authSessionID);
    given(mockAuthSession.getPropertyNames()).willReturn(Collections.enumeration(Collections.emptyList()));
    // When
    DefaultSessionActivator.INSTANCE.activateSession(mockState, mockSessionService, mockAuthSession, null, null);
    // Then
    verify(mockSessionService).destroyInternalSession(authSessionID);
}
Also used : SessionID(com.iplanet.dpro.session.SessionID) Test(org.testng.annotations.Test)

Aggregations

SessionID (com.iplanet.dpro.session.SessionID)105 Test (org.testng.annotations.Test)44 SessionException (com.iplanet.dpro.session.SessionException)31 SSOToken (com.iplanet.sso.SSOToken)23 InternalSession (com.iplanet.dpro.session.service.InternalSession)18 SSOException (com.iplanet.sso.SSOException)18 AuthContextLocalWrapper (org.forgerock.openam.core.rest.authn.core.wrappers.AuthContextLocalWrapper)17 HttpServletResponse (javax.servlet.http.HttpServletResponse)16 HttpServletRequest (javax.servlet.http.HttpServletRequest)15 Session (com.iplanet.dpro.session.Session)14 URL (java.net.URL)9 Map (java.util.Map)9 AuthLoginException (com.sun.identity.authentication.spi.AuthLoginException)8 IOException (java.io.IOException)5 HashMap (java.util.HashMap)5 SMSException (com.sun.identity.sm.SMSException)4 Token (org.forgerock.openam.cts.api.tokens.Token)4 SessionIDExtensions (com.iplanet.dpro.session.SessionIDExtensions)3 TokenRestriction (com.iplanet.dpro.session.TokenRestriction)3 SessionInfo (com.iplanet.dpro.session.share.SessionInfo)3