protected String extractSessionId(AtmosphereRequest request) { String path = request.getPathInfo(); if (path != null && path.length() > 0 && !"/".equals(path)) { if (path.startsWith("/")) path = path.substring(1); String[] parts = path.split("/"); if (parts.length >= 2) { // will must validate that it's in the same URI String requestURI = request.getRequestURI(); String protocol = parts[1]; parts = requestURI.substring(requestURI.indexOf(protocol)).split("/"); if (parts.length >= 2) { return parts[1] == null ? null : (parts[1].length() == 0 ? null : parts[1]); } else { return null; } } } return null; }
protected String extractSessionId(AtmosphereRequest request) { String path = request.getPathInfo(); if (path != null && path.length() > 0 && !"/".equals(path)) { if (path.startsWith("/")) path = path.substring(1); String[] parts = path.split("/"); if (parts.length >= 2) { // will must validate that it's in the same URI String requestURI = request.getRequestURI(); String protocol = parts[1]; parts = requestURI.substring(requestURI.indexOf(protocol)).split("/"); if (parts.length >= 2) { return parts[1] == null ? null : (parts[1].length() == 0 ? null : parts[1]); } else { return null; } } } return null; }
@Override public Action inspect(final AtmosphereResource r) { try { retrieveSpringSecurityContext(r); AtmosphereRequest request = r.getRequest(); String requestUserId = request.getPathInfo(); String expectedRequestPath = "/" + getSessionUserId(); if (!requestUserId.equals(expectedRequestPath)) { logger.warn("INVALID REQUEST FOR " + requestUserId + " FROM " + getSessionUserId()); return Action.CANCELLED; } return Action.CONTINUE; } catch (Exception e) { logger.warn("Exception determining Security of Atmosphere Session", e); return Action.CANCELLED; } }
try { String path = request.getPathInfo(); if (path == null || path.length() == 0 || "/".equals(path)) { logger.debug("Not a SocketIO client");
try { String path = request.getPathInfo(); if (path == null || path.length() == 0 || "/".equals(path)) { logger.debug("Not a SocketIO client");
/** * Creates channel (named {@link Broadcaster} in Atmosphere) based on the {@link org.atmosphere.cpr.AtmosphereRequest#getPathInfo()} * * @param resource An {@link AtmosphereResource} * @return */ public boolean apply(AtmosphereResource resource) { String pathInfo = resource.getRequest().getPathInfo(); BroadcasterFactory f = resource.getAtmosphereConfig().getBroadcasterFactory(); if (pathInfo == null) { resource.setBroadcaster(f.lookup("/*")); return true; } final Broadcaster b = f.lookup(pathInfo, true); resource.setBroadcaster(b); return true; } }