Example usage for java.net URL getPort

List of usage examples for java.net URL getPort

Introduction

In this page you can find the example usage for java.net URL getPort.

Prototype

public int getPort() 

Source Link

Document

Gets the port number of this URL .

Usage

From source file:com.grendelscan.commons.http.CookieJar.java

public List<Cookie> getMatchingCookies(final URL url) {
    int port = url.getPort();
    if (port < 0) {
        port = url.getDefaultPort();//from www .ja v a2  s  .  c  om
    }
    CookieOrigin origin = new CookieOrigin(url.getHost(), port, url.getPath(),
            url.getProtocol().equalsIgnoreCase("https"));
    return getMatchingCookies(origin);
}

From source file:com.netflix.spinnaker.halyard.deploy.spinnaker.v1.profile.SamlConfig.java

public SamlConfig(Security security) {
    if (!security.getAuthn().getSaml().isEnabled()) {
        return;/*from  w w w  .  ja  v a 2s.c o m*/
    }

    Saml saml = security.getAuthn().getSaml();

    this.enabled = saml.isEnabled();
    this.issuerId = saml.getIssuerId();
    this.metadataUrl = "file:" + saml.getMetadataLocal();
    if (StringUtils.isNotEmpty(saml.getMetadataRemote())) {
        this.metadataUrl = saml.getMetadataRemote();
    }

    this.keyStore = "file:" + saml.getKeyStore();
    this.keyStoreAliasName = saml.getKeyStoreAliasName();
    this.keyStorePassword = saml.getKeyStorePassword();

    URL u = saml.getServiceAddress();
    this.redirectProtocol = u.getProtocol();
    this.redirectHostname = u.getHost();
    if (u.getPort() != -1) {
        this.redirectHostname += ":" + u.getPort();
    }
    if (StringUtils.isNotEmpty(u.getPath())) {
        this.redirectBasePath = u.getPath();
    }
}

From source file:biz.gabrys.lesscss.extended.compiler.source.FtpSource.java

/**
 * Constructs a new instance and sets URL of the source file and its encoding.
 * @param url the source file URL.// w  w  w  .j  av  a  2s.  co  m
 * @param encoding the source file encoding.
 * @since 2.0
 */
public FtpSource(final URL url, final String encoding) {
    this.url = url;
    port = url.getPort() != -1 ? url.getPort() : FTP.DEFAULT_PORT;
    this.encoding = encoding;
}

From source file:com.couchbase.lite.performance.Test16_ParallelPushReplication.java

private boolean isSyncGateway(URL remote) {
    return (remote.getPort() == 4984);
}

From source file:bad.robot.http.apache.matchers.CredentialsMatcher.java

private CredentialsMatcher(URL url, String username, String password) {
    this.username = username;
    this.password = password;
    this.scope = new AuthScope(url.getHost(), url.getPort(), ANY_REALM, ANY_SCHEME);
}

From source file:com.thinkbiganalytics.nifi.rest.config.SpringNifiRestConfiguration.java

/**
 * Gets the configuration for the NiFi REST client.
 *
 * <p>Looks for {@code thinkbig.nifi.rest} properties first then for {@code nifi.rest} properties.</p>
 *
 * @return the NiFi REST client configuration
 *///  www  .  jav a 2  s. c  o m
@Bean(name = "nifiRestClientConfig")
@ConfigurationProperties(prefix = "nifi.rest")
public NifiRestClientConfig nifiRestClientConfig() {
    final NifiRestClientConfig config = new NifiRestClientConfig();
    config.setUsername(env.getProperty("thinkbig.nifi.rest.username"));
    config.setPassword(env.getProperty("thinkbig.nifi.rest.password"));
    config.setHttps(BooleanUtils.toBoolean(env.getProperty("thinkbig.nifi.rest.https")));
    config.setUseConnectionPooling(
            BooleanUtils.toBoolean(env.getProperty("thinkbig.nifi.rest.useConnectionPooling")));
    config.setTruststorePath(env.getProperty("thinkbig.nifi.rest.truststorePath"));
    config.setTruststorePassword(env.getProperty("thinkbig.nifi.rest.truststorePassword"));
    config.setKeystorePassword(env.getProperty("thinkbig.nifi.rest.keystorePassword"));
    config.setKeystorePath(env.getProperty("thinkbig.nifi.rest.keystorePath"));
    config.setTrustStoreType(env.getProperty("thinkbig.nifi.rest.truststoreType"));
    config.setKeystoreType(env.getProperty("thinkbig.nifi.rest.keystoreType"));
    final String host = env.getProperty("thinkbig.nifi.rest.host");
    if (host != null) {
        try {
            final URL url = new URL(host);
            config.setHost(url.getHost());
            config.setPort((url.getPort() > -1) ? url.getPort() : 8079);
        } catch (final MalformedURLException e) {
            throw new IllegalArgumentException("Invalid thinkbig.nifi.rest.host: " + host, e);
        }
    }

    return config;
}

From source file:io.fabric8.kubernetes.pipeline.KubernetesPipelineTest.java

private void configureCloud(JenkinsRuleNonLocalhost r) throws Exception {
    // Slaves running in Kubernetes (minikube) need to connect to this server, so localhost does not work
    URL url = r.getURL();
    URL nonLocalhostUrl = new URL(url.getProtocol(), InetAddress.getLocalHost().getHostAddress(), url.getPort(),
            url.getFile());//from   w  w  w .jav  a  2 s . c o m
    JenkinsLocationConfiguration.get().setUrl(nonLocalhostUrl.toString());

    r.jenkins.clouds.add(cloud);
}

From source file:org.sonatype.nexus.testsuite.NexusHttpsITSupport.java

/**
 * @return CookieOrigin suitable for validating session cookies from the given base URL
 *//*from   ww w. j ava 2 s.  c  om*/
protected CookieOrigin cookieOrigin(final URL url) {
    return new CookieOrigin(url.getHost(), url.getPort(), cookiePath(url), url.getProtocol().equals("https"));
}

From source file:org.uiautomation.ios.inspector.controllers.SessionGuesserController.java

private Session getSession() throws Exception {
    HttpClient client = HttpClientFactory.getClient();
    String url = cache.getEndPoint() + "/status";
    URL u = new URL(url);
    BasicHttpEntityEnclosingRequest r = new BasicHttpEntityEnclosingRequest("GET", url);

    HttpHost h = new HttpHost(u.getHost(), u.getPort());
    HttpResponse response = client.execute(h, r);

    JSONObject o = Helper.extractObject(response);
    String id = o.optString("sessionId");
    if (id == null) {
        throw new WebDriverException("cannot guess the sessionId for the IDE to use.");
    }//from   w ww  . j av  a2 s .co m
    return new Session(id);

}

From source file:com.dianping.cosmos.monitor.HttpClientService.java

private HttpUriRequest getGetRequest(String url, boolean useURI) throws Exception {
    HttpUriRequest request;// ww w.  j a v a 2  s  .c  o  m
    if (useURI) {
        URL requestURL = new URL(url);
        URI uri = new URI(requestURL.getProtocol(), null, requestURL.getHost(), requestURL.getPort(),
                requestURL.getPath(), requestURL.getQuery(), null);
        request = new HttpGet(uri);
    } else {
        request = new HttpGet(url);
    }
    return request;
}