Search in sources :

Example 21 with SessionInfo

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

the class JwtSessionMapperTest method canRoundtripSessionInfoAsPlaintextJson.

@Test
public void canRoundtripSessionInfoAsPlaintextJson() throws IOException {
    // Given
    SessionInfo inputSessionInfo = newExampleSessionInfo();
    JwtSessionMapper jwtSessionMapper = new JwtSessionMapperBuilder().build();
    // When
    String jsonString = jwtSessionMapper.asJson(inputSessionInfo);
    SessionInfo outputSessionInfo = jwtSessionMapper.fromJson(jsonString);
    // Then
    assertEquals(inputSessionInfo, outputSessionInfo);
}
Also used : SessionInfo(com.iplanet.dpro.session.share.SessionInfo) Test(org.testng.annotations.Test)

Example 22 with SessionInfo

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

the class JwtSessionMapperTest method canRoundtripSessionInfoAsSignedPlaintextJwt.

@Test
public void canRoundtripSessionInfoAsSignedPlaintextJwt() throws IOException {
    // Given
    SessionInfo inputSessionInfo = newExampleSessionInfo();
    JwtSessionMapper jwtSessionMapper = new JwtSessionMapperBuilder().signedUsingHS256("SHARED_SECRET").build();
    // When
    String jwtString = jwtSessionMapper.asJwt(inputSessionInfo);
    SessionInfo outputSessionInfo = jwtSessionMapper.fromJwt(jwtString);
    // Then
    assertEquals(inputSessionInfo, outputSessionInfo);
}
Also used : SessionInfo(com.iplanet.dpro.session.share.SessionInfo) Test(org.testng.annotations.Test)

Example 23 with SessionInfo

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

the class SessionPollerSender method run.

public void run() {
    try {
        SessionRequest sreq = new SessionRequest(SessionRequest.GetSession, sid.toString(), false);
        SessionResponse sres = pllSender.sendPLLRequest(session.getSessionServiceURL(), sreq);
        if (sres.getException() != null) {
            sessionCache.removeSID(sid);
            return;
        }
        List<SessionInfo> infos = sres.getSessionInfo();
        if (infos.size() == 1) {
            info = infos.get(0);
        }
    } catch (Exception ex) {
        sessionCache.removeSID(sid);
        if (debug.messageEnabled())
            debug.message("Could not connect to the session server" + ex.getMessage());
    }
    if (info != null) {
        if (debug.messageEnabled()) {
            debug.message("Updating" + info.toXMLString());
        }
        try {
            if (info.getState().equals("invalid") || info.getState().equals("destroyed")) {
                sessionCache.removeSID(sid);
            } else {
                long oldMaxCachingTime = session.getMaxCachingTime();
                long oldMaxIdleTime = session.getMaxIdleTime();
                long oldMaxSessionTime = session.getMaxSessionTime();
                session.update(info);
                if ((!session.isScheduled()) || (oldMaxCachingTime > session.getMaxCachingTime()) || (oldMaxIdleTime > session.getMaxIdleTime()) || (oldMaxSessionTime > session.getMaxSessionTime())) {
                    session.scheduleToTimerPool();
                }
            }
        } catch (SessionException se) {
            sessionCache.removeSID(sid);
            debug.error("Exception encountered while update in polling", se);
        }
    } else {
        sessionCache.removeSID(sid);
    }
    session.setIsPolling(false);
}
Also used : SessionInfo(com.iplanet.dpro.session.share.SessionInfo) SessionException(com.iplanet.dpro.session.SessionException) SessionResponse(com.iplanet.dpro.session.share.SessionResponse) SessionRequest(com.iplanet.dpro.session.share.SessionRequest) SessionException(com.iplanet.dpro.session.SessionException)

Example 24 with SessionInfo

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

the class CTSOperationsTest method shouldReadTokenFromRemoteWhenCTSFails.

@Test
public void shouldReadTokenFromRemoteWhenCTSFails() throws CoreTokenException, SessionException {
    // Given
    given(mockCTS.read(anyString())).willThrow(new ReadFailedException("id", new IOException()));
    SessionInfo mockSessionInfo = mock(SessionInfo.class);
    given(mockRemote.refresh(mockSession, false)).willReturn(mockSessionInfo);
    // When
    SessionInfo result = ctsOperations.refresh(mockSession, false);
    // Then
    assertThat(result).isEqualTo(mockSessionInfo);
}
Also used : ReadFailedException(org.forgerock.openam.cts.exceptions.ReadFailedException) SessionInfo(com.iplanet.dpro.session.share.SessionInfo) IOException(java.io.IOException) Test(org.testng.annotations.Test)

Example 25 with SessionInfo

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

the class LocalOperationsTest method shouldReturnSessionInfoOnRefresh.

@Test
public void shouldReturnSessionInfoOnRefresh() throws SessionException {
    // Given
    SessionInfo mockSessionInfo = mock(SessionInfo.class);
    given(mockService.getSessionInfo(any(SessionID.class), anyBoolean())).willReturn(mockSessionInfo);
    // When
    SessionInfo result = local.refresh(mock(Session.class), true);
    // Then
    assertThat(result).isEqualTo(mockSessionInfo);
}
Also used : SessionInfo(com.iplanet.dpro.session.share.SessionInfo) SessionID(com.iplanet.dpro.session.SessionID) Session(com.iplanet.dpro.session.Session) InternalSession(com.iplanet.dpro.session.service.InternalSession) Test(org.testng.annotations.Test)

Aggregations

SessionInfo (com.iplanet.dpro.session.share.SessionInfo)42 Test (org.testng.annotations.Test)18 SessionException (com.iplanet.dpro.session.SessionException)8 SessionID (com.iplanet.dpro.session.SessionID)6 SessionResponse (com.iplanet.dpro.session.share.SessionResponse)5 SessionRequest (com.iplanet.dpro.session.share.SessionRequest)4 InternalSession (com.iplanet.dpro.session.service.InternalSession)3 Session (com.iplanet.dpro.session.Session)2 TokenRestriction (com.iplanet.dpro.session.TokenRestriction)2 SSOException (com.iplanet.sso.SSOException)2 URL (java.net.URL)2 KeyPair (java.security.KeyPair)2 HashMap (java.util.HashMap)2 SigningManager (org.forgerock.json.jose.jws.SigningManager)2 StatelessSession (org.forgerock.openam.sso.providers.stateless.StatelessSession)2 ThreadPoolException (com.iplanet.am.util.ThreadPoolException)1 SessionTimedOutException (com.iplanet.dpro.session.SessionTimedOutException)1 SessionOperations (com.iplanet.dpro.session.operations.SessionOperations)1 Action (com.iplanet.services.naming.ServiceListeners.Action)1 SSOToken (com.iplanet.sso.SSOToken)1