/** * Get the username from config * * @return Returns lens client user name */ public String getUser() { return this.get(USER_NAME, DEFAULT_USER_NAME); }
private void setupRequestFilters() { if (this.conf.get(LensClientConfig.SESSION_FILTER_NAMES) != null) { String[] filterNames = this.conf.getStrings(LensClientConfig.SESSION_FILTER_NAMES); for (String filterName : filterNames) { Class wsFilterClass = this.conf.getClass(LensClientConfig.getWSFilterImplConfKey(filterName), null); if (wsFilterClass != null) { requestFilters.add(wsFilterClass); } log.info("Request filter added " + filterName); } } } /**
private void setupRequestFilters() { requestFilters.add(DelegationTokenClientFilter.class); requestFilters.add(SpnegoClientFilter.class); // add default filter if (this.conf.get(LensClientConfig.SESSION_FILTER_NAMES) != null) { String[] filterNames = this.conf.getStrings(LensClientConfig.SESSION_FILTER_NAMES); for (String filterName : filterNames) { Class wsFilterClass = this.conf.getClass(LensClientConfig.getWSFilterImplConfKey(filterName), null); if (wsFilterClass != null) { requestFilters.add(wsFilterClass); } log.info("Request filter added " + filterName); } } } /**
/** * Returns the configured lens server database client wants to access * * @return database returns database to connect, defaults to 'default' */ public String getLensDatabase() { return this.get(DBNAME_KEY, DEFAULT_DBNAME_VALUE); }
/** * Returns the configured lens server url * * @return server url */ public String getBaseURL() { return this.get(SERVER_BASE_URL, DEFAULT_SERVER_BASE_URL); }
/** * Returns the configured lens server database client wants to access * * @return database returns database to connect, defaults to 'default' */ public String getLensDatabase() { return this.get(DBNAME_KEY, DEFAULT_DBNAME_VALUE); }
/** * Get the username from config * * @return Returns lens client user name */ public String getUser() { return this.get(USER_NAME, DEFAULT_USER_NAME); }
/** * Returns the configured lens server url * * @return server url */ public String getBaseURL() { return this.get(SERVER_BASE_URL, DEFAULT_SERVER_BASE_URL); }
public LensHostnameVerifier(LensClientConfig config) { if (Boolean.valueOf(config.get(LensClientConfig.SSL_IGNORE_SERVER_CERT, String.valueOf(LensClientConfig.DEFAULT_SSL_IGNORE_SERVER_CERT_VALUE)))) { log.info("Will skip hostname verification."); ignoreHostVerification = true; lensServerHostBaseURL = config.get(LensClientConfig.SERVER_BASE_URL); } else { log.info("Host name verification is enabled."); ignoreHostVerification = false; } }
public LensTrustManager(LensClientConfig config) { if (Boolean.valueOf(config.get(LensClientConfig.SSL_IGNORE_SERVER_CERT, String.valueOf(LensClientConfig.DEFAULT_SSL_IGNORE_SERVER_CERT_VALUE)))) { log.debug("Will skip server cert verification."); ignoreCertCheck = true; } else { log.debug("Server cert verification is enabled."); ignoreCertCheck = false; try { trustManager = getTrustManager(); } catch (Exception e) { log.error(e.toString()); throw new RuntimeException(e); } } }
protected WebTarget getMLWebTarget() { Client client = connection.buildClient(); LensConnectionParams connParams = connection.getLensConnectionParams(); String baseURI = connParams.getBaseConnectionUrl(); String mlURI = connParams.getConf().get(LENS_ML_RESOURCE_PATH, DEFAULT_ML_RESOURCE_PATH); return client.target(baseURI).path(mlURI); }
/** * getClientBuilder : initializes client builder * specific to transfer protocol (TLS or SSL) * * @param config : client side config. * @return Client builder. */ private ClientBuilder getClientBuilder(LensClientConfig config) { if (Boolean.valueOf(config.get(LensClientConfig.SSL_ENABLED, String.valueOf(LensClientConfig.DEFAULT_SSL_ENABLED_VALUE)))) { try { log.info("SSL is enabled, Creating https client."); SSLContext sc = SSLContext.getInstance("TLSv1"); System.setProperty("https.protocols", "TLSv1"); TrustManager[] trustedCerts = {new LensTrustManager(config)}; sc.init(null, trustedCerts, new java.security.SecureRandom()); HostnameVerifier trustedHosts = new LensHostnameVerifier(config); return ClientBuilder.newBuilder().sslContext(sc).hostnameVerifier(trustedHosts) .register(MultiPartFeature.class).register(MoxyJsonFeature.class) .register(MoxyJsonConfigurationContextResolver.class); } catch (Exception e) { throw new RuntimeException(e); } } else { log.info("SSL is disabled, Creating http client."); return ClientBuilder.newBuilder().register(MultiPartFeature.class).register(MoxyJsonFeature.class) .register(MoxyJsonConfigurationContextResolver.class); } }