Helper method to detect if the given node can actually perform http config refresh.

@param sslEnabled true if ssl enabled, false otherwise.
@param nodeInfo the node info for the given node.
@return true if it is a valid config node, false otherwise.
500328
private static boolean isValidConfigNode(final boolean sslEnabled, final NodeInfo nodeInfo) {
        if (sslEnabled && nodeInfo.sslServices().containsKey(ServiceType.CONFIG)) {
            return true;
        } else if (nodeInfo.services().containsKey(ServiceType.CONFIG)) {
            return true;
        }
        return false;
    }
777345
public synchronized void refreshNodes() throws IOException {
    hostsReader.refresh();
    LOG.info("After refresh Included hosts: " +
        hostsReader.getHostNames().size() +
        " Excluded hosts: " + hostsReader.getExcludedHosts().size());
    Set<String> newHosts = hostsReader.getHostNames();
    Set<String> newExcludes = hostsReader.getExcludedHosts();
    Set<ClusterNode> hostsToExclude = new HashSet<ClusterNode>();
    for (ClusterNode tmpNode : nameToNode.values()) {
      String host = tmpNode.getHost();
      // Check if not included or explicitly excluded.
      if (!newHosts.contains(host) || newExcludes.contains(host)) {
        hostsToExclude.add(tmpNode);
      }
    }
    for (ClusterNode node: hostsToExclude) {
      synchronized (node) {
        for (Map.Entry<ResourceType, RunnableIndices> entry :
          typeToIndices.entrySet()) {
          ResourceType type = entry.getKey();
          RunnableIndices r = entry.getValue();
          if (r.hasRunnable(node)) {
            LOG.info("Node " + node.getName() + " is no longer " +
              type + " runnable because it is excluded");
            r.deleteRunnable(node);
          }
        }
      }
    }
  }
935732
public static boolean isKeepAlive(KeepAliveConfig keepAliveConfig, HttpCarbonMessage outboundRequestMsg)
            throws ConfigurationException {
        switch (keepAliveConfig) {
        case AUTO:
            return Float.valueOf((String) outboundRequestMsg.getProperty(Constants.HTTP_VERSION)) > Constants.HTTP_1_0;
        case ALWAYS:
            return true;
        case NEVER:
            return false;
        default:
            // The execution will never reach here. In case execution reach here means it should be an invalid value
            // for keep-alive configurations.
            throw new ConfigurationException("Invalid keep-alive configuration value : "
                    + keepAliveConfig.toString());
        }
    }
885815
private boolean isFallbackPossible(SSLSocket socket) {
    for (int i = nextModeIndex; i < connectionSpecs.size(); i++) {
      if (connectionSpecs.get(i).isCompatible(socket)) {
        return true;
      }
    }
    return false;
  }
185819
public static boolean isRestSSLEnabled(Configuration sslConfig) {
		@SuppressWarnings("deprecation")
		final boolean fallbackFlag = sslConfig.getBoolean(SecurityOptions.SSL_ENABLED);
		return sslConfig.getBoolean(SecurityOptions.SSL_REST_ENABLED, fallbackFlag);
	}
136554
private Observable<ProposedBucketConfigContext> refreshAgainstNode(final String bucketName, final NetworkAddress hostname) {
        return Buffers.wrapColdWithAutoRelease(Observable.defer(new Func0<Observable<GetBucketConfigResponse>>() {
            @Override
            public Observable<GetBucketConfigResponse> call() {
                return cluster().send(new GetBucketConfigRequest(bucketName, hostname));
            }
        }))
        .doOnNext(new Action1<GetBucketConfigResponse>() {
            @Override
            public void call(GetBucketConfigResponse response) {
                if (!response.status().isSuccess()) {
                    if (response.content() != null && response.content().refCnt() > 0) {
                        response.content().release();
                    }
                    throw new ConfigurationException("Could not fetch config from node: " + response);
                }
            }
        })
        .map(new Func1<GetBucketConfigResponse, ProposedBucketConfigContext>() {
            @Override
            public ProposedBucketConfigContext call(GetBucketConfigResponse response) {
                String raw = response.content().toString(CharsetUtil.UTF_8).trim();
                if (response.content().refCnt() > 0) {
                    response.content().release();
                }

                raw = raw.replace("$HOST", response.hostname().address());
                return new ProposedBucketConfigContext(bucketName, raw, hostname);
            }
        })
        .doOnError(new Action1<Throwable>() {
            @Override
            public void call(Throwable ex) {
                LOGGER.debug("Could not fetch config from bucket \"" + bucketName + "\" against \""
                        + hostname + "\".", ex);
            }
        });
    }
732068
@Override
    public boolean canUpdateNode(IUserLayoutNodeDescription node) {
        if (node == null) return false;

        return isFragmentOwner
                || node.isEditAllowed()
                || node instanceof IUserLayoutChannelDescription;
    }
1177446
private void checkSslConfigAvailability(SSLConfig sslConfig) {
        if (sslConfig != null && sslConfig.isEnabled()) {
            if (!BuildInfoProvider.getBuildInfo().isEnterprise()) {
                throw new IllegalStateException("SSL/TLS requires Hazelcast Enterprise Edition");
            }
        }
    }
860374
@Override
    public void onRefreshed(BoxAuthentication.BoxAuthenticationInfo info) {
        if (sameUser(info)) {
            BoxAuthentication.BoxAuthenticationInfo.cloneInfo(mAuthInfo, info);
            if (sessionAuthListener != null) {
                sessionAuthListener.onRefreshed(info);
            }
        }
    }
978588
public boolean isOnline(String nodeID) {
		if (this.nodeID.equals(nodeID)) {
			return true;
		}
		NodeDescriptor node = nodes.get(nodeID);
		if (node == null) {
			return false;
		}
		node.readLock.lock();
		try {
			return node.offlineSince == 0 && node.seq > 0;
		} finally {
			node.readLock.unlock();
		}
	}
330602
public synchronized void loadOutboundConnectionInfo(String sslCfgAlias, Map<String, Object> config, Set<String> newConnectionInfo) {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            Tr.entry(tc, "loadOutboundConnectionInfo");

        List<Map<String, Object>> outboundEntries = Nester.nest("outboundConnection", config);

        if (!outboundEntries.isEmpty()) {
            for (Map<String, Object> outboundEntry : outboundEntries) {
                String key = null;
                String host = (String) outboundEntry.get("host");

                String certAlias = (String) outboundEntry.get("clientCertificate");
                if (certAlias != null) {
                    sslCfgAlias = sslCfgAlias + ":" + certAlias;
                }

                Integer port = (Integer) outboundEntry.get("port");
                if (port != null) {
                    key = host + "," + port.toString();
                    if (dynamicHostPortSelections.containsKey(key)) {
                        if (!dynamicHostPortSelections.get(key).equals(sslCfgAlias)) {
                            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                                Tr.debug(tc, "loadOutboundConnectionInfo", "Existing " + key + " : " + dynamicHostPortSelections.get(key) + ",  trying to add " + sslCfgAlias);
                            }
                            issueConflictWarning(host, port.toString(), dynamicHostPortSelections.get(key));
                        }
                    } else {
                        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                            Tr.debug(tc, "loadOutboundConnectionInfo", "Adding " + key + " to the host port list, sslCfgAlias " + sslCfgAlias);
                        }
                        dynamicHostPortSelections.put(key, sslCfgAlias);
                    }
                } else {
                    // special check for host "*" and port "*"
                    if (host.equals("*")) {
                        if (!warningIssued && isDefaultOutboundRefSet(sslCfgAlias))
                            continue;
                    }

                    key = host + ",*";
                    if (dynamicHostSelections.containsKey(key)) {
                        if (!dynamicHostSelections.get(key).equals(sslCfgAlias))
                            issueConflictWarning(host, "*", dynamicHostSelections.get(key));
                    } else {
                        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                            Tr.debug(tc, "loadOutboundConnectionInfo", "Adding " + key + " to the host list");
                        }
                        dynamicHostSelections.put(key, sslCfgAlias);
                    }
                }

                newConnectionInfo.add(key);
                dynamicSelections.put(key, sslCfgAlias);
            }
        }

        // always clear the caches
        dynamicLookupCache.clear();
        synchronized (dynamicLookupMisses) {
            dynamicLookupMisses.clear();
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            Tr.exit(tc, "loadOutboundConnectionInfo");
    }
541824
public static boolean supportsWebActions(AccessibilityNodeInfoCompat node) {
        return AccessibilityNodeInfoUtils.supportsAnyAction(node,
                AccessibilityNodeInfoCompat.ACTION_NEXT_HTML_ELEMENT,
                AccessibilityNodeInfoCompat.ACTION_PREVIOUS_HTML_ELEMENT);
    }
1272512
private Observable<ProposedBucketConfigContext> refreshAgainstNode(final String bucketName,
        final NetworkAddress hostname) {
        final Credential credential = registrations().get(bucketName);
        if (credential == null) {
            LOGGER.debug("Ignoring refresh attempt since it seems the bucket registration is gone (closed).");
            return Observable.empty();
        }

        return Observable.defer(new Func0<Observable<BucketConfigResponse>>() {
            @Override
            public Observable<BucketConfigResponse> call() {
                return cluster()
                    .<BucketConfigResponse>send(new BucketConfigRequest(HttpLoader.TERSE_PATH, hostname, bucketName,
                        credential.username(), credential.password()))
                    .flatMap(new Func1<BucketConfigResponse, Observable<BucketConfigResponse>>() {
                        @Override
                        public Observable<BucketConfigResponse> call(BucketConfigResponse response) {
                            if (response.status().isSuccess()) {
                                LOGGER.debug("Successfully got config refresh from terse bucket remote.");
                                return Observable.just(response);
                            }

                            LOGGER.debug("Terse bucket config refresh failed, falling back to verbose.");
                            return cluster().send(
                                new BucketConfigRequest(HttpLoader.VERBOSE_PATH, hostname, bucketName,
                                    credential.username(), credential.password()));
                        }
                    });
            }
        }).map(new Func1<BucketConfigResponse, ProposedBucketConfigContext>() {
            @Override
            public ProposedBucketConfigContext call(final BucketConfigResponse response) {
                String config = response.config().replace("$HOST", hostname.address());
                return new ProposedBucketConfigContext(bucketName, config, hostname);
            }
        }).doOnError(new Action1<Throwable>() {
            @Override
            public void call(Throwable ex) {
                LOGGER.debug("Could not fetch config from bucket \"" + bucketName + "\" against \""
                    + hostname + "\".", ex);
            }
        });
    }
123429
public boolean addGrant(
      ClusterNode node, String sessionId, ResourceRequestInfo req) {
    synchronized (node) {
      if (node.deleted) {
        return false;
      }
      if (!node.checkForGrant(Utilities.getUnitResourceRequest(
        req.getType()), resourceLimit)) {
        return false;
      }

      node.addGrant(sessionId, req);
      loadManager.incrementLoad(req.getType());
      hostsToSessions.get(node).add(sessionId);
      if (!node.checkForGrant(Utilities.getUnitResourceRequest(
        req.getType()), resourceLimit)) {
        RunnableIndices r = typeToIndices.get(req.getType());
        r.deleteRunnable(node);
      }
    }
    return true;
  }
1170431
private boolean canScanNode(StructuralNode node) {
        if (node == null) {
            if (log.isDebugEnabled()) {
                log.debug("Ignoring null node");
            }
            return false;
        }

        HistoryReference hRef = node.getHistoryReference();
        if (hRef == null) {
            if (log.isDebugEnabled()) {
                log.debug("Ignoring null history reference for node: " + node.getName());
            }
            return false;
        }

        if (HistoryReference.TYPE_SCANNER == hRef.getHistoryType()) {
            if (log.isDebugEnabled()) {
                log.debug("Ignoring \"scanner\" type href [id=" + hRef.getHistoryId() + ", URL=" + hRef.getURI() + "]");
            }
            return false;
        }

        if (!nodeInScope(node.getName())) {
            if (log.isDebugEnabled()) {
                log.debug("Ignoring node not in scope: " + node.getName());
            }
            return false;
        }

        return true;
    }
473093
private static void configureEngine(SSLEngine engine, FlowType type, SSLLinkConfig config, SSLConnectionLink connLink) {
        // Update the engine with the latest config parameters.
        engine.setEnabledCipherSuites(config.getEnabledCipherSuites(engine));

        //Set the configured protocol on the SSLEngine
        String protocol = config.getSSLProtocol();
        if (protocol != null) {
            engine.setEnabledProtocols(new String[] { protocol });
        }

        if (type == FlowType.INBOUND) {
            engine.setUseClientMode(false);
            boolean flag = config.getBooleanProperty(Constants.SSLPROP_CLIENT_AUTHENTICATION);
            // When on z/OS, need to check the MutualAuthCBINDCheck property
            // to force client authentication
            //TODO: z/os
            //            if (PlatformHelperFactory.getPlatformHelper().isZOS() &&
            //            	 UserRegistryConfig.TYPE_LOCAL_OS.equals(SecurityObjectLocator.getSecurityConfig().getActiveUserRegistry().getType()))
            //            {
            //            	Boolean cbindCheckEnabled = Boolean.FALSE;
            //
            //            	//get the endpoint name off of the thread
            //                Map connectionInfo = JSSEHelper.getInstance().getInboundConnectionInfo();
            //                if (connectionInfo != null) {
            //                    String endpointName = (String) connectionInfo.get(Constants.CONNECTION_INFO_ENDPOINT_NAME);
            //                    //only enforce cbind check on web requests
            //                    if (endpointName != null && endpointName.startsWith("HTTP")) {
            //                    	if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            //                            Tr.debug(tc, "The endpoint, " + endpointName + ", is web and we are on z/OS. Proceeding to get the mutualAuthCbindCheck property.");
            //                        }
            //		                try {
            //		                    // Get cbind check flag using reflection
            //		                    final String className = "com.ibm.ws.security.zOS.NativeConfiguration";
            //		                    final Class<?> zNativeConfigClass = Class.forName(className);
            //		                    final Method getConfigMethod = zNativeConfigClass.getMethod("getConfig", (java.lang.Class[]) null);
            //		                    final Object configInstance = getConfigMethod.invoke((java.lang.Class[]) null, (java.lang.Object[]) null);
            //		                    final Method cbindCheckMethod = zNativeConfigClass.getMethod("isMutualAuthCBINDCheckEnabled", (java.lang.Class[]) null);
            //		                    cbindCheckEnabled = (Boolean) cbindCheckMethod.invoke(configInstance, (java.lang.Object[]) null);
            //		                } catch (Exception e) {
            //		                    if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
            //		                        Tr.debug(tc, "No class, object, or method found for CBIND check", new Object[] {e});
            //		                    FFDCFilter.processException(e, CLASS_NAME, "1237");
            //		                }
            //		                if (cbindCheckEnabled.booleanValue()) {
            //		                    flag = cbindCheckEnabled.booleanValue();
            //		                    if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            //		                        Tr.debug(tc, "The mutualAuthCBINDCheck is true, so hard-coded setNeedClientAuth to true.");}
            //		                }
            //		            }
            //                }
            //            }

            engine.setNeedClientAuth(flag);
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "Client auth needed is " + engine.getNeedClientAuth());
            }
            if (!flag) {
                // Client auth set to false, check client auth supported
                flag = config.getBooleanProperty(Constants.SSLPROP_CLIENT_AUTHENTICATION_SUPPORTED);
                engine.setWantClientAuth(flag);
                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                    Tr.debug(tc, "Client auth supported is " + engine.getWantClientAuth());
                }
            }
            // enable ALPN support if this is for an inbound connection
            AlpnSupportUtils.registerAlpnSupport(connLink, engine);

        } else {
            // Update engine with client side specific config parameters.
            engine.setUseClientMode(true);
        }

        try {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "Calling beginHandshake on engine");
            }
            engine.beginHandshake();
        } catch (SSLException se) {
            // no FFDC required
            if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) {
                Tr.event(tc, "Error while starting handshake; " + se);
            }
        }
    }
59669
public boolean closeOutbound() throws SSLException {
        if (sslEngine == null || sslEngine.isOutboundDone()) {
            return false;
        }

        sslEngine.closeOutbound();

        createOutNetBuffer(0);
        SSLEngineResult result;
        for (;;) {
            result = sslEngine.wrap(emptyBuffer.buf(), outNetBuffer.buf());
            if (result.getStatus() == SSLEngineResult.Status.BUFFER_OVERFLOW) {
                outNetBuffer.capacity(outNetBuffer.capacity() << 1);
                outNetBuffer.limit(outNetBuffer.capacity());
            } else {
                break;
            }
        }

        if (result.getStatus() != SSLEngineResult.Status.CLOSED) {
            throw new SSLException("Improper close state: " + result);
        }
        outNetBuffer.flip();
        return true;
    }