Search in sources :

Example 61 with SessionID

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

the class SessionAdapterTest method shouldAssignSessionHandle.

public void shouldAssignSessionHandle() {
    // Given
    long timestamp = 12345l;
    InternalSession mockSession = mock(InternalSession.class);
    SessionID mockSessionID = mock(SessionID.class);
    String sessionId = "badger";
    String sessionHandle = SessionID.SHANDLE_SCHEME_PREFIX + "ferret";
    given(mockSessionID.toString()).willReturn(sessionId);
    given(jsonSerialisation.deserialise(anyString(), any(Class.class))).willReturn(mockSession);
    given(mockSession.getExpirationTime()).willReturn(timestamp);
    given(mockSession.getID()).willReturn(mockSessionID);
    given(mockSession.getSessionHandle()).willReturn(sessionHandle);
    // some additional required mocking
    given(tokenIdFactory.toSessionTokenId(eq(mockSession))).willReturn(sessionId);
    given(jsonSerialisation.serialise(any())).willReturn("");
    // When
    Token token = adapter.toToken(mockSession);
    // Then
    assertThat(token.<String>getValue(SessionTokenField.SESSION_HANDLE.getField())).isEqualTo(sessionHandle);
}
Also used : InternalSession(com.iplanet.dpro.session.service.InternalSession) Token(org.forgerock.openam.cts.api.tokens.Token) SessionID(com.iplanet.dpro.session.SessionID)

Example 62 with SessionID

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

the class SessionAdapterTest method shouldAssignSessionID.

@Test
public void shouldAssignSessionID() {
    // Given
    long timestamp = 12345l;
    InternalSession mockSession = mock(InternalSession.class);
    SessionID mockSessionID = mock(SessionID.class);
    String sessionId = "badger";
    String sessionHandle = SessionID.SHANDLE_SCHEME_PREFIX + "ferret";
    given(mockSessionID.toString()).willReturn(sessionId);
    given(jsonSerialisation.deserialise(anyString(), any(Class.class))).willReturn(mockSession);
    given(mockSession.getExpirationTime()).willReturn(timestamp);
    given(mockSession.getID()).willReturn(mockSessionID);
    given(mockSession.getSessionHandle()).willReturn(sessionHandle);
    // some additional required mocking
    given(tokenIdFactory.toSessionTokenId(eq(mockSession))).willReturn(sessionId);
    given(jsonSerialisation.serialise(any())).willReturn("");
    // When
    Token token = adapter.toToken(mockSession);
    // Then
    assertThat(token.<String>getValue(SessionTokenField.SESSION_ID.getField())).isEqualTo(sessionId);
}
Also used : InternalSession(com.iplanet.dpro.session.service.InternalSession) Token(org.forgerock.openam.cts.api.tokens.Token) SessionID(com.iplanet.dpro.session.SessionID) Test(org.testng.annotations.Test)

Example 63 with SessionID

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

the class SessionAdapterTest method shouldAssignAttributeFromSessionLatestAccessTime.

@Test
public void shouldAssignAttributeFromSessionLatestAccessTime() {
    // Given
    long timestamp = 12345l;
    InternalSession mockSession = mock(InternalSession.class);
    SessionID mockSessionID = mock(SessionID.class);
    String sessionHandle = SessionID.SHANDLE_SCHEME_PREFIX + "ferret";
    given(mockSessionID.toString()).willReturn("badger");
    given(jsonSerialisation.deserialise(anyString(), any(Class.class))).willReturn(mockSession);
    given(mockSession.getExpirationTime()).willReturn(timestamp);
    given(mockSession.getID()).willReturn(mockSessionID);
    given(mockSession.getSessionHandle()).willReturn(sessionHandle);
    // some additional required mocking
    given(tokenIdFactory.toSessionTokenId(eq(mockSession))).willReturn("badger");
    given(jsonSerialisation.serialise(any())).willReturn("");
    // When
    Token token = adapter.toToken(mockSession);
    // Then
    assertThat(token.getExpiryTimestamp()).isNotNull();
}
Also used : InternalSession(com.iplanet.dpro.session.service.InternalSession) Token(org.forgerock.openam.cts.api.tokens.Token) SessionID(com.iplanet.dpro.session.SessionID) Test(org.testng.annotations.Test)

Example 64 with SessionID

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

the class StatelessSessionFactoryTest method shouldContainJwtInSessionID.

@Test
public void shouldContainJwtInSessionID() {
    SessionID mockSession = mock(SessionID.class);
    given(mockSession.getTail()).willReturn("badger");
    assertThat(factory.containsJwt(mockSession)).isTrue();
}
Also used : SessionID(com.iplanet.dpro.session.SessionID) Test(org.testng.annotations.Test)

Example 65 with SessionID

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

the class StatelessSessionFactoryTest method shouldNotUndoC66DecodingIfNotEncoded.

@Test
public void shouldNotUndoC66DecodingIfNotEncoded() {
    // Given
    final String fullJwtAlphabet = ".-_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
    final SessionID sessionID = new SessionID("notencoded@" + fullJwtAlphabet);
    // When
    final String result = StatelessSessionFactory.getJWTFromSessionID(sessionID, true);
    // Then
    assertThat(result).isEqualTo(fullJwtAlphabet);
    assertThat(sessionID.isC66Encoded()).isFalse();
}
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