private void validateVersion(final Session session) { final Map<String, List<String>> parameters = session.getRequestParameterMap(); activenessRegistrar.updateLastRequestTime(); final List<String> versionParam = parameters.getOrDefault( Versions.KSQL_V1_WS_PARAM, Collections.singletonList(Versions.KSQL_V1_WS)); if (versionParam.isEmpty()) { return; } if (versionParam.size() != 1) { throw new IllegalArgumentException("Received multiple api versions: " + versionParam); } if (!versionParam.get(0).equals(Versions.KSQL_V1_WS)) { throw new IllegalArgumentException("Received invalid api version: " + versionParam); } }
private KsqlRequest parseRequest(final Session session) { try { final List<String> jsonRequests = session.getRequestParameterMap() .getOrDefault("request", Collections.emptyList()); if (jsonRequests == null || jsonRequests.isEmpty()) { throw new IllegalArgumentException("missing request parameter"); } final String jsonRequest = Iterables.getLast(jsonRequests, ""); if (jsonRequest == null || jsonRequest.isEmpty()) { throw new IllegalArgumentException("request parameter empty"); } final KsqlRequest request = mapper.readValue(jsonRequest, KsqlRequest.class); if (request.getKsql().isEmpty()) { throw new IllegalArgumentException("\"ksql\" field of \"request\" must be populated"); } // To validate props: request.getStreamsProperties(); return request; } catch (final Exception e) { throw new IllegalArgumentException("Error parsing request: " + e.getMessage(), e); } }
private void givenRequestAndVersions(final List<String> jsonRequest, final List<String> versions) { final Builder<String, List<String>> builder = ImmutableMap.builder(); if (versions != null) { builder.put(Versions.KSQL_V1_WS_PARAM, versions); } if (jsonRequest != null) { builder.put("request", jsonRequest); } when(session.getRequestParameterMap()).thenReturn(builder.build()); }
@Override public String getQueryParameter(String name) { List<String> paramValues = session.getRequestParameterMap().get(name); if (paramValues != null && paramValues.size() > 0) { return paramValues.get(0); } return null; }
/** * Returns the desktop from the given websocket session. * * @param wsession websocket session * @return a desktop, null if desktop not found */ public static Desktop getDesktop(Session wsession) { org.zkoss.zk.ui.Session session = (org.zkoss.zk.ui.Session) wsession.getUserProperties() .get(ZKWebSocket.class.getName()); if (session == null) throw new IllegalStateException("ZK Session cannot be null!"); List<String> dtids = wsession.getRequestParameterMap().get("dtid"); if (dtids.isEmpty()) throw new IllegalStateException("the value of the key with 'dtid' cannot be null!"); DesktopCache desktopCache = ((SessionCtrl) session).getDesktopCache(); return desktopCache != null ? desktopCache.getDesktopIfAny(dtids.get(0)) : null; } }
if(s!=null && s instanceof WebSocket){ Session session = ((WebSocket) s).getSession(); List<String> vals = session.getRequestParameterMap().get(name); if(vals!=null && !vals.isEmpty()){ if(vals.size()==1){
public JavaxUpgradeHttpRequest(final Session session, EndpointConfig endpointConfig) { Map<String, Object> userProperties = session.getUserProperties(); if (userProperties == null || userProperties.isEmpty()) { // workaround for JBoss Wildfly 8.0.Final userProperties = endpointConfig.getUserProperties(); } this.httpSession = (HttpSession) userProperties.get("session"); this.headers = (Map<String, List<String>>) userProperties.get("headers"); this.queryString = session.getQueryString(); this.userPrincipal = session.getUserPrincipal(); Object requestURI = session.getRequestURI(); this.requestUri = requestURI != null ? requestURI.toString() : ""; this.parametersMap = new HashMap<>(); Map<String, List<String>> parameters = session.getRequestParameterMap(); if (parameters != null) { for (Map.Entry<String, List<String>> entry : parameters.entrySet()) { String name = entry.getKey(); List<String> value = entry.getValue(); parametersMap.put(name, value.toArray(new String[0])); } } }
public JavaxUpgradeHttpRequest(final Session session, EndpointConfig endpointConfig) { Map<String, Object> userProperties = session.getUserProperties(); if (userProperties == null || userProperties.isEmpty()) { // workaround for JBoss Wildfly 8.0.Final userProperties = endpointConfig.getUserProperties(); } this.httpSession = (HttpSession) userProperties.get("session"); this.headers = (Map<String, List<String>>) userProperties.get("headers"); this.queryString = session.getQueryString(); this.userPrincipal = session.getUserPrincipal(); Object requestURI = session.getRequestURI(); this.requestUri = requestURI != null ? requestURI.toString() : ""; this.parametersMap = new HashMap<>(); Map<String, List<String>> parameters = session.getRequestParameterMap(); if (parameters != null) { for (Map.Entry<String, List<String>> entry : parameters.entrySet()) { String name = entry.getKey(); List<String> value = entry.getValue(); parametersMap.put(name, value.toArray(new String[0])); } } }
@OnOpen public void onOpen(Session session) throws IOException { this.session = session; Map<String, List<String>> requestParameterMap = session.getRequestParameterMap(); List<String> refinementType = requestParameterMap.get("type"); if (Objects.nonNull(refinementType)) { String type = refinementType.get(0); if (type.equals("patterns")) { this.patternRefinement = new PatternRefinement(this); } else if (type.equals("tests")) { this.patternRefinement = new TestRefinement(this); } if (Objects.nonNull(this.patternRefinement)) { LOGGER.info("Opened consistency check web-socket with id: " + session.getId()); return; } } this.onClose(this.session); LOGGER.debug("Closed session due to missing or incompatible refinement type!"); }
private String getApplicationName(Session session) { String appName = null; @SuppressWarnings("unchecked") Map<String, List<String>> parameters = session.getRequestParameterMap(); if (parameters != null) { appName = parameters.get(WICKET_APP_PARAM_NAME).get(0); } else { // Glassfish 4 has null parameters map and non-null query string ... String queryString = session.getQueryString(); if (!Strings.isEmpty(queryString)) { String[] params = Strings.split(queryString, '&'); for (String paramPair : params) { String[] nameValues = Strings.split(paramPair, '='); if (WICKET_APP_PARAM_NAME.equals(nameValues[0])) { appName = nameValues[1]; } } } } Checks.notNull(appName, "The application name cannot be read from the upgrade request's parameters"); return appName; }
private String getApplicationName(Session session) { String appName = null; @SuppressWarnings("unchecked") Map<String, List<String>> parameters = session.getRequestParameterMap(); if (parameters != null) { appName = parameters.get(WICKET_APP_PARAM_NAME).get(0); } else { // Glassfish 4 has null parameters map and non-null query string ... String queryString = session.getQueryString(); if (!Strings.isEmpty(queryString)) { String[] params = Strings.split(queryString, '&'); for (String paramPair : params) { String[] nameValues = Strings.split(paramPair, '='); if (WICKET_APP_PARAM_NAME.equals(nameValues[0])) { appName = nameValues[1]; } } } } Checks.notNull(appName, "The application name cannot be read from the upgrade request's parameters"); return appName; }
transport = WebsocketTransportBuilder.get(address); Map<String, List<String>> queryparms = session.getRequestParameterMap(); String remoteId = null; for (final Entry<String, List<String>> param : queryparms.entrySet()) {
@Override public void onClose(Session session, CloseReason closeReason) { contextMap.remove(session.getRequestParameterMap().get("requestId").get(0)); final SessionImpl sessionImpl = wrapperMap.remove(session.getId()); if (sessionImpl != null) { try { WebsocketActionSupportImpl.setInstance(new WebsocketActionSupportImpl(sessionImpl)); for (Topic topic : sessionImpl.getCtx().getSpringContext().getTopics().values()) { try { topic.unsubscribe(); } catch (InvalidSubscriptionException ise) { // Ignored already unsubscribed } } } finally { WebsocketActionSupportImpl.clear(); sessionImpl.close(); } } }
@Override public void onClose(Session session, CloseReason closeReason) { contextMap.remove(session.getRequestParameterMap().get("requestId").get(0)); final SessionImpl sessionImpl = wrapperMap.remove(session.getId()); if (sessionImpl != null) { try { WebsocketActionSupportImpl.setInstance(new WebsocketActionSupportImpl(sessionImpl)); for (Topic topic : sessionImpl.getCtx().getSpringContext().getTopics().values()) { try { topic.unsubscribe(); } catch (InvalidSubscriptionException ise) { // Ignored already unsubscribed } } } finally { WebsocketActionSupportImpl.clear(); sessionImpl.close(); } } }
final WebsocketContext websocketContext = contextMap.get(session.getRequestParameterMap().get("requestId").get(0)); if (!allowAccess(session, websocketContext)) { try {
final WebsocketContext websocketContext = contextMap.get(session.getRequestParameterMap().get("requestId").get(0)); if (!allowAccess(session, websocketContext)) { try {
standard = new StandardWebSocketSession( Requests.getHeaders(), session.getRequestParameterMap(), session.getPathParameters(), session.getUserProperties(),