/** * Gives the endpoint based on the service group context ID of the request message. * * @param synCtx Request MessageContext, possibly containing a service group context ID. * @return Endpoint associated with the soap session, if current message is a soap session * message and if current message is not the first message of the session. Returns null, * if an Endpoint could not be found for the session. */ public SessionInformation getSession(MessageContext synCtx) { return SALSessions.getInstance().getSession( extractSessionID(synCtx.getEnvelope().getHeader(), QNAME_SERVICE_GROUP_ID)); }
return SALSessions.getInstance().getSession(extractSessionID(synCtx, COOKIE)); } else { List<String> sessionList = extractSessionIDs(synCtx, COOKIE); if (sessionList != null) { for (String sessionID : sessionList) { SessionInformation sessionInfoObj = SALSessions.getInstance().getSession(sessionID); if (sessionInfoObj != null && sessionInfoObj.getMember() != null) { Map<String, String> subDomainNames =
public SessionInformation getSession(MessageContext synCtx) { return SALSessions.getInstance().getSession( extractSessionID(synCtx.getEnvelope().getHeader(), CSID_QNAME)); }
/** * Gives the endpoint based on the service group context ID of the request message. * * @param synCtx Request MessageContext, possibly containing a service group context ID. * @return Endpoint associated with the soap session, if current message is a soap session * message and if current message is not the first message of the session. Returns null, * if an Endpoint could not be found for the session. */ public SessionInformation getSession(MessageContext synCtx) { return SALSessions.getInstance().getSession( extractSessionID(synCtx.getEnvelope().getHeader(), QNAME_SERVICE_GROUP_ID)); }
public SessionInformation getSession(MessageContext synCtx) { return SALSessions.getInstance().getSession( extractSessionID(synCtx.getEnvelope().getHeader(), CSID_QNAME)); }
return SALSessions.getInstance().getSession(extractSessionID(synCtx, COOKIE)); } else { List<String> sessionList = extractSessionIDs(synCtx, COOKIE); if (sessionList != null) { for (String sessionID : sessionList) { SessionInformation sessionInfoObj = SALSessions.getInstance().getSession(sessionID); if (sessionInfoObj != null && sessionInfoObj.getMember() != null) { Map<String, String> subDomainNames =
salSessions.updateSession(messageContext, sessionCookie); SessionInformation sessionInformation = salSessions.getSession("testCookie2"); Assert.assertEquals("Session not updated!", "testCookie2", sessionInformation.getId());
/** * Test updating session with session id * * @throws Exception */ @Test public void testUpdateWithId() throws Exception { BasicConfigurator.configure(); SynapseConfiguration synapseConfiguration = new SynapseConfiguration(); AxisConfiguration axisConfiguration = synapseConfiguration.getAxisConfiguration(); ConfigurationContext cfgCtx = new ConfigurationContext(axisConfiguration); SynapseEnvironment synapseEnvironment = new Axis2SynapseEnvironment(cfgCtx, synapseConfiguration); Axis2MessageContext axis2MessageContext = new Axis2MessageContext(new org.apache.axis2.context.MessageContext(), synapseConfiguration, synapseEnvironment); MessageContext messageContext = axis2MessageContext; Endpoint endpoint = new AddressEndpoint(); List<Endpoint> endpoints = new ArrayList<>(); endpoints.add(endpoint); messageContext.setProperty(SynapseConstants.PROP_SAL_ENDPOINT_ENDPOINT_LIST, endpoints); SALSessions salSessions = SALSessions.getInstance(); salSessions.initialize(false, cfgCtx); salSessions.updateSession(messageContext, "testSession"); SessionInformation sessionInformation = salSessions.getSession("testSession"); Assert.assertEquals("Session not updated!", "testSession", sessionInformation.getId()); }
/** * Test updating session with session id and old session where the old session id is same as current session id * * @throws Exception */ @Test public void testUpdateWithOldSessionSameName() throws Exception { BasicConfigurator.configure(); SynapseConfiguration synapseConfiguration = new SynapseConfiguration(); AxisConfiguration axisConfiguration = synapseConfiguration.getAxisConfiguration(); ConfigurationContext cfgCtx = new ConfigurationContext(axisConfiguration); SynapseEnvironment synapseEnvironment = new Axis2SynapseEnvironment(cfgCtx, synapseConfiguration); Axis2MessageContext axis2MessageContext = new Axis2MessageContext(new org.apache.axis2.context.MessageContext(), synapseConfiguration, synapseEnvironment); MessageContext messageContext = axis2MessageContext; Endpoint endpoint = new AddressEndpoint(); List<Endpoint> endpoints = new ArrayList<>(); endpoints.add(endpoint); messageContext.setProperty(SynapseConstants.PROP_SAL_ENDPOINT_ENDPOINT_LIST, endpoints); SALSessions salSessions = SALSessions.getInstance(); salSessions.initialize(false, cfgCtx); SessionInformation oldSessionInfo = new SessionInformation("testSession3", endpoints, 30000); messageContext.setProperty(SynapseConstants.PROP_SAL_CURRENT_SESSION_INFORMATION, oldSessionInfo); salSessions.updateSession(messageContext, "testSession3"); SessionInformation sessionInformation = salSessions.getSession("testSession3"); Assert.assertEquals("Session not updated!", "testSession3", sessionInformation.getId()); }
salSessions.updateSession(messageContext, sessionCookie); SessionInformation sessionInformation = salSessions.getSession("testCookie3"); Assert.assertEquals("Session not updated!", "testCookie3", sessionInformation.getId());
/** * Test updating session with session id and old session * * @throws Exception */ @Test public void testUpdateWithOldSession() throws Exception { BasicConfigurator.configure(); SynapseConfiguration synapseConfiguration = new SynapseConfiguration(); AxisConfiguration axisConfiguration = synapseConfiguration.getAxisConfiguration(); ConfigurationContext cfgCtx = new ConfigurationContext(axisConfiguration); SynapseEnvironment synapseEnvironment = new Axis2SynapseEnvironment(cfgCtx, synapseConfiguration); Axis2MessageContext axis2MessageContext = new Axis2MessageContext(new org.apache.axis2.context.MessageContext(), synapseConfiguration, synapseEnvironment); MessageContext messageContext = axis2MessageContext; Endpoint endpoint = new AddressEndpoint(); List<Endpoint> endpoints = new ArrayList<>(); endpoints.add(endpoint); SALSessions salSessions = SALSessions.getInstance(); salSessions.initialize(false, cfgCtx); SessionInformation oldSessionInfo = new SessionInformation("oldTestSession", endpoints, 30000); messageContext.setProperty(SynapseConstants.PROP_SAL_CURRENT_SESSION_INFORMATION, oldSessionInfo); salSessions.updateSession(messageContext, "testSession2"); SessionInformation sessionInformation = salSessions.getSession("testSession2"); Assert.assertEquals("Session not updated!", "testSession2", sessionInformation.getId()); }
/** * Test updating session with cookie * * @throws Exception */ @Test public void testUpdateWithCookie() throws Exception { BasicConfigurator.configure(); SynapseConfiguration synapseConfiguration = new SynapseConfiguration(); AxisConfiguration axisConfiguration = synapseConfiguration.getAxisConfiguration(); ConfigurationContext cfgCtx = new ConfigurationContext(axisConfiguration); SynapseEnvironment synapseEnvironment = new Axis2SynapseEnvironment(cfgCtx, synapseConfiguration); Axis2MessageContext axis2MessageContext = new Axis2MessageContext(new org.apache.axis2.context.MessageContext(), synapseConfiguration, synapseEnvironment); MessageContext messageContext = axis2MessageContext; Endpoint endpoint = new AddressEndpoint(); List<Endpoint> endpoints = new ArrayList<>(); endpoints.add(endpoint); messageContext.setProperty(SynapseConstants.PROP_SAL_ENDPOINT_ENDPOINT_LIST, endpoints); SALSessions salSessions = SALSessions.getInstance(); salSessions.initialize(false, cfgCtx); SessionCookie sessionCookie = new SessionCookie(); sessionCookie.setSessionId("testCookie"); salSessions.updateSession(messageContext, sessionCookie); SessionInformation sessionInformation = salSessions.getSession("testCookie"); Assert.assertEquals("Session not updated!", "testCookie", sessionInformation.getId()); }