use of org.wso2.carbon.identity.application.authentication.framework.model.FederatedUserSession in project carbon-identity-framework by wso2.
the class UserSessionDAOImplTest method testGetFederatedAuthSessionDetails.
@Test
public void testGetFederatedAuthSessionDetails() throws Exception {
setupSessionStore();
DataSource dataSource = mock(DataSource.class);
mockStatic(IdentityDatabaseUtil.class);
when(IdentityDatabaseUtil.getDataSource()).thenReturn(dataSource);
when(IdentityDatabaseUtil.getSessionDataSource()).thenReturn(dataSource);
when(dataSource.getConnection()).thenReturn(getConnection(DB_NAME));
FederatedUserSession federatedUserSession = userSessionDAO.getFederatedAuthSessionDetails(IDP_SESSION_INDEX);
assertEquals(federatedUserSession.getSessionId(), SESSION_CONTEXT_KEY);
assertEquals(federatedUserSession.getIdpName(), IDP_NAME);
assertEquals(federatedUserSession.getAuthenticatorName(), AUTHENTICATOR_ID);
assertEquals(federatedUserSession.getProtocolType(), PROTOCOL_TYPE);
}
use of org.wso2.carbon.identity.application.authentication.framework.model.FederatedUserSession in project carbon-identity-framework by wso2.
the class UserSessionDAO method getFederatedAuthSessionDetails.
/**
* Get federated user session details mapped for federated IDP sessionId.
*
* @param fedIdpSessionId sid claim in the logout token of the federated idp.
* @return A FederatedUserSession containing federated authentication session details.
* @throws SessionManagementServerException
*/
default FederatedUserSession getFederatedAuthSessionDetails(String fedIdpSessionId) throws SessionManagementServerException {
FederatedUserSession federatedUserSession;
JdbcTemplate jdbcTemplate = JdbcUtils.getNewTemplate(JdbcUtils.Database.SESSION);
try {
federatedUserSession = jdbcTemplate.fetchSingleRecord(SQLQueries.SQL_GET_FEDERATED_AUTH_SESSION_INFO_BY_SESSION_ID, (resultSet, rowNumber) -> new FederatedUserSession(resultSet.getString(SessionMgtConstants.FEDERATED_IDP_SESSION_ID), resultSet.getString(SessionMgtConstants.FEDERATED_SESSION_ID), resultSet.getString(SessionMgtConstants.FEDERATED_IDP_NAME), resultSet.getString(SessionMgtConstants.FEDERATED_AUTHENTICATOR_ID), resultSet.getString(SessionMgtConstants.FEDERATED_PROTOCOL_TYPE)), preparedStatement -> preparedStatement.setString(1, fedIdpSessionId));
return federatedUserSession;
} catch (DataAccessException e) {
throw new SessionManagementServerException(SessionMgtConstants.ErrorMessages.ERROR_CODE_UNABLE_TO_GET_FED_USER_SESSION, SessionMgtConstants.ErrorMessages.ERROR_CODE_UNABLE_TO_GET_FED_USER_SESSION.getDescription(), e);
}
}
Aggregations